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

Side by Side Diff: chromecast/media/cma/pipeline/media_pipeline_impl.cc

Issue 1306843003: CmaMediaPipelineClient to watch media pipeline status (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CmaMediaPipelineClient Created 5 years, 3 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 "chromecast/media/cma/pipeline/media_pipeline_impl.h" 5 #include "chromecast/media/cma/pipeline/media_pipeline_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 statistics_rolling_counter_(0), 59 statistics_rolling_counter_(0),
60 weak_factory_(this) { 60 weak_factory_(this) {
61 CMALOG(kLogControl) << __FUNCTION__; 61 CMALOG(kLogControl) << __FUNCTION__;
62 weak_this_ = weak_factory_.GetWeakPtr(); 62 weak_this_ = weak_factory_.GetWeakPtr();
63 thread_checker_.DetachFromThread(); 63 thread_checker_.DetachFromThread();
64 } 64 }
65 65
66 MediaPipelineImpl::~MediaPipelineImpl() { 66 MediaPipelineImpl::~MediaPipelineImpl() {
67 CMALOG(kLogControl) << __FUNCTION__; 67 CMALOG(kLogControl) << __FUNCTION__;
68 DCHECK(thread_checker_.CalledOnValidThread()); 68 DCHECK(thread_checker_.CalledOnValidThread());
69
70 weak_factory_.InvalidateWeakPtrs();
71
72 // Since av pipeline still need to access device components in their
73 // destructor, it's important to delete them first.
74 video_pipeline_.reset();
75 audio_pipeline_.reset();
76 media_pipeline_backend_.reset();
77 if (!client_.pipeline_backend_destroyed_cb.is_null())
78 client_.pipeline_backend_destroyed_cb.Run();
69 } 79 }
70 80
71 void MediaPipelineImpl::Initialize( 81 void MediaPipelineImpl::Initialize(
72 LoadType load_type, 82 LoadType load_type,
73 scoped_ptr<MediaPipelineBackend> media_pipeline_backend) { 83 scoped_ptr<MediaPipelineBackend> media_pipeline_backend) {
74 CMALOG(kLogControl) << __FUNCTION__; 84 CMALOG(kLogControl) << __FUNCTION__;
75 DCHECK(thread_checker_.CalledOnValidThread()); 85 DCHECK(thread_checker_.CalledOnValidThread());
76 media_pipeline_backend_.reset(media_pipeline_backend.release()); 86 media_pipeline_backend_.reset(media_pipeline_backend.release());
77 clock_device_ = media_pipeline_backend_->GetClock(); 87 clock_device_ = media_pipeline_backend_->GetClock();
88 if (!client_.pipeline_backend_created_cb.is_null())
gunsch 2015/08/31 15:56:52 can we remove these checks, since they're also che
yucliu1 2015/08/31 17:30:08 In some tests, SetClient is never called, which le
89 client_.pipeline_backend_created_cb.Run();
78 90
79 if (load_type == kLoadTypeURL || load_type == kLoadTypeMediaSource) { 91 if (load_type == kLoadTypeURL || load_type == kLoadTypeMediaSource) {
80 base::TimeDelta low_threshold(kLowBufferThresholdURL); 92 base::TimeDelta low_threshold(kLowBufferThresholdURL);
81 base::TimeDelta high_threshold(kHighBufferThresholdURL); 93 base::TimeDelta high_threshold(kHighBufferThresholdURL);
82 if (load_type == kLoadTypeMediaSource) { 94 if (load_type == kLoadTypeMediaSource) {
83 low_threshold = kLowBufferThresholdMediaSource; 95 low_threshold = kLowBufferThresholdMediaSource;
84 high_threshold = kHighBufferThresholdMediaSource; 96 high_threshold = kHighBufferThresholdMediaSource;
85 } 97 }
86 scoped_refptr<BufferingConfig> buffering_config( 98 scoped_refptr<BufferingConfig> buffering_config(
87 new BufferingConfig(low_threshold, high_threshold)); 99 new BufferingConfig(low_threshold, high_threshold));
88 buffering_controller_.reset(new BufferingController( 100 buffering_controller_.reset(new BufferingController(
89 buffering_config, 101 buffering_config,
90 base::Bind(&MediaPipelineImpl::OnBufferingNotification, weak_this_))); 102 base::Bind(&MediaPipelineImpl::OnBufferingNotification, weak_this_)));
91 } 103 }
92 104
93 audio_pipeline_.reset( 105 audio_pipeline_.reset(
94 new AudioPipelineImpl(media_pipeline_backend_->GetAudio())); 106 new AudioPipelineImpl(media_pipeline_backend_->GetAudio()));
95 107
96 video_pipeline_.reset( 108 video_pipeline_.reset(
97 new VideoPipelineImpl(media_pipeline_backend_->GetVideo())); 109 new VideoPipelineImpl(media_pipeline_backend_->GetVideo()));
98 } 110 }
99 111
100 void MediaPipelineImpl::SetClient(const MediaPipelineClient& client) { 112 void MediaPipelineImpl::SetClient(const MediaPipelineClient& client) {
101 DCHECK(thread_checker_.CalledOnValidThread()); 113 DCHECK(thread_checker_.CalledOnValidThread());
102 DCHECK(!client.error_cb.is_null()); 114 DCHECK(!client.error_cb.is_null());
103 DCHECK(!client.time_update_cb.is_null()); 115 DCHECK(!client.time_update_cb.is_null());
104 DCHECK(!client.buffering_state_cb.is_null()); 116 DCHECK(!client.buffering_state_cb.is_null());
117 DCHECK(!client.pipeline_backend_created_cb.is_null());
118 DCHECK(!client.pipeline_backend_destroyed_cb.is_null());
105 client_ = client; 119 client_ = client;
106 } 120 }
107 121
108 void MediaPipelineImpl::SetCdm(int cdm_id) { 122 void MediaPipelineImpl::SetCdm(int cdm_id) {
109 CMALOG(kLogControl) << __FUNCTION__ << " cdm_id=" << cdm_id; 123 CMALOG(kLogControl) << __FUNCTION__ << " cdm_id=" << cdm_id;
110 DCHECK(thread_checker_.CalledOnValidThread()); 124 DCHECK(thread_checker_.CalledOnValidThread());
111 NOTIMPLEMENTED(); 125 NOTIMPLEMENTED();
112 // TODO(gunsch): SetCdm(int) is not implemented. 126 // TODO(gunsch): SetCdm(int) is not implemented.
113 // One possibility would be a GetCdmByIdCB that's passed in. 127 // One possibility would be a GetCdmByIdCB that's passed in.
114 } 128 }
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 382
369 void MediaPipelineImpl::OnError(::media::PipelineStatus error) { 383 void MediaPipelineImpl::OnError(::media::PipelineStatus error) {
370 DCHECK(thread_checker_.CalledOnValidThread()); 384 DCHECK(thread_checker_.CalledOnValidThread());
371 DCHECK_NE(error, ::media::PIPELINE_OK) << "PIPELINE_OK is not an error!"; 385 DCHECK_NE(error, ::media::PIPELINE_OK) << "PIPELINE_OK is not an error!";
372 if (!client_.error_cb.is_null()) 386 if (!client_.error_cb.is_null())
373 client_.error_cb.Run(error); 387 client_.error_cb.Run(error);
374 } 388 }
375 389
376 } // namespace media 390 } // namespace media
377 } // namespace chromecast 391 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698