| OLD | NEW |
| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 pending_transition_.lock(); | 115 pending_transition_.lock(); |
| 116 if (pending_transition) { | 116 if (pending_transition) { |
| 117 // A transition is pending - cancel it. | 117 // A transition is pending - cancel it. |
| 118 pending_transition->Cancel(); | 118 pending_transition->Cancel(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 // These will be recorded as part of the new TimelineFunction. | 121 // These will be recorded as part of the new TimelineFunction. |
| 122 int64_t new_reference_time; | 122 int64_t new_reference_time; |
| 123 int64_t new_subject_time; | 123 int64_t new_subject_time; |
| 124 | 124 |
| 125 if (subject_time != kUnspecifiedTime) { |
| 126 new_subject_time = subject_time; |
| 127 end_of_stream_ = false; |
| 128 } |
| 129 |
| 125 if (effective_subject_time != kUnspecifiedTime) { | 130 if (effective_subject_time != kUnspecifiedTime) { |
| 126 // Infer new_reference_time from effective_subject_time. | 131 // Infer new_reference_time from effective_subject_time. |
| 127 new_reference_time = | 132 new_reference_time = |
| 128 current_timeline_function_.ApplyInverse(effective_subject_time); | 133 current_timeline_function_.ApplyInverse(effective_subject_time); |
| 129 | 134 |
| 130 // Figure out what the subject_time will be after this transition. | 135 // Figure out what the subject_time will be after this transition. |
| 131 if (subject_time == kUnspecifiedTime) { | 136 if (subject_time == kUnspecifiedTime) { |
| 132 new_subject_time = effective_subject_time; | 137 new_subject_time = effective_subject_time; |
| 133 } else { | |
| 134 new_subject_time = subject_time; | |
| 135 } | 138 } |
| 136 } else { | 139 } else { |
| 137 if (effective_reference_time == kUnspecifiedTime) { | 140 if (effective_reference_time == kUnspecifiedTime) { |
| 138 // Neither effective time was specified. Effective time is now. | 141 // Neither effective time was specified. Effective time is now. |
| 139 effective_reference_time = Timeline::local_now() + kDefaultLeadTime; | 142 effective_reference_time = Timeline::local_now() + kDefaultLeadTime; |
| 140 } | 143 } |
| 141 | 144 |
| 142 // new_reference_time is just effective_reference_time. | 145 // new_reference_time is just effective_reference_time. |
| 143 new_reference_time = effective_reference_time; | 146 new_reference_time = effective_reference_time; |
| 144 | 147 |
| 145 // Figure out what the subject_time will be after this transition. | 148 // Figure out what the subject_time will be after this transition. |
| 146 if (subject_time == kUnspecifiedTime) { | 149 if (subject_time == kUnspecifiedTime) { |
| 147 new_subject_time = current_timeline_function_(effective_reference_time); | 150 new_subject_time = current_timeline_function_(effective_reference_time); |
| 148 } else { | |
| 149 new_subject_time = subject_time; | |
| 150 } | 151 } |
| 151 } | 152 } |
| 152 | 153 |
| 153 if (pending_transition) { | 154 if (pending_transition) { |
| 154 // This transition cancels a previous one. Use effective_reference_time | 155 // This transition cancels a previous one. Use effective_reference_time |
| 155 // rather than effective_subject_time, because we can't be sure what | 156 // rather than effective_subject_time, because we can't be sure what |
| 156 // effective_subject_time will mean to the sites. | 157 // effective_subject_time will mean to the sites. |
| 157 effective_reference_time = new_reference_time; | 158 effective_reference_time = new_reference_time; |
| 158 effective_subject_time = kUnspecifiedTime; | 159 effective_subject_time = kUnspecifiedTime; |
| 159 | 160 |
| 160 // We don't want the sites to have to infer the subject_time, because we | 161 // We don't want the sites to have to infer the subject_time, because we |
| 161 // can't be sure what subject_time a site will infer. | 162 // can't be sure what subject_time a site will infer. |
| 162 subject_time = new_subject_time; | 163 subject_time = new_subject_time; |
| 163 } | 164 } |
| 164 | 165 |
| 165 // Recording the new pending transition. | 166 // Recording the new pending transition. |
| 166 std::shared_ptr<TimelineTransition> transition = | 167 std::shared_ptr<TimelineTransition> transition = |
| 167 std::shared_ptr<TimelineTransition>( | 168 std::shared_ptr<TimelineTransition>( |
| 168 new TimelineTransition(new_reference_time, new_subject_time, | 169 new TimelineTransition(new_reference_time, new_subject_time, |
| 169 reference_delta, subject_delta, callback)); | 170 reference_delta, subject_delta, callback)); |
| 170 | 171 |
| 171 pending_transition_ = transition; | 172 pending_transition_ = transition; |
| 172 | 173 |
| 173 // Initiate the transition for each site. | 174 // Initiate the transition for each site. |
| 174 for (const std::unique_ptr<SiteState>& site_state : site_states_) { | 175 for (const std::unique_ptr<SiteState>& site_state : site_states_) { |
| 176 site_state->end_of_stream_ = false; |
| 175 site_state->consumer_->SetTimelineTransform( | 177 site_state->consumer_->SetTimelineTransform( |
| 176 subject_time, reference_delta, subject_delta, effective_reference_time, | 178 subject_time, reference_delta, subject_delta, effective_reference_time, |
| 177 effective_subject_time, transition->NewCallback()); | 179 effective_subject_time, transition->NewCallback()); |
| 178 } | 180 } |
| 179 | 181 |
| 180 // If and when this transition is complete, adopt the new TimelineFunction | 182 // If and when this transition is complete, adopt the new TimelineFunction |
| 181 // and tell any status subscribers. | 183 // and tell any status subscribers. |
| 182 transition->WhenCompleted([this, transition]() { | 184 transition->WhenCompleted([this, transition]() { |
| 183 current_timeline_function_ = transition->new_timeline_function(); | 185 current_timeline_function_ = transition->new_timeline_function(); |
| 184 status_publisher_.SendUpdates(); | 186 status_publisher_.SendUpdates(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 completed_callback_.Run(); | 253 completed_callback_.Run(); |
| 252 completed_callback_.reset(); | 254 completed_callback_.reset(); |
| 253 } | 255 } |
| 254 }); | 256 }); |
| 255 } | 257 } |
| 256 | 258 |
| 257 MediaTimelineControllerImpl::TimelineTransition::~TimelineTransition() {} | 259 MediaTimelineControllerImpl::TimelineTransition::~TimelineTransition() {} |
| 258 | 260 |
| 259 } // namespace media | 261 } // namespace media |
| 260 } // namespace mojo | 262 } // namespace mojo |
| OLD | NEW |