| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 resulting_capability_.width = pvi->bmiHeader.biWidth; | 107 resulting_capability_.width = pvi->bmiHeader.biWidth; |
| 108 resulting_capability_.height = abs(pvi->bmiHeader.biHeight); | 108 resulting_capability_.height = abs(pvi->bmiHeader.biHeight); |
| 109 if (pvi->AvgTimePerFrame > 0) { | 109 if (pvi->AvgTimePerFrame > 0) { |
| 110 resulting_capability_.frame_rate = | 110 resulting_capability_.frame_rate = |
| 111 static_cast<int>(kSecondsToReferenceTime / pvi->AvgTimePerFrame); | 111 static_cast<int>(kSecondsToReferenceTime / pvi->AvgTimePerFrame); |
| 112 } else { | 112 } else { |
| 113 resulting_capability_.frame_rate = requested_capability_.frame_rate; | 113 resulting_capability_.frame_rate = requested_capability_.frame_rate; |
| 114 } | 114 } |
| 115 if (sub_type == kMediaSubTypeI420 && | 115 if (sub_type == kMediaSubTypeI420 && |
| 116 pvi->bmiHeader.biCompression == MAKEFOURCC('I', '4', '2', '0')) { | 116 pvi->bmiHeader.biCompression == MAKEFOURCC('I', '4', '2', '0')) { |
| 117 resulting_capability_.color = VideoCaptureCapability::kI420; | 117 resulting_capability_.color = kI420; |
| 118 return true; // This format is acceptable. | 118 return true; // This format is acceptable. |
| 119 } | 119 } |
| 120 if (sub_type == MEDIASUBTYPE_YUY2 && | 120 if (sub_type == MEDIASUBTYPE_YUY2 && |
| 121 pvi->bmiHeader.biCompression == MAKEFOURCC('Y', 'U', 'Y', '2')) { | 121 pvi->bmiHeader.biCompression == MAKEFOURCC('Y', 'U', 'Y', '2')) { |
| 122 resulting_capability_.color = VideoCaptureCapability::kYUY2; | 122 resulting_capability_.color = kYUY2; |
| 123 return true; // This format is acceptable. | 123 return true; // This format is acceptable. |
| 124 } | 124 } |
| 125 if (sub_type == MEDIASUBTYPE_RGB24 && | 125 if (sub_type == MEDIASUBTYPE_RGB24 && |
| 126 pvi->bmiHeader.biCompression == BI_RGB) { | 126 pvi->bmiHeader.biCompression == BI_RGB) { |
| 127 resulting_capability_.color = VideoCaptureCapability::kRGB24; | 127 resulting_capability_.color = kRGB24; |
| 128 return true; // This format is acceptable. | 128 return true; // This format is acceptable. |
| 129 } | 129 } |
| 130 return false; | 130 return false; |
| 131 } | 131 } |
| 132 | 132 |
| 133 HRESULT SinkInputPin::Receive(IMediaSample* sample) { | 133 HRESULT SinkInputPin::Receive(IMediaSample* sample) { |
| 134 const int length = sample->GetActualDataLength(); | 134 const int length = sample->GetActualDataLength(); |
| 135 uint8* buffer = NULL; | 135 uint8* buffer = NULL; |
| 136 if (FAILED(sample->GetPointer(&buffer))) | 136 if (FAILED(sample->GetPointer(&buffer))) |
| 137 return S_FALSE; | 137 return S_FALSE; |
| 138 | 138 |
| 139 observer_->FrameReceived(buffer, length); | 139 observer_->FrameReceived(buffer, length); |
| 140 return S_OK; | 140 return S_OK; |
| 141 } | 141 } |
| 142 | 142 |
| 143 void SinkInputPin::SetRequestedMediaCapability( | 143 void SinkInputPin::SetRequestedMediaCapability( |
| 144 const VideoCaptureCapability& capability) { | 144 const VideoCaptureCapability& capability) { |
| 145 requested_capability_ = capability; | 145 requested_capability_ = capability; |
| 146 resulting_capability_.width = 0; | 146 resulting_capability_.width = 0; |
| 147 resulting_capability_.height = 0; | 147 resulting_capability_.height = 0; |
| 148 resulting_capability_.frame_rate = 0; | 148 resulting_capability_.frame_rate = 0; |
| 149 resulting_capability_.color = VideoCaptureCapability::kColorUnknown; | 149 resulting_capability_.color = kColorUnknown; |
| 150 resulting_capability_.expected_capture_delay = 0; | 150 resulting_capability_.expected_capture_delay = 0; |
| 151 resulting_capability_.interlaced = false; | 151 resulting_capability_.interlaced = false; |
| 152 } | 152 } |
| 153 | 153 |
| 154 const VideoCaptureCapability& SinkInputPin::ResultingCapability() { | 154 const VideoCaptureCapability& SinkInputPin::ResultingCapability() { |
| 155 return resulting_capability_; | 155 return resulting_capability_; |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace media | 158 } // namespace media |
| OLD | NEW |