Recent IP Video Source class/module is not limited to use via registration as a video input/capture/source device. The filter is also registered as a regular filter and can be used programmatically in a regular way: CoCreateInstance, AddFilter etc.
A C++ code snippet below shows how to import interface definition, create an instance of the filter, set it up and start video from a camera:
#include <dshow.h> #pragma comment(lib, "strmiids.lib") #import "libid:BDCE8B49-8895-4605-8278-E9A1FBC889AC" no_namespace raw_interfaces_only raw_dispinterfaces named_guids // IpVideoSource // [...] inline VOID ATLENSURE_INLINE_SUCCEEDED(HRESULT nResult) { ATLENSURE_SUCCEEDED(nResult); } // [...] CComPtr<IBaseFilter> pBaseFilter; ATLENSURE_INLINE_SUCCEEDED(pBaseFilter.CoCreateInstance(CLSID_JpegVideoSourceFilter)); CComQIPtr<IJpegVideoSourceFilter> pJpegVideoSourceFilter = pBaseFilter; ATLENSURE_THROW(pJpegVideoSourceFilter, E_NOINTERFACE); ATLENSURE_INLINE_SUCCEEDED(pFilterGraph->AddFilter(pBaseFilter, L"Source")); ATLENSURE_INLINE_SUCCEEDED(pJpegVideoSourceFilter->put_Location(CComBSTR(_T("http://p.viewnetcam.com:60001/nphMotionJpeg?Resolution=640x480&Quality=Standard")))); ATLENSURE_INLINE_SUCCEEDED(pJpegVideoSourceFilter->put_Width(640)); ATLENSURE_INLINE_SUCCEEDED(pJpegVideoSourceFilter->put_Height(480)); #pragma region Render Output Pin CComPtr<IEnumPins> pEnumPins; ATLENSURE_INLINE_SUCCEEDED(pBaseFilter->EnumPins(&pEnumPins)); CComPtr<IPin> pPin; ATLENSURE_THROW(pEnumPins->Next(1, &pPin, NULL) == S_OK, E_FAIL); ATLASSERT(pPin); ATLENSURE_INLINE_SUCCEEDED(pFilterGraph->Render(pPin)); #pragma endregion
This starts M-JPEG video from Panasonic BB-HCM381A camera available to public online at http://p.viewnetcam.com:60001/nphMotionJpeg?Resolution=640×480&Quality=Standard
UPDATE: ATLENSURE_SUCCEEDED macro in the snippet replaced with ATLENSURE_INLINE_SUCCEEDED – see additional post on this.
C#.NET code snippet will look like this (using DirectShowLib):
using DirectShowLib; using AlaxInfoIpVideoSource; // [...] FilterGraph filterGraph = new FilterGraph(); IJpegVideoSourceFilter sourceFilter = Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("{A8DA2ECB-DEF6-414D-8CE2-E651640DBA4F}"))) as IJpegVideoSourceFilter; IBaseFilter sourceBaseFilter = sourceFilter as IBaseFilter; (filterGraph as IFilterGraph2).AddFilter(sourceBaseFilter, "Source"); sourceFilter.Location = @"http://p.viewnetcam.com:60001/nphMotionJpeg?Resolution=640x480&Quality=Standard"; sourceFilter.Width = 640; sourceFilter.Height = 480; IPin pin = DsFindPin.ByDirection(sourceBaseFilter, PinDirection.Output, 0); (filterGraph as IFilterGraph2).Render(pin); (filterGraph as IMediaControl).Run(); EventCode eventCode; (filterGraph as IMediaEvent).WaitForCompletion(-1, out eventCode);
Hi Roman!
I’m making my first steps in directshow.net and now I’m stuck.
using AlaxInfoIpVideoSource; -> “type or name could not be found”
When I try to add an assembly reference to IPVideoSource.dll, I get “This file may not be a managed assembly” (which is surely true)
I think I’m just missing anything…
Would you please help me?
MfG
Andreas