| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_TEST_WEBRTC_AUDIO_DEVICE_TEST_H_ | 5 #ifndef CONTENT_TEST_WEBRTC_AUDIO_DEVICE_TEST_H_ |
| 6 #define CONTENT_TEST_WEBRTC_AUDIO_DEVICE_TEST_H_ | 6 #define CONTENT_TEST_WEBRTC_AUDIO_DEVICE_TEST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "content/browser/renderer_host/media/mock_media_observer.h" | 15 #include "content/browser/renderer_host/media/mock_media_observer.h" |
| 16 #include "content/renderer/mock_content_renderer_client.h" | 16 #include "content/renderer/mock_content_renderer_client.h" |
| 17 #include "media/base/channel_layout.h" |
| 17 #include "ipc/ipc_channel.h" | 18 #include "ipc/ipc_channel.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "third_party/webrtc/common_types.h" | 20 #include "third_party/webrtc/common_types.h" |
| 20 | 21 |
| 21 class AudioInputRendererHost; | 22 class AudioInputRendererHost; |
| 22 class AudioManager; | 23 class AudioManager; |
| 23 class AudioRendererHost; | 24 class AudioRendererHost; |
| 24 class RenderThreadImpl; | 25 class RenderThreadImpl; |
| 25 class WebRTCMockRenderProcess; | 26 class WebRTCMockRenderProcess; |
| 26 | 27 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 102 |
| 102 protected: | 103 protected: |
| 103 T* ptr_; | 104 T* ptr_; |
| 104 }; | 105 }; |
| 105 | 106 |
| 106 // Individual tests can provide an implementation (or mock) of this interface | 107 // Individual tests can provide an implementation (or mock) of this interface |
| 107 // when the audio code queries for hardware capabilities on the IO thread. | 108 // when the audio code queries for hardware capabilities on the IO thread. |
| 108 class AudioUtilInterface { | 109 class AudioUtilInterface { |
| 109 public: | 110 public: |
| 110 virtual ~AudioUtilInterface() {} | 111 virtual ~AudioUtilInterface() {} |
| 111 virtual double GetAudioHardwareSampleRate() = 0; | 112 virtual int GetAudioHardwareSampleRate() = 0; |
| 112 virtual double GetAudioInputHardwareSampleRate( | 113 virtual int GetAudioInputHardwareSampleRate( |
| 113 const std::string& device_id) = 0; | 114 const std::string& device_id) = 0; |
| 114 virtual uint32 GetAudioInputHardwareChannelCount( | 115 virtual ChannelLayout GetAudioInputHardwareChannelLayout( |
| 115 const std::string& device_id) = 0; | 116 const std::string& device_id) = 0; |
| 116 }; | 117 }; |
| 117 | 118 |
| 118 // Implemented and defined in the cc file. | 119 // Implemented and defined in the cc file. |
| 119 class ReplaceContentClientRenderer; | 120 class ReplaceContentClientRenderer; |
| 120 | 121 |
| 121 class WebRTCAudioDeviceTest | 122 class WebRTCAudioDeviceTest |
| 122 : public ::testing::Test, | 123 : public ::testing::Test, |
| 123 public IPC::Channel::Listener { | 124 public IPC::Channel::Listener { |
| 124 public: | 125 public: |
| 125 WebRTCAudioDeviceTest(); | 126 WebRTCAudioDeviceTest(); |
| 126 virtual ~WebRTCAudioDeviceTest(); | 127 virtual ~WebRTCAudioDeviceTest(); |
| 127 | 128 |
| 128 virtual void SetUp() OVERRIDE; | 129 virtual void SetUp() OVERRIDE; |
| 129 virtual void TearDown() OVERRIDE; | 130 virtual void TearDown() OVERRIDE; |
| 130 | 131 |
| 131 // Sends an IPC message to the IO thread channel. | 132 // Sends an IPC message to the IO thread channel. |
| 132 bool Send(IPC::Message* message); | 133 bool Send(IPC::Message* message); |
| 133 | 134 |
| 134 void SetAudioUtilCallback(AudioUtilInterface* callback); | 135 void SetAudioUtilCallback(AudioUtilInterface* callback); |
| 135 | 136 |
| 136 protected: | 137 protected: |
| 137 void InitializeIOThread(const char* thread_name); | 138 void InitializeIOThread(const char* thread_name); |
| 138 void UninitializeIOThread(); | 139 void UninitializeIOThread(); |
| 139 void CreateChannel(const char* name); | 140 void CreateChannel(const char* name); |
| 140 void DestroyChannel(); | 141 void DestroyChannel(); |
| 141 | 142 |
| 142 void OnGetHardwareSampleRate(double* sample_rate); | 143 void OnGetHardwareSampleRate(int* sample_rate); |
| 143 void OnGetHardwareInputSampleRate(double* sample_rate); | 144 void OnGetHardwareInputSampleRate(int* sample_rate); |
| 144 void OnGetHardwareInputChannelCount(uint32* channels); | 145 void OnGetHardwareInputChannelLayout(ChannelLayout* channels); |
| 145 | 146 |
| 146 // IPC::Channel::Listener implementation. | 147 // IPC::Channel::Listener implementation. |
| 147 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 148 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 148 | 149 |
| 149 // Posts a final task to the IO message loop and waits for completion. | 150 // Posts a final task to the IO message loop and waits for completion. |
| 150 void WaitForIOThreadCompletion(); | 151 void WaitForIOThreadCompletion(); |
| 151 void WaitForAudioManagerCompletion(); | 152 void WaitForAudioManagerCompletion(); |
| 152 void WaitForMessageLoopCompletion(base::MessageLoopProxy* loop); | 153 void WaitForMessageLoopCompletion(base::MessageLoopProxy* loop); |
| 153 | 154 |
| 154 // Convenience getter for gmock. | 155 // Convenience getter for gmock. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 virtual ~WebRTCTransportImpl(); | 192 virtual ~WebRTCTransportImpl(); |
| 192 | 193 |
| 193 virtual int SendPacket(int channel, const void* data, int len) OVERRIDE; | 194 virtual int SendPacket(int channel, const void* data, int len) OVERRIDE; |
| 194 virtual int SendRTCPPacket(int channel, const void* data, int len) OVERRIDE; | 195 virtual int SendRTCPPacket(int channel, const void* data, int len) OVERRIDE; |
| 195 | 196 |
| 196 private: | 197 private: |
| 197 webrtc::VoENetwork* network_; | 198 webrtc::VoENetwork* network_; |
| 198 }; | 199 }; |
| 199 | 200 |
| 200 #endif // CONTENT_TEST_WEBRTC_AUDIO_DEVICE_TEST_H_ | 201 #endif // CONTENT_TEST_WEBRTC_AUDIO_DEVICE_TEST_H_ |
| OLD | NEW |