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

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

Issue 2428263004: 16 bpp video stream capture, render and createImageBitmap(video) using (CPU) shared memory buffers (Closed)
Patch Set: Review #33 and #34 fixes. Removed WebGL part of code. Thanks danakj@ and mcasas@. Created 4 years, 1 month 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
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/capture/video/win/sink_input_pin_win.h" 5 #include "media/capture/video/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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (sub_type == MEDIASUBTYPE_RGB24 && 88 if (sub_type == MEDIASUBTYPE_RGB24 &&
89 pvi->bmiHeader.biCompression == BI_RGB) { 89 pvi->bmiHeader.biCompression == BI_RGB) {
90 resulting_format_.pixel_format = PIXEL_FORMAT_RGB24; 90 resulting_format_.pixel_format = PIXEL_FORMAT_RGB24;
91 return true; 91 return true;
92 } 92 }
93 if (sub_type == MEDIASUBTYPE_RGB32 && 93 if (sub_type == MEDIASUBTYPE_RGB32 &&
94 pvi->bmiHeader.biCompression == BI_RGB) { 94 pvi->bmiHeader.biCompression == BI_RGB) {
95 resulting_format_.pixel_format = PIXEL_FORMAT_RGB32; 95 resulting_format_.pixel_format = PIXEL_FORMAT_RGB32;
96 return true; 96 return true;
97 } 97 }
98 if (sub_type == kMediaSubTypeY16 &&
99 pvi->bmiHeader.biCompression == MAKEFOURCC('Y', '1', '6', ' ')) {
100 resulting_format_.pixel_format = PIXEL_FORMAT_Y16;
101 return true;
102 }
103 if (sub_type == kMediaSubTypeZ16 &&
104 pvi->bmiHeader.biCompression == MAKEFOURCC('Z', '1', '6', ' ')) {
105 resulting_format_.pixel_format = PIXEL_FORMAT_Y16;
106 return true;
107 }
108 if (sub_type == kMediaSubTypeINVZ &&
109 pvi->bmiHeader.biCompression == MAKEFOURCC('I', 'N', 'V', 'Z')) {
110 resulting_format_.pixel_format = PIXEL_FORMAT_Y16;
111 return true;
112 }
98 113
99 #ifndef NDEBUG 114 #ifndef NDEBUG
100 WCHAR guid_str[128]; 115 WCHAR guid_str[128];
101 StringFromGUID2(sub_type, guid_str, arraysize(guid_str)); 116 StringFromGUID2(sub_type, guid_str, arraysize(guid_str));
102 DVLOG(2) << __func__ << " unsupported media type: " << guid_str; 117 DVLOG(2) << __func__ << " unsupported media type: " << guid_str;
103 #endif 118 #endif
104 return false; 119 return false;
105 } 120 }
106 121
107 bool SinkInputPin::GetValidMediaType(int index, AM_MEDIA_TYPE* media_type) { 122 bool SinkInputPin::GetValidMediaType(int index, AM_MEDIA_TYPE* media_type) {
108 if (media_type->cbFormat < sizeof(VIDEOINFOHEADER)) 123 if (media_type->cbFormat < sizeof(VIDEOINFOHEADER))
109 return false; 124 return false;
110 125
111 VIDEOINFOHEADER* const pvi = 126 VIDEOINFOHEADER* const pvi =
112 reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat); 127 reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat);
113 128
114 ZeroMemory(pvi, sizeof(VIDEOINFOHEADER)); 129 ZeroMemory(pvi, sizeof(VIDEOINFOHEADER));
115 pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 130 pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
116 pvi->bmiHeader.biPlanes = 1; 131 pvi->bmiHeader.biPlanes = 1;
117 pvi->bmiHeader.biClrImportant = 0; 132 pvi->bmiHeader.biClrImportant = 0;
118 pvi->bmiHeader.biClrUsed = 0; 133 pvi->bmiHeader.biClrUsed = 0;
119 if (requested_frame_rate_ > 0) 134 if (requested_frame_rate_ > 0)
120 pvi->AvgTimePerFrame = kSecondsToReferenceTime / requested_frame_rate_; 135 pvi->AvgTimePerFrame = kSecondsToReferenceTime / requested_frame_rate_;
121 136
122 media_type->majortype = MEDIATYPE_Video; 137 media_type->majortype = MEDIATYPE_Video;
123 media_type->formattype = FORMAT_VideoInfo; 138 media_type->formattype = FORMAT_VideoInfo;
124 media_type->bTemporalCompression = FALSE; 139 media_type->bTemporalCompression = FALSE;
125 140
126 if (requested_pixel_format_ == PIXEL_FORMAT_MJPEG) { 141 if (requested_pixel_format_ == PIXEL_FORMAT_MJPEG ||
127 // If the requested pixel format is MJPEG, accept only MJPEG. 142 requested_pixel_format_ == PIXEL_FORMAT_Y16) {
143 // If the requested pixel format is MJPEG or Y16, don't accept other.
128 // This is ok since the capabilities of the capturer have been 144 // This is ok since the capabilities of the capturer have been
129 // enumerated and we know that it is supported. 145 // enumerated and we know that it is supported.
130 if (index != 0) 146 if (index != 0)
131 return false; 147 return false;
132 148
133 pvi->bmiHeader = requested_info_header_; 149 pvi->bmiHeader = requested_info_header_;
134 return true; 150 return true;
135 } 151 }
136 152
137 switch (index) { 153 switch (index) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 226 }
211 227
212 observer_->FrameReceived(buffer, length, resulting_format_, timestamp); 228 observer_->FrameReceived(buffer, length, resulting_format_, timestamp);
213 return S_OK; 229 return S_OK;
214 } 230 }
215 231
216 SinkInputPin::~SinkInputPin() { 232 SinkInputPin::~SinkInputPin() {
217 } 233 }
218 234
219 } // namespace media 235 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698