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

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

Issue 2121043002: 16 bpp video stream capture, render and WebGL usage - Realsense R200 & SR300 support. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
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 // TODO(astojilj) Define GUIDs and move this to common place as the code is
99 // replicated around.
100 if ((sub_type.Data1 == MAKEFOURCC('Z', '1', '6', ' ') ||
101 sub_type.Data1 == MAKEFOURCC('I', 'N', 'V', 'Z')) &&
102 sub_type.Data1 == pvi->bmiHeader.biCompression) {
103 resulting_format_.pixel_format = PIXEL_FORMAT_Y16;
104 return true;
105 }
98 106
99 #ifndef NDEBUG 107 #ifndef NDEBUG
100 WCHAR guid_str[128]; 108 WCHAR guid_str[128];
101 StringFromGUID2(sub_type, guid_str, arraysize(guid_str)); 109 StringFromGUID2(sub_type, guid_str, arraysize(guid_str));
102 DVLOG(2) << __FUNCTION__ << " unsupported media type: " << guid_str; 110 DVLOG(2) << __FUNCTION__ << " unsupported media type: " << guid_str;
103 #endif 111 #endif
104 return false; 112 return false;
105 } 113 }
106 114
107 bool SinkInputPin::GetValidMediaType(int index, AM_MEDIA_TYPE* media_type) { 115 bool SinkInputPin::GetValidMediaType(int index, AM_MEDIA_TYPE* media_type) {
108 if (media_type->cbFormat < sizeof(VIDEOINFOHEADER)) 116 if (media_type->cbFormat < sizeof(VIDEOINFOHEADER))
109 return false; 117 return false;
110 118
111 VIDEOINFOHEADER* const pvi = 119 VIDEOINFOHEADER* const pvi =
112 reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat); 120 reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat);
113 121
114 ZeroMemory(pvi, sizeof(VIDEOINFOHEADER)); 122 ZeroMemory(pvi, sizeof(VIDEOINFOHEADER));
115 pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 123 pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
116 pvi->bmiHeader.biPlanes = 1; 124 pvi->bmiHeader.biPlanes = 1;
117 pvi->bmiHeader.biClrImportant = 0; 125 pvi->bmiHeader.biClrImportant = 0;
118 pvi->bmiHeader.biClrUsed = 0; 126 pvi->bmiHeader.biClrUsed = 0;
119 if (requested_frame_rate_ > 0) 127 if (requested_frame_rate_ > 0)
120 pvi->AvgTimePerFrame = kSecondsToReferenceTime / requested_frame_rate_; 128 pvi->AvgTimePerFrame = kSecondsToReferenceTime / requested_frame_rate_;
121 129
122 media_type->majortype = MEDIATYPE_Video; 130 media_type->majortype = MEDIATYPE_Video;
123 media_type->formattype = FORMAT_VideoInfo; 131 media_type->formattype = FORMAT_VideoInfo;
124 media_type->bTemporalCompression = FALSE; 132 media_type->bTemporalCompression = FALSE;
125 133
126 if (requested_pixel_format_ == PIXEL_FORMAT_MJPEG) { 134 if (requested_pixel_format_ == PIXEL_FORMAT_MJPEG ||
135 requested_pixel_format_ == PIXEL_FORMAT_Y16) {
127 // If the requested pixel format is MJPEG, accept only MJPEG. 136 // If the requested pixel format is MJPEG, accept only MJPEG.
137 // If the requested pixel format is Y16, accept only Y16.
128 // This is ok since the capabilities of the capturer have been 138 // This is ok since the capabilities of the capturer have been
129 // enumerated and we know that it is supported. 139 // enumerated and we know that it is supported.
130 if (index != 0) 140 if (index != 0)
131 return false; 141 return false;
132 142
133 pvi->bmiHeader = requested_info_header_; 143 pvi->bmiHeader = requested_info_header_;
134 return true; 144 return true;
135 } 145 }
136 146
137 switch (index) { 147 switch (index) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 219 }
210 220
211 observer_->FrameReceived(buffer, length, timestamp); 221 observer_->FrameReceived(buffer, length, timestamp);
212 return S_OK; 222 return S_OK;
213 } 223 }
214 224
215 SinkInputPin::~SinkInputPin() { 225 SinkInputPin::~SinkInputPin() {
216 } 226 }
217 227
218 } // namespace media 228 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698