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

Side by Side Diff: content/renderer/media/media_stream_video_source.cc

Issue 2081093002: Cleanup: Remove video constraint names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/renderer/media/media_stream_video_source.h" 5 #include "content/renderer/media/media_stream_video_source.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
16 #include "content/child/child_process.h" 16 #include "content/child/child_process.h"
17 #include "content/renderer/media/media_stream_video_track.h" 17 #include "content/renderer/media/media_stream_video_track.h"
18 #include "content/renderer/media/video_track_adapter.h" 18 #include "content/renderer/media/video_track_adapter.h"
19 19
20 namespace content { 20 namespace content {
21 21
22 // Constraint keys. Specified by draft-alvestrand-constraints-resolution-00b
23 const char MediaStreamVideoSource::kMinAspectRatio[] = "minAspectRatio";
24 const char MediaStreamVideoSource::kMaxAspectRatio[] = "maxAspectRatio";
25 const char MediaStreamVideoSource::kMaxWidth[] = "maxWidth";
26 const char MediaStreamVideoSource::kMinWidth[] = "minWidth";
27 const char MediaStreamVideoSource::kMaxHeight[] = "maxHeight";
28 const char MediaStreamVideoSource::kMinHeight[] = "minHeight";
29 const char MediaStreamVideoSource::kMaxFrameRate[] = "maxFrameRate";
30 const char MediaStreamVideoSource::kMinFrameRate[] = "minFrameRate";
31
32 // TODO(mcasas): Find a way to guarantee all constraints are added to the array.
33 const char* const kSupportedConstraints[] = {
34 MediaStreamVideoSource::kMaxAspectRatio,
35 MediaStreamVideoSource::kMinAspectRatio,
36 MediaStreamVideoSource::kMaxWidth,
37 MediaStreamVideoSource::kMinWidth,
38 MediaStreamVideoSource::kMaxHeight,
39 MediaStreamVideoSource::kMinHeight,
40 MediaStreamVideoSource::kMaxFrameRate,
41 MediaStreamVideoSource::kMinFrameRate,
42 };
43
44 namespace { 22 namespace {
45 23
46 const char* const kLegalVideoConstraints[] = { 24 const char* const kLegalVideoConstraints[] = {
47 "width", "height", "aspectRatio", "frameRate", 25 "width", "height", "aspectRatio", "frameRate",
48 "facingMode", "deviceId", "groupId", "mediaStreamSource", 26 "facingMode", "deviceId", "groupId", "mediaStreamSource",
49 }; 27 };
50 28
51 // Returns true if |constraint| has mandatory constraints. 29 // Returns true if |constraint| has mandatory constraints.
52 bool HasMandatoryConstraints(const blink::WebMediaConstraints& constraints) { 30 bool HasMandatoryConstraints(const blink::WebMediaConstraints& constraints) {
53 return constraints.basic().hasMandatory(); 31 return constraints.basic().hasMandatory();
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 // static 277 // static
300 MediaStreamVideoSource* MediaStreamVideoSource::GetVideoSource( 278 MediaStreamVideoSource* MediaStreamVideoSource::GetVideoSource(
301 const blink::WebMediaStreamSource& source) { 279 const blink::WebMediaStreamSource& source) {
302 if (source.isNull() || 280 if (source.isNull() ||
303 source.getType() != blink::WebMediaStreamSource::TypeVideo) { 281 source.getType() != blink::WebMediaStreamSource::TypeVideo) {
304 return nullptr; 282 return nullptr;
305 } 283 }
306 return static_cast<MediaStreamVideoSource*>(source.getExtraData()); 284 return static_cast<MediaStreamVideoSource*>(source.getExtraData());
307 } 285 }
308 286
309 // static, deprecated
310 bool MediaStreamVideoSource::IsConstraintSupported(const std::string& name) {
311 return std::find(kSupportedConstraints,
312 kSupportedConstraints + arraysize(kSupportedConstraints),
313 name) !=
314 kSupportedConstraints + arraysize(kSupportedConstraints);
315 }
316
317 MediaStreamVideoSource::MediaStreamVideoSource() 287 MediaStreamVideoSource::MediaStreamVideoSource()
318 : state_(NEW), 288 : state_(NEW),
319 track_adapter_( 289 track_adapter_(
320 new VideoTrackAdapter(ChildProcess::current()->io_task_runner())), 290 new VideoTrackAdapter(ChildProcess::current()->io_task_runner())),
321 weak_factory_(this) {} 291 weak_factory_(this) {}
322 292
323 // https://crbug.com/612084 293 // https://crbug.com/612084
324 MSVC_DISABLE_OPTIMIZE() 294 MSVC_DISABLE_OPTIMIZE()
325 NOINLINE MediaStreamVideoSource::~MediaStreamVideoSource() { 295 NOINLINE MediaStreamVideoSource::~MediaStreamVideoSource() {
326 DCHECK(CalledOnValidThread()); 296 DCHECK(CalledOnValidThread());
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 callback(callback) { 573 callback(callback) {
604 } 574 }
605 575
606 MediaStreamVideoSource::TrackDescriptor::TrackDescriptor( 576 MediaStreamVideoSource::TrackDescriptor::TrackDescriptor(
607 const TrackDescriptor& other) = default; 577 const TrackDescriptor& other) = default;
608 578
609 MediaStreamVideoSource::TrackDescriptor::~TrackDescriptor() { 579 MediaStreamVideoSource::TrackDescriptor::~TrackDescriptor() {
610 } 580 }
611 581
612 } // namespace content 582 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_video_source.h ('k') | content/renderer/media/media_stream_video_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698