annotate loader/dmo/buffer.c @ 10160:ad75409ed15e

support for pnm and rtsp stream opening with gui, patch by Ambrose Li <a.c.li@ieee.org>
author alex
date Fri, 23 May 2003 12:58:13 +0000
parents 8e00b6a9e40b
children 2c8cdb9123b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8294
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
1 #include "DMO_Filter.h"
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
2
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
3 #include "wine/winerror.h"
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
4 #include "wine/windef.h"
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
5
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
6 #include <stdio.h>
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
7 #include <string.h>
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
8 #include <stdlib.h>
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
9
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
10 struct _CMediaBuffer
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
11 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
12 IMediaBuffer_vt* vt;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
13 DECLARE_IUNKNOWN();
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
14 GUID interfaces[2];
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
15 void* mem;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
16 unsigned long len;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
17 unsigned long maxlen;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
18 int freemem;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
19 };
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
20
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
21 static HRESULT STDCALL CMediaBuffer_SetLength(IMediaBuffer* This,
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
22 unsigned long cbLength)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
23 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
24 CMediaBuffer* cmb = (CMediaBuffer*) This;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
25 Debug printf("CMediaBuffer_SetLength(%p) called (%ld, %ld)\n", This, cbLength, cmb->maxlen);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
26 if (cbLength > cmb->maxlen)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
27 return E_INVALIDARG;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
28 cmb->len = cbLength;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
29 return S_OK;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
30 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
31
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
32 static HRESULT STDCALL CMediaBuffer_GetMaxLength(IMediaBuffer* This,
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
33 /* [out] */ unsigned long *pcbMaxLength)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
34 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
35 CMediaBuffer* cmb = (CMediaBuffer*) This;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
36 Debug printf("CMediaBuffer_GetMaxLength(%p) called -> %ld\n", This, cmb->maxlen);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
37 if (!pcbMaxLength)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
38 return E_POINTER;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
39 *pcbMaxLength = cmb->maxlen;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
40 return S_OK;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
41 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
42
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
43 static HRESULT STDCALL CMediaBuffer_GetBufferAndLength(IMediaBuffer* This,
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
44 /* [out] */ char** ppBuffer,
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
45 /* [out] */ unsigned long* pcbLength)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
46 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
47 CMediaBuffer* cmb = (CMediaBuffer*) This;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
48 Debug printf("CMediaBuffer_GetBufferAndLength(%p) called -> %p %ld\n", This, cmb->mem, cmb->len);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
49 if (!ppBuffer && !pcbLength)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
50 return E_POINTER;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
51 if (ppBuffer)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
52 *ppBuffer = cmb->mem;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
53 if (pcbLength)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
54 *pcbLength = cmb->len;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
55 return S_OK;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
56 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
57
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
58 static void CMediaBuffer_Destroy(CMediaBuffer* This)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
59 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
60 Debug printf("CMediaBuffer_Destroy(%p) called\n", This);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
61 if (This->freemem)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
62 free(This->mem);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
63 free(This->vt);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
64 free(This);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
65 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
66
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
67 IMPLEMENT_IUNKNOWN(CMediaBuffer)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
68
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
69 CMediaBuffer* CMediaBufferCreate(unsigned long maxlen, void* mem,
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
70 unsigned long len, int copy)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
71 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
72 CMediaBuffer* This = (CMediaBuffer*) malloc(sizeof(CMediaBuffer));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
73
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
74 if (!This)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
75 return NULL;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
76
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
77 This->vt = (IMediaBuffer_vt*) malloc(sizeof(IMediaBuffer_vt));
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
78 if (!This->vt)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
79 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
80 CMediaBuffer_Destroy(This);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
81 return NULL;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
82 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
83
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
84 This->refcount = 1;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
85 This->len = len;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
86 This->maxlen = maxlen;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
87 This->freemem = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
88 This->mem = mem;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
89 if (copy)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
90 /* make a private copy of data */
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
91 This->mem = 0;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
92 if (This->mem == NULL)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
93 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
94 if (This->maxlen)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
95 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
96 This->mem = malloc(This->maxlen);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
97 if (!This->mem)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
98 {
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
99 CMediaBuffer_Destroy(This);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
100 return NULL;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
101 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
102 This->freemem = 1;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
103 if (copy)
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
104 memcpy(This->mem, mem, This->len);
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
105 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
106 }
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
107 This->vt->QueryInterface = CMediaBuffer_QueryInterface;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
108 This->vt->AddRef = CMediaBuffer_AddRef;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
109 This->vt->Release = CMediaBuffer_Release;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
110
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
111 This->vt->SetLength = CMediaBuffer_SetLength;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
112 This->vt->GetMaxLength = CMediaBuffer_GetMaxLength;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
113 This->vt->GetBufferAndLength = CMediaBuffer_GetBufferAndLength;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
114
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
115 This->interfaces[0] = IID_IUnknown;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
116 This->interfaces[1] = IID_IMediaBuffer;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
117
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
118 return This;
8e00b6a9e40b DMO interfaces (copied/converted(c++->c) from avifile)
arpi
parents:
diff changeset
119 }