예제 #1
0
void CSyncSource::applyChangedValues()
{
    String strBody = "";
    makePushBody_Ver3(strBody, "create", false);
    if ( strBody.length() > 0 )
    {
        CJSONEntry oEntry(strBody.c_str());
        processSyncCommand("insert", oEntry );
    }

    strBody = "";
    makePushBody_Ver3(strBody, "delete", false);
    if ( strBody.length() > 0 )
    {
        CJSONEntry oEntry(strBody.c_str());
        processSyncCommand("delete", oEntry );
    }

    strBody = "";
    makePushBody_Ver3(strBody, "update", false);
    if ( strBody.length() > 0 )
    {
        CJSONEntry oEntry(strBody.c_str());
        processSyncCommand("insert", oEntry );
    }
}
예제 #2
0
bool EMBeMediaFileManager::ExtractFileExistsFor(const string* p_opFileName)
{
	string oExtractFileName = EMBeMediaUtility::MakeExtractFileName(*p_opFileName); //ParseFullPath(oNoPathFileName, DIRECTORY_ID_AUDIO_DATA_USED);

	if(! FileExists(&oExtractFileName))
		return false;

	//Find out what the expected numframes is...

	entry_ref sRef;

	if(p_opFileName == NULL)
		EMDebugger("ERROR! File name is NULL!");
	
	BEntry oEntry(p_opFileName -> c_str(), false);
	oEntry.GetRef(&sRef);
	BMediaFile* opFile = new BMediaFile(&sRef);
	
	status_t vError = opFile -> InitCheck();
	if(vError != B_OK)
		EMDebugger("ERROR! Could not initialize media file!");
	media_file_format sFileFormat;
	vError = opFile -> GetFileFormatInfo(&sFileFormat);
	if(vError != B_OK)
		EMDebugger("ERROR! Could not read file format from file!");
	int32 vCount = opFile -> CountTracks();
	int64 vOriginalNumFrames = 0;//opFile -> NumberOfFramesInFile();
	for(int32 vIndex = 0; vIndex < vCount; vIndex++)
	{
		media_format sFormat;
		BMediaTrack* opTrack = opFile -> TrackAt(vIndex);
		vError = opTrack -> InitCheck();
		if(vError != B_OK)
			EMDebugger("ERROR! Could not initialize BMediaTrack!");
		if(opTrack -> EncodedFormat(&sFormat) != B_OK)
			EMDebugger("ERROR! Could not get format of BMediaTrack!");
		
		if(sFormat.type == B_MEDIA_RAW_AUDIO || sFormat.type == B_MEDIA_ENCODED_AUDIO)
		{
			vOriginalNumFrames = opTrack -> CountFrames();
			opFile -> ReleaseTrack(opTrack);
			if(vIndex == vCount-1)
				break;	
		}
		opFile -> ReleaseTrack(opTrack);
	}	
	delete opFile;
	
	if(vOriginalNumFrames <= 0)
		EMDebugger("0 frames in media track!?");
	
	//Compare the expected number of frames now...
	return CompareNumFramesInFile(&oExtractFileName, vOriginalNumFrames);
}
void					
BF_GUI_FilesPanel::Action_Tracker_Addons_Run(const char *pc_AddOn)
{
	ASSERT(pc_AddOn);
		
	image_id 	uImage;	
	uImage = load_add_on(pc_AddOn);
	if(0==uImage) return;
	
	BEntry 		oEntry(oPath.Path());
	entry_ref	uEntryRef;
	
	if(B_OK!=oEntry.GetRef(&uEntryRef)) return;
	
	void (*Func_AddOn)(entry_ref dir_ref, BMessage *msg, void *);
	if(B_OK!=get_image_symbol(uImage, "process_refs", B_SYMBOL_TYPE_TEXT, (void**)&Func_AddOn)) return;
	
	BMessage 			*poMessage = new BMessage();	
	BF_NodeCollection	loSelNode;
	loNode.GetSelecting(loSelNode);
	if(loSelNode.CountItems()==0) loSelNode.AddItem(Nodes_Focus());
	if(loSelNode.CountItems()==0) return;
	ASSERT(poMessage);
	
	BF_Node 	*poNode=NULL;
	entry_ref	uNodeRef;	
	BL_String	s;
	for(int iNode=0;iNode<loSelNode.CountItems();iNode++){
		poNode = loSelNode.NodeAt(iNode);
		s=oPath.Path();
		s<<"/";
		s<<poNode->sName;
		if(B_OK!=oEntry.SetTo(s.String()) || B_OK!=oEntry.GetRef(&uNodeRef)) continue;
		poMessage->AddRef("refs",&uNodeRef);
	}
	
	
	poMessage->AddRef("folder_ref",&uEntryRef);
	poMessage->AddPointer("func",(void*)Func_AddOn);
	
	// run thread //
	thread_id idThread = spawn_thread(BF_GUI_FilesPanel_Action_Tracker_Addons_Run_Thread,"tracker_addon_thread",B_THREAD_SUSPENDED,(void*)poMessage);	
	ASSERT(idThread>0,"can`t start thread\n");	
	ASSERT(B_OK==resume_thread(idThread));		
	set_thread_priority(idThread,1);				
}
예제 #4
0
bool EMBeMediaFileManager::CheckFileForVideoFormat(const string* p_opFileName)
{
	entry_ref m_sRef;
	BEntry oEntry(p_opFileName -> c_str(), false);
	oEntry.GetRef(&m_sRef);

	BMediaFile* opFile = new BMediaFile(&m_sRef, B_MEDIA_FILE_UNBUFFERED);
	//Point vidtrack to the Video-Track (temporary static at 0) (input file)
	//It is not always that the video data is on track 0?
	int32 tracks = opFile->CountTracks();
	media_format sFormat;
	BMediaTrack* opTrackOut = NULL;
	for (int32 i = 0; i < tracks; i++) 
	{
		opTrackOut = opFile -> TrackAt(i);
				
		//m_opTrackOut->EncodedFormat(&outfmt);
		//We wannt RAW Video.. nothing else can be handled :)
		//So we will have to negotiate for RAW_VIDEO through DecodeFormat(..)
		sFormat.type = B_MEDIA_RAW_VIDEO;
		sFormat.u.raw_video = media_raw_video_format::wildcard;
		status_t vErrorCode = opTrackOut -> DecodedFormat(&sFormat);
		if(vErrorCode != B_OK)
		{
			opFile -> ReleaseTrack(opTrackOut);
			opFile -> CloseFile();
			delete opFile;
			return false;
		}

		if(sFormat.IsVideo())
		{
			opFile -> ReleaseTrack(opTrackOut);
			opFile -> CloseFile();
			delete opFile;
			return true;
		}
		
	}
	if(opTrackOut != NULL)
		opFile -> ReleaseTrack(opTrackOut);
	opFile -> CloseFile();
	delete opFile;
	return false;
}
예제 #5
0
string EMBeMediaFileManager::ExtractAudioE(const string* p_opFileName)
{
	if(ExtractFileExistsFor(p_opFileName))
	{
//		string oNoPathFileName = EMBeMediaUtility::GetFileName(*p_opFileName);
//		oNoPathFileName += ".extract.wav";
		string oExtractFileName = EMBeMediaUtility::MakeExtractFileName(*p_opFileName); //ParseFullPath(oNoPathFileName, DIRECTORY_ID_AUDIO_DATA_USED);
		return oExtractFileName;
	}

	entry_ref sRef;
	string oNewFileName;

	if(p_opFileName == NULL)
		EMDebugger("ERROR! File name is NULL!");
	
	BEntry oEntry(p_opFileName -> c_str(), false);
	oEntry.GetRef(&sRef);

	BMediaFile* opFile = new BMediaFile(&sRef);

	status_t vError = opFile -> InitCheck();
	if(vError != B_OK)
		EMDebugger("ERROR! Could not initialize media file!");


	media_file_format sFileFormat;
	vError = opFile -> GetFileFormatInfo(&sFileFormat);
	if(vError != B_OK)
		EMDebugger("ERROR! Could not read file format from file!");

	int32 vCount = opFile -> CountTracks();
	
	for(int32 vIndex = 0; vIndex < vCount; vIndex++)
	{
		media_format sFormat;
		BMediaTrack* opTrack = opFile -> TrackAt(vIndex);
		vError = opTrack -> InitCheck();
		if(vError != B_OK)
			EMDebugger("ERROR! Could not initialize BMediaTrack!");
		
		if(opTrack -> EncodedFormat(&sFormat) != B_OK)
			EMDebugger("ERROR! Could not get format of BMediaTrack!");

		
		if((sFormat.type == B_MEDIA_RAW_AUDIO || sFormat.type == B_MEDIA_ENCODED_AUDIO) && vIndex == vCount-1)
		{
			//media_format sEncodedFormat;
			media_format sDecodedFormat;

			//Create the decode-stuff
			memcpy(&sDecodedFormat, &sFormat, sizeof(sDecodedFormat));
			status_t vErr = opTrack -> DecodedFormat(&sDecodedFormat);

			if(vErr != B_OK)
			{
			//	emerr << "ERROR! Format negotiation failed: " << strerror(vErr) << endl;
			} 

			EMMediaFormat oDecodedFormat(EM_TYPE_RAW_AUDIO);
			oDecodedFormat.CreateFormat(&sDecodedFormat);

			int64 vNumBytes = oDecodedFormat.m_vBufferSizeBytes;
			char* vpData = new char[vNumBytes];
			memset(vpData, 0, vNumBytes);

			int64 vFrames = vNumBytes / (oDecodedFormat.m_vBytesPerSample * oDecodedFormat.m_vNumChannels);
			vFrames=0;
			int64 vBytesPerFrame = oDecodedFormat.m_vNumChannels * oDecodedFormat.m_vBytesPerSample;
			media_header sHeader;
			
			int64 vNumProcessedFrames = 0;
			int64 vTotalTime = EMBeMediaUtility::FramesToTime(opTrack -> CountFrames(), &oDecodedFormat);

			int64 frame_count;
			frame_count = 0;
			int64 vCount = 0;
			while(true)
			{
				status_t vError = opTrack -> ReadFrames(vpData, &vFrames, &sHeader);
				if( vError !=B_OK)
				{
					if(frame_count==1)
						break;
					media_format rawAudioFormat;
					rawAudioFormat.type = B_MEDIA_RAW_AUDIO;
					rawAudioFormat.u.raw_audio = media_raw_audio_format::wildcard;
					status_t err = opTrack -> DecodedFormat(&rawAudioFormat);
					if( err !=B_OK)
					{
						break;
					}
					else
					oDecodedFormat.CreateFormat(&rawAudioFormat);
					frame_count = 1;
				}
				else
				{
					if(m_opNewFile == NULL)
					{
						oNewFileName = EMBeMediaUtility::MakeExtractFileName(*p_opFileName); //ParseFullPath(oNoPathFileName, DIRECTORY_ID_AUDIO_DATA_USED);			
						m_opNewFile = new EMWaveFileWriter(oNewFileName);
						m_opNewFile -> InitCheckE();
					}
				
					m_opNewFile -> WriteData(vpData, vFrames * vBytesPerFrame);
					vNumProcessedFrames += vFrames;
					
					if((vCount % 50) == 0)
					{
						char vpPercentage[10];
						sprintf(vpPercentage, "%d%%",  (int) (100 * (EMBeMediaUtility::FramesToTime(vNumProcessedFrames, &oDecodedFormat) / (float) vTotalTime)));
						string oString = string("Extracting audio data: ") + vpPercentage;
						//EMMediaEngine::Instance() -> GetCommandRepository() -> ExecuteCommand(COMMAND_WRITE_STATUS_BAR_MESSAGE, const_cast<char*>(oString.c_str()));
					}
					vCount++;
				}
			}
			if(vNumProcessedFrames <= 0)
			{
				return string("Noname");;
				EMDebugger("ERROR! Could not read any frames from the audio track, using BMediaTrack::ReadFrames(...). Very weird. Unsupported audio format perhaps?");
			}
			m_opNewFile -> WriteHeaderE(&oDecodedFormat);
			delete m_opNewFile;
			m_opNewFile = NULL;
			opFile -> ReleaseTrack(opTrack);
			opFile -> CloseFile();
			delete opFile;
			return oNewFileName;
		}
	}

	opFile -> CloseFile();
	delete opFile;
	return string("Noname");
}