/*
 * CPacketFilterGraph
 */
void CPacketFilterGraph::ClearGraph()
{
  DEBUG("=== Clear graph");
  if (mnFilters > 0) {
    StopAllFilters();
    PurgeAllFilters();
    DeleteAllConnections();
    RemoveAllFilters();
  }
  DEBUG("Clear graph done");
}
Example #2
0
wxGxObjectDialog::~wxGxObjectDialog()
{
	if(m_pwxGxContentView)
		m_pwxGxContentView->Deactivate();
	if(m_PopupCtrl)
		m_PopupCtrl->Deactivate();

    SerializeFramePos(true);

	RemoveAllFilters();

    wxDELETE(m_pwxGxContentView);

    wxDELETE(m_pGISAcceleratorTable);
}
Example #3
0
//
//  Sets the file we're going to play.
//
//  Returns true if the file can be played, false otherwise.
//
bool CMediaPlayer::SetFileName(LPCWSTR FileName)
{
    RemoveAllFilters();
    if (_FileName != NULL)
    {
        free(_FileName);
    }

    _FileName = _wcsdup(FileName);
    if (_FileName == NULL)
    {
        return false;
    }

    //
    //  Ask DirectShow to build a render graph for this file.
    //
    HRESULT hr = _GraphBuilder->RenderFile(_FileName, NULL);
    if (FAILED(hr))
    {
        MessageBox(_AppWindow, L"Unable to build graph for media file", L"Set Filename Error", MB_OK);
        return false;
    }


    //
    //  If we can figure out the length of this track retrieve it.
    //
    DWORD caps = AM_SEEKING_CanGetDuration;
    bool canSeek = (S_OK == _MediaSeeking->CheckCapabilities(&caps));
    if (canSeek)
    {
        _MediaSeeking->GetDuration(&this->_MediaPlayerTime);
    }
    return true;
}
Example #4
0
BOOL CDXVideoGrabber::PlayFile(const char* inFile, HWND hWnd)
{
	RemoveAllFilters();

	HRESULT hr = m_pGrabber.CoCreateInstance( CLSID_SampleGrabber );
	if( !m_pGrabber )
		return FALSE;

	CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabBase( m_pGrabber );
	// force it to connect to video, 24 bit
	//
	CMediaType VideoType;
	VideoType.SetType( &MEDIATYPE_Video );
	VideoType.SetSubtype( &MEDIASUBTYPE_RGB24 );
	hr = m_pGrabber->SetMediaType( &VideoType ); // shouldn't fail
	if( FAILED( hr ) )
		return FALSE;

	// add the grabber to the graph
	//
	hr = m_pIGraphBuilder->AddFilter( pGrabBase, L"Grabber" );
	if( FAILED( hr ) )
		return FALSE;

	RenderFile(inFile);

	AM_MEDIA_TYPE mt;
	hr = m_pGrabber->GetConnectedMediaType( &mt );
	if ( FAILED( hr) )
	{
		return FALSE;
	}

	VIDEOINFOHEADER * vih = (VIDEOINFOHEADER*) mt.pbFormat;
	if(m_pSGCB)
	{
		// 		m_pSGCB->SetOwner(GetParent(hWnd));
		m_pSGCB->SetWidth(vih->bmiHeader.biWidth);
		m_pSGCB->SetHeight(vih->bmiHeader.biHeight);
	}
	FreeMediaType( mt );

	// don't buffer the samples as they pass through
	//
	hr = m_pGrabber->SetBufferSamples( FALSE );

	// only grab one at a time, stop stream after
	// grabbing one sample
	//
	hr = m_pGrabber->SetOneShot( FALSE );

	// set the callback, so we can grab the one sample
	//
	hr = m_pGrabber->SetCallback( m_pSGCB, 1 );

	if(!SetDisplayWindow(hWnd))
	{
		return FALSE;
	}

	return Run();
}
Example #5
0
BOOL CDXCamara::PlayFile(const char* inFile, HWND hWnd)
{
	HRESULT hr;

	RemoveAllFilters();
	// get whatever capture device exists
	//
	CComPtr< IBaseFilter > pCap;
	GetDefaultCapDevice( &pCap );
	if( !pCap )
		return FALSE;

	// add the capture filter to the graph
	//
	hr = m_pIGraphBuilder->AddFilter( pCap, L"Cap" );
	if( FAILED( hr ) )
		return FALSE;

	hr = m_pGrabber.CoCreateInstance( CLSID_SampleGrabber );
	if( !m_pGrabber )
		return FALSE;

	CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabBase( m_pGrabber );
	// force it to connect to video, 24 bit
	//
	CMediaType VideoType;
	VideoType.SetType( &MEDIATYPE_Video );
	VideoType.SetSubtype( &MEDIASUBTYPE_RGB24 );
	hr = m_pGrabber->SetMediaType( &VideoType ); // shouldn't fail
	if( FAILED( hr ) )
		return FALSE;

	// add the grabber to the graph
	//
	hr = m_pIGraphBuilder->AddFilter( pGrabBase, L"Grabber" );
	if( FAILED( hr ) )
		return FALSE;

	// make a capture builder graph (for connecting help)
	//
	CComPtr< ICaptureGraphBuilder2 > pBuilder;
	hr = pBuilder.CoCreateInstance( CLSID_CaptureGraphBuilder2 );
	if( !pBuilder )
		return FALSE;

	hr = pBuilder->SetFiltergraph( m_pIGraphBuilder );

	if( FAILED( hr ) )
		return FALSE;


	// If there is a VP pin present on the video device, then put the 
	// renderer on CLSID_NullRenderer
	CComPtr<IPin> pVPPin;
	hr = pBuilder->FindPin(
		pCap, 
		PINDIR_OUTPUT, 
		&PIN_CATEGORY_VIDEOPORT, 
		NULL, 
		FALSE, 
		0, 
		&pVPPin);


	// If there is a VP pin, put the renderer on NULL Renderer
	CComPtr<IBaseFilter> pRenderer;
	if (S_OK == hr)
	{   
		hr = pRenderer.CoCreateInstance(CLSID_NullRenderer);    
		if (FAILED (hr))
		{
			return FALSE;
		}
		hr = m_pIGraphBuilder->AddFilter(pRenderer, L"NULL renderer");
		if (FAILED (hr))
		{
			return FALSE;
		}
	}

	hr = pBuilder->RenderStream(
		&PIN_CATEGORY_PREVIEW,
		&MEDIATYPE_Interleaved, 
		pCap, 
		pGrabBase, 
		pRenderer);
	if (FAILED (hr))
	{
		// try to render preview pin
		hr = pBuilder->RenderStream( 
			&PIN_CATEGORY_PREVIEW, 
			&MEDIATYPE_Video,
			pCap, 
			pGrabBase, 
			pRenderer);

		// try to render capture pin
		if( FAILED( hr ) )
		{
			hr = pBuilder->RenderStream( 
				&PIN_CATEGORY_CAPTURE, 
				&MEDIATYPE_Video,
				pCap, 
				pGrabBase, 
				pRenderer);
		}
	}

	if( FAILED( hr ) )
	{
		return FALSE;
	}

	// ask for the connection media type so we know how big
	// it is, so we can write out bitmaps
	//
	AM_MEDIA_TYPE mt;
	hr = m_pGrabber->GetConnectedMediaType( &mt );
	if ( FAILED( hr) )
	{
		return FALSE;
	}

	VIDEOINFOHEADER * vih = (VIDEOINFOHEADER*) mt.pbFormat;
	if(m_pSGCB)
	{
// 		m_pSGCB->SetOwner(GetParent(hWnd));
		m_pSGCB->SetWidth(vih->bmiHeader.biWidth);
		m_pSGCB->SetHeight(vih->bmiHeader.biHeight);
	}
	FreeMediaType( mt );

	// don't buffer the samples as they pass through
	//
	hr = m_pGrabber->SetBufferSamples( FALSE );

	// only grab one at a time, stop stream after
	// grabbing one sample
	//
	hr = m_pGrabber->SetOneShot( FALSE );

	// set the callback, so we can grab the one sample
	//
	hr = m_pGrabber->SetCallback( m_pSGCB, 1 );


// 	CComPtr< IBaseFilter > pMux;
// 	CComPtr< IFileSinkFilter > pSink;
// 	USES_CONVERSION;
// 
// 	hr = pBuilder->SetOutputFileName( &MEDIASUBTYPE_Avi,  T2W( inFile ), 
// 		&pMux, &pSink );
// 	if( FAILED( hr ) )
// 		return FALSE;
// 
// 	hr = pBuilder->RenderStream( &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
// 		pCap, NULL,pMux );
// 	if( FAILED( hr ) )
// 		return FALSE;

// 	hr = pBuilder->RenderStream( &PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
// 		pCap, NULL, NULL );
// 	if( FAILED( hr ) )
// 		return FALSE;

	if(!SetDisplayWindow(hWnd))
	{
		return FALSE;
	}

	return Run();
}