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

Side by Side Diff: content/browser/renderer_host/media/video_capture_manager.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 "content/browser/renderer_host/media/video_capture_manager.h" 5 #include "content/browser/renderer_host/media/video_capture_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Compares two VideoCaptureFormat by checking smallest frame_size area, then 54 // Compares two VideoCaptureFormat by checking smallest frame_size area, then
55 // by _largest_ frame_rate. Used to order a VideoCaptureFormats vector so that 55 // by _largest_ frame_rate. Used to order a VideoCaptureFormats vector so that
56 // the first entry for a given resolution has the largest frame rate, as needed 56 // the first entry for a given resolution has the largest frame rate, as needed
57 // by the ConsolidateCaptureFormats() method. 57 // by the ConsolidateCaptureFormats() method.
58 bool IsCaptureFormatSmaller(const media::VideoCaptureFormat& format1, 58 bool IsCaptureFormatSmaller(const media::VideoCaptureFormat& format1,
59 const media::VideoCaptureFormat& format2) { 59 const media::VideoCaptureFormat& format2) {
60 DCHECK(format1.frame_size.GetCheckedArea().IsValid()); 60 DCHECK(format1.frame_size.GetCheckedArea().IsValid());
61 DCHECK(format2.frame_size.GetCheckedArea().IsValid()); 61 DCHECK(format2.frame_size.GetCheckedArea().IsValid());
62 if (format1.frame_size.GetCheckedArea().ValueOrDefault(0) == 62 if (format1.frame_size.GetCheckedArea().ValueOrDefault(0) ==
63 format2.frame_size.GetCheckedArea().ValueOrDefault(0)) { 63 format2.frame_size.GetCheckedArea().ValueOrDefault(0)) {
64 return format1.frame_rate > format2.frame_rate; 64 return format1.frame_rate > format2.frame_rate ||
65 // Prefer Y16 capture format for the same frame rate.
66 // This is workaround for e.g. Realsense R200 IR stream.
67 (format1.frame_rate == format2.frame_rate &&
68 (format2.pixel_format != media::PIXEL_FORMAT_Y16));
65 } 69 }
66 return format1.frame_size.GetCheckedArea().ValueOrDefault(0) < 70 return format1.frame_size.GetCheckedArea().ValueOrDefault(0) <
67 format2.frame_size.GetCheckedArea().ValueOrDefault(0); 71 format2.frame_size.GetCheckedArea().ValueOrDefault(0);
68 } 72 }
69 73
70 bool IsCaptureFormatSizeEqual(const media::VideoCaptureFormat& format1, 74 bool IsCaptureFormatSizeEqual(const media::VideoCaptureFormat& format1,
71 const media::VideoCaptureFormat& format2) { 75 const media::VideoCaptureFormat& format2) {
72 DCHECK(format1.frame_size.GetCheckedArea().IsValid()); 76 DCHECK(format1.frame_size.GetCheckedArea().IsValid());
73 DCHECK(format2.frame_size.GetCheckedArea().IsValid()); 77 DCHECK(format2.frame_size.GetCheckedArea().IsValid());
74 return format1.frame_size.GetCheckedArea().ValueOrDefault(0) == 78 return format1.frame_size.GetCheckedArea().ValueOrDefault(0) ==
75 format2.frame_size.GetCheckedArea().ValueOrDefault(0); 79 format2.frame_size.GetCheckedArea().ValueOrDefault(0);
76 } 80 }
77 81
78 // This function receives a list of capture formats, removes duplicated 82 // This function receives a list of capture formats, removes duplicated
79 // resolutions while keeping the highest frame rate for each, and forcing I420 83 // resolutions while keeping the highest frame rate for each, and forcing I420
80 // pixel format. 84 // pixel format.
81 void ConsolidateCaptureFormats(media::VideoCaptureFormats* formats) { 85 void ConsolidateCaptureFormats(media::VideoCaptureFormats* formats) {
82 if (formats->empty()) 86 if (formats->empty())
83 return; 87 return;
84 std::sort(formats->begin(), formats->end(), IsCaptureFormatSmaller); 88 std::sort(formats->begin(), formats->end(), IsCaptureFormatSmaller);
85 // Due to the ordering imposed, the largest frame_rate is kept while removing 89 // Due to the ordering imposed, the largest frame_rate is kept while removing
86 // duplicated resolutions. 90 // duplicated resolutions.
87 media::VideoCaptureFormats::iterator last = 91 media::VideoCaptureFormats::iterator last =
88 std::unique(formats->begin(), formats->end(), IsCaptureFormatSizeEqual); 92 std::unique(formats->begin(), formats->end(), IsCaptureFormatSizeEqual);
89 formats->erase(last, formats->end()); 93 formats->erase(last, formats->end());
90 // Mark all formats as I420, since this is what the renderer side will get 94 // Mark all formats as I420, since this is what the renderer side will get
91 // anyhow: the actual pixel format is decided at the device level. 95 // anyhow: the actual pixel format is decided at the device level.
96 // Don't do this for Y16 format as it is handled separatelly.
92 for (media::VideoCaptureFormats::iterator it = formats->begin(); 97 for (media::VideoCaptureFormats::iterator it = formats->begin();
93 it != formats->end(); ++it) { 98 it != formats->end(); ++it) {
94 it->pixel_format = media::PIXEL_FORMAT_I420; 99 if (it->pixel_format != media::PIXEL_FORMAT_Y16)
100 it->pixel_format = media::PIXEL_FORMAT_I420;
95 } 101 }
96 } 102 }
97 103
98 // The maximum number of buffers in the capture pipeline. See 104 // The maximum number of buffers in the capture pipeline. See
99 // VideoCaptureController ctor comments for more details. 105 // VideoCaptureController ctor comments for more details.
100 const int kMaxNumberOfBuffers = 3; 106 const int kMaxNumberOfBuffers = 3;
101 // TODO(miu): The value for tab capture should be determined programmatically. 107 // TODO(miu): The value for tab capture should be determined programmatically.
102 // http://crbug.com/460318 108 // http://crbug.com/460318
103 const int kMaxNumberOfBuffersForTabCapture = 10; 109 const int kMaxNumberOfBuffersForTabCapture = 10;
104 110
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 if (!device_in_queue) { 1292 if (!device_in_queue) {
1287 // Session ID is only valid for Screen capture. So we can fake it to 1293 // Session ID is only valid for Screen capture. So we can fake it to
1288 // resume video capture devices here. 1294 // resume video capture devices here.
1289 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); 1295 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters);
1290 } 1296 }
1291 } 1297 }
1292 } 1298 }
1293 #endif // defined(OS_ANDROID) 1299 #endif // defined(OS_ANDROID)
1294 1300
1295 } // namespace content 1301 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_host.cc ('k') | content/browser/webrtc/webrtc_getusermedia_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698