Ejemplo n.º 1
0
void VideoFrameDesc::setParameters( const ProfileLoader::Profile& profile )
{
	// width
	if( profile.count( constants::avProfileWidth ) )
		setWidth( atoi( profile.find( constants::avProfileWidth )->second.c_str() ) );
	// height
	if( profile.count( constants::avProfileHeight ) )
		setHeight( atoi( profile.find( constants::avProfileHeight )->second.c_str() ) );
	// pixel format	
	if( profile.count( constants::avProfilePixelFormat ) )
		setPixelFormat( profile.find( constants::avProfilePixelFormat )->second );
	// fps
	if( profile.count( constants::avProfileFrameRate ) )
		setFps( atof( profile.find( constants::avProfileFrameRate )->second.c_str() ) );
}
Ejemplo n.º 2
0
void AudioDecoder::setProfile( const ProfileLoader::Profile& profile )
{
	LOG_DEBUG( "Set profile of audio decoder with:\n" << profile )

	AudioCodec& codec = _inputStream->getAudioCodec();

	// set threads before any other options
	if( profile.count( constants::avProfileThreads ) )
		codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
	else
		codec.getOption( constants::avProfileThreads ).setString( "auto" );

	// set decoder options
	for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
	{
		if( (*it).first == constants::avProfileIdentificator ||
			(*it).first == constants::avProfileIdentificatorHuman ||
			(*it).first == constants::avProfileType ||
			(*it).first == constants::avProfileThreads )
			continue;

		try
		{
			Option& decodeOption = codec.getOption( (*it).first );
			decodeOption.setString( (*it).second );
		}
		catch( std::exception& e )
		{
			LOG_WARN( "AudioDecoder - can't set option " << (*it).first <<  " to " << (*it).second << ": " << e.what() )
		}
	}
}
Ejemplo n.º 3
0
void AudioDecoder::setupDecoder( const ProfileLoader::Profile& profile )
{
	// check the given profile
	const bool isValid = ProfileLoader::checkAudioProfile( profile );
	if( ! isValid && ! profile.empty() )
	{
		const std::string msg( "Invalid audio profile to setup decoder." );
		LOG_ERROR( msg )
		throw std::runtime_error( msg );
	}

	if( ! profile.empty() )
	{
		LOG_INFO( "Setup audio decoder with:\n" << profile )
	}

	AudioCodec& codec = _inputStream->getAudioCodec();

	// set threads before any other options
	if( profile.count( constants::avProfileThreads ) )
		codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
	else
		codec.getOption( constants::avProfileThreads ).setInt( codec.getAVCodecContext().thread_count );

	// set decoder options
	for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
	{
		if( (*it).first == constants::avProfileIdentificator ||
			(*it).first == constants::avProfileIdentificatorHuman ||
			(*it).first == constants::avProfileType ||
			(*it).first == constants::avProfileThreads )
			continue;

		try
		{
			Option& decodeOption = codec.getOption( (*it).first );
			decodeOption.setString( (*it).second );
		}
		catch( std::exception& e )
		{
			LOG_WARN( "AudioDecoder - can't set option " << (*it).first <<  " to " << (*it).second << ": " << e.what() )
		}
	}

	// open decoder
	_inputStream->getAudioCodec().openCodec();
	_isSetup = true;
}