| 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 19 matching lines...) Expand all Loading... |
| 30 #include "webrtc/media/engine/webrtcvoe.h" | 30 #include "webrtc/media/engine/webrtcvoe.h" |
| 31 #include "webrtc/pc/channel.h" | 31 #include "webrtc/pc/channel.h" |
| 32 | 32 |
| 33 namespace cricket { | 33 namespace cricket { |
| 34 | 34 |
| 35 class AudioDeviceModule; | 35 class AudioDeviceModule; |
| 36 class AudioSource; | 36 class AudioSource; |
| 37 class VoEWrapper; | 37 class VoEWrapper; |
| 38 class WebRtcVoiceMediaChannel; | 38 class WebRtcVoiceMediaChannel; |
| 39 | 39 |
| 40 struct SendCodecSpec { | |
| 41 SendCodecSpec() { | |
| 42 webrtc::CodecInst empty_inst = {0}; | |
| 43 codec_inst = empty_inst; | |
| 44 codec_inst.pltype = -1; | |
| 45 } | |
| 46 bool operator==(const SendCodecSpec& rhs) const; | |
| 47 bool operator!=(const SendCodecSpec& rhs) const; | |
| 48 | |
| 49 bool nack_enabled = false; | |
| 50 bool transport_cc_enabled = false; | |
| 51 bool enable_codec_fec = false; | |
| 52 bool enable_opus_dtx = false; | |
| 53 int opus_max_playback_rate = 0; | |
| 54 int red_payload_type = -1; | |
| 55 int cng_payload_type = -1; | |
| 56 int cng_plfreq = -1; | |
| 57 webrtc::CodecInst codec_inst; | |
| 58 }; | |
| 59 | |
| 60 // WebRtcVoiceEngine is a class to be used with CompositeMediaEngine. | 40 // WebRtcVoiceEngine is a class to be used with CompositeMediaEngine. |
| 61 // It uses the WebRtc VoiceEngine library for audio handling. | 41 // It uses the WebRtc VoiceEngine library for audio handling. |
| 62 class WebRtcVoiceEngine final : public webrtc::TraceCallback { | 42 class WebRtcVoiceEngine final : public webrtc::TraceCallback { |
| 63 friend class WebRtcVoiceMediaChannel; | 43 friend class WebRtcVoiceMediaChannel; |
| 64 public: | 44 public: |
| 65 // Exposed for the WVoE/MC unit test. | 45 // Exposed for the WVoE/MC unit test. |
| 66 static bool ToCodecInst(const AudioCodec& in, webrtc::CodecInst* out); | 46 static bool ToCodecInst(const AudioCodec& in, webrtc::CodecInst* out); |
| 67 | 47 |
| 68 WebRtcVoiceEngine( | 48 WebRtcVoiceEngine( |
| 69 webrtc::AudioDeviceModule* adm, | 49 webrtc::AudioDeviceModule* adm, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 return VoiceMediaChannel::SendRtcp(&packet, rtc::PacketOptions()); | 210 return VoiceMediaChannel::SendRtcp(&packet, rtc::PacketOptions()); |
| 231 } | 211 } |
| 232 | 212 |
| 233 int GetReceiveChannelId(uint32_t ssrc) const; | 213 int GetReceiveChannelId(uint32_t ssrc) const; |
| 234 int GetSendChannelId(uint32_t ssrc) const; | 214 int GetSendChannelId(uint32_t ssrc) const; |
| 235 | 215 |
| 236 private: | 216 private: |
| 237 bool SetOptions(const AudioOptions& options); | 217 bool SetOptions(const AudioOptions& options); |
| 238 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs); | 218 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs); |
| 239 bool SetSendCodecs(const std::vector<AudioCodec>& codecs); | 219 bool SetSendCodecs(const std::vector<AudioCodec>& codecs); |
| 240 bool SetSendCodecs(int channel, const webrtc::RtpParameters& rtp_parameters); | |
| 241 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); | |
| 242 bool SetLocalSource(uint32_t ssrc, AudioSource* source); | 220 bool SetLocalSource(uint32_t ssrc, AudioSource* source); |
| 243 bool MuteStream(uint32_t ssrc, bool mute); | 221 bool MuteStream(uint32_t ssrc, bool mute); |
| 244 | 222 |
| 245 WebRtcVoiceEngine* engine() { return engine_; } | 223 WebRtcVoiceEngine* engine() { return engine_; } |
| 246 int GetLastEngineError() { return engine()->GetLastEngineError(); } | 224 int GetLastEngineError() { return engine()->GetLastEngineError(); } |
| 247 int GetOutputLevel(int channel); | 225 int GetOutputLevel(int channel); |
| 248 void ChangePlayout(bool playout); | 226 void ChangePlayout(bool playout); |
| 249 int CreateVoEChannel(); | 227 int CreateVoEChannel(); |
| 250 bool DeleteVoEChannel(int channel); | 228 bool DeleteVoEChannel(int channel); |
| 251 bool IsDefaultRecvStream(uint32_t ssrc) { | 229 bool IsDefaultRecvStream(uint32_t ssrc) { |
| 252 return default_recv_ssrc_ == static_cast<int64_t>(ssrc); | 230 return default_recv_ssrc_ == static_cast<int64_t>(ssrc); |
| 253 } | 231 } |
| 254 bool SetMaxSendBitrate(int bps); | 232 bool SetMaxSendBitrate(int bps); |
| 255 bool SetChannelSendParameters(int channel, | |
| 256 const webrtc::RtpParameters& parameters); | |
| 257 bool SetMaxSendBitrate(int channel, int bps); | |
| 258 bool HasSendCodec() const { | |
| 259 return send_codec_spec_.codec_inst.pltype != -1; | |
| 260 } | |
| 261 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters); | 233 bool ValidateRtpParameters(const webrtc::RtpParameters& parameters); |
| 262 void SetupRecording(); | 234 void SetupRecording(); |
| 263 | 235 |
| 264 rtc::ThreadChecker worker_thread_checker_; | 236 rtc::ThreadChecker worker_thread_checker_; |
| 265 | 237 |
| 266 WebRtcVoiceEngine* const engine_ = nullptr; | 238 WebRtcVoiceEngine* const engine_ = nullptr; |
| 267 std::vector<AudioCodec> send_codecs_; | 239 std::vector<AudioCodec> send_codecs_; |
| 268 std::vector<AudioCodec> recv_codecs_; | 240 std::vector<AudioCodec> recv_codecs_; |
| 269 int max_send_bitrate_bps_ = 0; | |
| 270 AudioOptions options_; | 241 AudioOptions options_; |
| 271 rtc::Optional<int> dtmf_payload_type_; | 242 rtc::Optional<int> dtmf_payload_type_; |
| 272 bool desired_playout_ = false; | 243 bool desired_playout_ = false; |
| 273 bool recv_transport_cc_enabled_ = false; | 244 bool recv_transport_cc_enabled_ = false; |
| 274 bool recv_nack_enabled_ = false; | 245 bool recv_nack_enabled_ = false; |
| 275 bool playout_ = false; | 246 bool playout_ = false; |
| 276 bool send_ = false; | 247 bool send_ = false; |
| 277 webrtc::Call* const call_ = nullptr; | 248 webrtc::Call* const call_ = nullptr; |
| 278 | 249 |
| 279 // SSRC of unsignalled receive stream, or -1 if there isn't one. | 250 // SSRC of unsignalled receive stream, or -1 if there isn't one. |
| 280 int64_t default_recv_ssrc_ = -1; | 251 int64_t default_recv_ssrc_ = -1; |
| 281 // Volume for unsignalled stream, which may be set before the stream exists. | 252 // Volume for unsignalled stream, which may be set before the stream exists. |
| 282 double default_recv_volume_ = 1.0; | 253 double default_recv_volume_ = 1.0; |
| 283 // Sink for unsignalled stream, which may be set before the stream exists. | 254 // Sink for unsignalled stream, which may be set before the stream exists. |
| 284 std::unique_ptr<webrtc::AudioSinkInterface> default_sink_; | 255 std::unique_ptr<webrtc::AudioSinkInterface> default_sink_; |
| 285 // Default SSRC to use for RTCP receiver reports in case of no signaled | 256 // Default SSRC to use for RTCP receiver reports in case of no signaled |
| 286 // send streams. See: https://code.google.com/p/webrtc/issues/detail?id=4740 | 257 // send streams. See: https://code.google.com/p/webrtc/issues/detail?id=4740 |
| 287 // and https://code.google.com/p/chromium/issues/detail?id=547661 | 258 // and https://code.google.com/p/chromium/issues/detail?id=547661 |
| 288 uint32_t receiver_reports_ssrc_ = 0xFA17FA17u; | 259 uint32_t receiver_reports_ssrc_ = 0xFA17FA17u; |
| 289 | 260 |
| 290 class WebRtcAudioSendStream; | 261 class WebRtcAudioSendStream; |
| 291 std::map<uint32_t, WebRtcAudioSendStream*> send_streams_; | 262 std::map<uint32_t, WebRtcAudioSendStream*> send_streams_; |
| 292 std::vector<webrtc::RtpExtension> send_rtp_extensions_; | 263 std::vector<webrtc::RtpExtension> send_rtp_extensions_; |
| 293 | 264 |
| 294 class WebRtcAudioReceiveStream; | 265 class WebRtcAudioReceiveStream; |
| 295 std::map<uint32_t, WebRtcAudioReceiveStream*> recv_streams_; | 266 std::map<uint32_t, WebRtcAudioReceiveStream*> recv_streams_; |
| 296 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 267 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
| 297 | 268 |
| 298 SendCodecSpec send_codec_spec_; | 269 webrtc::AudioSendStream::Config::SendCodecSpec send_codec_spec_; |
| 299 | 270 |
| 300 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcVoiceMediaChannel); | 271 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcVoiceMediaChannel); |
| 301 }; | 272 }; |
| 302 } // namespace cricket | 273 } // namespace cricket |
| 303 | 274 |
| 304 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVOICEENGINE_H_ | 275 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVOICEENGINE_H_ |
| OLD | NEW |