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

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

Issue 2094473002: Motown: Don't build out pipelines for streams that don't get rendered. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Remove NullTimelineControlSite placeholder - no longer needed. 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
« no previous file with comments | « services/media/factory_service/media_sink_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "services/media/factory_service/media_sink_impl.h" 6 #include "services/media/factory_service/media_sink_impl.h"
7 #include "services/media/framework/util/conversion_pipeline_builder.h" 7 #include "services/media/framework/util/conversion_pipeline_builder.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 10 matching lines...) Expand all
21 } 21 }
22 22
23 MediaSinkImpl::MediaSinkImpl(InterfaceHandle<MediaRenderer> renderer, 23 MediaSinkImpl::MediaSinkImpl(InterfaceHandle<MediaRenderer> renderer,
24 MediaTypePtr media_type, 24 MediaTypePtr media_type,
25 InterfaceRequest<MediaSink> request, 25 InterfaceRequest<MediaSink> request,
26 MediaFactoryService* owner) 26 MediaFactoryService* owner)
27 : MediaFactoryService::Product<MediaSink>(this, request.Pass(), owner), 27 : MediaFactoryService::Product<MediaSink>(this, request.Pass(), owner),
28 consumer_(MojoConsumer::Create()), 28 consumer_(MojoConsumer::Create()),
29 producer_(MojoProducer::Create()), 29 producer_(MojoProducer::Create()),
30 renderer_(MediaRendererPtr::Create(renderer.Pass())) { 30 renderer_(MediaRendererPtr::Create(renderer.Pass())) {
31 DCHECK(renderer_);
31 DCHECK(media_type); 32 DCHECK(media_type);
32 33
33 PartRef consumer_ref = graph_.Add(consumer_); 34 PartRef consumer_ref = graph_.Add(consumer_);
34 PartRef producer_ref = graph_.Add(producer_); 35 PartRef producer_ref = graph_.Add(producer_);
35 36
36 consumer_->SetPrimeRequestedCallback( 37 consumer_->SetPrimeRequestedCallback(
37 [this](const MediaConsumer::PrimeCallback& callback) { 38 [this](const MediaConsumer::PrimeCallback& callback) {
38 ready_.When([this, callback]() { 39 ready_.When([this, callback]() {
39 DCHECK(producer_); 40 DCHECK(producer_);
40 producer_->PrimeConnection(callback); 41 producer_->PrimeConnection(callback);
41 }); 42 });
42 }); 43 });
43 consumer_->SetFlushRequestedCallback( 44 consumer_->SetFlushRequestedCallback(
44 [this, consumer_ref](const MediaConsumer::FlushCallback& callback) { 45 [this, consumer_ref](const MediaConsumer::FlushCallback& callback) {
45 ready_.When([this, consumer_ref, callback]() { 46 ready_.When([this, consumer_ref, callback]() {
46 DCHECK(producer_); 47 DCHECK(producer_);
47 graph_.FlushOutput(consumer_ref.output()); 48 graph_.FlushOutput(consumer_ref.output());
48 producer_->FlushConnection(callback); 49 producer_->FlushConnection(callback);
49 }); 50 });
50 }); 51 });
51 52
52 // TODO(dalesat): Temporary, remove.
53 if (!renderer_) {
54 // Throwing away the content.
55 graph_.ConnectParts(consumer_ref, producer_ref);
56 graph_.Prepare();
57 ready_.Occur();
58 return;
59 }
60
61 // TODO(dalesat): Once we have c++14, get rid of this shared pointer hack. 53 // TODO(dalesat): Once we have c++14, get rid of this shared pointer hack.
62 input_stream_type_ = media_type.To<std::unique_ptr<StreamType>>(); 54 input_stream_type_ = media_type.To<std::unique_ptr<StreamType>>();
63 55
64 renderer_->GetSupportedMediaTypes([this, consumer_ref, producer_ref]( 56 renderer_->GetSupportedMediaTypes([this, consumer_ref, producer_ref](
65 Array<MediaTypeSetPtr> supported_media_types) { 57 Array<MediaTypeSetPtr> supported_media_types) {
66 std::unique_ptr<std::vector<std::unique_ptr<StreamTypeSet>>> 58 std::unique_ptr<std::vector<std::unique_ptr<StreamTypeSet>>>
67 supported_stream_types = supported_media_types.To<std::unique_ptr< 59 supported_stream_types = supported_media_types.To<std::unique_ptr<
68 std::vector<std::unique_ptr<media::StreamTypeSet>>>>(); 60 std::vector<std::unique_ptr<media::StreamTypeSet>>>>();
69 std::unique_ptr<StreamType> producer_stream_type; 61 std::unique_ptr<StreamType> producer_stream_type;
70 62
(...skipping 23 matching lines...) Expand all
94 } 86 }
95 87
96 MediaSinkImpl::~MediaSinkImpl() {} 88 MediaSinkImpl::~MediaSinkImpl() {}
97 89
98 void MediaSinkImpl::GetConsumer(InterfaceRequest<MediaConsumer> consumer) { 90 void MediaSinkImpl::GetConsumer(InterfaceRequest<MediaConsumer> consumer) {
99 consumer_->AddBinding(consumer.Pass()); 91 consumer_->AddBinding(consumer.Pass());
100 } 92 }
101 93
102 void MediaSinkImpl::GetTimelineControlSite( 94 void MediaSinkImpl::GetTimelineControlSite(
103 InterfaceRequest<MediaTimelineControlSite> req) { 95 InterfaceRequest<MediaTimelineControlSite> req) {
104 if (renderer_) { 96 DCHECK(renderer_);
105 renderer_->GetTimelineControlSite(req.Pass()); 97 renderer_->GetTimelineControlSite(req.Pass());
106 return;
107 }
108
109 new NullTimelineControlSite(req.Pass());
110 }
111
112 MediaSinkImpl::NullTimelineControlSite::NullTimelineControlSite(
113 InterfaceRequest<MediaTimelineControlSite> control_site_request)
114 : control_site_binding_(this, control_site_request.Pass()),
115 consumer_binding_(this) {}
116
117 MediaSinkImpl::NullTimelineControlSite::~NullTimelineControlSite() {}
118
119 void MediaSinkImpl::NullTimelineControlSite::GetStatus(
120 uint64_t version_last_seen,
121 const GetStatusCallback& callback) {
122 DCHECK(get_status_callback_.is_null());
123 get_status_callback_ = callback;
124 }
125
126 void MediaSinkImpl::NullTimelineControlSite::GetTimelineConsumer(
127 InterfaceRequest<TimelineConsumer> timeline_consumer) {
128 consumer_binding_.Bind(timeline_consumer.Pass());
129 }
130
131 void MediaSinkImpl::NullTimelineControlSite::SetTimelineTransform(
132 int64_t subject_time,
133 uint32_t reference_delta,
134 uint32_t subject_delta,
135 int64_t effective_reference_time,
136 int64_t effective_subject_time,
137 const SetTimelineTransformCallback& callback) {
138 callback.Run(true);
139 } 98 }
140 99
141 } // namespace media 100 } // namespace media
142 } // namespace mojo 101 } // namespace mojo
OLDNEW
« no previous file with comments | « services/media/factory_service/media_sink_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698