Exemple #1
0
void
VideoSource::ReloadVideo(const std::string sFileName, FrameQueue *pFrameQueue, VideoParser *pVideoParser)
{
    // fill in SourceData struct as much as we can right now. Client must specify parser at a later point
    assert(0 != pFrameQueue);
    oSourceData_.hVideoParser = pVideoParser->hParser_;
    oSourceData_.pFrameQueue  = pFrameQueue;

    cuvidDestroyVideoSource(hVideoSource_);

    CUVIDSOURCEPARAMS oVideoSourceParameters;
    // Fill parameter struct
    memset(&oVideoSourceParameters, 0, sizeof(CUVIDSOURCEPARAMS));
    oVideoSourceParameters.pUserData = &oSourceData_;               // will be passed to data handlers
    oVideoSourceParameters.pfnVideoDataHandler = HandleVideoData;   // our local video-handler callback
    oVideoSourceParameters.pfnAudioDataHandler = 0;
    // now create the actual source
    CUresult oResult = cuvidCreateVideoSource(&hVideoSource_, sFileName.c_str(), &oVideoSourceParameters);
    assert(CUDA_SUCCESS == oResult);
}
	VideoSource::~VideoSource()
	{
		cuvidDestroyVideoSource(hVideoSource_);
	}