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

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

Issue 218763007: Update MediaStreamTrack::Stop to latest draft. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments and added tests. Created 6 years, 8 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
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 330 }
331 case ENDED: 331 case ENDED:
332 case STARTED: { 332 case STARTED: {
333 // Currently, reconfiguring the source is not supported. 333 // Currently, reconfiguring the source is not supported.
334 FinalizeAddTrack(); 334 FinalizeAddTrack();
335 } 335 }
336 } 336 }
337 } 337 }
338 338
339 void MediaStreamVideoSource::RemoveTrack(MediaStreamVideoTrack* video_track) { 339 void MediaStreamVideoSource::RemoveTrack(MediaStreamVideoTrack* video_track) {
340 DCHECK(CalledOnValidThread());
340 std::vector<MediaStreamVideoTrack*>::iterator it = 341 std::vector<MediaStreamVideoTrack*>::iterator it =
341 std::find(tracks_.begin(), tracks_.end(), video_track); 342 std::find(tracks_.begin(), tracks_.end(), video_track);
342 DCHECK(it != tracks_.end()); 343 DCHECK(it != tracks_.end());
343 tracks_.erase(it); 344 tracks_.erase(it);
345 if (tracks_.empty())
346 StopSource();
344 } 347 }
345 348
346 void MediaStreamVideoSource::InitAdapter() { 349 void MediaStreamVideoSource::InitAdapter() {
347 if (adapter_) 350 if (adapter_)
348 return; 351 return;
349 // Create the webrtc::MediaStreamVideoSourceInterface adapter. 352 // Create the webrtc::MediaStreamVideoSourceInterface adapter.
350 // It needs the constraints so that constraints used by a PeerConnection 353 // It needs the constraints so that constraints used by a PeerConnection
351 // will be available such as constraints for CPU adaptation and a tab 354 // will be available such as constraints for CPU adaptation and a tab
352 // capture. 355 // capture.
353 bool is_screencast = 356 bool is_screencast =
354 device_info().device.type == MEDIA_TAB_VIDEO_CAPTURE || 357 device_info().device.type == MEDIA_TAB_VIDEO_CAPTURE ||
355 device_info().device.type == MEDIA_DESKTOP_VIDEO_CAPTURE; 358 device_info().device.type == MEDIA_DESKTOP_VIDEO_CAPTURE;
356 capture_adapter_ = factory_->CreateVideoCapturer(is_screencast); 359 capture_adapter_ = factory_->CreateVideoCapturer(is_screencast);
357 capture_adapter_->SetRequestedFormat(current_format_); 360 capture_adapter_->SetRequestedFormat(current_format_);
358 adapter_ = factory_->CreateVideoSource(capture_adapter_, 361 adapter_ = factory_->CreateVideoSource(capture_adapter_,
359 current_constraints_); 362 current_constraints_);
360 } 363 }
361 364
362 webrtc::VideoSourceInterface* MediaStreamVideoSource::GetAdapter() { 365 webrtc::VideoSourceInterface* MediaStreamVideoSource::GetAdapter() {
363 if (!adapter_) { 366 if (!adapter_) {
364 InitAdapter(); 367 InitAdapter();
365 } 368 }
366 return adapter_; 369 return adapter_;
367 } 370 }
368 371
369 void MediaStreamVideoSource::DoStopSource() { 372 void MediaStreamVideoSource::DoStopSource() {
373 DCHECK(CalledOnValidThread());
370 DVLOG(3) << "DoStopSource()"; 374 DVLOG(3) << "DoStopSource()";
371 StopSourceImpl(); 375 StopSourceImpl();
372 state_ = ENDED; 376 state_ = ENDED;
373 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); 377 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded);
374 } 378 }
375 379
376 void MediaStreamVideoSource::DeliverVideoFrame( 380 void MediaStreamVideoSource::DeliverVideoFrame(
377 const scoped_refptr<media::VideoFrame>& frame) { 381 const scoped_refptr<media::VideoFrame>& frame) {
378 scoped_refptr<media::VideoFrame> video_frame(frame); 382 scoped_refptr<media::VideoFrame> video_frame(frame);
379 383
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 MediaStreamVideoSource::RequestedConstraints::RequestedConstraints( 515 MediaStreamVideoSource::RequestedConstraints::RequestedConstraints(
512 const blink::WebMediaConstraints& constraints, 516 const blink::WebMediaConstraints& constraints,
513 const ConstraintsCallback& callback) 517 const ConstraintsCallback& callback)
514 : constraints(constraints), callback(callback) { 518 : constraints(constraints), callback(callback) {
515 } 519 }
516 520
517 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() { 521 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() {
518 } 522 }
519 523
520 } // namespace content 524 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698