コード例 #1
0
/// @brief Get provider 
/// @param video 
/// @return 
///
VideoProvider *VideoProviderFactory::GetProvider(std::string video) {
//XXX	std::vector<std::string> list = GetClasses(OPT_GET("Video/Provider")->GetString());
	std::vector<std::string> list = GetClasses("ffmpegsource");
	if (video.find("?dummy") == 0) list.insert(list.begin(), "Dummy");
	list.insert(list.begin(), "YUV4MPEG");

	bool fileFound = false;
	bool fileSupported = false;
	std::string errors;
	errors.reserve(1024);
	for (int i = 0; i < (signed)list.size(); ++i) {
		std::string err;
		try {
			VideoProvider *provider = Create(list[i], video);
			LOG_I("manager/video/provider") << list[i] << ": opened " << video;
			if (provider->WantsCaching()) {
				return new VideoProviderCache(provider);
			}
			return provider;
		}
		catch (agi::FileNotFoundError const&) {
			err = list[i] + ": file not found.";
			// Keep trying other providers as this one may just not be able to
			// open a valid path
		}
		catch (VideoNotSupported const&) {
			fileFound = true;
			err = list[i] + ": video is not in a supported format.";
		}
		catch (VideoOpenError const& ex) {
			fileSupported = true;
			err = list[i] + ": " + ex.GetMessage();
		}
		catch (agi::vfr::Error const& ex) {
			fileSupported = true;
			err = list[i] + ": " + ex.GetMessage();
		}
		errors += err;
		errors += "\n";
		LOG_D("manager/video/provider") << err;
	}

	// No provider could open the file
	LOG_E("manager/video/provider") << "Could not open " << video;
	std::string msg = "Could not open " + video + ":\n" + errors;

	if (!fileFound) throw agi::FileNotFoundError(video);
	if (!fileSupported) throw VideoNotSupported(msg);
	throw VideoOpenError(msg);
}
コード例 #2
0
/// @brief Get provider
/// @param video
/// @return
///
VideoProvider *VideoProviderFactory::GetProvider(wxString video) {
	std::vector<std::string> list = GetClasses(OPT_GET("Video/Provider")->GetString());
	if (video.StartsWith("?dummy")) list.insert(list.begin(), "Dummy");
	list.insert(list.begin(), "YUV4MPEG");

	bool fileFound = false;
	bool fileSupported = false;
	std::string errors;
	errors.reserve(1024);
	for (auto const& factory : list) {
		std::string err;
		try {
			VideoProvider *provider = Create(factory, video);
			LOG_I("manager/video/provider") << factory << ": opened " << from_wx(video);
			if (provider->WantsCaching()) {
				return new VideoProviderCache(provider);
			}
			return provider;
		}
		catch (agi::FileNotFoundError const&) {
			err = factory + ": file not found.";
			// Keep trying other providers as this one may just not be able to
			// open a valid path
		}
		catch (VideoNotSupported const&) {
			fileFound = true;
			err = factory + ": video is not in a supported format.";
		}
		catch (VideoOpenError const& ex) {
			fileSupported = true;
			err = factory + ": " + ex.GetMessage();
		}
		catch (agi::vfr::Error const& ex) {
			fileSupported = true;
			err = factory + ": " + ex.GetMessage();
		}
		errors += err;
		errors += "\n";
		LOG_D("manager/video/provider") << err;
	}

	// No provider could open the file
	LOG_E("manager/video/provider") << "Could not open " << from_wx(video);
	std::string msg = "Could not open " + from_wx(video) + ":\n" + errors;

	if (!fileFound) throw agi::FileNotFoundError(from_wx(video));
	if (!fileSupported) throw VideoNotSupported(msg);
	throw VideoOpenError(msg);
}
コード例 #3
0
/**
* @brief 
*
* @param provider
* @param link
*/
ImageTimestamper::ImageTimestamper( VideoProvider &provider, const FeedLink &link ) :
    VideoConsumer( cClass(), provider, link ),
    VideoProvider( cClass(), provider.name() ),
    Thread( identity() ),
    mTimestampFormat( "%N - %y/%m/%d %H:%M:%S.%f" ),
    mTimestampLocation( 0, 0 )
{
}
コード例 #4
0
/**
* @brief 
*
* @param pixelFormat
* @param width
* @param height
* @param provider
* @param link
*/
ImageScale::ImageScale(const Rational &scale, VideoProvider &provider, const FeedLink &link ) :
    VideoConsumer( cClass(), provider, link ),
    VideoProvider( cClass(), provider.name() ),
    Thread( identity() ),
    mScale( scale ),
    mWidth( 0 ),
    mHeight( 0 ),
    mScaleContext( NULL )
{
}
コード例 #5
0
/**
* @brief 
*
* @param pixelFormat
* @param width
* @param height
* @param provider
* @param link
*/
ImageConvert::ImageConvert( PixelFormat pixelFormat, int width, int height, VideoProvider &provider, const FeedLink &link ) :
    VideoConsumer( cClass(), provider, link ),
    VideoProvider( cClass(), provider.name() ),
    Thread( identity() ),
    mPixelFormat( pixelFormat ),
    mWidth( width ),
    mHeight( height ),
    mConvertContext( NULL )
{
}
コード例 #6
0
///////////////////
// Track current line
void FrameMain::OnVideoTrackPoints(wxCommandEvent &event) {
	videoBox->videoDisplay->Stop();

	// Get line
	AssDialogue *curline = SubsBox->GetDialogue(EditBox->linen);
	if (!curline) return;

	FexTrackerConfig config;
	DialogFexTracker configDlg( this, &config );
	configDlg.ShowModal();

	if( !config.FeatureNumber ) return;

	// Get Video
	VideoProvider *movie = VideoProvider::GetProvider(videoBox->videoDisplay->videoName, wxString(_T("")));

	// Create Tracker
	if( curline->Tracker ) delete curline->Tracker;
	curline->Tracker = new FexTracker( movie->GetWidth(), movie->GetHeight(), config.FeatureNumber );
	curline->Tracker->minFeatures = config.FeatureNumber;
	curline->Tracker->Cfg = config;

	// Start progress
	volatile bool canceled = false;
	DialogProgress *progress = new DialogProgress(this,_("FexTracker"),&canceled,_("Tracking points"),0,1);
	progress->Show();

	// Allocate temp image
	float* FloatImg = new float[ movie->GetWidth()*movie->GetHeight() ];

	int StartFrame = VFR_Output.GetFrameAtTime(curline->Start.GetMS(),true);
	int EndFrame = VFR_Output.GetFrameAtTime(curline->End.GetMS(),false);

	for( int Frame = StartFrame; Frame <= EndFrame; Frame ++ )
	{
		progress->SetProgress( Frame-StartFrame, EndFrame-StartFrame );
		if( canceled ) break;

		movie->GetFloatFrame( FloatImg, Frame );
		curline->Tracker->ProcessImage( FloatImg );
	}

	delete FloatImg;
	delete movie;

	// Clean up progress
	if (!canceled) 
		progress->Destroy();
	else
	{
		delete curline->Tracker;
		curline->Tracker = 0;
	}

	videoBox->videoDisplay->RefreshVideo();
}
コード例 #7
0
ファイル: shm_sink.cpp プロジェクト: ThereIsNoYeti/sflphone
void SHMSink::render_callback(VideoProvider &provider, size_t bytes)
{
    shm_lock();

    if (!resize_area(sizeof(SHMHeader) + bytes)) {
        ERROR("Could not resize area");
        return;
    }

    provider.fillBuffer(static_cast<void*>(shm_area_->data));
    shm_area_->buffer_size = bytes;
    shm_area_->buffer_gen++;
    sem_post(&shm_area_->notification);
    shm_unlock();
}
コード例 #8
0
/**
* @brief 
*
* @param provider
* @param link
*/
FilterSwapUV::FilterSwapUV( VideoProvider &provider, const FeedLink &link ) :
    VideoConsumer( cClass(), provider, link ),
    VideoProvider( cClass(), provider.name() ),
    Thread( identity() )
{
}