I am able to copy a VideoInfoHeader which is part AMMediaType with the following lines:
AMMediaType mediaType = new AMMediaType();
VideoInfoHeader videoInfo = new VideoInfoHeader();
(pSampleGrabber as ISampleGrabber).GetConnectedMediaType(mediaType);
videoInfo = (VideoInfoHeader)Marshal.PtrToStructure(mediaType.formatPtr, typeof(VideoInfoHeader));
that I got from SampleGrabber Parameter is Incorrect and other ressources on the internet. However I am not able to copy the whole AMMediaType-Structure. The pointer to the VideoInfoHeader is lost.
So I was wondering if there exists a helper function that copies an AMMediaType to a different location in memory, looks for pointers like VideoInfoHeader and copies the content of the VideoInfoHeader and other referenced data to a new location (including pointing formatPtr to the right location).
I am using this in the following scenario: I retrieve all possible IPin mediatypes of a video input device and show the AMMediaTypes in a Windows.Forms - Combobox. When I read the SelectedObject from the Combobox, the pointer to the VideoInfoHeader is zero. This is where it fails to connect using my selected pin configuration when constructing the filtergraph.