Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: media/capture/video/win/sink_input_pin_win.cc

Issue 2369983003: Win video capture: Fix capture format and frame buffer mismatch (Closed)
Patch Set: Revert changes to video_capture_device_client.cc Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/capture/video/win/sink_input_pin_win.h" 5 #include "media/capture/video/win/sink_input_pin_win.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 // Avoid including strsafe.h via dshow as it will cause build warnings. 9 // Avoid including strsafe.h via dshow as it will cause build warnings.
10 #define NO_DSHOW_STRSAFE 10 #define NO_DSHOW_STRSAFE
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 return false; 184 return false;
185 } 185 }
186 186
187 media_type->bFixedSizeSamples = TRUE; 187 media_type->bFixedSizeSamples = TRUE;
188 media_type->lSampleSize = pvi->bmiHeader.biSizeImage; 188 media_type->lSampleSize = pvi->bmiHeader.biSizeImage;
189 return true; 189 return true;
190 } 190 }
191 191
192 HRESULT SinkInputPin::Receive(IMediaSample* sample) { 192 HRESULT SinkInputPin::Receive(IMediaSample* sample) {
193 const int length = sample->GetActualDataLength(); 193 const int length = sample->GetActualDataLength();
194 uint8_t* buffer = NULL;
195 194
196 if (length <= 0) { 195 if (length <= 0 ||
197 DLOG(WARNING) << "Media sample length is 0 or less."; 196 static_cast<size_t>(length) < resulting_format_.ImageAllocationSize()) {
197 DLOG(WARNING) << "Wrong media sample length: " << length;
198 return S_FALSE; 198 return S_FALSE;
199 } 199 }
200 200
201 uint8_t* buffer = nullptr;
201 if (FAILED(sample->GetPointer(&buffer))) 202 if (FAILED(sample->GetPointer(&buffer)))
202 return S_FALSE; 203 return S_FALSE;
203 204
204 REFERENCE_TIME start_time, end_time; 205 REFERENCE_TIME start_time, end_time;
205 base::TimeDelta timestamp = media::kNoTimestamp; 206 base::TimeDelta timestamp = media::kNoTimestamp;
206 if (SUCCEEDED(sample->GetTime(&start_time, &end_time))) { 207 if (SUCCEEDED(sample->GetTime(&start_time, &end_time))) {
207 DCHECK(start_time <= end_time); 208 DCHECK(start_time <= end_time);
208 timestamp = base::TimeDelta::FromMicroseconds(start_time / 10); 209 timestamp = base::TimeDelta::FromMicroseconds(start_time / 10);
209 } 210 }
210 211
211 observer_->FrameReceived(buffer, length, timestamp); 212 observer_->FrameReceived(buffer, length, resulting_format_, timestamp);
212 return S_OK; 213 return S_OK;
213 } 214 }
214 215
215 SinkInputPin::~SinkInputPin() { 216 SinkInputPin::~SinkInputPin() {
216 } 217 }
217 218
218 } // namespace media 219 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/video/win/sink_input_pin_win.h ('k') | media/capture/video/win/video_capture_device_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698