62{
66 DWORD cbDstStream, cbSrcStream;
73 LONGLONG tStart = -1, tStop = -1, tMed;
74 LONGLONG mtStart = -1, mtStop = -1, mtMed;
75
77 hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
79 {
80 ERR(
"Cannot get pointer to sample data (%x)\n",
hr);
83 }
84
85 preroll = (IMediaSample_IsPreroll(pSample) ==
S_OK);
86
87 IMediaSample_GetTime(pSample, &tStart, &tStop);
88 if (IMediaSample_GetMediaTime(pSample, &mtStart, &mtStop) !=
S_OK)
89 mtStart = mtStop = -1;
90 cbSrcStream = IMediaSample_GetActualDataLength(pSample);
91
92
93 if (IMediaSample_IsDiscontinuity(pSample) ==
S_OK)
94 {
95 This->lasttime_real = tStart;
96 This->lasttime_sent = tStart;
97 }
98 else if (
This->lasttime_real == tStart)
99 tStart =
This->lasttime_sent;
100 else
101 WARN(
"Discontinuity\n");
102
103 tMed = tStart;
104 mtMed = mtStart;
105
106 TRACE(
"Sample data ptr = %p, size = %d\n", pbSrcStream, cbSrcStream);
107
108 hr = IPin_ConnectionMediaType(
This->tf.ppPins[0], &amt);
110 {
111 ERR(
"Unable to retrieve media type\n");
114 }
115
116 ash.
pbSrc = pbSrcStream;
118
120 {
123 {
124 ERR(
"Unable to get delivery buffer (%x)\n",
hr);
127 }
128 IMediaSample_SetPreroll(pOutSample, preroll);
129
130 hr = IMediaSample_SetActualDataLength(pOutSample, 0);
132
133 hr = IMediaSample_GetPointer(pOutSample, &pbDstStream);
135 ERR(
"Unable to get pointer to buffer (%x)\n",
hr);
137 }
138 cbDstStream = IMediaSample_GetSize(pOutSample);
139
143 ash.
pbDst = pbDstStream;
145
147 ERR(
"Cannot prepare header %d\n",
res);
149 }
150 unprepare_header =
TRUE;
151
152 if (IMediaSample_IsDiscontinuity(pSample) ==
S_OK)
153 {
155 IMediaSample_SetDiscontinuity(pOutSample,
TRUE);
156
157 IMediaSample_SetDiscontinuity(pSample,
FALSE);
158 }
159 else
160 {
162 IMediaSample_SetDiscontinuity(pOutSample,
FALSE);
163 }
164
166 {
168 ERR(
"Cannot convert data header %d\n",
res);
170 }
171
173
176
177
179 {
183 }
184
185 TRACE(
"Sample start time: %u.%03u\n", (
DWORD)(tStart/10000000), (
DWORD)((tStart/10000)%1000));
187 {
188 IMediaSample_SetTime(pOutSample, &tStart, &tStop);
189 tStart = tMed = tStop;
190 }
191 else if (tStop != tStart)
192 {
193 tMed = tStop - tStart;
195 IMediaSample_SetTime(pOutSample, &tStart, &tMed);
196 tStart = tMed;
197 }
198 else
199 {
200 ERR(
"No valid timestamp found\n");
201 IMediaSample_SetTime(pOutSample,
NULL,
NULL);
202 }
203
204 if (mtStart < 0) {
205 IMediaSample_SetMediaTime(pOutSample,
NULL,
NULL);
207 IMediaSample_SetMediaTime(pOutSample, &mtStart, &mtStop);
208 mtStart = mtMed = mtStop;
209 } else if (mtStop >= mtStart) {
210 mtMed = mtStop - mtStart;
212 IMediaSample_SetMediaTime(pOutSample, &mtStart, &mtMed);
213 mtStart = mtMed;
214 } else {
215 IMediaSample_SetMediaTime(pOutSample,
NULL,
NULL);
216 }
217
218 TRACE(
"Sample stop time: %u.%03u\n", (
DWORD)(tStart/10000000), (
DWORD)((tStart/10000)%1000));
219
223
226 ERR(
"Error sending sample (%x)\n",
hr);
228 }
229
232 ERR(
"Cannot unprepare header %d\n",
res);
233 unprepare_header =
FALSE;
236
237 IMediaSample_Release(pOutSample);
239
240 }
241
242 This->lasttime_real = tStop;
243 This->lasttime_sent = tMed;
244
247}
MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwPrepare)
MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwConvert)
MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwUnprepare)
#define MMSYSERR_MOREDATA
#define ACM_STREAMCONVERTF_START
HRESULT WINAPI BaseOutputPinImpl_Deliver(BaseOutputPin *This, IMediaSample *pSample)
HRESULT WINAPI BaseOutputPinImpl_GetDeliveryBuffer(BaseOutputPin *This, IMediaSample **ppSample, REFERENCE_TIME *tStart, REFERENCE_TIME *tStop, DWORD dwFlags)
#define VFW_E_NOT_CONNECTED
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)