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 ::media::DemuxerStream::Type target_type = |
| 329 audio ? ::media::DemuxerStream::AUDIO : ::media::DemuxerStream::VIDEO; |
| 330 for (const auto& demuxer_stream : streams) { |
| 331 if (demuxer_stream->type() == target_type) { |
| 332 stream = demuxer_stream; |
| 333 break; |
| 334 } |
| 335 } |
328 CHECK(stream); | 336 CHECK(stream); |
329 | 337 |
330 DemuxResult demux_result; | 338 DemuxResult demux_result; |
331 if (audio) { | 339 if (audio) { |
332 demux_result.audio_config = stream->audio_decoder_config(); | 340 demux_result.audio_config = stream->audio_decoder_config(); |
333 } else { | 341 } else { |
334 demux_result.video_config = stream->video_decoder_config(); | 342 demux_result.video_config = stream->video_decoder_config(); |
335 } | 343 } |
336 | 344 |
337 bool end_of_stream = false; | 345 bool end_of_stream = false; |
338 while (!end_of_stream) { | 346 while (!end_of_stream) { |
339 base::RunLoop run_loop; | 347 base::RunLoop run_loop; |
340 stream->Read(base::Bind(&OnNewBuffer, | 348 stream->Read(base::Bind(&OnNewBuffer, |
341 base::Unretained(&demux_result.frames), | 349 base::Unretained(&demux_result.frames), |
342 run_loop.QuitClosure())); | 350 run_loop.QuitClosure())); |
343 run_loop.Run(); | 351 run_loop.Run(); |
344 CHECK(!demux_result.frames.empty()); | 352 CHECK(!demux_result.frames.empty()); |
345 end_of_stream = demux_result.frames.back()->end_of_stream(); | 353 end_of_stream = demux_result.frames.back()->end_of_stream(); |
346 } | 354 } |
347 | 355 |
348 demuxer.Stop(); | 356 demuxer.Stop(); |
349 return demux_result; | 357 return demux_result; |
350 } | 358 } |
351 | 359 |
352 } // namespace media | 360 } // namespace media |
353 } // namespace chromecast | 361 } // namespace chromecast |
OLD | NEW |