Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/video/capture/win/sink_input_pin_win.h" | 5 #include "media/video/capture/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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 media_type->lSampleSize = pvi->bmiHeader.biSizeImage; | 62 media_type->lSampleSize = pvi->bmiHeader.biSizeImage; |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| 65 | 65 |
| 66 switch (index) { | 66 switch (index) { |
| 67 case 0: { | 67 case 0: { |
| 68 pvi->bmiHeader.biCompression = MAKEFOURCC('I', '4', '2', '0'); | 68 pvi->bmiHeader.biCompression = MAKEFOURCC('I', '4', '2', '0'); |
| 69 pvi->bmiHeader.biBitCount = 12; // bit per pixel | 69 pvi->bmiHeader.biBitCount = 12; // bit per pixel |
| 70 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); | 70 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); |
| 71 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); | 71 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); |
| 72 pvi->bmiHeader.biSizeImage = | 72 pvi->bmiHeader.biSizeImage = requested_format_.ImageAllocationSize(); |
| 73 requested_format_.frame_size.GetArea() * 3 / 2; | |
| 74 media_type->subtype = kMediaSubTypeI420; | 73 media_type->subtype = kMediaSubTypeI420; |
| 75 break; | 74 break; |
| 76 } | 75 } |
| 77 case 1: { | 76 case 1: { |
| 78 pvi->bmiHeader.biCompression = MAKEFOURCC('Y', 'U', 'Y', '2'); | 77 pvi->bmiHeader.biCompression = MAKEFOURCC('Y', 'U', 'Y', '2'); |
| 79 pvi->bmiHeader.biBitCount = 16; | 78 pvi->bmiHeader.biBitCount = 16; |
| 80 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); | 79 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); |
| 81 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); | 80 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); |
| 82 pvi->bmiHeader.biSizeImage = requested_format_.frame_size.GetArea() * 2; | 81 pvi->bmiHeader.biSizeImage = requested_format_.ImageAllocationSize(); |
| 83 media_type->subtype = MEDIASUBTYPE_YUY2; | 82 media_type->subtype = MEDIASUBTYPE_YUY2; |
| 84 break; | 83 break; |
| 85 } | 84 } |
| 86 case 2: { | 85 case 2: { |
| 87 pvi->bmiHeader.biCompression = BI_RGB; | 86 pvi->bmiHeader.biCompression = BI_RGB; |
| 88 pvi->bmiHeader.biBitCount = 24; | 87 pvi->bmiHeader.biBitCount = 24; |
| 89 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); | 88 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); |
| 90 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); | 89 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); |
| 91 pvi->bmiHeader.biSizeImage = requested_format_.frame_size.GetArea() * 3; | 90 pvi->bmiHeader.biSizeImage = requested_format_.ImageAllocationSize(); |
| 92 media_type->subtype = MEDIASUBTYPE_RGB24; | 91 media_type->subtype = MEDIASUBTYPE_RGB24; |
| 93 break; | 92 break; |
| 94 } | 93 } |
| 95 default: | 94 default: |
| 96 return false; | 95 return false; |
| 97 } | 96 } |
| 98 | 97 |
| 99 media_type->bFixedSizeSamples = TRUE; | 98 media_type->bFixedSizeSamples = TRUE; |
| 100 media_type->lSampleSize = pvi->bmiHeader.biSizeImage; | 99 media_type->lSampleSize = pvi->bmiHeader.biSizeImage; |
| 101 return true; | 100 return true; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 } | 142 } |
| 144 if (sub_type == MEDIASUBTYPE_RGB24 && | 143 if (sub_type == MEDIASUBTYPE_RGB24 && |
| 145 pvi->bmiHeader.biCompression == BI_RGB) { | 144 pvi->bmiHeader.biCompression == BI_RGB) { |
| 146 resulting_format_.pixel_format = PIXEL_FORMAT_RGB24; | 145 resulting_format_.pixel_format = PIXEL_FORMAT_RGB24; |
| 147 return true; // This format is acceptable. | 146 return true; // This format is acceptable. |
| 148 } | 147 } |
| 149 return false; | 148 return false; |
| 150 } | 149 } |
| 151 | 150 |
| 152 HRESULT SinkInputPin::Receive(IMediaSample* sample) { | 151 HRESULT SinkInputPin::Receive(IMediaSample* sample) { |
| 153 const int length = sample->GetActualDataLength(); | 152 const int length = sample->GetActualDataLength(); |
|
perkj_chrome
2015/02/10 08:01:00
this is where length it set. Prefer to check lengh
| |
| 154 uint8* buffer = NULL; | 153 uint8* buffer = NULL; |
| 155 if (FAILED(sample->GetPointer(&buffer))) | 154 if (FAILED(sample->GetPointer(&buffer))) |
| 156 return S_FALSE; | 155 return S_FALSE; |
| 157 | 156 |
| 158 observer_->FrameReceived(buffer, length); | 157 observer_->FrameReceived(buffer, length); |
| 159 return S_OK; | 158 return S_OK; |
| 160 } | 159 } |
| 161 | 160 |
| 162 void SinkInputPin::SetRequestedMediaFormat(const VideoCaptureFormat& format) { | 161 void SinkInputPin::SetRequestedMediaFormat(const VideoCaptureFormat& format) { |
| 163 requested_format_ = format; | 162 requested_format_ = format; |
| 164 resulting_format_.frame_size.SetSize(0, 0); | 163 resulting_format_.frame_size.SetSize(0, 0); |
| 165 resulting_format_.frame_rate = 0; | 164 resulting_format_.frame_rate = 0; |
| 166 resulting_format_.pixel_format = PIXEL_FORMAT_UNKNOWN; | 165 resulting_format_.pixel_format = PIXEL_FORMAT_UNKNOWN; |
| 167 } | 166 } |
| 168 | 167 |
| 169 const VideoCaptureFormat& SinkInputPin::ResultingFormat() { | 168 const VideoCaptureFormat& SinkInputPin::ResultingFormat() { |
| 170 return resulting_format_; | 169 return resulting_format_; |
| 171 } | 170 } |
| 172 | 171 |
| 173 } // namespace media | 172 } // namespace media |
| OLD | NEW |