| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <random> | 8 #include <random> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 base::RunLoop run_loop; | 58 base::RunLoop run_loop; |
| 59 run_loop.RunUntilIdle(); | 59 run_loop.RunUntilIdle(); |
| 60 | 60 |
| 61 int num_iterations = kMinNumIterations + rng() % kMaxNumIterations; | 61 int num_iterations = kMinNumIterations + rng() % kMaxNumIterations; |
| 62 do { | 62 do { |
| 63 if (input_type.has_video) { | 63 if (input_type.has_video) { |
| 64 // VideoFrames cannot be arbitrarily small. | 64 // VideoFrames cannot be arbitrarily small. |
| 65 const auto visible_rect = gfx::Size(16 + rng() % 128, 16 + rng() % 128); | 65 const auto visible_rect = gfx::Size(16 + rng() % 128, 16 + rng() % 128); |
| 66 const auto video_frame = VideoFrame::CreateBlackFrame(visible_rect); | 66 const auto video_frame = VideoFrame::CreateBlackFrame(visible_rect); |
| 67 const auto is_key_frame = rng() % 2; | 67 const auto is_key_frame = rng() % 2; |
| 68 muxer.OnEncodedVideo(WebmMuxer::VideoParameters(video_frame), | 68 const auto has_alpha_frame = rng() % 4; |
| 69 base::MakeUnique<std::string>(str), | 69 muxer.OnEncodedVideo( |
| 70 base::TimeTicks(), is_key_frame); | 70 WebmMuxer::VideoParameters(video_frame), |
| 71 base::MakeUnique<std::string>(str), |
| 72 has_alpha_frame ? base::MakeUnique<std::string>(str) : nullptr, |
| 73 base::TimeTicks(), is_key_frame); |
| 71 base::RunLoop run_loop; | 74 base::RunLoop run_loop; |
| 72 run_loop.RunUntilIdle(); | 75 run_loop.RunUntilIdle(); |
| 73 } | 76 } |
| 74 | 77 |
| 75 if (input_type.has_audio) { | 78 if (input_type.has_audio) { |
| 76 const ChannelLayout layout = rng() % 2 ? media::CHANNEL_LAYOUT_STEREO | 79 const ChannelLayout layout = rng() % 2 ? media::CHANNEL_LAYOUT_STEREO |
| 77 : media::CHANNEL_LAYOUT_MONO; | 80 : media::CHANNEL_LAYOUT_MONO; |
| 78 const int sample_rate = | 81 const int sample_rate = |
| 79 kSampleRatesInKHz[rng() % arraysize(kSampleRatesInKHz)]; | 82 kSampleRatesInKHz[rng() % arraysize(kSampleRatesInKHz)]; |
| 80 | 83 |
| 81 const AudioParameters params( | 84 const AudioParameters params( |
| 82 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, layout, sample_rate, | 85 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, layout, sample_rate, |
| 83 16 /* bits_per_sample */, 60 * sample_rate); | 86 16 /* bits_per_sample */, 60 * sample_rate); |
| 84 muxer.OnEncodedAudio(params, base::MakeUnique<std::string>(str), | 87 muxer.OnEncodedAudio(params, base::MakeUnique<std::string>(str), |
| 85 base::TimeTicks()); | 88 base::TimeTicks()); |
| 86 base::RunLoop run_loop; | 89 base::RunLoop run_loop; |
| 87 run_loop.RunUntilIdle(); | 90 run_loop.RunUntilIdle(); |
| 88 } | 91 } |
| 89 } while (num_iterations--); | 92 } while (num_iterations--); |
| 90 } | 93 } |
| 91 | 94 |
| 92 return 0; | 95 return 0; |
| 93 } | 96 } |
| OLD | NEW |