| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 bool sending() const { return send_ != SEND_NOTHING; } | 245 bool sending() const { return send_ != SEND_NOTHING; } |
| 246 int GetReceiveChannelNum(uint32 ssrc) const; | 246 int GetReceiveChannelNum(uint32 ssrc) const; |
| 247 int GetSendChannelNum(uint32 ssrc) const; | 247 int GetSendChannelNum(uint32 ssrc) const; |
| 248 | 248 |
| 249 private: | 249 private: |
| 250 bool SetSendCodecs(const std::vector<AudioCodec>& codecs); | 250 bool SetSendCodecs(const std::vector<AudioCodec>& codecs); |
| 251 bool SetSendRtpHeaderExtensions( | 251 bool SetSendRtpHeaderExtensions( |
| 252 const std::vector<RtpHeaderExtension>& extensions); | 252 const std::vector<RtpHeaderExtension>& extensions); |
| 253 bool SetOptions(const AudioOptions& options); | 253 bool SetOptions(const AudioOptions& options); |
| 254 bool SetRecvOptions(int channel_id); |
| 254 bool SetMaxSendBandwidth(int bps); | 255 bool SetMaxSendBandwidth(int bps); |
| 255 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs); | 256 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs); |
| 256 bool SetRecvRtpHeaderExtensions( | 257 bool SetRecvRtpHeaderExtensions( |
| 257 const std::vector<RtpHeaderExtension>& extensions); | 258 const std::vector<RtpHeaderExtension>& extensions); |
| 258 bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer); | 259 bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer); |
| 259 bool MuteStream(uint32 ssrc, bool mute); | 260 bool MuteStream(uint32 ssrc, bool mute); |
| 260 | 261 |
| 261 WebRtcVoiceEngine* engine() { return engine_; } | 262 WebRtcVoiceEngine* engine() { return engine_; } |
| 262 int GetLastEngineError() { return engine()->GetLastEngineError(); } | 263 int GetLastEngineError() { return engine()->GetLastEngineError(); } |
| 263 int GetOutputLevel(int channel); | 264 int GetOutputLevel(int channel); |
| 264 bool GetRedSendCodec(const AudioCodec& red_codec, | 265 bool GetRedSendCodec(const AudioCodec& red_codec, |
| 265 const std::vector<AudioCodec>& all_codecs, | 266 const std::vector<AudioCodec>& all_codecs, |
| 266 webrtc::CodecInst* send_codec); | 267 webrtc::CodecInst* send_codec); |
| 267 bool EnableRtcp(int channel); | 268 bool EnableRtcp(int channel); |
| 268 bool ResetRecvCodecs(int channel); | |
| 269 bool SetPlayout(int channel, bool playout); | 269 bool SetPlayout(int channel, bool playout); |
| 270 static uint32 ParseSsrc(const void* data, size_t len, bool rtcp); | |
| 271 static Error WebRtcErrorToChannelError(int err_code); | 270 static Error WebRtcErrorToChannelError(int err_code); |
| 272 | 271 |
| 273 class WebRtcVoiceChannelRenderer; | 272 class WebRtcVoiceChannelRenderer; |
| 274 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of | 273 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of |
| 275 // WebRtcVoiceChannelRenderer will be created for every new stream and | 274 // WebRtcVoiceChannelRenderer will be created for every new stream and |
| 276 // will be destroyed when the stream goes away. | 275 // will be destroyed when the stream goes away. |
| 277 typedef std::map<uint32, WebRtcVoiceChannelRenderer*> ChannelMap; | 276 typedef std::map<uint32, WebRtcVoiceChannelRenderer*> ChannelMap; |
| 278 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool, | 277 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool, |
| 279 unsigned char); | 278 unsigned char); |
| 280 | 279 |
| 281 void SetNack(int channel, bool nack_enabled); | 280 void SetNack(int channel, bool nack_enabled); |
| 282 void SetNack(const ChannelMap& channels, bool nack_enabled); | 281 void SetNack(const ChannelMap& channels, bool nack_enabled); |
| 283 bool SetSendCodec(const webrtc::CodecInst& send_codec); | 282 bool SetSendCodec(const webrtc::CodecInst& send_codec); |
| 284 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); | 283 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); |
| 285 bool ChangePlayout(bool playout); | 284 bool ChangePlayout(bool playout); |
| 286 bool ChangeSend(SendFlags send); | 285 bool ChangeSend(SendFlags send); |
| 287 bool ChangeSend(int channel, SendFlags send); | 286 bool ChangeSend(int channel, SendFlags send); |
| 288 void ConfigureSendChannel(int channel); | 287 void ConfigureSendChannel(int channel); |
| 289 bool ConfigureRecvChannel(int channel); | 288 bool ConfigureRecvChannel(int channel); |
| 290 bool DeleteChannel(int channel); | 289 bool DeleteChannel(int channel); |
| 291 bool InConferenceMode() const { | |
| 292 return options_.conference_mode.GetWithDefaultIfUnset(false); | |
| 293 } | |
| 294 bool IsDefaultChannel(int channel_id) const { | 290 bool IsDefaultChannel(int channel_id) const { |
| 295 return channel_id == voe_channel(); | 291 return channel_id == voe_channel(); |
| 296 } | 292 } |
| 297 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); | 293 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); |
| 298 bool SetSendBitrateInternal(int bps); | 294 bool SetSendBitrateInternal(int bps); |
| 299 | 295 |
| 300 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, | 296 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, |
| 301 const RtpHeaderExtension* extension); | 297 const RtpHeaderExtension* extension); |
| 302 void RecreateAudioReceiveStreams(); | 298 void RecreateAudioReceiveStreams(); |
| 303 void AddAudioReceiveStream(uint32 ssrc); | 299 void AddAudioReceiveStream(uint32 ssrc); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 323 AudioOptions options_; | 319 AudioOptions options_; |
| 324 bool dtmf_allowed_; | 320 bool dtmf_allowed_; |
| 325 bool desired_playout_; | 321 bool desired_playout_; |
| 326 bool nack_enabled_; | 322 bool nack_enabled_; |
| 327 bool playout_; | 323 bool playout_; |
| 328 bool typing_noise_detected_; | 324 bool typing_noise_detected_; |
| 329 SendFlags desired_send_; | 325 SendFlags desired_send_; |
| 330 SendFlags send_; | 326 SendFlags send_; |
| 331 webrtc::Call* const call_; | 327 webrtc::Call* const call_; |
| 332 | 328 |
| 329 uint32_t default_recv_ssrc_; |
| 330 int default_recv_channel_id_; |
| 331 |
| 333 // send_channels_ contains the channels which are being used for sending. | 332 // send_channels_ contains the channels which are being used for sending. |
| 334 // When the default channel (voe_channel) is used for sending, it is | 333 // When the default channel (voe_channel) is used for sending, it is |
| 335 // contained in send_channels_, otherwise not. | 334 // contained in send_channels_, otherwise not. |
| 336 ChannelMap send_channels_; | 335 ChannelMap send_channels_; |
| 337 std::vector<RtpHeaderExtension> send_extensions_; | 336 std::vector<RtpHeaderExtension> send_extensions_; |
| 338 uint32 default_receive_ssrc_; | 337 ChannelMap receive_channels_; |
| 339 // Note the default channel (voe_channel()) can reside in both | |
| 340 // receive_channels_ and send_channels_ in non-conference mode and in that | |
| 341 // case it will only be there if a non-zero default_receive_ssrc_ is set. | |
| 342 ChannelMap receive_channels_; // for multiple sources | |
| 343 std::map<uint32, webrtc::AudioReceiveStream*> receive_streams_; | 338 std::map<uint32, webrtc::AudioReceiveStream*> receive_streams_; |
| 344 std::map<uint32, StreamParams> receive_stream_params_; | 339 std::map<uint32, StreamParams> receive_stream_params_; |
| 345 // receive_channels_ can be read from WebRtc callback thread. Access from | 340 // receive_channels_ can be read from WebRtc callback thread. Access from |
| 346 // the WebRtc thread must be synchronized with edits on the worker thread. | 341 // the WebRtc thread must be synchronized with edits on the worker thread. |
| 347 // Reads on the worker thread are ok. | 342 // Reads on the worker thread are ok. |
| 348 std::vector<RtpHeaderExtension> receive_extensions_; | 343 std::vector<RtpHeaderExtension> receive_extensions_; |
| 349 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 344 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
| 350 | |
| 351 // Do not lock this on the VoE media processor thread; potential for deadlock | |
| 352 // exists. | |
| 353 mutable rtc::CriticalSection receive_channels_cs_; | |
| 354 }; | 345 }; |
| 355 | 346 |
| 356 } // namespace cricket | 347 } // namespace cricket |
| 357 | 348 |
| 358 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ | 349 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ |
| OLD | NEW |