OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromecast/media/cma/test/frame_segmenter_for_test.h" | 5 #include "chromecast/media/cma/test/frame_segmenter_for_test.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 ::media::FFmpegDemuxer demuxer( | 316 ::media::FFmpegDemuxer demuxer( |
317 base::ThreadTaskRunnerHandle::Get(), &data_source, | 317 base::ThreadTaskRunnerHandle::Get(), &data_source, |
318 base::Bind(&OnEncryptedMediaInitData), base::Bind(&OnMediaTracksUpdated), | 318 base::Bind(&OnEncryptedMediaInitData), base::Bind(&OnMediaTracksUpdated), |
319 new ::media::MediaLog()); | 319 new ::media::MediaLog()); |
320 ::media::WaitableMessageLoopEvent init_event; | 320 ::media::WaitableMessageLoopEvent init_event; |
321 demuxer.Initialize(&fake_demuxer_host, | 321 demuxer.Initialize(&fake_demuxer_host, |
322 init_event.GetPipelineStatusCB(), | 322 init_event.GetPipelineStatusCB(), |
323 false); | 323 false); |
324 init_event.RunAndWaitForStatus(::media::PIPELINE_OK); | 324 init_event.RunAndWaitForStatus(::media::PIPELINE_OK); |
325 | 325 |
326 ::media::DemuxerStream* stream = demuxer.GetStream( | 326 std::vector<::media::DemuxerStream*> streams = demuxer.GetStreams(); |
327 audio ? ::media::DemuxerStream::AUDIO : ::media::DemuxerStream::VIDEO); | 327 ::media::DemuxerStream* stream = nullptr; |
328 for (const auto& s : streams) { | |
329 if (audio && s->type() == ::media::DemuxerStream::AUDIO) { | |
tguilbert
2017/01/24 23:24:40
NIT: Can you remove one of the ifs, and use
::med
servolk
2017/01/25 00:57:32
Done.
| |
330 stream = s; | |
331 break; | |
332 } | |
333 if (!audio && s->type() == ::media::DemuxerStream::VIDEO) { | |
334 stream = s; | |
335 break; | |
336 } | |
337 } | |
328 CHECK(stream); | 338 CHECK(stream); |
329 | 339 |
330 DemuxResult demux_result; | 340 DemuxResult demux_result; |
331 if (audio) { | 341 if (audio) { |
332 demux_result.audio_config = stream->audio_decoder_config(); | 342 demux_result.audio_config = stream->audio_decoder_config(); |
333 } else { | 343 } else { |
334 demux_result.video_config = stream->video_decoder_config(); | 344 demux_result.video_config = stream->video_decoder_config(); |
335 } | 345 } |
336 | 346 |
337 bool end_of_stream = false; | 347 bool end_of_stream = false; |
338 while (!end_of_stream) { | 348 while (!end_of_stream) { |
339 base::RunLoop run_loop; | 349 base::RunLoop run_loop; |
340 stream->Read(base::Bind(&OnNewBuffer, | 350 stream->Read(base::Bind(&OnNewBuffer, |
341 base::Unretained(&demux_result.frames), | 351 base::Unretained(&demux_result.frames), |
342 run_loop.QuitClosure())); | 352 run_loop.QuitClosure())); |
343 run_loop.Run(); | 353 run_loop.Run(); |
344 CHECK(!demux_result.frames.empty()); | 354 CHECK(!demux_result.frames.empty()); |
345 end_of_stream = demux_result.frames.back()->end_of_stream(); | 355 end_of_stream = demux_result.frames.back()->end_of_stream(); |
346 } | 356 } |
347 | 357 |
348 demuxer.Stop(); | 358 demuxer.Stop(); |
349 return demux_result; | 359 return demux_result; |
350 } | 360 } |
351 | 361 |
352 } // namespace media | 362 } // namespace media |
353 } // namespace chromecast | 363 } // namespace chromecast |
OLD | NEW |