| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 case 2: { | 84 case 2: { |
| 85 pvi->bmiHeader.biCompression = BI_RGB; | 85 pvi->bmiHeader.biCompression = BI_RGB; |
| 86 pvi->bmiHeader.biBitCount = 24; | 86 pvi->bmiHeader.biBitCount = 24; |
| 87 pvi->bmiHeader.biWidth = requested_info_header_.biWidth; | 87 pvi->bmiHeader.biWidth = requested_info_header_.biWidth; |
| 88 pvi->bmiHeader.biHeight = requested_info_header_.biHeight; | 88 pvi->bmiHeader.biHeight = requested_info_header_.biHeight; |
| 89 pvi->bmiHeader.biSizeImage = GetArea(requested_info_header_) * 3; | 89 pvi->bmiHeader.biSizeImage = GetArea(requested_info_header_) * 3; |
| 90 media_type->subtype = MEDIASUBTYPE_RGB24; | 90 media_type->subtype = MEDIASUBTYPE_RGB24; |
| 91 break; | 91 break; |
| 92 } | 92 } |
| 93 case 3: { |
| 94 pvi->bmiHeader.biCompression = BI_RGB; |
| 95 pvi->bmiHeader.biBitCount = 32; |
| 96 pvi->bmiHeader.biWidth = requested_info_header_.biWidth; |
| 97 pvi->bmiHeader.biHeight = requested_info_header_.biHeight; |
| 98 pvi->bmiHeader.biSizeImage = GetArea(requested_info_header_) * 4; |
| 99 media_type->subtype = MEDIASUBTYPE_RGB32; |
| 100 break; |
| 101 } |
| 93 default: | 102 default: |
| 94 return false; | 103 return false; |
| 95 } | 104 } |
| 96 | 105 |
| 97 media_type->bFixedSizeSamples = TRUE; | 106 media_type->bFixedSizeSamples = TRUE; |
| 98 media_type->lSampleSize = pvi->bmiHeader.biSizeImage; | 107 media_type->lSampleSize = pvi->bmiHeader.biSizeImage; |
| 99 return true; | 108 return true; |
| 100 } | 109 } |
| 101 | 110 |
| 102 bool SinkInputPin::IsMediaTypeValid(const AM_MEDIA_TYPE* media_type) { | 111 bool SinkInputPin::IsMediaTypeValid(const AM_MEDIA_TYPE* media_type) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 120 abs(pvi->bmiHeader.biHeight)); | 129 abs(pvi->bmiHeader.biHeight)); |
| 121 if (pvi->AvgTimePerFrame > 0) { | 130 if (pvi->AvgTimePerFrame > 0) { |
| 122 resulting_format_.frame_rate = | 131 resulting_format_.frame_rate = |
| 123 static_cast<int>(kSecondsToReferenceTime / pvi->AvgTimePerFrame); | 132 static_cast<int>(kSecondsToReferenceTime / pvi->AvgTimePerFrame); |
| 124 } else { | 133 } else { |
| 125 resulting_format_.frame_rate = requested_frame_rate_; | 134 resulting_format_.frame_rate = requested_frame_rate_; |
| 126 } | 135 } |
| 127 if (sub_type == kMediaSubTypeI420 && | 136 if (sub_type == kMediaSubTypeI420 && |
| 128 pvi->bmiHeader.biCompression == MAKEFOURCC('I', '4', '2', '0')) { | 137 pvi->bmiHeader.biCompression == MAKEFOURCC('I', '4', '2', '0')) { |
| 129 resulting_format_.pixel_format = PIXEL_FORMAT_I420; | 138 resulting_format_.pixel_format = PIXEL_FORMAT_I420; |
| 130 return true; // This format is acceptable. | 139 return true; |
| 131 } | 140 } |
| 132 if (sub_type == MEDIASUBTYPE_YUY2 && | 141 if (sub_type == MEDIASUBTYPE_YUY2 && |
| 133 pvi->bmiHeader.biCompression == MAKEFOURCC('Y', 'U', 'Y', '2')) { | 142 pvi->bmiHeader.biCompression == MAKEFOURCC('Y', 'U', 'Y', '2')) { |
| 134 resulting_format_.pixel_format = PIXEL_FORMAT_YUY2; | 143 resulting_format_.pixel_format = PIXEL_FORMAT_YUY2; |
| 135 return true; // This format is acceptable. | 144 return true; |
| 136 } | 145 } |
| 137 if (sub_type == MEDIASUBTYPE_MJPG && | 146 if (sub_type == MEDIASUBTYPE_MJPG && |
| 138 pvi->bmiHeader.biCompression == MAKEFOURCC('M', 'J', 'P', 'G')) { | 147 pvi->bmiHeader.biCompression == MAKEFOURCC('M', 'J', 'P', 'G')) { |
| 139 resulting_format_.pixel_format = PIXEL_FORMAT_MJPEG; | 148 resulting_format_.pixel_format = PIXEL_FORMAT_MJPEG; |
| 140 return true; // This format is acceptable. | 149 return true; |
| 141 } | 150 } |
| 142 if (sub_type == MEDIASUBTYPE_RGB24 && | 151 if (sub_type == MEDIASUBTYPE_RGB24 && |
| 143 pvi->bmiHeader.biCompression == BI_RGB) { | 152 pvi->bmiHeader.biCompression == BI_RGB) { |
| 144 resulting_format_.pixel_format = PIXEL_FORMAT_RGB24; | 153 resulting_format_.pixel_format = PIXEL_FORMAT_RGB24; |
| 145 return true; // This format is acceptable. | 154 return true; |
| 155 } |
| 156 if (sub_type == MEDIASUBTYPE_RGB32 && |
| 157 pvi->bmiHeader.biCompression == BI_RGB) { |
| 158 resulting_format_.pixel_format = PIXEL_FORMAT_RGB32; |
| 159 return true; |
| 146 } | 160 } |
| 147 return false; | 161 return false; |
| 148 } | 162 } |
| 149 | 163 |
| 150 HRESULT SinkInputPin::Receive(IMediaSample* sample) { | 164 HRESULT SinkInputPin::Receive(IMediaSample* sample) { |
| 151 const int length = sample->GetActualDataLength(); | 165 const int length = sample->GetActualDataLength(); |
| 152 uint8* buffer = NULL; | 166 uint8* buffer = NULL; |
| 153 | 167 |
| 154 if (length <= 0) { | 168 if (length <= 0) { |
| 155 DLOG(WARNING) << "Media sample length is 0 or less."; | 169 DLOG(WARNING) << "Media sample length is 0 or less."; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 173 resulting_format_.frame_size.SetSize(0, 0); | 187 resulting_format_.frame_size.SetSize(0, 0); |
| 174 resulting_format_.frame_rate = 0; | 188 resulting_format_.frame_rate = 0; |
| 175 resulting_format_.pixel_format = PIXEL_FORMAT_UNKNOWN; | 189 resulting_format_.pixel_format = PIXEL_FORMAT_UNKNOWN; |
| 176 } | 190 } |
| 177 | 191 |
| 178 const VideoCaptureFormat& SinkInputPin::ResultingFormat() { | 192 const VideoCaptureFormat& SinkInputPin::ResultingFormat() { |
| 179 return resulting_format_; | 193 return resulting_format_; |
| 180 } | 194 } |
| 181 | 195 |
| 182 } // namespace media | 196 } // namespace media |
| OLD | NEW |