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

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

Issue 900233002: Enumerate MJPEG as the prefered format if set. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nit. Created 5 years, 10 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
« no previous file with comments | « no previous file | media/video/capture/win/video_capture_device_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 27 matching lines...) Expand all
38 pvi->bmiHeader.biClrUsed = 0; 38 pvi->bmiHeader.biClrUsed = 0;
39 if (requested_format_.frame_rate > 0) { 39 if (requested_format_.frame_rate > 0) {
40 pvi->AvgTimePerFrame = 40 pvi->AvgTimePerFrame =
41 kSecondsToReferenceTime / requested_format_.frame_rate; 41 kSecondsToReferenceTime / requested_format_.frame_rate;
42 } 42 }
43 43
44 media_type->majortype = MEDIATYPE_Video; 44 media_type->majortype = MEDIATYPE_Video;
45 media_type->formattype = FORMAT_VideoInfo; 45 media_type->formattype = FORMAT_VideoInfo;
46 media_type->bTemporalCompression = FALSE; 46 media_type->bTemporalCompression = FALSE;
47 47
48 if (requested_format_.pixel_format == PIXEL_FORMAT_MJPEG) {
49 // If the requested pixel format is MJPEG, accept only MJPEG.
50 // This is ok since the capabilities of the capturer have been
51 // enumerated and we know that it is supported.
52 if (index != 0)
53 return false;
54
55 pvi->bmiHeader.biCompression = MAKEFOURCC('M', 'J', 'P', 'G');
56 pvi->bmiHeader.biBitCount = 0;
57 pvi->bmiHeader.biWidth = requested_format_.frame_size.width();
58 pvi->bmiHeader.biHeight = requested_format_.frame_size.height();
59 pvi->bmiHeader.biSizeImage = 0;
60 media_type->subtype = MEDIASUBTYPE_MJPG;
61 media_type->bFixedSizeSamples = FALSE;
62 media_type->lSampleSize = pvi->bmiHeader.biSizeImage;
63 return true;
64 }
65
48 switch (index) { 66 switch (index) {
49 case 0: { 67 case 0: {
50 pvi->bmiHeader.biCompression = MAKEFOURCC('I', '4', '2', '0'); 68 pvi->bmiHeader.biCompression = MAKEFOURCC('I', '4', '2', '0');
51 pvi->bmiHeader.biBitCount = 12; // bit per pixel 69 pvi->bmiHeader.biBitCount = 12; // bit per pixel
52 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); 70 pvi->bmiHeader.biWidth = requested_format_.frame_size.width();
53 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); 71 pvi->bmiHeader.biHeight = requested_format_.frame_size.height();
54 pvi->bmiHeader.biSizeImage = 72 pvi->bmiHeader.biSizeImage =
55 requested_format_.frame_size.GetArea() * 3 / 2; 73 requested_format_.frame_size.GetArea() * 3 / 2;
56 media_type->subtype = kMediaSubTypeI420; 74 media_type->subtype = kMediaSubTypeI420;
57 break; 75 break;
58 } 76 }
59 case 1: { 77 case 1: {
60 pvi->bmiHeader.biCompression = MAKEFOURCC('Y', 'U', 'Y', '2'); 78 pvi->bmiHeader.biCompression = MAKEFOURCC('Y', 'U', 'Y', '2');
61 pvi->bmiHeader.biBitCount = 16; 79 pvi->bmiHeader.biBitCount = 16;
62 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); 80 pvi->bmiHeader.biWidth = requested_format_.frame_size.width();
63 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); 81 pvi->bmiHeader.biHeight = requested_format_.frame_size.height();
64 pvi->bmiHeader.biSizeImage = requested_format_.frame_size.GetArea() * 2; 82 pvi->bmiHeader.biSizeImage = requested_format_.frame_size.GetArea() * 2;
65 media_type->subtype = MEDIASUBTYPE_YUY2; 83 media_type->subtype = MEDIASUBTYPE_YUY2;
66 break; 84 break;
67 } 85 }
68 case 2: { 86 case 2: {
69 pvi->bmiHeader.biCompression = MAKEFOURCC('M', 'J', 'P', 'G');
70 pvi->bmiHeader.biBitCount = 0;
71 pvi->bmiHeader.biWidth = requested_format_.frame_size.width();
72 pvi->bmiHeader.biHeight = requested_format_.frame_size.height();
73 pvi->bmiHeader.biSizeImage = 0;
74 media_type->subtype = MEDIASUBTYPE_MJPG;
75 break;
76 }
77 case 3: {
78 pvi->bmiHeader.biCompression = BI_RGB; 87 pvi->bmiHeader.biCompression = BI_RGB;
79 pvi->bmiHeader.biBitCount = 24; 88 pvi->bmiHeader.biBitCount = 24;
80 pvi->bmiHeader.biWidth = requested_format_.frame_size.width(); 89 pvi->bmiHeader.biWidth = requested_format_.frame_size.width();
81 pvi->bmiHeader.biHeight = requested_format_.frame_size.height(); 90 pvi->bmiHeader.biHeight = requested_format_.frame_size.height();
82 pvi->bmiHeader.biSizeImage = requested_format_.frame_size.GetArea() * 3; 91 pvi->bmiHeader.biSizeImage = requested_format_.frame_size.GetArea() * 3;
83 media_type->subtype = MEDIASUBTYPE_RGB24; 92 media_type->subtype = MEDIASUBTYPE_RGB24;
84 break; 93 break;
85 } 94 }
86 default: 95 default:
87 return false; 96 return false;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 resulting_format_.frame_size.SetSize(0, 0); 164 resulting_format_.frame_size.SetSize(0, 0);
156 resulting_format_.frame_rate = 0; 165 resulting_format_.frame_rate = 0;
157 resulting_format_.pixel_format = PIXEL_FORMAT_UNKNOWN; 166 resulting_format_.pixel_format = PIXEL_FORMAT_UNKNOWN;
158 } 167 }
159 168
160 const VideoCaptureFormat& SinkInputPin::ResultingFormat() { 169 const VideoCaptureFormat& SinkInputPin::ResultingFormat() {
161 return resulting_format_; 170 return resulting_format_;
162 } 171 }
163 172
164 } // namespace media 173 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/video/capture/win/video_capture_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698