I'm writing a PVR for windows using DirectShow and the Stream Buffer Engine but am having a problem with the MPEG-2 Demultiplexer. The stream comming from my TVTuner device is a hardware encoded MPEG2 stream (from the Hauppauge WinTV USB2). When I add the video output pin to the demultiplexer manually through graph edit, everything works just fine, but when I add the pin through c++ the program works untill I call the Stop() function for the graph and it crashes. It gives me a 'division by zero' error somewhere within the microsoft code.
I'm wondering if anyone out there knows how to add the pin in C++ without it crashing when run Stop() on the graph? Or is there a way to load the filter directly from a saved GraphEdit file? (I could just load the working filter I made manually then)
Here are the settings that I am using in my program to set up the pin in C++:
AM_MEDIA_TYPE pMediaVideoType;
MPEG2VIDEOINFO video_info;
interface IMPEG2StreamIdMap *StreamIdMapVideo;
memset(&pMediaVideoType , 0x0 , sizeof(pMediaVideoType));
memset(&video_info , 0x0 , sizeof(MPEG2VIDEOINFO));
//Type settings for the output stream
pMediaVideoType.majortype = MEDIATYPE_Video;
pMediaVideoType.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
pMediaVideoType.formattype
= FORMAT_MPEG2Video ;
//not sure exactly what I need these for
pMediaVideoType.bFixedSize
Samples = FALSE;
pMediaVideoType.bTemporalC
ompression
= TRUE;
pMediaVideoType.lSampleSiz
e = 0;
pMediaVideoType.cbFormat = sizeof(MPEG2VIDEOINFO);
pMediaVideoType.pbFormat = (BYTE *)&video_info;
//creat the pin
hr = MPEG2_demux_interface->Cre
ateOutputP
in(&pMedia
VideoType,
L"Video",
&pMPEG2_demux_videoPin);
//get an interface to the pin so that I can map it with the 0xE0 for default MPEG2 Elementary Stream
hr = pMPEG2_demux_videoPin->Que
ryInterfac
e( IID_IMPEG2StreamIdMap,
(void **) &StreamIdMapVideo);
hr = StreamIdMapVideo->MapStrea
mId(VideoS
treamID , //0xE0
MPEG2_PROGRAM_ELEMENTARY_S
TREAM , 0, 0);
Start Free Trial