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

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

Issue 2097953002: Motown: Rename MediaProducer/Consumer to MediaPacketProducer/Consumer (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fixed #ifndef guards Created 4 years, 5 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/bind.h" 5 #include "base/bind.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "services/media/factory_service/media_source_impl.h" 8 #include "services/media/factory_service/media_source_impl.h"
9 #include "services/media/framework/util/callback_joiner.h" 9 #include "services/media/framework/util/callback_joiner.h"
10 #include "services/media/framework/util/conversion_pipeline_builder.h" 10 #include "services/media/framework/util/conversion_pipeline_builder.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 MediaSourceStreamDescriptor::New(); 95 MediaSourceStreamDescriptor::New();
96 descriptor->index = i; 96 descriptor->index = i;
97 descriptor->media_type = streams_[i]->media_type(); 97 descriptor->media_type = streams_[i]->media_type();
98 descriptor->original_media_type = streams_[i]->original_media_type(); 98 descriptor->original_media_type = streams_[i]->original_media_type();
99 result[i] = descriptor.Pass(); 99 result[i] = descriptor.Pass();
100 } 100 }
101 callback.Run(result.Pass()); 101 callback.Run(result.Pass());
102 }); 102 });
103 } 103 }
104 104
105 void MediaSourceImpl::GetProducer(uint32_t stream_index, 105 void MediaSourceImpl::GetPacketProducer(
106 InterfaceRequest<MediaProducer> producer) { 106 uint32_t stream_index,
107 InterfaceRequest<MediaPacketProducer> producer) {
107 RCHECK(init_complete_.occurred()); 108 RCHECK(init_complete_.occurred());
108 109
109 if (stream_index >= streams_.size()) { 110 if (stream_index >= streams_.size()) {
110 return; 111 return;
111 } 112 }
112 113
113 streams_[stream_index]->GetProducer(producer.Pass()); 114 streams_[stream_index]->GetPacketProducer(producer.Pass());
114 }
115
116 void MediaSourceImpl::GetPullModeProducer(
117 uint32_t stream_index,
118 InterfaceRequest<MediaPullModeProducer> producer) {
119 RCHECK(init_complete_.occurred());
120
121 if (stream_index >= streams_.size()) {
122 return;
123 }
124
125 streams_[stream_index]->GetPullModeProducer(producer.Pass());
126 } 115 }
127 116
128 void MediaSourceImpl::GetStatus(uint64_t version_last_seen, 117 void MediaSourceImpl::GetStatus(uint64_t version_last_seen,
129 const GetStatusCallback& callback) { 118 const GetStatusCallback& callback) {
130 status_publisher_.Get(version_last_seen, callback); 119 status_publisher_.Get(version_last_seen, callback);
131 } 120 }
132 121
133 void MediaSourceImpl::Prepare(const PrepareCallback& callback) { 122 void MediaSourceImpl::Prepare(const PrepareCallback& callback) {
134 RCHECK(init_complete_.occurred()); 123 RCHECK(init_complete_.occurred());
135 124
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 MediaSourceImpl::Stream::~Stream() {} 197 MediaSourceImpl::Stream::~Stream() {}
209 198
210 MediaTypePtr MediaSourceImpl::Stream::media_type() const { 199 MediaTypePtr MediaSourceImpl::Stream::media_type() const {
211 return MediaType::From(stream_type_); 200 return MediaType::From(stream_type_);
212 } 201 }
213 202
214 MediaTypePtr MediaSourceImpl::Stream::original_media_type() const { 203 MediaTypePtr MediaSourceImpl::Stream::original_media_type() const {
215 return MediaType::From(original_stream_type_); 204 return MediaType::From(original_stream_type_);
216 } 205 }
217 206
218 void MediaSourceImpl::Stream::GetProducer( 207 void MediaSourceImpl::Stream::GetPacketProducer(
219 InterfaceRequest<MediaProducer> producer) { 208 InterfaceRequest<MediaPacketProducer> producer) {
220 if (pull_mode_producer_) {
221 // Can't have both push mode and pull mode producers.
222 return;
223 }
224
225 if (!producer_) { 209 if (!producer_) {
226 producer_ = MojoProducer::Create(); 210 producer_ = MojoPacketProducer::Create();
227 graph_->ConnectOutputToPart(output_, graph_->Add(producer_)); 211 graph_->ConnectOutputToPart(output_, graph_->Add(producer_));
228 } 212 }
229 213
230 producer_->AddBinding(producer.Pass()); 214 producer_->AddBinding(producer.Pass());
231 } 215 }
232 216
233 void MediaSourceImpl::Stream::GetPullModeProducer(
234 InterfaceRequest<MediaPullModeProducer> producer) {
235 if (producer_) {
236 // Can't have both push mode and pull mode producers.
237 return;
238 }
239
240 if (!pull_mode_producer_) {
241 pull_mode_producer_ = MojoPullModeProducer::Create();
242 graph_->ConnectOutputToPart(output_, graph_->Add(pull_mode_producer_));
243 }
244
245 pull_mode_producer_->AddBinding(producer.Pass());
246 }
247
248 void MediaSourceImpl::Stream::EnsureSink() { 217 void MediaSourceImpl::Stream::EnsureSink() {
249 if (producer_ == nullptr && pull_mode_producer_ == nullptr) { 218 if (producer_ == nullptr) {
250 null_sink_ = NullSink::Create(); 219 null_sink_ = NullSink::Create();
251 graph_->ConnectOutputToPart(output_, graph_->Add(null_sink_)); 220 graph_->ConnectOutputToPart(output_, graph_->Add(null_sink_));
252 } 221 }
253 } 222 }
254 223
255 void MediaSourceImpl::Stream::PrimeConnection( 224 void MediaSourceImpl::Stream::PrimeConnection(
256 const MojoProducer::PrimeConnectionCallback callback) { 225 const MojoPacketProducer::PrimeConnectionCallback callback) {
257 if (producer_ != nullptr) { 226 if (producer_ != nullptr) {
258 producer_->PrimeConnection(callback); 227 producer_->PrimeConnection(callback);
259 } else { 228 } else {
260 callback.Run(); 229 callback.Run();
261 } 230 }
262 } 231 }
263 232
264 void MediaSourceImpl::Stream::FlushConnection( 233 void MediaSourceImpl::Stream::FlushConnection(
265 const MojoProducer::FlushConnectionCallback callback) { 234 const MojoPacketProducer::FlushConnectionCallback callback) {
266 if (producer_ != nullptr) { 235 if (producer_ != nullptr) {
267 producer_->FlushConnection(callback); 236 producer_->FlushConnection(callback);
268 } else { 237 } else {
269 callback.Run(); 238 callback.Run();
270 } 239 }
271 } 240 }
272 241
273 } // namespace media 242 } // namespace media
274 } // namespace mojo 243 } // namespace mojo
OLDNEW
« no previous file with comments | « services/media/factory_service/media_source_impl.h ('k') | services/media/factory_service/media_timeline_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698