81{
84 DWORD cbDstStream, cbSrcStream;
91 LONGLONG tStart = -1, tStop = -1, tMed;
92 LONGLONG mtStart = -1, mtStop = -1, mtMed;
93
94
95
96
97
98 if (!
This->source.pMemInputPin)
99 {
100 WARN(
"Source is not connected, returning VFW_E_NOT_CONNECTED.\n");
102 }
103
104 if (
This->filter.state == State_Stopped)
106
107 if (
This->sink.flushing)
109
110 hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
112 {
113 ERR(
"Failed to get input buffer pointer, hr %#lx.\n",
hr);
115 }
116
117 preroll = (IMediaSample_IsPreroll(pSample) ==
S_OK);
118
119 IMediaSample_GetTime(pSample, &tStart, &tStop);
120 if (IMediaSample_GetMediaTime(pSample, &mtStart, &mtStop) !=
S_OK)
121 mtStart = mtStop = -1;
122 cbSrcStream = IMediaSample_GetActualDataLength(pSample);
123
124
125 if (IMediaSample_IsDiscontinuity(pSample) ==
S_OK)
126 {
127 This->lasttime_real = tStart;
128 This->lasttime_sent = tStart;
129 }
130 else if (
This->lasttime_real == tStart)
131 tStart =
This->lasttime_sent;
132 else
133 WARN(
"Discontinuity\n");
134
135 tMed = tStart;
136 mtMed = mtStart;
137
138 ash.
pbSrc = pbSrcStream;
140
142 {
144 {
145 ERR(
"Failed to get sample, hr %#lx.\n",
hr);
147 }
148 IMediaSample_SetPreroll(pOutSample, preroll);
149
150 hr = IMediaSample_SetActualDataLength(pOutSample, 0);
152
153 hr = IMediaSample_GetPointer(pOutSample, &pbDstStream);
155 ERR(
"Failed to get output buffer pointer, hr %#lx.\n",
hr);
157 }
158 cbDstStream = IMediaSample_GetSize(pOutSample);
159
163 ash.
pbDst = pbDstStream;
165
167 ERR(
"Cannot prepare header %d\n",
res);
169 }
170 unprepare_header =
TRUE;
171
172 if (IMediaSample_IsDiscontinuity(pSample) ==
S_OK)
173 {
175 IMediaSample_SetDiscontinuity(pOutSample,
TRUE);
176
177 IMediaSample_SetDiscontinuity(pSample,
FALSE);
178 }
179 else
180 {
182 IMediaSample_SetDiscontinuity(pOutSample,
FALSE);
183 }
184
186 {
188 ERR(
"Cannot convert data header %d\n",
res);
190 }
191
193
196
197
199 {
203 }
204
207 {
208 IMediaSample_SetTime(pOutSample, &tStart, &tStop);
209 tStart = tMed = tStop;
210 }
211 else if (tStop != tStart)
212 {
213 tMed = tStop - tStart;
215 IMediaSample_SetTime(pOutSample, &tStart, &tMed);
216 tStart = tMed;
217 }
218 else
219 {
220 ERR(
"No valid timestamp found\n");
221 IMediaSample_SetTime(pOutSample,
NULL,
NULL);
222 }
223
224 if (mtStart < 0) {
225 IMediaSample_SetMediaTime(pOutSample,
NULL,
NULL);
227 IMediaSample_SetMediaTime(pOutSample, &mtStart, &mtStop);
228 mtStart = mtMed = mtStop;
229 } else if (mtStop >= mtStart) {
230 mtMed = mtStop - mtStart;
232 IMediaSample_SetMediaTime(pOutSample, &mtStart, &mtMed);
233 mtStart = mtMed;
234 } else {
235 IMediaSample_SetMediaTime(pOutSample,
NULL,
NULL);
236 }
237
239
240 hr = IMemInputPin_Receive(
This->source.pMemInputPin, pOutSample);
243 ERR(
"Failed to send sample, hr %#lx.\n",
hr);
245 }
246
249 ERR(
"Cannot unprepare header %d\n",
res);
250 unprepare_header =
FALSE;
253
254 IMediaSample_Release(pOutSample);
256
257 }
258
259 This->lasttime_real = tStop;
260 This->lasttime_sent = tMed;
261
263}
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
static const char * debugstr_time(REFERENCE_TIME time)
#define VFW_E_WRONG_STATE
#define VFW_E_NOT_CONNECTED