OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "webrtc/common.h" | 24 #include "webrtc/common.h" |
25 #include "webrtc/config.h" | 25 #include "webrtc/config.h" |
26 #include "webrtc/media/base/rtputils.h" | 26 #include "webrtc/media/base/rtputils.h" |
27 #include "webrtc/media/engine/webrtccommon.h" | 27 #include "webrtc/media/engine/webrtccommon.h" |
28 #include "webrtc/media/engine/webrtcvoe.h" | 28 #include "webrtc/media/engine/webrtcvoe.h" |
29 #include "webrtc/pc/channel.h" | 29 #include "webrtc/pc/channel.h" |
30 | 30 |
31 namespace cricket { | 31 namespace cricket { |
32 | 32 |
33 class AudioDeviceModule; | 33 class AudioDeviceModule; |
34 class AudioRenderer; | 34 class AudioSource; |
35 class VoEWrapper; | 35 class VoEWrapper; |
36 class WebRtcVoiceMediaChannel; | 36 class WebRtcVoiceMediaChannel; |
37 | 37 |
38 // WebRtcVoiceEngine is a class to be used with CompositeMediaEngine. | 38 // WebRtcVoiceEngine is a class to be used with CompositeMediaEngine. |
39 // It uses the WebRtc VoiceEngine library for audio handling. | 39 // It uses the WebRtc VoiceEngine library for audio handling. |
40 class WebRtcVoiceEngine final : public webrtc::TraceCallback { | 40 class WebRtcVoiceEngine final : public webrtc::TraceCallback { |
41 friend class WebRtcVoiceMediaChannel; | 41 friend class WebRtcVoiceMediaChannel; |
42 public: | 42 public: |
43 // Exposed for the WVoE/MC unit test. | 43 // Exposed for the WVoE/MC unit test. |
44 static bool ToCodecInst(const AudioCodec& in, webrtc::CodecInst* out); | 44 static bool ToCodecInst(const AudioCodec& in, webrtc::CodecInst* out); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 const AudioOptions& options() const { return options_; } | 149 const AudioOptions& options() const { return options_; } |
150 | 150 |
151 rtc::DiffServCodePoint PreferredDscp() const override; | 151 rtc::DiffServCodePoint PreferredDscp() const override; |
152 | 152 |
153 bool SetSendParameters(const AudioSendParameters& params) override; | 153 bool SetSendParameters(const AudioSendParameters& params) override; |
154 bool SetRecvParameters(const AudioRecvParameters& params) override; | 154 bool SetRecvParameters(const AudioRecvParameters& params) override; |
155 bool SetPlayout(bool playout) override; | 155 bool SetPlayout(bool playout) override; |
156 bool PausePlayout(); | 156 bool PausePlayout(); |
157 bool ResumePlayout(); | 157 bool ResumePlayout(); |
158 bool SetSend(SendFlags send) override; | 158 bool SetSend(bool send) override; |
159 bool PauseSend(); | 159 bool PauseSend(); |
160 bool ResumeSend(); | 160 bool ResumeSend(); |
161 bool SetAudioSend(uint32_t ssrc, | 161 bool SetAudioSend(uint32_t ssrc, |
162 bool enable, | 162 bool enable, |
163 const AudioOptions* options, | 163 const AudioOptions* options, |
164 AudioRenderer* renderer) override; | 164 AudioSource* source) override; |
165 bool AddSendStream(const StreamParams& sp) override; | 165 bool AddSendStream(const StreamParams& sp) override; |
166 bool RemoveSendStream(uint32_t ssrc) override; | 166 bool RemoveSendStream(uint32_t ssrc) override; |
167 bool AddRecvStream(const StreamParams& sp) override; | 167 bool AddRecvStream(const StreamParams& sp) override; |
168 bool RemoveRecvStream(uint32_t ssrc) override; | 168 bool RemoveRecvStream(uint32_t ssrc) override; |
169 bool GetActiveStreams(AudioInfo::StreamList* actives) override; | 169 bool GetActiveStreams(AudioInfo::StreamList* actives) override; |
170 int GetOutputLevel() override; | 170 int GetOutputLevel() override; |
171 int GetTimeSinceLastTyping() override; | 171 int GetTimeSinceLastTyping() override; |
172 void SetTypingDetectionParameters(int time_window, | 172 void SetTypingDetectionParameters(int time_window, |
173 int cost_per_typing, | 173 int cost_per_typing, |
174 int reporting_threshold, | 174 int reporting_threshold, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 | 209 |
210 int GetReceiveChannelId(uint32_t ssrc) const; | 210 int GetReceiveChannelId(uint32_t ssrc) const; |
211 int GetSendChannelId(uint32_t ssrc) const; | 211 int GetSendChannelId(uint32_t ssrc) const; |
212 | 212 |
213 private: | 213 private: |
214 bool SetSendCodecs(const std::vector<AudioCodec>& codecs); | 214 bool SetSendCodecs(const std::vector<AudioCodec>& codecs); |
215 bool SetOptions(const AudioOptions& options); | 215 bool SetOptions(const AudioOptions& options); |
216 bool SetMaxSendBandwidth(int bps); | 216 bool SetMaxSendBandwidth(int bps); |
217 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs); | 217 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs); |
218 bool SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer); | 218 bool SetLocalSource(uint32_t ssrc, AudioSource* source); |
219 bool MuteStream(uint32_t ssrc, bool mute); | 219 bool MuteStream(uint32_t ssrc, bool mute); |
220 | 220 |
221 WebRtcVoiceEngine* engine() { return engine_; } | 221 WebRtcVoiceEngine* engine() { return engine_; } |
222 int GetLastEngineError() { return engine()->GetLastEngineError(); } | 222 int GetLastEngineError() { return engine()->GetLastEngineError(); } |
223 int GetOutputLevel(int channel); | 223 int GetOutputLevel(int channel); |
224 bool SetPlayout(int channel, bool playout); | 224 bool SetPlayout(int channel, bool playout); |
225 void SetNack(int channel, bool nack_enabled); | 225 void SetNack(int channel, bool nack_enabled); |
226 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); | 226 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); |
227 bool ChangePlayout(bool playout); | 227 bool ChangePlayout(bool playout); |
228 bool ChangeSend(SendFlags send); | |
229 bool ChangeSend(int channel, SendFlags send); | |
230 int CreateVoEChannel(); | 228 int CreateVoEChannel(); |
231 bool DeleteVoEChannel(int channel); | 229 bool DeleteVoEChannel(int channel); |
232 bool IsDefaultRecvStream(uint32_t ssrc) { | 230 bool IsDefaultRecvStream(uint32_t ssrc) { |
233 return default_recv_ssrc_ == static_cast<int64_t>(ssrc); | 231 return default_recv_ssrc_ == static_cast<int64_t>(ssrc); |
234 } | 232 } |
235 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); | 233 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); |
236 bool SetSendBitrateInternal(int bps); | 234 bool SetSendBitrateInternal(int bps); |
237 | 235 |
238 rtc::ThreadChecker worker_thread_checker_; | 236 rtc::ThreadChecker worker_thread_checker_; |
239 | 237 |
240 WebRtcVoiceEngine* const engine_ = nullptr; | 238 WebRtcVoiceEngine* const engine_ = nullptr; |
241 std::vector<AudioCodec> recv_codecs_; | 239 std::vector<AudioCodec> recv_codecs_; |
242 std::vector<AudioCodec> send_codecs_; | 240 std::vector<AudioCodec> send_codecs_; |
243 std::unique_ptr<webrtc::CodecInst> send_codec_; | 241 std::unique_ptr<webrtc::CodecInst> send_codec_; |
244 bool send_bitrate_setting_ = false; | 242 bool send_bitrate_setting_ = false; |
245 int send_bitrate_bps_ = 0; | 243 int send_bitrate_bps_ = 0; |
246 AudioOptions options_; | 244 AudioOptions options_; |
247 rtc::Optional<int> dtmf_payload_type_; | 245 rtc::Optional<int> dtmf_payload_type_; |
248 bool desired_playout_ = false; | 246 bool desired_playout_ = false; |
249 bool nack_enabled_ = false; | 247 bool nack_enabled_ = false; |
250 bool transport_cc_enabled_ = false; | 248 bool transport_cc_enabled_ = false; |
251 bool playout_ = false; | 249 bool playout_ = false; |
252 SendFlags desired_send_ = SEND_NOTHING; | 250 bool send_ = false; |
253 SendFlags send_ = SEND_NOTHING; | |
254 webrtc::Call* const call_ = nullptr; | 251 webrtc::Call* const call_ = nullptr; |
255 | 252 |
256 // SSRC of unsignalled receive stream, or -1 if there isn't one. | 253 // SSRC of unsignalled receive stream, or -1 if there isn't one. |
257 int64_t default_recv_ssrc_ = -1; | 254 int64_t default_recv_ssrc_ = -1; |
258 // Volume for unsignalled stream, which may be set before the stream exists. | 255 // Volume for unsignalled stream, which may be set before the stream exists. |
259 double default_recv_volume_ = 1.0; | 256 double default_recv_volume_ = 1.0; |
260 // Sink for unsignalled stream, which may be set before the stream exists. | 257 // Sink for unsignalled stream, which may be set before the stream exists. |
261 std::unique_ptr<webrtc::AudioSinkInterface> default_sink_; | 258 std::unique_ptr<webrtc::AudioSinkInterface> default_sink_; |
262 // Default SSRC to use for RTCP receiver reports in case of no signaled | 259 // Default SSRC to use for RTCP receiver reports in case of no signaled |
263 // send streams. See: https://code.google.com/p/webrtc/issues/detail?id=4740 | 260 // send streams. See: https://code.google.com/p/webrtc/issues/detail?id=4740 |
264 // and https://code.google.com/p/chromium/issues/detail?id=547661 | 261 // and https://code.google.com/p/chromium/issues/detail?id=547661 |
265 uint32_t receiver_reports_ssrc_ = 0xFA17FA17u; | 262 uint32_t receiver_reports_ssrc_ = 0xFA17FA17u; |
266 | 263 |
267 class WebRtcAudioSendStream; | 264 class WebRtcAudioSendStream; |
268 std::map<uint32_t, WebRtcAudioSendStream*> send_streams_; | 265 std::map<uint32_t, WebRtcAudioSendStream*> send_streams_; |
269 std::vector<webrtc::RtpExtension> send_rtp_extensions_; | 266 std::vector<webrtc::RtpExtension> send_rtp_extensions_; |
270 | 267 |
271 class WebRtcAudioReceiveStream; | 268 class WebRtcAudioReceiveStream; |
272 std::map<uint32_t, WebRtcAudioReceiveStream*> recv_streams_; | 269 std::map<uint32_t, WebRtcAudioReceiveStream*> recv_streams_; |
273 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 270 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
274 | 271 |
275 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcVoiceMediaChannel); | 272 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcVoiceMediaChannel); |
276 }; | 273 }; |
277 } // namespace cricket | 274 } // namespace cricket |
278 | 275 |
279 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVOICEENGINE_H_ | 276 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVOICEENGINE_H_ |
OLD | NEW |