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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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; // This format is acceptable. |
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; // This format is acceptable. |
146 } | 155 } |
156 if (sub_type == MEDIASUBTYPE_RGB32 && | |
157 pvi->bmiHeader.biCompression == BI_RGB) { | |
mcasas
2015/03/27 01:02:11
Indent two extra right
emircan
2015/03/27 17:50:39
Done.
| |
158 resulting_format_.pixel_format = PIXEL_FORMAT_ARGB; | |
159 return true; // This format is acceptable. | |
mcasas
2015/03/27 01:02:11
Comment is irrelevant (similar ones too).
emircan
2015/03/27 17:50:39
Done.
| |
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."; |
156 return S_FALSE; | 170 return S_FALSE; |
(...skipping 16 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 |