Beispiel #1
0
HRESULT 
recChannel_t::unmap(void)
{
     __CONTEXT("recChannel_t::unmap");
	
	IBaseFilter * pFilter = NULL;
	int hr =0;
	hr = pGraph->FindFilterByName(L"Video Renderer",&pFilter);
	
	if (!hr)
	{
	 	IVideoWindow *pWindowInfo = NULL;
		hr = pFilter->QueryInterface(IID_IVideoWindow, (void **)&pWindowInfo);
		errorCheck(hr);
		pWindowInfo->put_Visible(OAFALSE);
		pWindowInfo->put_AutoShow(OAFALSE);
		pWindowInfo->Release();
	}
	
	pControl->StopWhenReady();
#ifdef _WINDOWS
    if (fControl)
    {
        fControl->CWnd::ShowWindow(SW_HIDE);
    }
#endif
	mapping = false;
	return 0;
}
Beispiel #2
0
/*
 * Class:     sage_DShowMediaPlayer
 * Method:    setVideoHWND0
 * Signature: (JJ)V
 */
JNIEXPORT void JNICALL Java_sage_DShowMediaPlayer_setVideoHWND0
  (JNIEnv *env, jobject jo, jlong dataPtr, jlong vhwnd)
{
	CPlayerData* playData = (CPlayerData*) dataPtr;
	IGraphBuilder* pGraph = playData->GetGraph();
	IVideoWindow* pVW = NULL;
	HRESULT hr = pGraph->QueryInterface(IID_IVideoWindow, (void**)&pVW);
	if (SUCCEEDED(hr))
	{
		slog((env, "DShowPlayer setVideoHWND(%d)\r\n", (int) vhwnd));
		pVW->put_AutoShow(OAFALSE);
		pVW->put_Owner((OAHWND)vhwnd);
		pVW->put_MessageDrain((OAHWND)vhwnd);
		pVW->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
		pVW->put_Visible(OATRUE);

		// We do all of our own aspect ratio control, so don't let DShow do any for us
		// by setting the aspect ratio mode on the video rendering filter's pin
		IEnumFilters *pEnum = NULL;
		hr = pGraph->EnumFilters(&pEnum);
		if (SUCCEEDED(hr))
		{
			IBaseFilter *currFilt = NULL;
			while (pEnum->Next(1, &currFilt, NULL) == S_OK)
			{
				IPin *overlayPin = NULL;
				hr = currFilt->FindPin(L"Input0", &overlayPin);
				if (SUCCEEDED(hr))
				{
					// Right pin name, let's see if it's overlay
					IMixerPinConfig *pOverlayMix = NULL;
					hr = overlayPin->QueryInterface(IID_IMixerPinConfig, (void**)&pOverlayMix);
					if (SUCCEEDED(hr))
					{
						pOverlayMix->SetAspectRatioMode(AM_ARMODE_STRETCHED);
						SAFE_RELEASE(pOverlayMix);
					}
					SAFE_RELEASE(overlayPin);
				}
				SAFE_RELEASE(currFilt);
			}
			SAFE_RELEASE(pEnum);
			hr = S_OK;
		}
		SAFE_RELEASE(pVW);
	}
	HTESTPRINT(hr);
}
bool CHogVideo::Hog()
{
    if (!m_pGraph && !m_pMediaControl && !m_pVideoWindow)
        return false;

    this->UnHog();

    HRESULT hr = NULL;
    IGraphBuilder *pGraph           = (IGraphBuilder*)  m_pGraph;
    IMediaControl *pMediaControl    = (IMediaControl*)  m_pMediaControl;
    IVideoWindow  *pVideoWindow     = (IVideoWindow*)   m_pVideoWindow;

    // Build the graph. IMPORTANT: Change string to a file on your system.
    hr = pGraph->RenderFile(m_wszFilename, NULL);
    if (SUCCEEDED(hr))
    {
        // Run the graph.
        hr = pMediaControl->Run();
        // Hide the window
        pVideoWindow->put_WindowState(SW_HIDE);
        pVideoWindow->put_AutoShow(OAFALSE);
        pVideoWindow->put_Visible(OAFALSE);
        pVideoWindow->put_Top(-100);
        pVideoWindow->put_Left(-100);
        pVideoWindow->put_Width(0);
        pVideoWindow->put_Height(0);

        if (SUCCEEDED(hr))
        {
            // Hog the resource.
            pMediaControl->Pause();
            return true;
        }
        else
            return false;
    }
    else
        return false;
}
Beispiel #4
0
void Video::play( char *fileName, DWORD )
{
	WCHAR wPath[100];
	HRESULT hr;
	IMediaControl *pMC;

	if(!init_success)
		return;

	MultiByteToWideChar( CP_ACP, 0, fileName, -1, wPath, 100 );

	if( (hr = pGraph->RenderFile(wPath, NULL)) == 0)
	{

		// use full screen video interface
		// try to change display mode
		IVideoWindow *iVideoWindow = NULL;
		if( (hr = pGraph->QueryInterface(IID_IVideoWindow, (void **) &iVideoWindow)) == 0)
		{
#ifdef CREATE_DUMMY_WINDOW
			if(hwnd)
			{
				HRESULT hr2 = iVideoWindow->put_MessageDrain((OAHWND) hwnd);
				hr2 = 0;
			}
#endif

#ifdef FULL_SCREEN_VIDEO
			IFilter *iFilter;
			if( pGraph->FindFilterByName(L"Video Renderer", &iFilter) == 0)
			{
				IBasicVideo *iBasicVideo;
				if( iFilter->QueryInterface(IID_IBasicVideo, (void **)&iBasicVideo) == 0)
				{
					IFullScreenVideo *iFullScreenVideo;
					IDirectDrawVideo *iDirectDrawVideo;
					if( iFilter->QueryInterface(IID_IFullScreenVideo, (void **)&iFullScreenVideo) == 0)
					{
						iFullScreenVideo->Release();
					}
					else if( iFilter->QueryInterface(IID_IDirectDrawVideo, (void **)&iDirectDrawVideo) == 0)
					{
						HRESULT hr2;
						hr2 = iDirectDrawVideo->UseWhenFullScreen(OATRUE);
						iDirectDrawVideo->Release();
					}

					iBasicVideo->Release();
				}
				iFilter->Release();
			}
			hr=iVideoWindow->put_FullScreenMode(OATRUE);
#endif

			/* // code to find all filter in the filter graph
			{
				IEnumFilters *iEnumFilters;
				pGraph->EnumFilters(&iEnumFilters);

				ULONG filterCount = 16;
				IFilter *iFilters[16];
				iEnumFilters->Next(filterCount, iFilters, &filterCount);

				for( ULONG j = 0; j < filterCount; ++j )
				{
					FILTER_INFO filterInfo;
					iFilters[j]->QueryFilterInfo(&filterInfo);
					filterInfo.pGraph->Release();
					iFilters[j]->Release();
				}

				iEnumFilters->Release();
			}*/

			iVideoWindow->HideCursor(OATRUE);
			iVideoWindow->put_Visible( OAFALSE );
			iVideoWindow->put_AutoShow( OAFALSE );
			LONG windowStyle;
			iVideoWindow->get_WindowStyle( &windowStyle);
			windowStyle &= ~WS_BORDER & ~WS_CAPTION & ~WS_SIZEBOX & ~WS_THICKFRAME &
				~WS_HSCROLL & ~WS_VSCROLL & ~WS_VISIBLE;
			iVideoWindow->put_WindowStyle( windowStyle);
		}
		else
			iVideoWindow = NULL;
		
		if( (hr = pGraph->QueryInterface(IID_IMediaControl, (void **) &pMC)) == 0)
		{
			pMC->Run();					// sometimes it returns 1, but still ok
			state = PLAYING;
			pMC->Release();
		}

		if( iVideoWindow )
		{
			iVideoWindow->put_Visible( OAFALSE );
			LONG windowStyle;
			iVideoWindow->get_WindowStyle( &windowStyle);
			windowStyle &= ~WS_BORDER & ~WS_CAPTION & ~WS_SIZEBOX & ~WS_THICKFRAME &
				~WS_HSCROLL & ~WS_VSCROLL & ~WS_VISIBLE;
			iVideoWindow->put_WindowStyle( windowStyle);

			LONG maxWidth;
			LONG maxHeight;
			hr=iVideoWindow->GetMaxIdealImageSize( &maxWidth, &maxHeight);
#ifdef FULL_SCREEN_VIDEO
#else
			iVideoWindow->put_BorderColor( RGB(0,0,0) );
			iVideoWindow->put_WindowState(SW_MAXIMIZE);

			IBaseFilter *iFilter;
			if( pGraph->FindFilterByName((const WCHAR *)L"Video Renderer", &iFilter) == 0)
			{
				IBasicVideo *iBasicVideo;
				if( iFilter->QueryInterface(IID_IBasicVideo, (void **)&iBasicVideo) == 0)
				{
					LONG screenWidth;
					LONG screenHeight;
					LONG videoWidth;
					LONG videoHeight;
					if( iVideoWindow->get_Width(&screenWidth) == 0 &&
						iVideoWindow->get_Height(&screenHeight) == 0 &&
						iBasicVideo->GetVideoSize(&videoWidth, &videoHeight) == 0)
					{
						// zoom in by 2 if possible
						if( screenWidth >= videoWidth * 2 &&
							screenHeight >= videoHeight * 2)
						{
							videoWidth *= 2;
							videoHeight *= 2;
						}

						// center the video client area
						iBasicVideo->SetDestinationPosition(
							(screenWidth-videoWidth)/2, (screenHeight-videoHeight)/2,
							videoWidth, videoHeight);
					}

					iBasicVideo->Release();
				}
				iFilter->Release();
			}
#endif
			iVideoWindow->HideCursor(OATRUE);
			iVideoWindow->SetWindowForeground(OATRUE);
		}

		if(iVideoWindow)
		{
			iVideoWindow->Release();
			iVideoWindow = NULL;
		}
	}

	if( hr && !skip_on_fail_flag)
		err.run("video.play error %d", hr );
}
Beispiel #5
0
void 
recChannel_t::refresh_channel(bool all)
{
     __CONTEXT("recChannel_t::refresh_channel");
    pControl->Stop();
#ifdef _WINDOWS
    if (fControl)
    {
        fControl->CWnd::ShowWindow(SW_HIDE);
    }
#endif
	
	if (pSource!=NULL)
    {
		pGraph->RemoveFilter(pSource);
		camInfo->setFree(true);
	}
	
	// Enumerate the filters in the graph.
	IEnumFilters *pEnum = NULL;
	int hr = pGraph->EnumFilters(&pEnum);
	if (SUCCEEDED(hr))
	{
		IBaseFilter *pFilter = NULL;
		while (S_OK == pEnum->Next(1, &pFilter, NULL))
		{
			CLSID filterId;
			pFilter->GetClassID(&filterId);
			if(filterId == CLSID_VideoRenderer ||
			   filterId == CLSID_VideoMixingRenderer)
			{
				IVideoWindow *pWindowInfo = NULL;
				pFilter->QueryInterface(IID_IVideoWindow, (void **)&pWindowInfo);
				pWindowInfo->get_Height(&windowInfo.heigth);
				pWindowInfo->get_Left(&windowInfo.left);
				pWindowInfo->get_Top(&windowInfo.top);
				pWindowInfo->get_Width(&windowInfo.width);
           		pWindowInfo->put_AutoShow(OAFALSE);
			    pWindowInfo->put_Visible(OAFALSE);
        	   	if (all)
				{
                   	pGraph->RemoveFilter(pFilter);
					pFilter->Release();
					pEnum->Reset();
					pWindowInfo->Release();
				}

			}else{
                
                pGraph->RemoveFilter(pFilter);    
                pFilter->Release();
                pEnum->Reset();
			}
		}
		pEnum->Release();
	}
	if (all)
	{
		pGraph->Release();
		hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, 
                          IID_IGraphBuilder, (void **)&pGraph);
		errorCheck(hr);
	}
	hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
	errorCheck(hr);

}