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

Side by Side Diff: services/media/framework/util/conversion_pipeline_builder.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 "services/media/framework/parts/decoder.h" 5 #include "services/media/framework/parts/decoder.h"
6 #include "services/media/framework/parts/lpcm_reformatter.h" 6 #include "services/media/framework/parts/lpcm_reformatter.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/util/formatting.h" 8 #include "services/media/framework/util/formatting.h"
9 9
10 namespace mojo { 10 namespace mojo {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 *out_type = nullptr; 137 *out_type = nullptr;
138 return AddResult::kFailed; 138 return AddResult::kFailed;
139 } 139 }
140 140
141 *output = graph->ConnectOutputToPart(*output, graph->Add(decoder)).output(); 141 *output = graph->ConnectOutputToPart(*output, graph->Add(decoder)).output();
142 *out_type = decoder->output_stream_type(); 142 *out_type = decoder->output_stream_type();
143 143
144 return AddResult::kProgressed; 144 return AddResult::kProgressed;
145 } 145 }
146 146
147 // Attempts to add transforms to the pipeline given an input compressed video
148 // stream type with (in_type) and the set of output types we need to convert to
149 // (out_type_sets). If the call succeeds, *out_type is set to the new output
150 // type. Otherwise, *out_type is set to nullptr.
151 AddResult AddTransformsForCompressedVideo(
152 const VideoStreamType& in_type,
153 const std::vector<std::unique_ptr<StreamTypeSet>>& out_type_sets,
154 Graph* graph,
155 OutputRef* output,
156 std::unique_ptr<StreamType>* out_type) {
157 DCHECK(out_type);
158 DCHECK(graph);
159
160 // TODO(dalesat): See if we already have a matching video type.
161
162 // Need to decode. Create a decoder and go from there.
163 std::shared_ptr<Decoder> decoder;
164 Result result = Decoder::Create(in_type, &decoder);
165 if (result != Result::kOk) {
166 // No decoder found.
167 *out_type = nullptr;
168 return AddResult::kFailed;
169 }
170
171 *output = graph->ConnectOutputToPart(*output, graph->Add(decoder)).output();
172 *out_type = decoder->output_stream_type();
173
174 return AddResult::kProgressed;
175 }
176
147 // Attempts to add transforms to the pipeline given an input LPCM stream type 177 // Attempts to add transforms to the pipeline given an input LPCM stream type
148 // (in_type) and the output lpcm stream type set for the type we need to 178 // (in_type) and the output lpcm stream type set for the type we need to
149 // convert to (out_type_set). If the call succeeds, *out_type is set to the new 179 // convert to (out_type_set). If the call succeeds, *out_type is set to the new
150 // output type. Otherwise, *out_type is set to nullptr. 180 // output type. Otherwise, *out_type is set to nullptr.
151 AddResult AddTransformsForLpcm(const AudioStreamType& in_type, 181 AddResult AddTransformsForLpcm(const AudioStreamType& in_type,
152 const AudioStreamTypeSet& out_type_set, 182 const AudioStreamTypeSet& out_type_set,
153 Graph* graph, 183 Graph* graph,
154 OutputRef* output, 184 OutputRef* output,
155 std::unique_ptr<StreamType>* out_type) { 185 std::unique_ptr<StreamType>* out_type) {
156 DCHECK(graph); 186 DCHECK(graph);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 265
236 switch (in_type.medium()) { 266 switch (in_type.medium()) {
237 case StreamType::Medium::kAudio: 267 case StreamType::Medium::kAudio:
238 if (in_type.encoding() == StreamType::kAudioEncodingLpcm) { 268 if (in_type.encoding() == StreamType::kAudioEncodingLpcm) {
239 return AddTransformsForLpcm(*in_type.audio(), out_type_sets, graph, 269 return AddTransformsForLpcm(*in_type.audio(), out_type_sets, graph,
240 output, out_type); 270 output, out_type);
241 } else { 271 } else {
242 return AddTransformsForCompressedAudio(*in_type.audio(), out_type_sets, 272 return AddTransformsForCompressedAudio(*in_type.audio(), out_type_sets,
243 graph, output, out_type); 273 graph, output, out_type);
244 } 274 }
275 case StreamType::Medium::kVideo:
276 if (in_type.encoding() == StreamType::kVideoEncodingUncompressed) {
277 *out_type = in_type.Clone();
278 return AddResult::kFinished;
279 } else {
280 return AddTransformsForCompressedVideo(*in_type.video(), out_type_sets,
281 graph, output, out_type);
282 }
245 default: 283 default:
246 NOTREACHED() << "conversion not supported for medium" << in_type.medium(); 284 NOTREACHED() << "conversion not supported for medium" << in_type.medium();
247 *out_type = nullptr; 285 *out_type = nullptr;
248 return AddResult::kFailed; 286 return AddResult::kFailed;
249 } 287 }
250 } 288 }
251 289
252 } // namespace 290 } // namespace
253 291
254 bool BuildConversionPipeline( 292 bool BuildConversionPipeline(
(...skipping 27 matching lines...) Expand all
282 *out_type = std::move(converted_type); 320 *out_type = std::move(converted_type);
283 return true; 321 return true;
284 } 322 }
285 323
286 type_to_convert = converted_type.get(); 324 type_to_convert = converted_type.get();
287 } 325 }
288 } 326 }
289 327
290 } // namespace media 328 } // namespace media
291 } // namespace mojo 329 } // namespace mojo
OLDNEW
« no previous file with comments | « services/media/factory_service/media_timeline_controller_impl.cc ('k') | services/media/framework_ffmpeg/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698