| 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 "remoting/client/audio_decode_scheduler.h" |
| 6 |
| 5 #include "base/bind.h" | 7 #include "base/bind.h" |
| 6 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 7 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 8 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 9 #include "remoting/base/auto_thread.h" | 11 #include "remoting/base/auto_thread.h" |
| 10 #include "remoting/base/auto_thread_task_runner.h" | 12 #include "remoting/base/auto_thread_task_runner.h" |
| 11 #include "remoting/client/audio_decode_scheduler.h" | |
| 12 #include "remoting/client/fake_audio_consumer.h" | 13 #include "remoting/client/fake_audio_consumer.h" |
| 14 #include "remoting/proto/audio.pb.h" |
| 13 #include "remoting/protocol/session_config.h" | 15 #include "remoting/protocol/session_config.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 17 |
| 16 namespace { | 18 namespace { |
| 17 | 19 |
| 18 const int kAudioSampleBytes = 4; | 20 const int kAudioSampleBytes = 4; |
| 19 const uint8_t kDummyAudioData = 0x8B; | 21 const uint8_t kDummyAudioData = 0x8B; |
| 20 | 22 |
| 21 } // namespace | 23 } // namespace |
| 22 | 24 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 46 | 48 |
| 47 void AudioDecodeSchedulerTest::TearDown() { | 49 void AudioDecodeSchedulerTest::TearDown() { |
| 48 // Release the task runners, so that the test can quit. | 50 // Release the task runners, so that the test can quit. |
| 49 audio_decode_task_runner_ = nullptr; | 51 audio_decode_task_runner_ = nullptr; |
| 50 main_task_runner_ = nullptr; | 52 main_task_runner_ = nullptr; |
| 51 | 53 |
| 52 // Run the MessageLoop until everything has torn down. | 54 // Run the MessageLoop until everything has torn down. |
| 53 run_loop_.Run(); | 55 run_loop_.Run(); |
| 54 } | 56 } |
| 55 | 57 |
| 56 // TODO(nicholss) could share the following in a common class for use | 58 // TODO(nicholss): Could share the following in a common class for use |
| 57 // other places. | 59 // in other places. |
| 58 std::unique_ptr<AudioPacket> CreatePacketWithSamplingRate_( | 60 std::unique_ptr<AudioPacket> CreatePacketWithSamplingRate_( |
| 59 AudioPacket::SamplingRate rate, | 61 AudioPacket::SamplingRate rate, |
| 60 int samples) { | 62 int samples) { |
| 61 std::unique_ptr<AudioPacket> packet(new AudioPacket()); | 63 std::unique_ptr<AudioPacket> packet(new AudioPacket()); |
| 62 packet->set_encoding(AudioPacket::ENCODING_RAW); | 64 packet->set_encoding(AudioPacket::ENCODING_RAW); |
| 63 packet->set_sampling_rate(rate); | 65 packet->set_sampling_rate(rate); |
| 64 packet->set_bytes_per_sample(AudioPacket::BYTES_PER_SAMPLE_2); | 66 packet->set_bytes_per_sample(AudioPacket::BYTES_PER_SAMPLE_2); |
| 65 packet->set_channels(AudioPacket::CHANNELS_STEREO); | 67 packet->set_channels(AudioPacket::CHANNELS_STEREO); |
| 66 | 68 |
| 67 // The data must be a multiple of 4 bytes (channels x bytes_per_sample). | 69 // The data must be a multiple of 4 bytes (channels x bytes_per_sample). |
| (...skipping 20 matching lines...) Expand all Loading... |
| 88 new AudioDecodeScheduler(main_task_runner_, audio_decode_task_runner_, | 90 new AudioDecodeScheduler(main_task_runner_, audio_decode_task_runner_, |
| 89 audio_consumer->GetWeakPtr())); | 91 audio_consumer->GetWeakPtr())); |
| 90 | 92 |
| 91 audio_scheduler->Initialize(*session_config_); | 93 audio_scheduler->Initialize(*session_config_); |
| 92 | 94 |
| 93 audio_scheduler->ProcessAudioPacket(CreatePacket44100Hz_(1000), | 95 audio_scheduler->ProcessAudioPacket(CreatePacket44100Hz_(1000), |
| 94 base::Bind(&base::DoNothing)); | 96 base::Bind(&base::DoNothing)); |
| 95 | 97 |
| 96 audio_scheduler.reset(); | 98 audio_scheduler.reset(); |
| 97 audio_consumer.reset(); | 99 audio_consumer.reset(); |
| 100 // TODO(nicholss): This test does not really test anything. Add a way to get |
| 101 // a count of the calls to AddAudioPacket. |
| 98 } | 102 } |
| 99 | 103 |
| 100 } // namespace remoting | 104 } // namespace remoting |
| OLD | NEW |