Example #1
0
extern "C" int WINAPI pos(HWND,HWND,char *data,char*,BOOL,BOOL)
{
	CComPtr<IFilterGraph> pFG;
	if(!GetFilterGraph(&pFG))
		return 1;

	CComQIPtr<IMediaSeeking> pMS = pFG;
	REFERENCE_TIME pos, dur;
	if(FAILED(pMS->GetCurrentPosition(&pos)) || FAILED(pMS->GetDuration(&dur)))
		return 1;

	if(dur > 10000000i64*60*60)
	{
		sprintf(data, _T("%02d:%02d:%02d/%02d:%02d:%02d"), 
			(int)(pos/10000000/60/60), (int)(pos/10000000/60)%60, (int)(pos/10000000)%60,
			(int)(dur/10000000/60/60), (int)(dur/10000000/60)%60, (int)(dur/10000000)%60);
	}
	else
	{
		sprintf(data, _T("%02d:%02d/%02d:%02d"), 
			(int)(pos/10000000/60)%60, (int)(pos/10000000)%60,
			(int)(dur/10000000/60)%60, (int)(dur/10000000)%60);
	}

	return 3;
}
Example #2
0
MEDIA_TIME	FMPlayerDShow::GetDuration()
{
	CComQIPtr<IMediaSeeking> iSeeking = m_FilterGraph; 
	MEDIA_TIME rtDur = 0; 
	if (iSeeking)
	{
		iSeeking->GetDuration(&rtDur);
	}
	return rtDur; 
}
Example #3
0
HRESULT CBaseMuxerInputPin::CompleteConnect(IPin* pReceivePin)
{
    HRESULT hr = __super::CompleteConnect(pReceivePin);
    if (FAILED(hr)) {
        return hr;
    }

    // duration

    m_rtDuration = 0;
    CComQIPtr<IMediaSeeking> pMS;
    if ((pMS = GetFilterFromPin(pReceivePin)) || (pMS = pReceivePin)) {
        pMS->GetDuration(&m_rtDuration);
    }

    // properties

    for (CComPtr<IPin> pPin = pReceivePin; pPin; pPin = GetUpStreamPin(GetFilterFromPin(pPin))) {
        if (CComQIPtr<IDSMPropertyBag> pPB = pPin) {
            ULONG cProperties = 0;
            if (SUCCEEDED(pPB->CountProperties(&cProperties)) && cProperties > 0) {
                for (ULONG iProperty = 0; iProperty < cProperties; iProperty++) {
                    PROPBAG2 PropBag;
                    memset(&PropBag, 0, sizeof(PropBag));
                    ULONG cPropertiesReturned = 0;
                    if (FAILED(pPB->GetPropertyInfo(iProperty, 1, &PropBag, &cPropertiesReturned))) {
                        continue;
                    }

                    HRESULT hr2;
                    CComVariant var;
                    if (SUCCEEDED(pPB->Read(1, &PropBag, NULL, &var, &hr2)) && SUCCEEDED(hr2)) {
                        SetProperty(PropBag.pstrName, &var);
                    }

                    CoTaskMemFree(PropBag.pstrName);
                }
            }
        }
    }

    (static_cast<CBaseMuxerFilter*>(m_pFilter))->AddInput();

    return S_OK;
}
Example #4
0
STDMETHODIMP CLMoviePlayer::Show(ILXFrameworkFrame* frame)
{
	CComPtr<ILXFrameworkApp> app;
	frame->GetApp(&app);

	CComPtr<ILXUIMDIFrameElement> frameelement;
	frame->get_Element(&frameelement);

	CComPtr<ILXUIDocument> appdocument;
	app->get_Document(&appdocument);

	CComPtr<ILXUIElement> mdiclient;
	frameelement->getMDIClient(&mdiclient);

	CComPtr<ILDOMDocument> doc;
	doc.CoCreateInstance(CLSID_LDOMDocument);

	VARIANT_BOOL success;
	doc->load(_variant_t(L"C:\\media_layout.xml"), &success);

	CComPtr<ILDOMElement> documentElement;
	doc->get_documentElement(&documentElement);

	CComPtr<ILDOMNode> layout;
	appdocument->importNode(documentElement, VARIANT_TRUE/*deep*/, &layout);

	CComQIPtr<ILMediaSeeking> seeking = m_filterGraph;
	LONGLONG duration;
	seeking->GetDuration(&duration);

// find the renderer filter
	CComPtr<ILBasicVideo> basicVideo;
	m_filterGraph->QueryFilterInterface(IID_ILBasicVideo, (IUnknown**)&basicVideo);

	/*
	if (basicVideo)
	{
		*/
		CComPtr<ILDOMElement> mdichild;
		appdocument->createElementNS(L"http://www.lerstad.com/2004/lxui", L"mdichild", &mdichild);
		if (mdichild)
		{
			CComPtr<ILXUIPageElement> page;
			appdocument->createElementNS(L"http://www.lerstad.com/2004/lxui", L"page", (ILDOMElement**)&page);
			if (page)
			{
				CComPtr<ILDOMElement> e;
				appdocument->createElementNS(L"http://www.lerstad.com/2004/lxui", L"content", &e);
				if (e)
				{
					e->appendChild(layout, NULL);

#if 0
					long cookie;
					e->addBehavior(L"#factory#videoview", &CComVariant(GetUnknown()), &cookie);
#endif

					page->appendChild(e, NULL);
				}
				mdichild->appendChild(page, NULL);
			}

			mdiclient->appendChild(mdichild, NULL);

			CComPtr<ILDOMElement> durationElement;
			appdocument->getElementById(L"media_duration", &durationElement);
			if (durationElement)
			{
				WCHAR str[64];
				swprintf(str, L"%g", (double)duration / LTIME_SCALE);
				durationElement->put_textContent(str);
			}

			CComPtr<ILDOMElement> videoElement;
			appdocument->getElementById(L"video", &videoElement);
			if (videoElement)
			{
				long cookie;
				videoElement->addBehavior(L"#factory#videoview", &CComVariant(GetUnknown()), &cookie);
			}

		}
	//}

	return S_OK;
}
Example #5
0
STDMETHODIMP CLX3DViewer::put_src(/*[in]*/ BSTR newVal)
{
	HRESULT hr;

	m_src = newVal;

	CComPtr<IServiceProvider> sp;
	hr = m_spClientSite->QueryInterface(IID_IServiceProvider, (void**)&sp);
	if (SUCCEEDED(hr))
	{
		CComPtr<IBindHost> bindHost;
		hr = sp->QueryService(SID_SBindHost, &bindHost);
		if (SUCCEEDED(hr))
		{
			CComPtr<IMoniker> imkName;

			CComPtr<IBindCtx> ctx;
			hr = CreateBindCtx(0/*reserved*/, &ctx);
			if (SUCCEEDED(hr))
			{
				hr = bindHost->CreateMoniker(m_src, NULL, &imkName, 0);
				if (SUCCEEDED(hr))
				{
					hr = m_filterGraph.CoCreateInstance(CLSID_LFilterGraph);
					if (SUCCEEDED(hr))
					{
						hr = m_filterGraph->AddSourceFilterForMoniker(imkName, ctx, L"", NULL);

						if (SUCCEEDED(hr))
						{
							CComQIPtr<ILMediaSeeking> seeking = m_filterGraph;
							LONGLONG duration;
							seeking->GetDuration(&duration);
							m_duration = duration / 100000.0;

							if (m_duration > 0)
							{
								m_slider.Enable(TRUE);
								m_slider.SetMaxPos(m_duration);
							}
							else
							{
								m_slider.Enable(FALSE);
							}

						// find the renderer filter
							CComPtr<ILBasicVideo> basicVideo;
							m_filterGraph->QueryFilterInterface(IID_ILBasicVideo, (IUnknown**)&basicVideo);
							if (basicVideo)
							{
								m_basicVideo = basicVideo;
							}
						}
					}
				}
			}
		}
	}

	return hr;

#if 0
#if 0
	m_viewpointStack.RemoveAll();
	m_navigationinfoStack.RemoveAll();
#endif

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

	CComBSTR m_src = newVal;

	CComQIPtr<IServiceProvider> sp = m_spClientSite;
	if (sp)
	{
		CComPtr<IMoniker> imkName;

		CComPtr<IBindHost> bindHost;
		if (SUCCEEDED(sp->QueryService(SID_SBindHost, &bindHost)))
		{
			bindHost->CreateMoniker(m_src, NULL, &imkName, 0);
		}
		else
		{
			CreateURLMoniker(NULL, m_src, &imkName);
		}

		if (imkName)
		{
			CComPtr<IBindCtx> bctx;
			if (SUCCEEDED(CreateBindCtx(0/*reserved*/, &bctx)))
			{
				CComPtr<IStream> stream;
				imkName->BindToStorage(bctx, NULL, IID_IStream, (void**)&stream);
				if (stream)
				{
					LPOLESTR szDisplayName;
					imkName->GetDisplayName(bctx, NULL, &szDisplayName);
					_bstr_t url = szDisplayName;
					CoTaskMemFree(szDisplayName);

					LPTSTR ext = PathFindExtension(url);
					if (ext && !strcmp(ext, ".mp4"))
					{
						m_file.CoCreateInstance(L"LMPEG4.MP4File");
						if (m_file)
						{
							//CComPtr<ILX3DScene> scene;

							CComPtr<IUnknown> unk;
							m_file->OpenStream(stream);
							
							//m_scene = static_cast<CComObject<CLSAIScene>*>(scene.p);
							//scene.Detach();

							CComQIPtr<ILBaseFilter> baseFilter = m_file;
							if (baseFilter)
							{
								CComPtr<ILPin> outputpin;
								baseFilter->GetPin(0, &outputpin);

								CComObject<CMoviePlayerFilter>::CreateInstance(&m_pFilter);
								m_pFilter->AddRef();
								m_pFilter->m_pMoviePlayer = this;

								// TODO, don't have it like this
								CComPtr<ILReferenceClock> clock;
								clock.CoCreateInstance(L"LMedia.LSystemClock");
								m_pFilter->m_clock = clock.Detach();
								m_pFilter->m_tStart = 0;

								outputpin->Connect(m_pFilter->m_pInput, NULL/*pMediaType*/);

								if (TRUE)
								{
									baseFilter->Run(0);
								}
							}
							else
							{
								::MessageBox(NULL, "Error opening file", "LViewer", MB_OK);
							}
						}
					}
					else
					{
						CComObject<CLSAIScene>::CreateInstance(&m_scene);
						if (m_scene)
						{
							m_scene->AddRef();

							m_scene->m_url = (BSTR)url;
							CoTaskMemFree(szDisplayName);

							m_scene->readStream(stream);

#if 0
							InitStacks();
#endif
						}
					}
				}
			}
		}
	}
#endif

	return S_OK;
}