diff loader/dshow/DS_Filter.c @ 22398:49f01f8fbd60

Rework of copying samples from directshow codecs. Using callback function provided by filter to store and process samples from codec instead of explicit typecast to DS_Filter.
author voroshil
date Fri, 02 Mar 2007 18:52:10 +0000
parents 254733f57707
children 3758413ca0c6
line wrap: on
line diff
--- a/loader/dshow/DS_Filter.c	Fri Mar 02 17:59:19 2007 +0000
+++ b/loader/dshow/DS_Filter.c	Fri Mar 02 18:52:10 2007 +0000
@@ -95,9 +95,34 @@
 #endif
 }
 
+static HRESULT STDCALL DS_Filter_CopySample(void* pUserData,IMediaSample* pSample){
+    char* pointer;
+    int len;
+    SampleProcUserData* pData=(SampleProcUserData*)pUserData;
+    Debug printf("CopySample called(%p,%p)\n",pSample,pUserData);
+    if (pSample->vt->GetPointer(pSample, (BYTE**) &pointer))
+	return 1;
+    len = pSample->vt->GetActualDataLength(pSample);
+    if (len == 0)
+	len = pSample->vt->GetSize(pSample);//for iv50
+
+    pData->frame_pointer = pointer;
+    pData->frame_size = len;
+/*
+    FILE* file=fopen("./uncompr.bmp", "wb");
+    char head[14]={0x42, 0x4D, 0x36, 0x10, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00};
+    *(int*)(&head[2])=len+0x36;
+    fwrite(head, 14, 1, file);
+    fwrite(&((VIDEOINFOHEADER*)me.type.pbFormat)->bmiHeader, sizeof(BITMAPINFOHEADER), 1, file);
+    fwrite(pointer, len, 1, file);
+    fclose(file);
+*/
+    return 0;
+}
+
 DS_Filter* DS_FilterCreate(const char* dllname, const GUID* id,
 			   AM_MEDIA_TYPE* in_fmt,
-			   AM_MEDIA_TYPE* out_fmt)
+			   AM_MEDIA_TYPE* out_fmt,SampleProcUserData* pUserData)
 {
     int init = 0;
 //    char eb[250];
@@ -262,7 +287,7 @@
 	//Notify remote pin about choosed allocator
 	This->m_pImp->vt->NotifyAllocator(This->m_pImp, This->m_pAll, 0);
 
-	This->m_pOurOutput = COutputPinCreate(This->m_pDestType);
+	This->m_pOurOutput = COutputPinCreate(This->m_pDestType,DS_Filter_CopySample,pUserData);
 
 	result = This->m_pOutputPin->vt->ReceiveConnection(This->m_pOutputPin,
 							   (IPin*) This->m_pOurOutput,