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

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: Rebased 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
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "content/renderer/media/media_stream_dependency_factory.h" 13 #include "content/renderer/media/media_stream_dependency_factory.h"
14 #include "content/renderer/media/media_stream_video_track.h" 14 #include "content/renderer/media/media_stream_video_track.h"
15 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" 15 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 // Constraint keys. Specified by draft-alvestrand-constraints-resolution-00b 19 // Constraint keys. Specified by draft-alvestrand-constraints-resolution-00b
20 const char MediaStreamVideoSource::kMinAspectRatio[] = "minAspectRatio"; 20 const char MediaStreamVideoSource::kMinAspectRatio[] = "minAspectRatio";
21 const char MediaStreamVideoSource::kMaxAspectRatio[] = "maxAspectRatio"; 21 const char MediaStreamVideoSource::kMaxAspectRatio[] = "maxAspectRatio";
22 const char MediaStreamVideoSource::kMaxWidth[] = "maxWidth"; 22 const char MediaStreamVideoSource::kMaxWidth[] = "maxWidth";
23 const char MediaStreamVideoSource::kMinWidth[] = "minWidth"; 23 const char MediaStreamVideoSource::kMinWidth[] = "minWidth";
24 const char MediaStreamVideoSource::kMaxHeight[] = "maxHeight"; 24 const char MediaStreamVideoSource::kMaxHeight[] = "maxHeight";
25 const char MediaStreamVideoSource::kMinHeight[] = "minHeight"; 25 const char MediaStreamVideoSource::kMinHeight[] = "minHeight";
26 const char MediaStreamVideoSource::kMaxFrameRate[] = "maxFrameRate"; 26 const char MediaStreamVideoSource::kMaxFrameRate[] = "maxFrameRate";
27 const char MediaStreamVideoSource::kMinFrameRate[] = "minFrameRate"; 27 const char MediaStreamVideoSource::kMinFrameRate[] = "minFrameRate";
28 28
29 const char* kSupportedConstraints[] = { 29 const char* kSupportedConstraints[] = {
30 MediaStreamVideoSource::kMaxAspectRatio, 30 MediaStreamVideoSource::kMaxAspectRatio,
tommi (sloooow) - chröme 2014/04/07 10:05:44 2 space indent
perkj_chrome 2014/04/07 15:33:52 Done.
31 MediaStreamVideoSource::kMinAspectRatio, 31 MediaStreamVideoSource::kMinAspectRatio,
32 MediaStreamVideoSource::kMaxWidth, 32 MediaStreamVideoSource::kMaxWidth,
33 MediaStreamVideoSource::kMinWidth, 33 MediaStreamVideoSource::kMinWidth,
34 MediaStreamVideoSource::kMaxHeight, 34 MediaStreamVideoSource::kMaxHeight,
35 MediaStreamVideoSource::kMinHeight, 35 MediaStreamVideoSource::kMinHeight,
36 MediaStreamVideoSource::kMaxFrameRate, 36 MediaStreamVideoSource::kMaxFrameRate,
37 MediaStreamVideoSource::kMinFrameRate, 37 MediaStreamVideoSource::kMinFrameRate,
38 }; 38 };
39 39
40 const int MediaStreamVideoSource::kDefaultWidth = 640; 40 const int MediaStreamVideoSource::kDefaultWidth = 640;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 349 }
350 case ENDED: 350 case ENDED:
351 case STARTED: { 351 case STARTED: {
352 // Currently, reconfiguring the source is not supported. 352 // Currently, reconfiguring the source is not supported.
353 FinalizeAddTrack(); 353 FinalizeAddTrack();
354 } 354 }
355 } 355 }
356 } 356 }
357 357
358 void MediaStreamVideoSource::RemoveTrack(MediaStreamVideoTrack* video_track) { 358 void MediaStreamVideoSource::RemoveTrack(MediaStreamVideoTrack* video_track) {
359 DCHECK(CalledOnValidThread());
359 std::vector<MediaStreamVideoTrack*>::iterator it = 360 std::vector<MediaStreamVideoTrack*>::iterator it =
360 std::find(tracks_.begin(), tracks_.end(), video_track); 361 std::find(tracks_.begin(), tracks_.end(), video_track);
361 DCHECK(it != tracks_.end()); 362 DCHECK(it != tracks_.end());
362 tracks_.erase(it); 363 tracks_.erase(it);
364 if (tracks_.empty())
365 StopSource();
363 } 366 }
364 367
365 void MediaStreamVideoSource::InitAdapter() { 368 void MediaStreamVideoSource::InitAdapter() {
366 if (adapter_) 369 if (adapter_)
367 return; 370 return;
368 // Create the webrtc::MediaStreamVideoSourceInterface adapter. 371 // Create the webrtc::MediaStreamVideoSourceInterface adapter.
369 // It needs the constraints so that constraints used by a PeerConnection 372 // It needs the constraints so that constraints used by a PeerConnection
370 // will be available such as constraints for CPU adaptation and a tab 373 // will be available such as constraints for CPU adaptation and a tab
371 // capture. 374 // capture.
372 bool is_screencast = 375 bool is_screencast =
373 device_info().device.type == MEDIA_TAB_VIDEO_CAPTURE || 376 device_info().device.type == MEDIA_TAB_VIDEO_CAPTURE ||
374 device_info().device.type == MEDIA_DESKTOP_VIDEO_CAPTURE; 377 device_info().device.type == MEDIA_DESKTOP_VIDEO_CAPTURE;
375 capture_adapter_ = factory_->CreateVideoCapturer(is_screencast); 378 capture_adapter_ = factory_->CreateVideoCapturer(is_screencast);
376 adapter_ = factory_->CreateVideoSource(capture_adapter_, 379 adapter_ = factory_->CreateVideoSource(capture_adapter_,
377 current_constraints_); 380 current_constraints_);
378 } 381 }
379 382
380 webrtc::VideoSourceInterface* MediaStreamVideoSource::GetAdapter() { 383 webrtc::VideoSourceInterface* MediaStreamVideoSource::GetAdapter() {
381 if (!adapter_) { 384 if (!adapter_) {
382 InitAdapter(); 385 InitAdapter();
383 } 386 }
384 return adapter_; 387 return adapter_;
385 } 388 }
386 389
387 void MediaStreamVideoSource::DoStopSource() { 390 void MediaStreamVideoSource::DoStopSource() {
391 DCHECK(CalledOnValidThread());
388 DVLOG(3) << "DoStopSource()"; 392 DVLOG(3) << "DoStopSource()";
389 StopSourceImpl(); 393 StopSourceImpl();
390 state_ = ENDED; 394 state_ = ENDED;
391 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); 395 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded);
392 } 396 }
393 397
394 void MediaStreamVideoSource::DeliverVideoFrame( 398 void MediaStreamVideoSource::DeliverVideoFrame(
395 const scoped_refptr<media::VideoFrame>& frame) { 399 const scoped_refptr<media::VideoFrame>& frame) {
396 scoped_refptr<media::VideoFrame> video_frame(frame); 400 scoped_refptr<media::VideoFrame> video_frame(frame);
397 401
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 MediaStreamVideoSource::RequestedConstraints::RequestedConstraints( 533 MediaStreamVideoSource::RequestedConstraints::RequestedConstraints(
530 const blink::WebMediaConstraints& constraints, 534 const blink::WebMediaConstraints& constraints,
531 const ConstraintsCallback& callback) 535 const ConstraintsCallback& callback)
532 : constraints(constraints), callback(callback) { 536 : constraints(constraints), callback(callback) {
533 } 537 }
534 538
535 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() { 539 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() {
536 } 540 }
537 541
538 } // namespace content 542 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698