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

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

Issue 366243003: VideoTrackAdapter: Add passing frames monitor, notify MSVCS -> MSVTrack(s) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: grunell@ comments and added a UT with 1 source muted pinging two tracks. Created 6 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 | Annotate | Revision Log
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/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "content/child/child_process.h" 14 #include "content/child/child_process.h"
15 #include "content/renderer/media/media_stream_constraints_util.h" 15 #include "content/renderer/media/media_stream_constraints_util.h"
16 #include "content/renderer/media/media_stream_video_track.h" 16 #include "content/renderer/media/media_stream_video_track.h"
17 #include "content/renderer/media/video_track_adapter.h" 17 #include "content/renderer/media/video_track_adapter.h"
18 #include "media/base/bind_to_current_loop.h"
18 19
19 namespace content { 20 namespace content {
20 21
21 // Constraint keys. Specified by draft-alvestrand-constraints-resolution-00b 22 // Constraint keys. Specified by draft-alvestrand-constraints-resolution-00b
22 const char MediaStreamVideoSource::kMinAspectRatio[] = "minAspectRatio"; 23 const char MediaStreamVideoSource::kMinAspectRatio[] = "minAspectRatio";
23 const char MediaStreamVideoSource::kMaxAspectRatio[] = "maxAspectRatio"; 24 const char MediaStreamVideoSource::kMaxAspectRatio[] = "maxAspectRatio";
24 const char MediaStreamVideoSource::kMaxWidth[] = "maxWidth"; 25 const char MediaStreamVideoSource::kMaxWidth[] = "maxWidth";
25 const char MediaStreamVideoSource::kMinWidth[] = "minWidth"; 26 const char MediaStreamVideoSource::kMinWidth[] = "minWidth";
26 const char MediaStreamVideoSource::kMaxHeight[] = "maxHeight"; 27 const char MediaStreamVideoSource::kMaxHeight[] = "maxHeight";
27 const char MediaStreamVideoSource::kMinHeight[] = "minHeight"; 28 const char MediaStreamVideoSource::kMinHeight[] = "minHeight";
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 bool MediaStreamVideoSource::IsConstraintSupported(const std::string& name) { 344 bool MediaStreamVideoSource::IsConstraintSupported(const std::string& name) {
344 for (size_t i = 0; i < arraysize(kSupportedConstraints); ++i) { 345 for (size_t i = 0; i < arraysize(kSupportedConstraints); ++i) {
345 if (kSupportedConstraints[i] == name) 346 if (kSupportedConstraints[i] == name)
346 return true; 347 return true;
347 } 348 }
348 return false; 349 return false;
349 } 350 }
350 351
351 MediaStreamVideoSource::MediaStreamVideoSource() 352 MediaStreamVideoSource::MediaStreamVideoSource()
352 : state_(NEW), 353 : state_(NEW),
354 muted_state_(false),
353 track_adapter_(new VideoTrackAdapter( 355 track_adapter_(new VideoTrackAdapter(
354 ChildProcess::current()->io_message_loop_proxy())), 356 ChildProcess::current()->io_message_loop_proxy())),
355 weak_factory_(this) { 357 weak_factory_(this) {
356 } 358 }
357 359
358 MediaStreamVideoSource::~MediaStreamVideoSource() { 360 MediaStreamVideoSource::~MediaStreamVideoSource() {
359 } 361 }
360 362
361 void MediaStreamVideoSource::AddTrack( 363 void MediaStreamVideoSource::AddTrack(
362 MediaStreamVideoTrack* track, 364 MediaStreamVideoTrack* track,
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 int max_height; 547 int max_height;
546 GetDesiredMaxWidthAndHeight(it->constraints, &max_width, &max_height); 548 GetDesiredMaxWidthAndHeight(it->constraints, &max_width, &max_height);
547 double max_aspect_ratio; 549 double max_aspect_ratio;
548 double min_aspect_ratio; 550 double min_aspect_ratio;
549 GetDesiredMinAndMaxAspectRatio(it->constraints, 551 GetDesiredMinAndMaxAspectRatio(it->constraints,
550 &min_aspect_ratio, 552 &min_aspect_ratio,
551 &max_aspect_ratio); 553 &max_aspect_ratio);
552 double max_frame_rate = 0.0f; 554 double max_frame_rate = 0.0f;
553 GetConstraintValueAsDouble(it->constraints, 555 GetConstraintValueAsDouble(it->constraints,
554 kMaxFrameRate, &max_frame_rate); 556 kMaxFrameRate, &max_frame_rate);
557
558 VideoTrackAdapter::OnMutedCallback on_mute_callback =
559 media::BindToCurrentLoop(base::Bind(
560 &MediaStreamVideoSource::SetMutedState,
561 weak_factory_.GetWeakPtr()));
555 track_adapter_->AddTrack(it->track, it->frame_callback, 562 track_adapter_->AddTrack(it->track, it->frame_callback,
556 max_width, max_height, 563 max_width, max_height,
557 min_aspect_ratio, max_aspect_ratio, 564 min_aspect_ratio, max_aspect_ratio,
558 max_frame_rate); 565 max_frame_rate, current_format_.frame_rate,
566 on_mute_callback);
559 } 567 }
560 568
561 DVLOG(3) << "FinalizeAddTrack() success " << success; 569 DVLOG(3) << "FinalizeAddTrack() success " << success;
562 570
563 if (!it->callback.is_null()) 571 if (!it->callback.is_null())
564 it->callback.Run(this, success); 572 it->callback.Run(this, success);
565 } 573 }
566 } 574 }
567 575
568 void MediaStreamVideoSource::SetReadyState( 576 void MediaStreamVideoSource::SetReadyState(
569 blink::WebMediaStreamSource::ReadyState state) { 577 blink::WebMediaStreamSource::ReadyState state) {
570 DVLOG(3) << "MediaStreamVideoSource::SetReadyState state " << state; 578 DVLOG(3) << "MediaStreamVideoSource::SetReadyState state " << state;
571 if (!owner().isNull()) { 579 if (!owner().isNull()) {
572 owner().setReadyState(state); 580 owner().setReadyState(state);
573 } 581 }
574 for (std::vector<MediaStreamVideoTrack*>::iterator it = tracks_.begin(); 582 for (std::vector<MediaStreamVideoTrack*>::iterator it = tracks_.begin();
575 it != tracks_.end(); ++it) { 583 it != tracks_.end(); ++it) {
576 (*it)->OnReadyStateChanged(state); 584 (*it)->OnReadyStateChanged(state);
577 } 585 }
578 } 586 }
579 587
588 void MediaStreamVideoSource::SetMutedState(bool muted_state) {
589 DCHECK(CalledOnValidThread());
590 DVLOG(3) << "MediaStreamVideoSource::SetMutedState state=" << muted_state;
591 // WebMediaStreamSource doesn't have a muted state, the tracks do.
592 for (std::vector<MediaStreamVideoTrack*>::iterator it = tracks_.begin();
593 it != tracks_.end(); ++it) {
594 (*it)->SetMutedState(muted_state);
595 }
596 }
597
580 MediaStreamVideoSource::RequestedConstraints::RequestedConstraints( 598 MediaStreamVideoSource::RequestedConstraints::RequestedConstraints(
581 MediaStreamVideoTrack* track, 599 MediaStreamVideoTrack* track,
582 const VideoCaptureDeliverFrameCB& frame_callback, 600 const VideoCaptureDeliverFrameCB& frame_callback,
583 const blink::WebMediaConstraints& constraints, 601 const blink::WebMediaConstraints& constraints,
584 const ConstraintsCallback& callback) 602 const ConstraintsCallback& callback)
585 : track(track), 603 : track(track),
586 frame_callback(frame_callback), 604 frame_callback(frame_callback),
587 constraints(constraints), 605 constraints(constraints),
588 callback(callback) { 606 callback(callback) {
589 } 607 }
590 608
591 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() { 609 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() {
592 } 610 }
593 611
594 } // namespace content 612 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698