예제 #1
0
int64 EMMediaClipRepository::CountClipsForTrack(const EMMediaTrack* p_opTrack, EMMediaType p_eSpecType)
{
	int64 vCount = 0;
	LockContainer();
	try
	{
		Rewind();
		while(Current() != NULL)
		{
			if(Current() -> GetTrack() -> GetID() == p_opTrack -> GetID() &&
				! Current() -> IsObjectDeleted() && (p_eSpecType & Current() -> GetType()) != 0)
				vCount++;

			if(Current() -> GetTrack() == NULL)
				EMDebugger("ERROR! NULL as track owner!");
			Next();
		}
	}
	catch(...)
	{
		EMDebugger("ERROR! Exception in EMMediaClipRepository::CountClipsForTrack");
	}
	UnlockContainer();
	return vCount;
}
예제 #2
0
//Takes two IDs - the plugin entry id and the effect track id, and returns the id of the new instantiated plugin
void* MediaCommandSetEffect::ExecuteE(void* p_upPluginEntryID, void* p_upEffectTrackID, void* p_upSlotNumber)
{
	try
	{
		int32 vEntryID = *static_cast<int32*>(p_upPluginEntryID); //New entry ID
		int32 vFXTrackID = *static_cast<int32*>(p_upEffectTrackID); //Existing track ID
		int32 vSlotNumber = *static_cast<uint32*>(p_upSlotNumber); //Already occupied slot number

		EMPluginEntry* opPluginEntry = EMPluginRepository::Instance() -> Find(vEntryID);
		EMMediaEffectTrack* opFXTrack = EMMediaEffectTrackRepository::Instance() -> Find(vFXTrackID);
 
		if(opPluginEntry == NULL)
			EMDebugger("ERROR! Could not locate the specified plugin entry ID!");
		if(opFXTrack == NULL)
			EMDebugger("ERROR! Could not locate the specified effect track ID!");

		EMPlugin* opNewPlugin = opPluginEntry -> InstantiateNativePlugin();
		if(opNewPlugin != NULL)
		{
			opNewPlugin -> ShowDialog();
			opFXTrack -> SetEffect(opNewPlugin, vSlotNumber);
			EMMediaEngine::Instance() -> GetMediaProject() -> SetDirty(true);
			m_vReturnValue = opNewPlugin -> GetID();
			return static_cast<void*>(&m_vReturnValue);
		}
		else
			EMDebugger("ERROR! Could not instantiate EMPluginEntry into an EMPlugin!");
	}
	catch(...)
	{
		eo << "Exception in SetEffect!" << ef;
	}
	return NULL;
}	
bool EMMediaTransitionTrackRepository::LoadData(EMProjectDataLoader* p_opLoader)
{
	if(p_opLoader -> LoadString() != string("EMMediaTransitionTrackRepository - Begin"))
	{
		EMDebugger("ERROR! Error in project file!");
		return false;
	}

	uint32 vSize = p_opLoader -> LoadUInt32();
	for(uint32 vIndex = 0; vIndex < vSize; vIndex++)
	{
		EMMediaVideoTransitionTrack* opTransitionTrack = EM_new EMMediaVideoTransitionTrack("Dummy name - change loader if present!");
		opTransitionTrack -> InitCheckE();
		if(! opTransitionTrack -> LoadData(p_opLoader))
		{
			delete opTransitionTrack;
			return false;
		}
		Add(opTransitionTrack);
	}

	if(p_opLoader -> LoadString() != string("EMMediaTransitionTrackRepository - End"))
	{
		EMDebugger("ERROR! Error in project file!");
		return false;
	}
	
	return true;
}
예제 #4
0
void MediaCommandSetTrackInput::UndoE()
{
	if(m_vRecentTrackID != -1 && m_vRecentInputID != -1)
	{
		EMMediaEngine* opEngine = EMMediaEngine::Instance();
		EMMediaProject* opProject = opEngine -> GetMediaProject();
		EMInputRepository* opInputs = EMInputRepository::Instance();

		EMMediaTrack* opTrack = NULL;
		opProject -> GetUsedTracks() -> LockContainer();
		try
		{
			opTrack = opProject -> GetUsedTracks() -> Find(m_vRecentTrackID);
		}
		catch(...)
		{
			EMDebugger("ERROR! Exception in MediaCommandSetTrackInput::UndoE");
		}
		opProject -> GetUsedTracks() -> UnlockContainer();
		if(opTrack == NULL)
		{
			opProject -> GetUnusedTracks() -> LockContainer();
			try
			{
				opProject -> GetUnusedTracks() -> Find(m_vRecentTrackID);
			}
			catch(...)
			{
				EMDebugger("ERROR! Exception in MediaCommandSetTrackInput::UndoE");
			}
			opProject -> GetUnusedTracks() -> UnlockContainer();
		}

		EMRealtimeInputDescriptor* opInput = NULL;
		opInputs -> LockContainer();
		try
		{
			opInput = opInputs -> Find(m_vRecentInputID);
		}
		catch(...)
		{
			EMDebugger("ERROR! Exception in MediaCommandSetTrackInput::UndoE");
		}
		opInputs -> UnlockContainer();
		if(opTrack != NULL && opInput != NULL)
		{
			//opTrack -> SetDestination(opOutput);
			opTrack -> SetInput(opInput);
			//Do somehting else!
		}
	}
	else
		EMDebugger("Bad stored track or bad stored input ID in SetTrackInput Command");
}
예제 #5
0
bool EMBeAudioOutputNode::Shutdown()
{
	status_t e = EMBeMediaUtility::GetRosterE() -> StopNode(Node(), true);
	if(e != B_OK)
		EMDebugger((string(string("ERROR! Could not stop node: ") + string(strerror(e)))).c_str());
	status_t vErrorCode = EMBeMediaUtility::GetRosterE() -> Disconnect(m_oConnection.m_sProducer.node, m_oConnection.m_sOutput.source, m_oConnection.m_sConsumer.node, m_oConnection.m_sInput.destination); //.source, m_oConnection.m_sInput.destination, &m_oConnection.m_sFormat, &m_oConnection.m_sOutput, &m_oConnection.m_sInput);
	if(vErrorCode != B_OK)
		EMDebugger("ERROR! Could not disconnect Titan's audio output from the system's audio output!");
	EMBeOutputNode::Shutdown();
	return true;
}
예제 #6
0
string EMBeMediaFileManager::CopyTo(const string* p_opSourceFile, const string* p_opTargetDirectory)
{
	string oFileName = EMBeMediaUtility::GetFileName(*p_opSourceFile);
	string oTargetFile = *p_opTargetDirectory + "/" + oFileName;

	EMMediaFile* opInFile = NULL;
	if(! EMMediaFileRepository::Instance() -> FindFileName(p_opSourceFile))
	{
		if(! EMMediaFileRepository::Instance() -> AddFile(p_opSourceFile))
			EMDebugger("ERROR! Could not add source file to file repository!");
	}

	opInFile = EMMediaFileRepository::Instance() -> FindFileName(p_opSourceFile);
	if(opInFile == NULL)
		EMDebugger("ERROR! In file still NULL!?");
	opInFile -> InitCheckE();
		

	EMMediaFile* opOutFile = NULL;
	if(! EMMediaFileRepository::Instance() -> FindFileName(&oTargetFile))
	{
		if(! EMMediaFileRepository::Instance() -> AddFile(&oTargetFile))
			EMDebugger("ERROR! Could not add target file to file repository!");
	}
	opOutFile = EMMediaFileRepository::Instance() -> FindFileName(&oTargetFile);
	if(opOutFile == NULL)
		EMDebugger("ERROR! Out file still NULL!?");
	opOutFile -> InitCheckE();
	
	opInFile -> Open(EM_READ);
	opOutFile -> Open(EM_WRITE);
	
	int64 vPosition = 0;
	char vpBuffer[1024];
	int64 vCount = 0;	
	int64 vLength = opInFile -> GetLength();
	while(vPosition < vLength)
	{
		int64 vNumRead = opInFile -> Read(vpBuffer, 1024, vPosition);
		opOutFile -> Write(vpBuffer, vNumRead);
		vPosition += vNumRead;

		if((vCount % 1024 * 25) == 0)
		{
			char vpPercentage[10];
			sprintf(vpPercentage, "%d%%",  (int) (100 * (vPosition) / (float) vLength));
			string oString = string("Importing audio to working directory: ") + vpPercentage;
			//EMMediaEngine::Instance() -> GetCommandRepository() -> ExecuteCommand(COMMAND_WRITE_STATUS_BAR_MESSAGE, const_cast<char*>(oString.c_str()));
		}
	}
	
	return oTargetFile;
}
예제 #7
0
void MediaCommandSetTrackOutput::UndoE()
{
	if(m_vRecentTrackID != -1 && m_vRecentOutputID != -1)
	{
		EMMediaEngine* opEngine = EMMediaEngine::Instance();
		EMMediaProject* opProject = opEngine -> GetMediaProject();
		EMOutputRepository* opOutputs = EMOutputRepository::Instance();

		EMMediaTrack* opTrack = NULL;
		opProject -> GetUsedTracks() -> LockContainer();
		try
		{
			opTrack = opProject -> GetUsedTracks() -> Find(m_vRecentTrackID);
		}
		catch(...)
		{
			EMDebugger("ERROR! Exception in MediaCommandSetTrackOutput::ExecuteE");
		}

		opProject -> GetUsedTracks() -> UnlockContainer();
		if(opTrack == NULL)
		{
			opProject -> GetUnusedTracks() -> LockContainer();
			try
			{
				opProject -> GetUnusedTracks() -> Find(m_vRecentTrackID);
			}
			catch(...)
			{
				EMDebugger("ERROR! Exception in MediaCommandSetTrackOutput::ExecuteE");
			}
			opProject -> GetUnusedTracks() -> UnlockContainer();
		}

		EMRealtimeOutputDescriptor* opOutput = NULL;
		opOutputs -> LockContainer();
		try
		{
			opOutput = opOutputs -> Find(m_vRecentOutputID);
		}
		catch(...)
		{
			EMDebugger("ERROR! Exception in MediaCommandSetTrackOutput::ExecuteE");
		}
		opOutputs -> UnlockContainer();

		if(opTrack != NULL && opOutput != NULL)
			opTrack -> SetTrackDestination(opOutput);
	}
}
bool EMVideoTransitionClip::LoadData(EMProjectDataLoader* p_opLoader)
{
	string oTest = p_opLoader -> LoadString();

	if(oTest != "EMVideoTransitionClip - begin")
	{
		EMDebugger("EMVideoTransitionClip::LoadData - Error: Mismatched data structure!");
	}

	EMMediaClip::LoadData(p_opLoader);
	EMBufferDestination::LoadData(p_opLoader);

	m_vTransStart = p_opLoader -> LoadInt64();
	m_vTransStop = p_opLoader -> LoadInt64();
	m_vSwap = p_opLoader -> LoadBool();

	string oUniqueID = p_opLoader -> LoadString();


	EMPluginRepository* opClips = EMPluginRepository::Instance();

	opClips -> LockContainer();
	opClips -> Rewind();

	while((opClips -> Current() != NULL) && (opClips -> Current() -> GetUniqueID() != oUniqueID))
		opClips -> Next();

	m_opTransEntry = opClips -> Current();

	opClips -> UnlockContainer();


	if(m_opTransEntry == NULL)
		EMDebugger("EMVideoTransitionClip::LoadData - Error: Couldn't find transition!");

	if(m_opTrans != NULL)
		delete m_opTrans;

	m_opTrans = static_cast<EMWinDirectXVideoTransition*>(m_opTransEntry -> InstantiateNativePlugin());
//	m_opTrans -> LoadData(p_opLoader);
	m_opTrans -> LoadSetting(p_opLoader);

	oTest = p_opLoader -> LoadString();
	if(oTest != "EMVideoTransitionClip - end")
	{
		EMDebugger("EMVideoTransitionClip::LoadData - Error: Mismatched data structure!");
	}

	return true;
}
예제 #9
0
bool EMBeMediaTimer::IncreaseAudioThenFrame(int64 p_vWithFrames)
{
//	status_t vAcquireResult = acquire_sem(m_vTimeProtectionSemaphore);
//	if(vAcquireResult != B_NO_ERROR)
//		EMDebugger("ERROR! EMBeMediaTimer could not acquire semaphore for timer protection!");

	if(p_vWithFrames >= 0)
	{
		m_vAudioThen += p_vWithFrames;
		if(m_vIsLooped || EMMediaEngine::Instance() -> GetMediaProject() -> IsRenderingAudio() || EMMediaEngine::Instance() -> GetMediaProject() -> IsRenderingVideo())
		{
			if(m_vLoopStart != m_vLoopEnd)
			{
				if(m_vAudioThen >= m_vLoopEnd && ! EMMediaEngine::Instance() -> GetMediaProject() -> IsRenderingAudio() && ! EMMediaEngine::Instance() -> GetMediaProject() -> IsRenderingVideo())
				{
					m_vAudioThen = m_vLoopStart;
//					release_sem(m_vTimeProtectionSemaphore);
					return true;
				}
				else if(m_vAudioThen > m_vLoopEnd && (EMMediaEngine::Instance() -> GetMediaProject() -> IsRenderingAudio() || EMMediaEngine::Instance() -> GetMediaProject() -> IsRenderingVideo()))
				{
//					release_sem(m_vTimeProtectionSemaphore);
					//Do something here!
					return false;
				}
			}
		}
	}
	else
		EMDebugger("ERROR in MediaTimer::IncreaseAudioThenFrame. Cannot increase with negative number of frames!");
	return true;
//	release_sem(m_vTimeProtectionSemaphore);
}
예제 #10
0
EMMediaFormat* EMWaveFileReader::ReadFormatE()
{
	if(m_vHasFormat && m_opFormat != NULL)
		return m_opFormat;

	EMWaveChunk opChunk;
	EMWaveRiff opRiffChunk;
	EMWaveFormat opFormatChunk;

	m_opFile -> SeekFromStart(0);
	m_vCurrentPosition = 0;
	m_vCurrentPosition += m_opFile -> Read(&opChunk, 8, m_vCurrentPosition);
	if(strncmp(opChunk.id, "RIFF", 4) == 0)
		m_vCurrentPosition += m_opFile -> Read(&opRiffChunk, 4, m_vCurrentPosition);	//Skip past 'WAVE'
	else
	{
		m_vHasFormat = false;
		return NULL;
	}

	m_vCurrentPosition += m_opFile -> Read(&opChunk, 8, m_vCurrentPosition);
	if(strncmp(opChunk.id, "fmt ", 4) == 0)
	{
		m_vCurrentPosition += m_opFile -> Read(&opFormatChunk, 16, m_vCurrentPosition);
		if(opChunk.size > 16)
			m_vCurrentPosition = m_vCurrentPosition + opChunk.size - 16;
	}

	m_vCurrentPosition += m_opFile -> Read(&opChunk, 8, m_vCurrentPosition);
	if(strncmp(opChunk.id, "PAD ", 4) == 0)
		m_vCurrentPosition = m_vCurrentPosition + opChunk.size;
	else if(strncmp(opChunk.id, "data", 4) == 0)
		m_vCurrentPosition = m_vCurrentPosition - 8;

	m_vCurrentPosition += m_opFile -> Read(&opChunk, 8, m_vCurrentPosition);
	if(strncmp(opChunk.id, "data ", 4) == 0)
	{
		m_opFormat -> m_eType = EM_TYPE_RAW_AUDIO;
		m_opFormat -> m_vFrameRate = opFormatChunk.samplerate;
		m_opFormat -> m_vNumChannels = opFormatChunk.chans;
		if(opFormatChunk.bitspersample == 8)
			m_opFormat -> m_vBytesPerSample = 1;
		else if(opFormatChunk.bitspersample == 16)
			m_opFormat -> m_vBytesPerSample = 2;
		else
			EMDebugger("Unknown audio sample format in file!"); //TODO: Throw exception instead?
		m_vSizeBytes = opChunk.size;
	}		
	else
	{
		//eo << "Audio file format is \"" << opChunk.id << "\"." << ef;
//		EMDebugger("Unknown audio file format!"); //TODO: Throw exception instead?
		m_vHasFormat = false;
		return NULL;
	}

	m_vHeaderLength = m_vCurrentPosition; //m_opFile -> GetPosition(); //m_opFile -> tellg();
	m_vHasFormat = true;
	return m_opFormat;
}
예제 #11
0
void EMBeMediaTimer::SeekToFrame(int64 p_vNewFrame)
{
	Lock();
	
	//if(m_vIsStarted)
	//	Notify(EM_MESSAGE_PAUSE);
		
	status_t vAcquireResult = acquire_sem(m_vTimeProtectionSemaphore);
	if(vAcquireResult != B_NO_ERROR)
		EMDebugger("ERROR! EMBeMediaTimer could not acquire semaphore for timer protection!");

	if(p_vNewFrame < 0) 
		p_vNewFrame = 0;
	
	m_vNow = p_vNewFrame;
	m_vAudioThen = p_vNewFrame;
	m_vVideoThen = p_vNewFrame;
	release_sem(m_vTimeProtectionSemaphore);
	//Notify(EM_MESSAGE_TIME_SEEKED);

	//if(m_vIsStarted)
	//	Notify(EM_MESSAGE_RESUME);

	Unlock();
}
예제 #12
0
EMMediaPoolEntry::EMMediaPoolEntry(EMProjectDataLoader* p_opLoader, uint32 vUndecidedType)
{
	uint32 vID = static_cast<uint32>(p_opLoader -> LoadUInt32());
	m_vID = (int32) vID;
	m_vUsed = 0; //static_cast<int32>(p_opLoader -> LoadUInt32());
	
//	uint32 vType = p_opLoader -> LoadUInt32();

	if((vUndecidedType & EM_TYPE_RAW_AUDIO) == EM_TYPE_RAW_AUDIO) m_eType = EM_TYPE_RAW_AUDIO;
	else if((vUndecidedType & EM_TYPE_ENCODED_AUDIO) == EM_TYPE_RAW_AUDIO) m_eType = EM_TYPE_ENCODED_AUDIO;
	else if((vUndecidedType & EM_TYPE_ANY_AUDIO) == EM_TYPE_RAW_AUDIO) m_eType = EM_TYPE_ANY_AUDIO;
	else if((vUndecidedType & EM_TYPE_UNKNOWN_AUDIO) == EM_TYPE_UNKNOWN_AUDIO) m_eType = EM_TYPE_UNKNOWN_AUDIO;

	else if((vUndecidedType & EM_TYPE_RAW_VIDEO) == EM_TYPE_RAW_VIDEO) m_eType = EM_TYPE_RAW_VIDEO;
	else if((vUndecidedType & EM_TYPE_ENCODED_VIDEO) == EM_TYPE_ENCODED_VIDEO) m_eType = EM_TYPE_ENCODED_VIDEO;
	else if((vUndecidedType & EM_TYPE_ANY_VIDEO) == EM_TYPE_ANY_VIDEO) m_eType = EM_TYPE_ANY_VIDEO;
	else if((vUndecidedType & EM_TYPE_UNKNOWN_VIDEO) == EM_TYPE_UNKNOWN_VIDEO) m_eType = EM_TYPE_UNKNOWN_VIDEO;
	else if((vUndecidedType & EM_TYPE_BMP) == EM_TYPE_BMP) m_eType = EM_TYPE_BMP;
	else if((vUndecidedType & EM_TYPE_GIF) == EM_TYPE_GIF) m_eType = EM_TYPE_GIF;
	else if((vUndecidedType & EM_TYPE_JPG) == EM_TYPE_JPG) m_eType = EM_TYPE_JPG;
	else if((vUndecidedType & EM_TYPE_TGA) == EM_TYPE_TGA) m_eType = EM_TYPE_TGA;
	else 
		EMDebugger("ERROR! Unknown type saved in project file!");

	/*if((m_eType & EM_TYPE_ANY_AUDIO) > 0)
		m_oFileName = EMMediaUtility::Instance() -> ParseFullPath(p_opLoader -> LoadString(), DIRECTORY_ID_AUDIO_DATA_USED);
	else
		m_oFileName = string(p_opLoader -> LoadString());*/
}
예제 #13
0
void EMWaveFileReader::ReadData(void* p_vpBuffer, int64& p_vInOutNumBytes, int64 p_vBytePosition, int64 p_vBufferOffset, int32 p_vNumBytesPerSample)
{

	//eo << "Parameters: " << ef;
	//eo << "vpBuffer: " << (int) p_vpBuffer << ef;
	//eo << "p_vInOutNumBytes: " << (int) p_vInOutNumBytes << ef;
	//eo << "p_vBytePosition: " << (int) p_vBytePosition << ef;
	//eo << "p_vBufferOffset: " << (int) p_vBufferOffset << ef;

	if(! HasFormat())
		ReadFormatE();

	//m_opSem -> Acquire();

	if(m_vIsInitialized && m_vHasFormat)
	{
		p_vBytePosition += m_vHeaderLength; //Make sure we don't forget to include the header-length when addressing media file data!
		char* ptr = static_cast<char*>(p_vpBuffer);
		if(p_vBufferOffset > 0)
			memset(ptr, 0, p_vBufferOffset);

		ptr += p_vBufferOffset;
		
		int64 vGCount = m_opFile -> Read(ptr, p_vInOutNumBytes - p_vBufferOffset, p_vBytePosition);
		
		p_vInOutNumBytes = vGCount;
	}
	else
		EMDebugger("It's an error to try to Read a wave file when it's not opened and/or the format hasn't been read yet! Use InitCheckE and ReadFormatE first!"); //TODO: Throw exception instead?
	
	//m_opSem -> Release();
}
void* MediaInfoCommandGetOutputName::ExecuteE(void* p_upOutputID, void*, void*)
{
	//eo << "MediaInfoCommandGetOutputName" << ef;
	int32* vID = static_cast<int32*>(p_upOutputID);
	int32 vTargetID = *vID;
	EMOutputRepository* opOutputs = EMOutputRepository::Instance();

	opOutputs -> LockContainer();
	try
	{
		opOutputs -> Rewind();
		while(opOutputs -> Current() != NULL)
		{
			if(opOutputs -> Current() -> GetID() == vTargetID)
			{
				string oName = opOutputs -> Current() -> GetName();
				for(int v = 0; v < oName.length() +1; m_vpReturnValue[v++] = '\0')
					;
				memcpy(m_vpReturnValue, oName.c_str(), oName.length());
				opOutputs -> UnlockContainer();
				return static_cast<void*>(m_vpReturnValue);	
			}
			opOutputs -> Next();
		}
	}
	catch(...)
	{
		EMDebugger("ERROR! Exception in MediaInfoCommandGetOutputName::ExecuteE");
	}
	opOutputs -> UnlockContainer();
	return NULL;
}
예제 #15
0
bool
EMInputRepository	::	SetAsActiveMIDIInput(int32 p_vInputID, int32 p_vOutputID)
{
	LockContainer();
	try
	{
		Rewind();
		while(Current() != NULL)
		{
			EMRealtimeInputDescriptor* opInput = Current();
			if((opInput -> GetType() & EM_TYPE_MIDI) > 0)
			{
				EMRealtimeMIDIInputDescriptor* opMIDIInput =
					 static_cast<EMRealtimeMIDIInputDescriptor*>(opInput);

				if(opMIDIInput -> GetID() == p_vInputID)
					opMIDIInput -> SetActive(true, p_vOutputID);
				else
					opMIDIInput -> SetActive(false, 0);
			}
			Next();
		}
	}
	catch(...)
	{
		EMDebugger("ERROR! Exception while setting active MIDI track!");
	}
	UnlockContainer();
	return true;
}
예제 #16
0
void* MediaCommandSetTrackPan::ExecuteE(void* p_opParameterOne, void* p_opParameterTwo, void* p_opParameterThree)
{
	//;//cout_commented_out_4_release << "MediaCommandSetTrackPan" << endl;
	EMMediaEngine* opEngine = EMMediaEngine::Instance();
	EMMediaProject* opProject = opEngine -> GetMediaProject();

	int32* vID = static_cast<int32*>(p_opParameterOne);
	int32 vPan = *(static_cast<int32*>(p_opParameterTwo));

	EMMediaTrack* opTrack = NULL;
	opProject -> GetUsedTracks() -> LockContainer();
	try
	{
		opTrack = opProject -> GetUsedTracks() -> Find(*vID);
	}
	catch(...)
	{
		EMDebugger("ERROR! Exception in MediaCommandSetTrackPan::ExecuteE");
	}
	opProject -> GetUsedTracks() -> UnlockContainer();
	if(opTrack == NULL)
	{
		opProject -> GetUnusedTracks() -> LockContainer();
		try
		{
			opTrack = opProject -> GetUnusedTracks() -> Find(*vID);
		}
		catch(...)
		{
			EMDebugger("ERROR! Exception in MediaCommandSetTrackPan::ExecuteE");
		}
		opProject -> GetUnusedTracks() -> UnlockContainer();
	}
		
//	delete vID;
	
	if(opTrack == NULL)
		return NULL; //TODO: Throw exception instead?
	
	m_opRecentTrack = opTrack;
	m_vRecentPan = opTrack -> GetPan();
	opTrack -> SetPan(vPan);
	EMMediaEngine::Instance() -> GetMediaProject() -> SetDirty(true);
	EMMediaTimer::Instance() -> SeekToFrame(EMMediaTimer::Instance() -> NowFrame());
	return NULL;
}
void* MediaInfoCommandGetMIDISignalMeterValue::ExecuteE(void* p_upFloatArray, void* , void*)
{
	float* vpMeterValues = static_cast<float*>(p_upFloatArray);

	if(EMMediaEngine::Instance() -> GetMediaProject() == NULL)
		return NULL;

	if(EMMediaEngine::Instance() -> GetMediaProject() -> GetUsedTracks() == NULL)
		return NULL;

	if(EMMediaEngine::Instance() -> GetMediaProject() -> GetUnusedTracks() == NULL)
		return NULL;

	EMMediaEngine::Instance() -> GetMediaProject() -> GetUsedTracks() -> LockContainer();
	EMMediaEngine::Instance() -> GetMediaProject() -> GetUnusedTracks() -> LockContainer();

	int32 vTrackNumber = 0;
	list<EMMediaTrack*>::iterator oTrackIterator;

	for(oTrackIterator = EMMediaTrackRepository::m_opTracks -> begin(); oTrackIterator != EMMediaTrackRepository::m_opTracks -> end(); oTrackIterator++)
	{
		EMMediaTrack* opCurrentTrack = (*oTrackIterator);
		if((opCurrentTrack -> GetType() & EM_TYPE_MIDI) > 0 && ! opCurrentTrack -> IsObjectDeleted())
		{
			EMMediaMIDITrack* opMIDITrack = static_cast<EMMediaMIDITrack*>(opCurrentTrack);
			if(opMIDITrack -> GetSignalMeter() == NULL)
					EMDebugger("ERROR! MIDI track has no signal meter!");
#ifdef _DEBUG
#ifdef EM_SHOW_AUDIO_CACHE
			EMWinRealtimeAudioOutputDescriptor* opOut = static_cast<EMWinRealtimeAudioOutputDescriptor*>(EMOutputRepository::Instance() -> SearchForName(string(EM_OUTPUT_TO_MONITOR)));
			if(opOut != NULL)
			{
				int32 vMax = opOut -> GetDSPlayback() -> Capacity();
				int32 vUse = opOut -> GetDSPlayback() -> Used();
				float vVal = 1.0 * ((float) vUse) / ((float) vMax);
				vpMeterValues[vTrackNumber] = vVal;
			}
			else
				vpMeterValues[vTrackNumber] = 0.0;
#else
			vpMeterValues[vTrackNumber] = static_cast<EMMediaMIDISignalMeter*>(opMIDITrack -> GetSignalMeter()) -> GetLatestSignal();
#endif
#else
			vpMeterValues[vTrackNumber] = static_cast<EMMediaMIDISignalMeter*>(opMIDITrack -> GetSignalMeter()) -> GetLatestSignal();
#endif
			vTrackNumber++;
		}
	}

	EMMediaEngine::Instance() -> GetMediaProject() -> GetUsedTracks() -> UnlockContainer();
	EMMediaEngine::Instance() -> GetMediaProject() -> GetUnusedTracks() -> UnlockContainer();

	return NULL;
}
예제 #18
0
파일: BeOutputNode.cpp 프로젝트: dakk/Faber
void EMBeOutputNode::SetRunMode(run_mode mode)
{
	// We don't support offline run mode, so broadcast an error if we're set to
	// B_OFFLINE.  Unfortunately, we can't actually reject the mode change...
	if(mode == B_OFFLINE)
	{
		ReportError(B_NODE_FAILED_SET_RUN_MODE);
		EMDebugger("ERROR! We don't like OFFLINE MODE!");
	}
	BMediaEventLooper::SetRunMode(mode);
}
예제 #19
0
//Takes two IDs - the plugin entry id and the effect track id
void* MediaCommandShowEffectDialog::ExecuteE(void* p_upPluginID, void* p_upEffectTrackID, void*)
{
	int32 vPluginID = *static_cast<int32*>(p_upPluginID); //Existing Effect ID
	int32 vFXTrackID = *static_cast<int32*>(p_upEffectTrackID); //Existing track ID

	EMMediaEffectTrack* opFXTrack = EMMediaEffectTrackRepository::Instance() -> Find(vFXTrackID);
	if(opFXTrack == NULL)
		EMDebugger("ERROR! Could not locate the specified effect track ID!");

	EMPlugin* opPlugin = opFXTrack -> FindEffect(vPluginID);
	if(opPlugin == NULL)
		EMDebugger("ERROR! Could not locate the specified plugin ID!");

	if(!opPlugin -> ShowDialog())
	{
//		EMDebugger("ERROR! Unknown plugin, or ShowDialog not implemented for that type of plugin!");
	}

	return NULL;
}
예제 #20
0
EMMediaClipRepository* EMMediaClipRepository::New(EMMediaType p_eType)
{

	if((p_eType & EM_TYPE_ANY_AUDIO) > 0)
		return EM_new EMBeAudioClipRepository();
	else if((p_eType & EM_TYPE_ANY_VIDEO) > 0)
		return EM_new EMBeVideoClipRepository();

	EMDebugger("ERROR! Unknown type! Can't create new EMMediaClipRepository!");
	return NULL;
}
예제 #21
0
bool EMWaveFileWriter::InitCheckE()
{
	m_opSem -> Acquire();

	m_opFile = EMMediaFile::Create(&m_oFileName);
	if(m_opFile == NULL)
		EMDebugger("ERROR! Could not find media file in file repository");
	m_opFile -> Open(EM_WRITE);
	char vpPad[44];
	m_opFile -> Write(vpPad, 44); //Make a header that's empty (unset)
	;//cout_commented_out_4_release << "Ok! WaveWriter have written 44 bytes of header space now, so filepos is " << m_opFile -> GetPosition() << endl;
	m_vIsInitialized = true;
	
	m_opSem -> Release();
	return true;
}
예제 #22
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);
}
예제 #23
0
bool EMMediaClipRepository::ClearData()
{
	LockContainer();
	try
	{
		while(Size() > 0)
		{
			Rewind();
			EMMediaClip* opClip = Remove(Current());
			delete opClip;
		}
	}
	catch(...)
	{
		EMDebugger("ERROR! Exception in EMMediaClipRepository::ClearData()");
	}
	UnlockContainer();
	return true;
}
예제 #24
0
bool EMWaveFileReader::InitCheckE()
{
//	m_opSem -> Acquire();

	m_opFile = EMMediaFileRepository::Instance() -> FindFileName(&m_oFileName); //new ifstream();
	if(m_opFile == NULL)
	{
		EMMediaFileRepository::Instance() -> AddFile(&m_oFileName);
		m_opFile = EMMediaFileRepository::Instance() -> FindFileName(&m_oFileName); //new ifstream();
		if(m_opFile == NULL)
			EMDebugger("ERROR! Could still not find file in repository!");
	}

	m_opFile -> Open(EM_READ);
	
	m_vIsInitialized = ReadFormatE() == NULL ? false : true;

//	m_opSem -> Release();
	return m_vIsInitialized;
}
예제 #25
0
int64 EMMediaClipRepository::CountActiveClips()
{
	int64 vCount = 0;
	LockContainer();
	try
	{
		Rewind();
		while(Current() != NULL)
		{
			if(! Current() -> IsObjectDeleted())
				vCount++;
			Next();
		}
	}
	catch(...)
	{
		EMDebugger("ERROR! Exception in EMMediaClipRepository::CountActiveClips");
	}
	UnlockContainer();
	return vCount;
}
예제 #26
0
void* MediaCommandImportMedia::ExecuteE(void* p_upFileName, void* p_upArray, void*)
{
	//;//cout_commented_out_4_release << "MediaCommandImportMedia" << endl;
	string oFileName(static_cast<const char*>(p_upFileName));
	int32* vpArray = static_cast<int32*>(p_upArray);

	EMMediaEngine* opEngine = EMMediaEngine::Instance();
	if(opEngine -> GetMediaProject() -> GetMediaPool() == NULL)
		EMDebugger("ERROR! Media pool is NULL!");
	try
	{
		EMMediaPool* opPool = opEngine -> GetMediaProject() -> GetMediaPool();
		opPool -> AddMediaFileE(oFileName, vpArray);
		EMMediaEngine::Instance() -> GetMediaProject() -> SetDirty(true);
	}
	catch(EMException* e)
	{
		EMExceptionHandler::Instance() -> HandleException(*e);
	}
	return NULL;
}
void* MediaInfoCommandGetEffectInfo::ExecuteE(void* p_upMediaEffectID, void*, void*)
{
	int32 vMediaEffectID = *static_cast<int32*>(p_upMediaEffectID);

	EMMediaEffectTrackRepository* opFXTrackRep = EMMediaEffectTrackRepository::Instance();

	bool vBreakLoop = false;
	EMPlugin* opWantedPlugin = NULL;
	EMMediaEffectTrack* opFXTrack = NULL;

	opFXTrackRep -> LockContainer();
	opFXTrackRep -> Rewind();
	while(opFXTrackRep -> Current() != NULL && ! vBreakLoop)
	{
		if(!(opFXTrackRep -> Current() -> IsObjectDeleted()))
		{
			opFXTrack = opFXTrackRep -> Current();
			opWantedPlugin = opFXTrack -> FindEffect(vMediaEffectID);
			if(opWantedPlugin != NULL)
				break;
		}
		opFXTrackRep -> Next();
	}
	opFXTrackRep -> UnlockContainer();

	if(opWantedPlugin != NULL && opFXTrack != NULL)
	{
		m_oReturnValue.m_vID = opWantedPlugin -> GetID();
		m_oReturnValue.m_eType = (EMMediaType) opWantedPlugin -> GetType();
		m_oReturnValue.m_ePluginType = opWantedPlugin -> GetPluginType();
		m_oReturnValue.m_oPluginName = opWantedPlugin -> GetName();
		m_oReturnValue.m_vSlotNumber = opFXTrack -> GetSlotFor(opWantedPlugin);
		m_oReturnValue.m_vEntryID = opWantedPlugin -> GetEntryID();
		m_oReturnValue.m_vDryWetMix = opWantedPlugin -> GetDryWetMix();
	}
	else
		EMDebugger("ERROR! Could not find the effect with the specified ID!");

	return static_cast<void*>(&m_oReturnValue);
}
예제 #28
0
EMCommand* EMNetworkCommandFactory::CreateNetworkCommand(uint32 p_vType)
{
	switch(p_vType)
	{
		case NETWORK_COMMAND_SEND_MESSAGE:
			return EM_new NetworkCommandSendMessage();
		case NETWORK_COMMAND_SEND_FILE:
			return EM_new NetworkCommandSendFile();
		case NETWORK_COMMAND_RECEIVE_FILE:
			return EM_new NetworkCommandReceiveFile();
		case NETWORK_COMMAND_FIND_USER:
			return EM_new NetworkCommandFindUser();
		case NETWORK_COMMAND_ADD_USER:
			return EM_new NetworkCommandAddUser();
		case NETWORK_COMMAND_DELETE_USER:
			return EM_new NetworkCommandDeleteUser();


		case NETWORK_INFO_COMMAND_GET_MESSAGE:
			return EM_new NetworkInfoCommandGetNextMessage();
		case NETWORK_INFO_COMMAND_USER_STATUS_MESSAGE:
			return EM_new NetworkInfoCommandGetNextUserStatusMessage();
		case NETWORK_INFO_COMMAND_NUMBER_OF_USERS:
			return EM_new NetworkInfoCommandGetNumberOfUsers();
		case NETWORK_INFO_COMMAND_GET_USER_INFOS:
			return EM_new NetworkInfoCommandGetUserInfos();
		case NETWORK_INFO_COMMAND_GET_NEXT_FILE_INFO:
			return EM_new NetworkInfoCommandGetNextFileInfo();
		case NETWORK_INFO_COMMAND_GET_NEXT_DOWNLOADED_FILE:
			return EM_new NetworkInfoCommandGetNextDownloadedFile();
		case NETWORK_INFO_COMMAND_GET_NEXT_FOUND_USER:
			return EM_new NetworkInfoCommandGetNextFoundUser();


		default:
			EMDebugger("ERROR! EMNetworkCommandFactory could not find that network command!");
	}
	
	return NULL;
}
예제 #29
0
bool EMBeAudioOutputNode::Initialize()
{
	EMBeMediaUtility::GetRosterE() -> RegisterNode(this);
	
	//First, call parent's implementation
	if(! EMBeOutputNode::Initialize())
	{
		//emerr << "ERROR! EMBeAudioOutputNode could not initialize parent!" << endl;
		return false;
	}

	media_node mTimeSource;
	//memcpy(&(m_oConnection.m_sProducer), &(Node()), sizeof(media_node));
	memcpy(&(m_oConnection.m_sConsumer), &(m_spPhysicalOutInput -> node), sizeof(media_node));
	EMBeMediaUtility::GetRosterE() -> GetTimeSource(&mTimeSource);
	EMBeMediaUtility::GetRosterE() -> SetTimeSourceFor(m_oConnection.m_sProducer.node, mTimeSource.node);
	BTimeSource* opTimeSource = EMBeMediaUtility::GetRosterE() -> MakeTimeSourceFor(m_oConnection.m_sProducer);

/*	if(EMBeMediaUtility::GetRosterE() -> SetTimeSourceFor(m_oConnection.m_sConsumer.node, opTimeSource -> Node().node) != B_OK)
		EMDebugger("ERROR! Could not set time source for consumer node!");
	EMBeMediaUtility::GetRosterE() -> StartNode(opTimeSource -> Node(), 0);
	opTimeSource -> Release();
*/
	int32 count = 1;
	status_t err = EMBeMediaUtility::GetRosterE() -> GetFreeOutputsFor(Node()/*m_oConnection.m_sProducer*/, &m_oConnection.m_sOutput, 1, &count);
	memcpy(&(m_oConnection.m_sInput), m_spPhysicalOutInput, sizeof(media_input));
	m_oConnection.m_sFormat.type = B_MEDIA_RAW_AUDIO;	
	memcpy(&(m_oConnection.m_sFormat.u.raw_audio), &(media_raw_audio_format::wildcard), sizeof(media_raw_audio_format));

	err = EMBeMediaUtility::GetRosterE() -> Connect(m_oConnection.m_sOutput.source, m_oConnection.m_sInput.destination, &m_oConnection.m_sFormat, &m_oConnection.m_sOutput, &m_oConnection.m_sInput);
	if(err != B_OK)
		EMDebugger("ERROR! Could not connect audio titan output to system audio output!");

	memcpy(&(m_oConnection.m_sSource), &(m_oConnection.m_sOutput.source), sizeof(media_source));
	memcpy(&(m_oConnection.m_sDestination), &(m_oConnection.m_sOutput.destination), sizeof(media_destination));

	EMBeMediaUtility::GetRosterE() -> SetRunModeNode(m_oConnection.m_sProducer, BMediaNode::B_INCREASE_LATENCY);
	return true;
}
void* MediaInfoCommandGetTransition::ExecuteE(void* p_upMediaClipID, void*, void*)
{
	EMVideoTransitionClip* opClip;
	int32 vClipID   = *(static_cast<int32*>(p_upMediaClipID));

	EMMediaClipRepository* opVideoTransitionClipRepository = EMMediaEngine::Instance() -> GetMediaProject() -> GetVideoTransitionClipRepository();

	opVideoTransitionClipRepository -> LockContainer();
	try
	{
		opClip = static_cast<EMVideoTransitionClip*>(opVideoTransitionClipRepository -> Find(vClipID));
	}
	catch(...)
	{
		EMDebugger("ERROR! Exception in MediaInfoCommandGetTransition::ExecuteE");
	}
	opVideoTransitionClipRepository -> UnlockContainer();

	m_vTransID = opClip -> GetTransition() -> GetEntryID();

	return static_cast<void*>(&m_vTransID);
}