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

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: rebase Created 4 years, 2 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
11 #include <dshow.h> 11 #include <dshow.h>
12 #include <stdint.h> 12 #include <stdint.h>
13 13
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "media/base/timestamp_constants.h" 16 #include "media/base/timestamp_constants.h"
17 #include "media/capture/video/video_capture_utils.h"
17 18
18 namespace media { 19 namespace media {
19 20
20 const REFERENCE_TIME kSecondsToReferenceTime = 10000000; 21 const REFERENCE_TIME kSecondsToReferenceTime = 10000000;
21 22
22 static DWORD GetArea(const BITMAPINFOHEADER& info_header) { 23 static DWORD GetArea(const BITMAPINFOHEADER& info_header) {
23 return info_header.biWidth * info_header.biHeight; 24 return info_header.biWidth * info_header.biHeight;
24 } 25 }
25 26
26 SinkInputPin::SinkInputPin(IBaseFilter* filter, SinkFilterObserver* observer) 27 SinkInputPin::SinkInputPin(IBaseFilter* filter, SinkFilterObserver* observer)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (sub_type == MEDIASUBTYPE_RGB24 && 89 if (sub_type == MEDIASUBTYPE_RGB24 &&
89 pvi->bmiHeader.biCompression == BI_RGB) { 90 pvi->bmiHeader.biCompression == BI_RGB) {
90 resulting_format_.pixel_format = PIXEL_FORMAT_RGB24; 91 resulting_format_.pixel_format = PIXEL_FORMAT_RGB24;
91 return true; 92 return true;
92 } 93 }
93 if (sub_type == MEDIASUBTYPE_RGB32 && 94 if (sub_type == MEDIASUBTYPE_RGB32 &&
94 pvi->bmiHeader.biCompression == BI_RGB) { 95 pvi->bmiHeader.biCompression == BI_RGB) {
95 resulting_format_.pixel_format = PIXEL_FORMAT_RGB32; 96 resulting_format_.pixel_format = PIXEL_FORMAT_RGB32;
96 return true; 97 return true;
97 } 98 }
99 if (sub_type.Data1 == pvi->bmiHeader.biCompression) {
100 if (IsY16FormatFourCc(sub_type.Data1)) {
101 resulting_format_.pixel_format = PIXEL_FORMAT_Y16;
102 return true;
103 }
104 }
98 105
99 #ifndef NDEBUG 106 #ifndef NDEBUG
100 WCHAR guid_str[128]; 107 WCHAR guid_str[128];
101 StringFromGUID2(sub_type, guid_str, arraysize(guid_str)); 108 StringFromGUID2(sub_type, guid_str, arraysize(guid_str));
102 DVLOG(2) << __func__ << " unsupported media type: " << guid_str; 109 DVLOG(2) << __func__ << " unsupported media type: " << guid_str;
103 #endif 110 #endif
104 return false; 111 return false;
105 } 112 }
106 113
107 bool SinkInputPin::GetValidMediaType(int index, AM_MEDIA_TYPE* media_type) { 114 bool SinkInputPin::GetValidMediaType(int index, AM_MEDIA_TYPE* media_type) {
108 if (media_type->cbFormat < sizeof(VIDEOINFOHEADER)) 115 if (media_type->cbFormat < sizeof(VIDEOINFOHEADER))
109 return false; 116 return false;
110 117
111 VIDEOINFOHEADER* const pvi = 118 VIDEOINFOHEADER* const pvi =
112 reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat); 119 reinterpret_cast<VIDEOINFOHEADER*>(media_type->pbFormat);
113 120
114 ZeroMemory(pvi, sizeof(VIDEOINFOHEADER)); 121 ZeroMemory(pvi, sizeof(VIDEOINFOHEADER));
115 pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 122 pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
116 pvi->bmiHeader.biPlanes = 1; 123 pvi->bmiHeader.biPlanes = 1;
117 pvi->bmiHeader.biClrImportant = 0; 124 pvi->bmiHeader.biClrImportant = 0;
118 pvi->bmiHeader.biClrUsed = 0; 125 pvi->bmiHeader.biClrUsed = 0;
119 if (requested_frame_rate_ > 0) 126 if (requested_frame_rate_ > 0)
120 pvi->AvgTimePerFrame = kSecondsToReferenceTime / requested_frame_rate_; 127 pvi->AvgTimePerFrame = kSecondsToReferenceTime / requested_frame_rate_;
121 128
122 media_type->majortype = MEDIATYPE_Video; 129 media_type->majortype = MEDIATYPE_Video;
123 media_type->formattype = FORMAT_VideoInfo; 130 media_type->formattype = FORMAT_VideoInfo;
124 media_type->bTemporalCompression = FALSE; 131 media_type->bTemporalCompression = FALSE;
125 132
126 if (requested_pixel_format_ == PIXEL_FORMAT_MJPEG) { 133 if (requested_pixel_format_ == PIXEL_FORMAT_MJPEG ||
127 // If the requested pixel format is MJPEG, accept only MJPEG. 134 requested_pixel_format_ == PIXEL_FORMAT_Y16) {
135 // 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 136 // This is ok since the capabilities of the capturer have been
129 // enumerated and we know that it is supported. 137 // enumerated and we know that it is supported.
130 if (index != 0) 138 if (index != 0)
131 return false; 139 return false;
132 140
133 pvi->bmiHeader = requested_info_header_; 141 pvi->bmiHeader = requested_info_header_;
134 return true; 142 return true;
135 } 143 }
136 144
137 switch (index) { 145 switch (index) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 } 218 }
211 219
212 observer_->FrameReceived(buffer, length, resulting_format_, timestamp); 220 observer_->FrameReceived(buffer, length, resulting_format_, timestamp);
213 return S_OK; 221 return S_OK;
214 } 222 }
215 223
216 SinkInputPin::~SinkInputPin() { 224 SinkInputPin::~SinkInputPin() {
217 } 225 }
218 226
219 } // namespace media 227 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/video/video_capture_utils.cc ('k') | media/capture/video/win/video_capture_device_factory_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698