コード例 #1
0
string AudioDevice::registerSound(ci::fs::path pathToSound, bool looping, bool is3d, bool asStream)
{
    if ( !boost::filesystem::exists( pathToSound ) ) {
        app::console() << "[NOTICE] " << pathToSound << " doesn't exist" << endl;
        return "";
    }

    std::stringstream namestream;
    namestream << deviceName << "-" << pathToSound.filename().string() << "-" << mSounds.size();
    string name = namestream.str();

    app::console() << "Adding " << name << endl;

    if(mSounds.find(name)!=mSounds.end()) {
        app::console() << "[WARNING] " << name << " already exists on this device. Re-adding." << endl;
    }

    if( asStream ) {
        FMODErrorCheck( mSystem->createStream( pathToSound.string().c_str(), FMOD_DEFAULT, NULL, &mSounds[name]) );
    } else {
        FMODErrorCheck( mSystem->createSound( pathToSound.string().c_str(), FMOD_DEFAULT, NULL, &mSounds[name]) );
    }

    FMOD_MODE mode;
    mode = is3d ? FMOD_3D|FMOD_3D_LINEARSQUAREROLLOFF : FMOD_2D;
    mode |= looping ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF;
    FMODErrorCheck( mSounds.at(name)->setMode( mode ) );

    return name;
}
コード例 #2
0
ファイル: Curl.cpp プロジェクト: bgbotond/Cinder-Curl
bool Curl::ftpUpload( const std::string &ftpUrl, const std::string &userName, const std::string &password, const ci::fs::path &path )
{
	bool ret = true;
	CURL *curl = curl_easy_init();
	CURLcode  res;

	if( ! curl )
		return false;

	FILE        *fileSource;
	curl_off_t   fileSize;
	std::string  fileName = path.filename().string();
	std::string  tempName = fileName + ".uploading";
	std::string  renameFromCommand = "RNFR " + tempName;
	std::string  renameToCommand   = "RNTO " + fileName;
	std::string  urlFullPath   = ftpUrl + "/" + tempName;
	std::string  userPass = userName + ":" + password;

	struct curl_slist *headerList = NULL;

	if( ! ci::fs::exists( path ))
	{
		cerr << "error: " << "Couldn't open file: " << path << endl;
		curl_easy_cleanup( curl );
		curl_global_cleanup();
		return false;
	}

	fileSize = (curl_off_t)ci::fs::file_size( path );

	fileSource = fopen( path.string().c_str(), "rb" ); // get a FILE * of the same file

	curl_global_init( CURL_GLOBAL_ALL ); // In windows, this will init the winsock stuff

	// build a list of commands to pass to libcurl
	headerList = curl_slist_append( headerList, renameFromCommand.c_str());
	headerList = curl_slist_append( headerList, renameToCommand.c_str());

	curl_easy_setopt( curl, CURLOPT_UPLOAD          , 1L                        ); // enable uploading
	curl_easy_setopt( curl, CURLOPT_URL             , urlFullPath.c_str()       ); // specify target
	curl_easy_setopt( curl, CURLOPT_USERPWD         , userPass.c_str()          ); // specify user/password
	curl_easy_setopt( curl, CURLOPT_POSTQUOTE       , headerList                ); // pass in that last of FTP commands to run after the transfer
	curl_easy_setopt( curl, CURLOPT_READDATA        , fileSource                ); // now specify which file to upload
	curl_easy_setopt( curl, CURLOPT_INFILESIZE_LARGE, fileSize                  ); // Set the size of the file to upload (optional).  If you give a *_LARGE option you MUST make sure that the type of the passed-in argument is a curl_off_t. If you use CURLOPT_INFILESIZE (without _LARGE) you must make sure that to pass in a type 'long' argument

	res = curl_easy_perform( curl );

	if( res != CURLE_OK )
	{
		cerr << "error: " << curl_easy_strerror( res ) << endl;
		ret = false;
	}

	curl_slist_free_all( headerList ); // clean up the FTP commands list
	curl_easy_cleanup( curl );
	fclose( fileSource );
	curl_global_cleanup();

	return ret;
}
コード例 #3
0
ファイル: CCL_MocapData.cpp プロジェクト: Craigson/CCLmerged
std::vector<CCL_MocapJoint> loadMotionCaptureFromJson(const ci::fs::path &file)
{
  vector<CCL_MocapJoint> mJoints;

  Jzon::Object rootNode;
  Jzon::FileReader::ReadFile(file.string(), rootNode);

  const Jzon::Array &joints = rootNode.Get("joints").AsArray();
  for( Jzon::Array::const_iterator it = joints.begin() ; it != joints.end();++it){
      Jzon::Object joint = (*it).AsObject();
      // name
      string name = joint.Get("name").ToString();

      // xPos
      Jzon::Array xPosList = joint.Get("xPos").AsArray();
      vector<float> xPosVec;
      for( Jzon::Array::iterator itt = xPosList.begin() ; itt != xPosList.end();++itt){
          float pos = stof((*itt).ToString());
          xPosVec.push_back(pos);
      }
      // yPos
      Jzon::Array yPosList = joint.Get("yPos").AsArray();
      vector<float>yPosVec;
      for( Jzon::Array::iterator itt = yPosList.begin() ; itt != yPosList.end();++itt){
          float pos = stof((*itt).ToString());
          yPosVec.push_back(pos);
      }
      // zPos
      Jzon::Array zPosList = joint.Get("zPos").AsArray();
      vector<float> zPosVec;
      for( Jzon::Array::iterator itt = zPosList.begin() ; itt != zPosList.end();++itt){
          float pos = stof((*itt).ToString());
          zPosVec.push_back(pos);
      }


    //  cout << "JOINT NAME:"<<name<<endl;
      CCL_MocapJoint cclJoint = CCL_MocapJoint(name,10);

      cclJoint.xPositions = xPosVec;
      cclJoint.yPositions = yPosVec;
      cclJoint.zPositions = zPosVec;
      cclJoint.loadPositions();


      mJoints.push_back(cclJoint);

  }
/*
  for( int i  = 0 ; i < 10 ; i++) {
      CCL_MocapJoint jointt = mJoints[i];
      for( int j = 0 ; j < 3 ; j++){
          cout << "[" << jointt.jointName << "] (" << jointt.jointPositions[j].x << "," <<jointt.jointPositions[j].y << ","<< jointt.jointPositions[j].z <<")"<< endl;
      }
  }*/

  return mJoints;
};
コード例 #4
0
    InputSourceRef InputSource::getResource(const ci::fs::path &relativePath)
    {
        auto source = make_shared<InputSource>(TYPE_RESOURCE);
        source->relativePath = relativePath;
        source->filePathHint = relativePath.string();
        
#if defined(CINDER_COCOA)
        source->filePath = FileSystem::getResourcePath(relativePath);
#endif
        
        return source;
    }
