I'm having troubles sending a media sample over the graph, I'm wondering wether that is because of the receiving filter or my own fault.
the thing I'm trying to send is a uncompressed 24 bit image, the bitmap info header data of it is pretty much as this:
mediatype: BI_RGB24 Width: 320 Height: 240 Bitcount: 24 Size of the image in bytes: 230400 compression: BI_RGB
so my questions about it are: - What should I do with the ALLOCATOR_PROPERTIES - What do I have to put in IMediaSample SetActualDataLength - How can I fill the pointer returned by IMediaSample GetPointer so that the sample gets accepted?
Maarten Lankhorst wrote:
I'm having troubles sending a media sample over the graph, I'm wondering wether that is because of the receiving filter or my own fault.
the thing I'm trying to send is a uncompressed 24 bit image, the bitmap info header data of it is pretty much as this:
mediatype: BI_RGB24 Width: 320 Height: 240 Bitcount: 24 Size of the image in bytes: 230400 compression: BI_RGB
so my questions about it are:
- What should I do with the ALLOCATOR_PROPERTIES
- What do I have to put in IMediaSample SetActualDataLength
- How can I fill the pointer returned by IMediaSample GetPointer so
that the sample gets accepted?
You should/must grab DirectX9SDK from Microsoft and look into the code of DirectShow/baseclasses. What you are trying to do is actually long and tedious procedure that is almost impossible to explain. Even if you get it right with one Filter it might not work with the next filter. In principle there is a 2 stage, 3 steps each, negotiation between 2 filters about the Allocator properties and the Format header (it is actually even more steps) at the end if agreed, Not only the Format header is important but also some other properties of the Media sample object, and the Allocator object.
From what I understand from the License of this source, is, that you can use it to study and debug. What I suggest is that you compile a few of the Example filters in the SDK, than under Debugger examine how they connect, than try them with your Filter and compare. You will have to do this on windows, probably with MSVC++. I was able to compile DirectShow/baseclasses with GCC, but there where bugs. Look at the tons of warnings, start with them.
Sorry if this sounds a bit as a discouragement. I have years of experience with Video filters and I still cringe to the taught of writing a video filter without DirectShow/baseclasses. I did want to, but never got to it, because it feels hard. But maybe you are not that far, maybe you are almost there, have a look under the debugger.
Free Life Boaz
Maarten Lankhorst wrote:
I'm having troubles sending a media sample over the graph, I'm wondering wether that is because of the receiving filter or my own fault.
the thing I'm trying to send is a uncompressed 24 bit image, the bitmap info header data of it is pretty much as this:
mediatype: BI_RGB24 Width: 320 Height: 240 Bitcount: 24 Size of the image in bytes: 230400 compression: BI_RGB
so my questions about it are:
- What should I do with the ALLOCATOR_PROPERTIES
props.cbAlign - do you have any alignment requirements? if not, set to 1. props.cbPrefix - do you have any private data you want to include before the sample? if not, set to 0. props.cbBuffer - maximum size of the buffer (recommended is 0x20000 or 64kb) props.cBuffers - how many samples will you be processing at once?
- What do I have to put in IMediaSample SetActualDataLength
The value corresponding to "Size of the image in bytes."
- How can I fill the pointer returned by IMediaSample GetPointer so
that the sample gets accepted?
The media sample contains no format information so it shouldn't be rejected. Just memcpy the bytes.
Rob
Robert Shearman wrote:
Maarten Lankhorst wrote:
I'm having troubles sending a media sample over the graph, I'm wondering wether that is because of the receiving filter or my own fault.
the thing I'm trying to send is a uncompressed 24 bit image, the bitmap info header data of it is pretty much as this:
mediatype: BI_RGB24 Width: 320 Height: 240 Bitcount: 24 Size of the image in bytes: 230400 compression: BI_RGB
so my questions about it are:
- What should I do with the ALLOCATOR_PROPERTIES
props.cbAlign - do you have any alignment requirements? if not, set to 1. props.cbPrefix - do you have any private data you want to include before the sample? if not, set to 0. props.cbBuffer - maximum size of the buffer (recommended is 0x20000 or 64kb) props.cBuffers - how many samples will you be processing at once?
I allocated 4 buffers of 64kB now to hold the sample, it's probably more friendly then 1 buffer of 230kB
- What do I have to put in IMediaSample SetActualDataLength
The value corresponding to "Size of the image in bytes."
Had that, turned out it wasn't the reason I got an invalid error
- How can I fill the pointer returned by IMediaSample GetPointer so
that the sample gets accepted?
The media sample contains no format information so it shouldn't be rejected. Just memcpy the bytes.
Rob
I tried using the graph edit tool from Graph Edit, connected my outputpin to videorenderer's input pin I got this: trace:quartz:VideoRenderer_SendSampleData 0x77ca8108 0x7cfd0000 131072 trace:quartz:IPinImpl_ConnectionMediaType (0x77ca8268/0x77ca8268)->(0x77a9f8f8) trace:quartz:VideoRenderer_SendSampleData biSize = 298763094 trace:quartz:VideoRenderer_SendSampleData biWidth = -1442840129 trace:quartz:VideoRenderer_SendSampleData biHeigth = 1515803904 trace:quartz:VideoRenderer_SendSampleData biPlanes = 64268 trace:quartz:VideoRenderer_SendSampleData biBitCount = 30633 trace:quartz:VideoRenderer_SendSampleData biCompression = "X\x00\x00\x00"... trace:quartz:VideoRenderer_SendSampleData biSizeImage = 2009760832
Somehow my media format got messed up, I'll look at the source, figure out what I did wrong then return working on this happily, I bet it's the same reason msn returned E_FAIL :)
*Takes another deep look into his probably messed up code, does this mean I have to rewrite it earlier then I thought? O_O*
Maarten Lankhorst wrote:
I tried using the graph edit tool from Graph Edit, connected my outputpin to videorenderer's input pin I got this: trace:quartz:VideoRenderer_SendSampleData 0x77ca8108 0x7cfd0000 131072 trace:quartz:IPinImpl_ConnectionMediaType (0x77ca8268/0x77ca8268)->(0x77a9f8f8) trace:quartz:VideoRenderer_SendSampleData biSize = 298763094 trace:quartz:VideoRenderer_SendSampleData biWidth = -1442840129 trace:quartz:VideoRenderer_SendSampleData biHeigth = 1515803904 trace:quartz:VideoRenderer_SendSampleData biPlanes = 64268 trace:quartz:VideoRenderer_SendSampleData biBitCount = 30633 trace:quartz:VideoRenderer_SendSampleData biCompression = "X\x00\x00\x00"... trace:quartz:VideoRenderer_SendSampleData biSizeImage = 2009760832
Somehow my media format got messed up, I'll look at the source, figure out what I did wrong then return working on this happily, I bet it's the same reason msn returned E_FAIL :)
*Takes another deep look into his probably messed up code, does this mean I have to rewrite it earlier then I thought? O_O*
The video format is taken from the pin's This->mtCurrent. This should be set in OutputPin_ConnectSpecific. On a semi-related note though, the video renderer shouldn't be asking for it from the upstream pin for *every* sample. It only needs to ask for it once (on pause?).
Rob