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

Side by Side Diff: services/media/factory_service/media_timeline_controller_impl.cc

Issue 2069873003: Motown: Define MediaRenderer and make it the way we identify renderers. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix build break...audio_track_controller.* gone for good. 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "mojo/services/media/common/cpp/timeline.h" 6 #include "mojo/services/media/common/cpp/timeline.h"
7 #include "services/media/factory_service/media_timeline_controller_impl.h" 7 #include "services/media/factory_service/media_timeline_controller_impl.h"
8 #include "services/media/framework_mojo/mojo_type_conversions.h" 8 #include "services/media/framework_mojo/mojo_type_conversions.h"
9 9
10 namespace mojo { 10 namespace mojo {
(...skipping 26 matching lines...) Expand all
37 callback.Run(version, status.Pass()); 37 callback.Run(version, status.Pass());
38 }); 38 });
39 } 39 }
40 40
41 MediaTimelineControllerImpl::~MediaTimelineControllerImpl() { 41 MediaTimelineControllerImpl::~MediaTimelineControllerImpl() {
42 status_publisher_.SendUpdates(); 42 status_publisher_.SendUpdates();
43 } 43 }
44 44
45 void MediaTimelineControllerImpl::AddControlSite( 45 void MediaTimelineControllerImpl::AddControlSite(
46 InterfaceHandle<MediaTimelineControlSite> control_site) { 46 InterfaceHandle<MediaTimelineControlSite> control_site) {
47 site_states_.emplace_back( 47 site_states_.push_back(std::unique_ptr<SiteState>(new SiteState(
48 this, MediaTimelineControlSitePtr::Create(std::move(control_site))); 48 this, MediaTimelineControlSitePtr::Create(std::move(control_site)))));
49 site_states_.back().HandleStatusUpdates(); 49
50 site_states_.back()->HandleStatusUpdates();
50 } 51 }
51 52
52 void MediaTimelineControllerImpl::GetControlSite( 53 void MediaTimelineControllerImpl::GetControlSite(
53 InterfaceRequest<MediaTimelineControlSite> control_site) { 54 InterfaceRequest<MediaTimelineControlSite> control_site) {
54 if (control_site_binding_.is_bound()) { 55 if (control_site_binding_.is_bound()) {
55 control_site_binding_.Close(); 56 control_site_binding_.Close();
56 } 57 }
57 58
58 control_site_binding_.Bind(control_site.Pass()); 59 control_site_binding_.Bind(control_site.Pass());
59 } 60 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 164
164 // Recording the new pending transition. 165 // Recording the new pending transition.
165 std::shared_ptr<TimelineTransition> transition = 166 std::shared_ptr<TimelineTransition> transition =
166 std::shared_ptr<TimelineTransition>( 167 std::shared_ptr<TimelineTransition>(
167 new TimelineTransition(new_reference_time, new_subject_time, 168 new TimelineTransition(new_reference_time, new_subject_time,
168 reference_delta, subject_delta, callback)); 169 reference_delta, subject_delta, callback));
169 170
170 pending_transition_ = transition; 171 pending_transition_ = transition;
171 172
172 // Initiate the transition for each site. 173 // Initiate the transition for each site.
173 for (const SiteState& site_state : site_states_) { 174 for (const std::unique_ptr<SiteState>& site_state : site_states_) {
174 site_state.consumer_->SetTimelineTransform( 175 site_state->consumer_->SetTimelineTransform(
175 subject_time, reference_delta, subject_delta, effective_reference_time, 176 subject_time, reference_delta, subject_delta, effective_reference_time,
176 effective_subject_time, transition->NewCallback()); 177 effective_subject_time, transition->NewCallback());
177 } 178 }
178 179
179 // If and when this transition is complete, adopt the new TimelineFunction 180 // If and when this transition is complete, adopt the new TimelineFunction
180 // and tell any status subscribers. 181 // and tell any status subscribers.
181 transition->WhenCompleted([this, transition]() { 182 transition->WhenCompleted([this, transition]() {
182 current_timeline_function_ = transition->new_timeline_function(); 183 current_timeline_function_ = transition->new_timeline_function();
183 status_publisher_.SendUpdates(); 184 status_publisher_.SendUpdates();
184 }); 185 });
185 } 186 }
186 187
187 void MediaTimelineControllerImpl::HandleSiteEndOfStreamChange() { 188 void MediaTimelineControllerImpl::HandleSiteEndOfStreamChange() {
188 bool end_of_stream = true; 189 bool end_of_stream = true;
189 for (const SiteState& site_state : site_states_) { 190 for (const std::unique_ptr<SiteState>& site_state : site_states_) {
190 if (!site_state.end_of_stream_) { 191 if (!site_state->end_of_stream_) {
191 end_of_stream = false; 192 end_of_stream = false;
192 break; 193 break;
193 } 194 }
194 } 195 }
195 196
196 if (end_of_stream_ != end_of_stream) { 197 if (end_of_stream_ != end_of_stream) {
197 end_of_stream_ = end_of_stream; 198 end_of_stream_ = end_of_stream;
198 status_publisher_.SendUpdates(); 199 status_publisher_.SendUpdates();
199 } 200 }
200 } 201 }
201 202
202 MediaTimelineControllerImpl::SiteState::SiteState( 203 MediaTimelineControllerImpl::SiteState::SiteState(
203 MediaTimelineControllerImpl* parent, 204 MediaTimelineControllerImpl* parent,
204 MediaTimelineControlSitePtr site) 205 MediaTimelineControlSitePtr site)
205 : parent_(parent), site_(site.Pass()) { 206 : parent_(parent), site_(site.Pass()) {
206 site_->GetTimelineConsumer(GetProxy(&consumer_)); 207 site_->GetTimelineConsumer(GetProxy(&consumer_));
207 } 208 }
208 209
209 MediaTimelineControllerImpl::SiteState::SiteState(SiteState&& other)
210 : parent_(other.parent_),
211 site_(other.site_.Pass()),
212 consumer_(other.consumer_.Pass()) {}
213
214 MediaTimelineControllerImpl::SiteState::~SiteState() {} 210 MediaTimelineControllerImpl::SiteState::~SiteState() {}
215 211
216 void MediaTimelineControllerImpl::SiteState::HandleStatusUpdates( 212 void MediaTimelineControllerImpl::SiteState::HandleStatusUpdates(
217 uint64_t version, 213 uint64_t version,
218 MediaTimelineControlSiteStatusPtr status) { 214 MediaTimelineControlSiteStatusPtr status) {
219 if (status) { 215 if (status) {
220 // Respond to any end-of-stream changes. 216 // Respond to any end-of-stream changes.
221 if (end_of_stream_ != status->end_of_stream) { 217 if (end_of_stream_ != status->end_of_stream) {
222 end_of_stream_ = status->end_of_stream; 218 end_of_stream_ = status->end_of_stream;
223 parent_->HandleSiteEndOfStreamChange(); 219 parent_->HandleSiteEndOfStreamChange();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 completed_callback_.Run(); 251 completed_callback_.Run();
256 completed_callback_.reset(); 252 completed_callback_.reset();
257 } 253 }
258 }); 254 });
259 } 255 }
260 256
261 MediaTimelineControllerImpl::TimelineTransition::~TimelineTransition() {} 257 MediaTimelineControllerImpl::TimelineTransition::~TimelineTransition() {}
262 258
263 } // namespace media 259 } // namespace media
264 } // namespace mojo 260 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698