Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

direct show app..

196 views
Skip to first unread message

Vishuonline

unread,
Jan 26, 2006, 5:02:02 PM1/26/06
to
Hi,

I am using the following sample code for rendering a video stream directly
from the camera. I am getting an error "HRESULT: 0x0004027e (262782) " in
RenderStream API call. How do I make a work around to this problem ? I am
sure there is a way to do this.. please help. My Smartphone device is a Qtek
8310.

GetFirstCameraDriver(szCameraName);
HRESULT rslt = InitCaptureGraphBuilder(&pGraph,&pCaptureGraph);
if(rslt == S_OK)
{
CComPtr<IBaseFilter> m_pVideoCaptureFilter;
CComPtr<IPersistPropertyBag> pPropertyBag;

m_pVideoCaptureFilter.CoCreateInstance( CLSID_VideoCapture );
m_pVideoCaptureFilter.QueryInterface( &pPropertyBag );

varCamName = szCameraName;
if( varCamName.vt != VT_BSTR )
{
return E_OUTOFMEMORY;
}
PropBag.Write( L"VCapName", &varCamName );
pPropertyBag->Load( &PropBag, NULL ); // pPropertyBag.Release();rslt =
262782
pGraph->AddFilter( m_pVideoCaptureFilter, L"Video capture source" );
rslt = pCaptureGraph->RenderStream(&PIN_CATEGORY_PREVIEW,
&MEDIATYPE_Video, m_pVideoCaptureFilter, NULL, NULL);
}

Thanks in Advance

Vishuonline

unread,
Jan 27, 2006, 3:31:29 PM1/27/06
to
Hi,

Still no success.

I have noticed in other posts that the first or the default video capture
device's name is "CAM1:" when enumerated. How come I am getting "CAP1:" ??
Also When I use CLSID_VideoRendered for "
m_pVideoCaptureFilter.CoCreateInstance( CLSID_VideoCapture ); " I am geting
"there is no source code available for the current location". Folks.. I am
lost in this directshow .. ? please show me some pointers..

Best

Gary Daniels [MS]

unread,
Jan 30, 2006, 6:34:50 PM1/30/06
to
HResult 0x0004027e is not an error code, it's a success indicating that the
preview was rendered through the smart tee. Your camera driver is a two pin
driver and therefore the preview is rendered from the capture pin through
the smart tee. Only HRESULTs starting with 0x8xxxx are failure codes, the
rest are success codes indicating additional information.

Try setting up the video renderer window location and running the graph, i
believe everything will work fine.

Gary Daniels
Windows CE Multimedia and Graphics

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.


"Vishuonline" <Vishu...@discussions.microsoft.com> wrote in message
news:F245E10D-91C9-43D0...@microsoft.com...

Vishuonline

unread,
Feb 1, 2006, 10:12:03 AM2/1/06
to
Thanks Gary for the response. It did work. The only differnce was... the
command pMediaControl->Run(). I think this is what i was missing all the
while. I assumed that RenderStream of the graphbuilder was also running the
graph.

Also I am in the need of a custom grabber that gives me access to the raw
image data that is being rendered live on to the screen. This I need to
perform some image processing in realtime. Is there any way of getting this
accomplished without writing a custom filter?? I am not very experienced with
DirectShow programming and COM/ActiveX. Is there any sample filter code for
the CE or Sp or PPC platforms? I tried to create a filter following your
previous responses to another post on this forum. But I am stuck in the mire
of link errors. It will be of much help if you could give me some pointers.

Best Regards,

Gary Daniels [MS]

unread,
Feb 6, 2006, 8:52:39 PM2/6/06
to
Here is an ultra stripped down renderer filter that inherits from the
CBaseRenderer, it only implements the minimum to function, it'll connect to
any filter, and it doesn't do anything with the samples it recieves. All of
the real work is left to the base classes. It inherits from CBaseRenderer
not CBaseRendererAsync so it is syncronous, which means it recieves the
samples as the upstream filter delivers them. If it inherited from
CBaseRendererAsync then the samples would be put into a queue and
DoRenderSample would run in a separate thread. It's simple to modify this
filter to be a transform filter, you just change it to inherit from
CBaseTransform or CBaseFilter and implement the necessary functions; you
would have to create the input/output pins, DoRenderSample would be replaced
with Recieve in the input pin, etc.

The bulk of the code below is to handle the registration of the filter via
RegSvr. If you were to manually create the registry keys for the filter
instead of relying on com to register it for you all you would need is the
CNullRend class.

This should give you something to work with, you'll have to figure out what
base class functionality you need to override and what other interfaces your
filter needs to implement. For starters you'll most likely need to implement
some class that handles retrieving whatever information you need from the
filter and the NonDelegatingQueryInterface method on the filter in order to
retrieve the pointer to the interface to use in your application.


LIBRARIES ===
You need to link to these libraries in order to compile.
TARGETLIBS are strmiids.lib, uuid.lib, ole32.lib, mmtimer.lib, and
coredll.lib
SOURCELIBS is strmbase.lib

End LIBRARIES ====

