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 #include "content/renderer/media/mock_media_stream_dispatcher.h" | 5 #include "content/renderer/media/mock_media_stream_dispatcher.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "content/public/common/media_stream_request.h" | 8 #include "content/public/common/media_stream_request.h" |
| 9 #include "media/base/audio_parameters.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
10 | 11 |
11 // Used for ID for output devices and for matching output device ID for input | 12 // Used for ID for output devices and for matching output device ID for input |
12 // devices. | 13 // devices. |
13 const char kAudioOutputDeviceIdPrefix[] = "audio_output_device_id"; | 14 const char kAudioOutputDeviceIdPrefix[] = "audio_output_device_id"; |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 MockMediaStreamDispatcher::MockMediaStreamDispatcher() | 18 MockMediaStreamDispatcher::MockMediaStreamDispatcher() |
18 : MediaStreamDispatcher(NULL), | 19 : MediaStreamDispatcher(NULL), |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 audio.device.id = test_same_id_ ? "test_id" : "audio_input_device_id"; | 111 audio.device.id = test_same_id_ ? "test_id" : "audio_input_device_id"; |
111 audio.device.id = audio.device.id + base::IntToString(session_id_); | 112 audio.device.id = audio.device.id + base::IntToString(session_id_); |
112 audio.device.name = "microphone"; | 113 audio.device.name = "microphone"; |
113 audio.device.type = MEDIA_DEVICE_AUDIO_CAPTURE; | 114 audio.device.type = MEDIA_DEVICE_AUDIO_CAPTURE; |
114 audio.device.video_facing = MEDIA_VIDEO_FACING_NONE; | 115 audio.device.video_facing = MEDIA_VIDEO_FACING_NONE; |
115 if (matched_output) { | 116 if (matched_output) { |
116 audio.device.matched_output_device_id = | 117 audio.device.matched_output_device_id = |
117 kAudioOutputDeviceIdPrefix + base::IntToString(session_id_); | 118 kAudioOutputDeviceIdPrefix + base::IntToString(session_id_); |
118 } | 119 } |
119 audio.session_id = session_id_; | 120 audio.session_id = session_id_; |
| 121 audio.device.input.sample_rate = media::AudioParameters::kAudioCDSampleRate; |
| 122 audio.device.input.channel_layout = media::CHANNEL_LAYOUT_STEREO; |
| 123 audio.device.input.frames_per_buffer = audio.device.input.sample_rate / 100; |
120 audio_input_array_.push_back(audio); | 124 audio_input_array_.push_back(audio); |
121 } | 125 } |
122 | 126 |
123 void MockMediaStreamDispatcher::AddAudioOutputDeviceToArray() { | 127 void MockMediaStreamDispatcher::AddAudioOutputDeviceToArray() { |
124 StreamDeviceInfo audio; | 128 StreamDeviceInfo audio; |
125 audio.device.id = kAudioOutputDeviceIdPrefix + base::IntToString(session_id_); | 129 audio.device.id = kAudioOutputDeviceIdPrefix + base::IntToString(session_id_); |
126 audio.device.name = "speaker"; | 130 audio.device.name = "speaker"; |
127 audio.device.type = MEDIA_DEVICE_AUDIO_OUTPUT; | 131 audio.device.type = MEDIA_DEVICE_AUDIO_OUTPUT; |
128 audio.device.video_facing = MEDIA_VIDEO_FACING_NONE; | 132 audio.device.video_facing = MEDIA_VIDEO_FACING_NONE; |
129 audio.session_id = session_id_; | 133 audio.session_id = session_id_; |
130 audio_output_array_.push_back(audio); | 134 audio_output_array_.push_back(audio); |
131 } | 135 } |
132 | 136 |
133 void MockMediaStreamDispatcher::AddVideoDeviceToArray(bool facing_user) { | 137 void MockMediaStreamDispatcher::AddVideoDeviceToArray(bool facing_user) { |
134 StreamDeviceInfo video; | 138 StreamDeviceInfo video; |
135 video.device.id = test_same_id_ ? "test_id" : "video_device_id"; | 139 video.device.id = test_same_id_ ? "test_id" : "video_device_id"; |
136 video.device.id = video.device.id + base::IntToString(session_id_); | 140 video.device.id = video.device.id + base::IntToString(session_id_); |
137 video.device.name = "usb video camera"; | 141 video.device.name = "usb video camera"; |
138 video.device.type = MEDIA_DEVICE_VIDEO_CAPTURE; | 142 video.device.type = MEDIA_DEVICE_VIDEO_CAPTURE; |
139 video.device.video_facing = facing_user ? MEDIA_VIDEO_FACING_USER | 143 video.device.video_facing = facing_user ? MEDIA_VIDEO_FACING_USER |
140 : MEDIA_VIDEO_FACING_ENVIRONMENT; | 144 : MEDIA_VIDEO_FACING_ENVIRONMENT; |
141 video.session_id = session_id_; | 145 video.session_id = session_id_; |
142 video_array_.push_back(video); | 146 video_array_.push_back(video); |
143 } | 147 } |
144 | 148 |
145 } // namespace content | 149 } // namespace content |
OLD | NEW |