コード例 #5
0
ファイル: AssetFileSystem.cpp プロジェクト: Ahbee/Cinder
bool AssetFileSystem_exists( ci::fs::path path )
{
	bool result = false;
	if( nullptr != EventManagerAndroid::instance() ) {
		AAssetManager *assetMan = GetNativeAssetManager();
		AAsset *asset = AAssetManager_open( assetMan, path.string().c_str(), AASSET_MODE_UNKNOWN );
		if( nullptr != asset ) {
			result = true;
			AAsset_close( asset );
		}
	}
	return result;
}
コード例 #6
0
bool ciWMFVideoPlayer::loadMovie(ci::fs::path path, string audioDevice)
{
	 if (!_player)
	 { 
		//ofLogError("ciWMFVideoPlayer") << "Player not created. Can't open the movie.";
		 return false;
	}

	//fs::path path = getAssetPath(name);
	DWORD fileAttr = GetFileAttributesW(path.c_str());
	if (fileAttr == INVALID_FILE_ATTRIBUTES) 
	{
		stringstream s;
		s << "The video file '" << path << "'is missing.";
		//ofLog(OF_LOG_ERROR,"ciWMFVideoPlayer:" + s.str());
		return false;
	}
	
	//cout << "Videoplayer[" << _id << "] loading " << name << endl;
	HRESULT hr = S_OK;
	string s = path.string();
	std::wstring w(s.length(), L' ');
	std::copy(s.begin(), s.end(), w.begin());

	std::wstring a(audioDevice.length(), L' ');
	std::copy(audioDevice.begin(), audioDevice.end(), a.begin());

	hr = _player->OpenURL( w.c_str(), a.c_str() );
	if (!_sharedTextureCreated)
	{
		_width = _player->getWidth();
		_height = _player->getHeight();

		gl::Texture::Format format;
		format.setInternalFormat(GL_RGBA);
		format.setTargetRect();
		_tex = gl::Texture::create(_width,_height, format);
		//_tex.allocate(_width,_height,GL_RGBA,true);
		_player->m_pEVRPresenter->createSharedTexture(_width, _height, _tex->getId());
		_sharedTextureCreated = true;
	}
	else 
	{
		if ((_width != _player->getWidth()) || (_height != _player->getHeight()))
		{
			_player->m_pEVRPresenter->releaseSharedTexture();

			_width = _player->getWidth();
			_height = _player->getHeight();

			gl::Texture::Format format;
			format.setInternalFormat(GL_RGBA);
			format.setTargetRect();
			_tex = gl::Texture::create(_width,_height, format);
			//_tex.allocate(_width,_height,GL_RGBA,true);
			_player->m_pEVRPresenter->createSharedTexture(_width, _height, _tex->getId());
		}
	}

	_waitForLoadedToPlay = false;
	return true;
}
コード例 #7
0
MoviePlayer::MoviePlayer(const ci::fs::path &path) :
hasNewFrame(false),
mVideoTextureRef(NULL),
mPlayable(false),
mLoaded(false),
mDuration(-1),
mWidth(0),
mHeight(0),
mIsDone(true),
mSeekable(false),
mFrameCount(0),
mPlayingForward(true),
mLoop(false)
{
	MoviePlayer::startVLC();

	std::string moviePathStr = path.string();
	libvlc_media_t *media;
	media = libvlc_media_new_path(libvlc, moviePathStr.c_str());
	
	libvlc_media_parse(media);

	mDuration = libvlc_media_get_duration(media);

	libvlc_media_track_t** tracks = NULL;
	unsigned int track_count = libvlc_media_tracks_get(media, &tracks);

	if (tracks != NULL)
	{
		for (unsigned int i = 0; i < track_count; ++i)
		{
			libvlc_media_track_t* track = tracks[i];

			if (track->i_type == libvlc_track_video)
			{
				libvlc_video_track_t* videoTrack = track->video;
				mWidth = videoTrack->i_width;
				mHeight= videoTrack->i_height;
				
			}
		}
	}

	libvlc_media_tracks_release(tracks, track_count);
	
	medialist = libvlc_media_list_new(libvlc);
	libvlc_media_list_add_media(medialist, media);

	//mediaplayer = libvlc_media_player_new_from_media(media);

	mediaplayer = libvlc_media_player_new(libvlc);
	medialistplayer = libvlc_media_list_player_new(libvlc);

	libvlc_media_list_player_set_media_list(medialistplayer, medialist);
	libvlc_media_list_player_set_media_player(medialistplayer, mediaplayer);

	libvlc_media_release(media);

	SetVideoCallbacks(mediaplayer, this);
	libvlc_video_set_format(mediaplayer, "RGBA", mWidth, mHeight, mWidth * 4); //RV16	

	eventManager = libvlc_media_player_event_manager(mediaplayer);

	SetVideoCallback(eventManager, libvlc_MediaPlayerMediaChanged, this);
	//libvlc_MediaPlayerNothingSpecial
	//libvlc_MediaPlayerOpening
	//libvlc_MediaPlayerBuffering
	SetVideoCallback(eventManager, libvlc_MediaPlayerPlaying, this);
	//libvlc_MediaPlayerPaused
	//libvlc_MediaPlayerStopped
	//libvlc_MediaPlayerForward
	//libvlc_MediaPlayerBackward
	SetVideoCallback(eventManager, libvlc_MediaPlayerEndReached, this);
	SetVideoCallback(eventManager, libvlc_MediaPlayerEncounteredError, this);
	//libvlc_MediaPlayerTimeChanged
	//libvlc_MediaPlayerPositionChanged
	SetVideoCallback(eventManager, libvlc_MediaPlayerSeekableChanged, this);
	SetVideoCallback(eventManager, libvlc_MediaPlayerPausableChanged, this);
	//libvlc_MediaPlayerTitleChanged
	//libvlc_MediaPlayerSnapshotTaken
	SetVideoCallback(eventManager, libvlc_MediaPlayerLengthChanged, this);
	//libvlc_MediaPlayerVout
	//libvlc_MediaPlayerScrambledChanged
	//libvlc_MediaPlayerESAdded
	//libvlc_MediaPlayerESDeleted
	//libvlc_MediaPlayerESSelected
	
	mDataSource = new BYTE[mWidth * mHeight * 4 * sizeof(BYTE)];
	memset(mDataSource, 0, mWidth * mHeight * 4 * sizeof(BYTE));

	glGenTextures(1, &mTexture);
	glBindTexture(GL_TEXTURE_2D, mTexture);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
	glPixelStorei(GL_UNPACK_ROW_LENGTH, mWidth);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mWidth, mHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, mDataSource);
	glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
	glBindTexture(GL_TEXTURE_2D, 0);

	mVideoTextureRef = ci::gl::Texture::create(GL_TEXTURE_2D, mTexture, mWidth, mHeight, true);

	mLoaded = true;
}