NULLREND.def ==========
// These exports are necessary in order for com to register the filter
LIBRARY nullrend.dll
EXPORTS
DllMain PRIVATE
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE

End NULLREND.DEF ===================

NULLREND.CPP ====================================
#include <windows.h>
#include <streams.h>
#include <initguid.h>

// this is needed for COM to register the component with RegSvr
extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
STDAPI DllRegisterServer() { return AMovieDllRegisterServer2( TRUE ); }
STDAPI DllUnregisterServer() { return AMovieDllRegisterServer2( FALSE ); }
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{ return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved); }

// Define your filter guid here
DEFINE_GUID(CLSID_NullRend,
0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);

// Fill in media type information below, this information is used when
registering the filter with dshow
const AMOVIESETUP_MEDIATYPE sudPinTypes =
{ &MEDIATYPE_NULL, &MEDIASUBTYPE_NULL };
const AMOVIESETUP_PIN sudPins =
{ L"Null", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, 1, &sudPinTypes };
const AMOVIESETUP_FILTER sudNULL =
{ &CLSID_NullRend, L"NullRend", MERIT_DO_NOT_USE, 1, &sudPins };

// this filter is based off of the base renderer, so it has 1 input pin and
no output pins.
// It's currently a no-op renderer which will connect to anything
(CheckMediaType always
// succeeds and DoRenderSample does nothing with the sample.
class CNullRend : public CBaseRenderer
{
public:
DECLARE_IUNKNOWN;

CNullRend(LPUNKNOWN pUnk, HRESULT *phr) :
CBaseRenderer(CLSID_NullRend, NAME("CNullRend"), pUnk, phr) {}

static CUnknown* WINAPI CreateInstance(LPUNKNOWN punk, HRESULT *phr)
{ return
new CNullRend(punk, phr); }
HRESULT CheckMediaType(const CMediaType *pMT) { return S_OK; }
// This is called for each media sample received.
HRESULT DoRenderSample(IMediaSample *pMediaSample) { return S_OK; }
// this is necessary for automatic registration of the filter when doing
a regsvr32.
AMOVIESETUP_FILTER *GetSetupData() { return((AMOVIESETUP_FILTER
*)&sudNULL); }

private:

};

CFactoryTemplate g_Templates[] =
{ L"NullRend", &CLSID_NullRend, CNullRend::CreateInstance, NULL, &sudNULL };
int g_cTemplates = 1;

End NULLREND.cpp =================================


Gary Daniels
Windows CE Multimedia and Graphics

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.


"Vishuonline" <Vishu...@discussions.microsoft.com> wrote in message

news:EECF9E39-D13F-4AC4...@microsoft.com...

Vishuonline

unread,
Feb 9, 2006, 4:18:27 PM2/9/06
to
Gary. Thanks much!. Your reply helped me get started in the right path.. But
I am facing a problem along the way. The camera is returning a YU12 stream.
And I dont want my filter to do a lot of processing. How can I force my
video/camera to give me RGB24 or RGB8 stream? I tried forcing this from the
filter side (by returning S_OK from CheckMediaType during filter connection
process only when the MEDIASUBTYPE_RGB24) as well as using the
IAMStreamConfig before connecting the filters. Both the attempts were of no
avail.

Can you give me some pointers ?

Best,

Gary Daniels [MS]

unread,
Feb 9, 2006, 5:24:45 PM2/9/06
to
You can query the camera driver for the formats it supports and select one,
if there's an RGB format available. Once you set the format then the camera
driver will only connect with that format. If the camera driver dosn't
support RGB then you'll need to build the graph with the color converter
inserted. Modifying your CheckMediaType to only succeed with RGB formats
should have triggered the color converter automatically, i don't know why it
didn't...

I belive you'll end up with an RGB16 format instead of RGB8 or 24, I know
YV12 to RGB16 is a valid color conversion. The color converter doesn't
support all possible color conversions (it would be way too large to be used
on an embedded device if it did). It must support the conversion from the
camera driver format to an RGB format because the video renderer requires
that conversion to be available to render the preview window.

You could try not setting any format with IAMStreamConfig and have your
CheckMediaType fail everything, and then inspect all of the formats that are
tried. I suspect you'll find an RGB format in there.

Gary Daniels
Windows CE Multimedia and Graphics

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.


"Vishuonline" <Vishu...@discussions.microsoft.com> wrote in message

news:7FB64306-CD27-4FA4...@microsoft.com...

Vishuonline

unread,
Feb 13, 2006, 11:03:13 AM2/13/06
to
Gary,

Thanks!! Seems like my camera does not support RGB capture. Strange though,
because in the native video/camera control there is an option to capture
grayscale content.. maybe it is also using some custom transform filters for
transforming the stream received from the control. When I run though the
CheckMediaType function in the debugger, I do have a check for RGB and the
code block does gets executed(several times) when the filter connection is
happening; but the connect function always fails..!!

In anycase, I Looked into the yuv12 to RGB conversion and it is seemless, i
mean no extra cost. The video frame size I am getting is 176x144. And of the
buffer of (176x144X1.5) the first (176x144) bytes contain the information I
need!. The rest of the buffer contains hue and saturation information, that I
dont need for my processing ! I have come a long way from.. the start..

I still have 1 major/small issue, if you can add comments:
1. In my null renderer filter, I added a function to hold the pointer for a
callback funtion from my application. OK, this function does get a valid
pointer for the callback funtion and saves it; but when it comes to invoke
the callback in the DoRenderSample, it simply does not and in my debugger
window the pointer basically resolves to point to CBaseRenderer::Stop().

I had this callback working for couple of hours in the beginning. This is
the state of the app when my callback function was working. The filter is
registered and my application is built with the lib file from the filter
project. I did not have to transfer the filter dll and place it the windows
or my application's directory; even then it worked. Then I was shuffling
between some modifications in the application and the filter, and then I
started getting a message that the one of the components needed for my
application to function is not present. From this point my callback stopped
wokring. I am trying all ways to traceback my steps.. but it has been
terribly elusive. Any suggestions??

Gary Daniels [MS]

unread,
Feb 21, 2006, 5:54:10 PM2/21/06
to
I honestly have no idea why that would happen. DirectShow runs in process so
the function pointer shouldn't be modified or resolve to a different address
than the one you would expect. I use a grabber filter which does this and
haven't had any problems.

Gary Daniels
Windows CE Multimedia and Graphics

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.


"Vishuonline" <Vishu...@discussions.microsoft.com> wrote in message

news:B4407804-E904-4195...@microsoft.com...

Vishuonline

unread,
Feb 22, 2006, 10:11:28 AM2/22/06
to
Thanks for the response!. I could not reason it out.. But when I made another
filter with simply the CLSID changed, it worked. It is scary, in the sense..
that if in future it stops abruptly then I have no clue where to shoot. In
anycase the app is doing good so far, and I hope to read up on this stuff
more. I am having an issue though while stopping the graph.

My requirement is that the custom rendering filter that I have in place,
should be able to stop the graph when it finds an "interesting" frame. (Oh,,,
btw my application is primarily performing image processing on the frames it
receives..) So to achieve this, this is what I am doing. In the Callback
function, I do the image processing and I set the return value of the
callback to indicate if the frame received was "interesting" or not. If the
frame is "interesting", then the DoRenderSample invokes the
Notify(EC_COMPLETE,0,0) call to notify the graph manager it does not want any
more frames. {Is there any more elegant way of performing this, without
worrying about frames in the queue or threads etc?}Then my Applications's
Notify function receives a graph event of the type EC_COMPLETE and in that
function I invoke iMediaControl->Stop(). My graph stops and I "Release()"
the ComPtrs of the various filters and interfaces. But I am facing an issue
when I am restarting the graph. My connect function for connecting the
videocapturefilter and the smarttee filter, fails.

Can anyone throw some light on this?

Vishuonline

unread,
Feb 27, 2006, 7:27:28 PM2/27/06
to
I got it right.. No problem. I have been stuck with smthing else. Is there a
way to programmatically change the "Ambience" of the video capture? My end
goal is to alter the video stream properties. I tried the IAMVideoProcAmp
interface and for some reason it does not seem to be effective. I tried
setting both exremes of the properties hue saturation, brightness, contract ,
etc.. but the video quality does not change a bit..

Please throw some light.

Regards,

Gary Daniels [MS]

unread,
Mar 2, 2006, 5:32:42 PM3/2/06
to
Are you setting the flags to manual when calling IAMVideoProcAmp? Does
IAMVideoProcAmp::GetRange return a supported range of values and flags?

The Zoom camera control property is an LTK required feature which is used by
the Windows Mobile camera application, have you tried zooming? If you can
get Zoom to work then all of the other properties are used done the same. If
you can get Zoom to work, but brightness/contrast/etc. do not, then this may
be a camera driver bug.

A NULL camera driver framework is provided to the OEM's for developing their
camera driver. If the OEM didn't adjust the supported properties then the
driver would claim to support something which it doesn't actually support,
the member variable containing the requested property value would be set but
never used.

Windows CE Multimedia and Graphics

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.

"Vishuonline" <Vishu...@discussions.microsoft.com> wrote in message

news:070A4326-A5B5-4BE0...@microsoft.com...

rahul

unread,
Mar 14, 2006, 5:30:59 AM3/14/06
to

I tried this Nullrend example with my own directshow filter and on HTC
Universal it is getting registered properly but on Dell Axim X51v ,it
gives following error:

LoadLibrary("MyFilter.ax") failed.GetLastError return 7e.

Although MyFilter.ax is available on the device.

What could be the reason for this behaviour? Does anybody else facing
such problem also?

rzr

unread,
Mar 30, 2006, 10:26:15 AM3/30/06
to
Hi gary thanx for helping us,
you said that you use a grabber filter which does this and

haven't had any problems.

I had build my own too it's working , but now I'd like to have more
info on how to reimplement this method ISampleGrabber::GetCurrentBuffer
which does not appear in the gabber sample.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directshow/htm/isamplegrabbergetcurrentbuffer.asp

How is it buffered, how to pull data using the Recieve method, is a
callback used ? well any tracks is welcome

0 new messages