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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses | 173 // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses |
174 // WebRtc Voice Engine. | 174 // WebRtc Voice Engine. |
175 class WebRtcVoiceMediaChannel : public VoiceMediaChannel, | 175 class WebRtcVoiceMediaChannel : public VoiceMediaChannel, |
176 public webrtc::Transport { | 176 public webrtc::Transport { |
177 public: | 177 public: |
178 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, | 178 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, |
179 const AudioOptions& options, | 179 const AudioOptions& options, |
180 webrtc::Call* call); | 180 webrtc::Call* call); |
181 ~WebRtcVoiceMediaChannel() override; | 181 ~WebRtcVoiceMediaChannel() override; |
182 | 182 |
183 int voe_channel() const { return voe_channel_; } | 183 int default_send_channel_id() const { return default_send_channel_id_; } |
184 bool valid() const { return voe_channel_ != -1; } | 184 bool valid() const { return default_send_channel_id_ != -1; } |
185 const AudioOptions& options() const { return options_; } | 185 const AudioOptions& options() const { return options_; } |
186 | 186 |
187 bool SetSendParameters(const AudioSendParameters& params) override; | 187 bool SetSendParameters(const AudioSendParameters& params) override; |
188 bool SetRecvParameters(const AudioRecvParameters& params) override; | 188 bool SetRecvParameters(const AudioRecvParameters& params) override; |
189 bool SetPlayout(bool playout) override; | 189 bool SetPlayout(bool playout) override; |
190 bool PausePlayout(); | 190 bool PausePlayout(); |
191 bool ResumePlayout(); | 191 bool ResumePlayout(); |
192 bool SetSend(SendFlags send) override; | 192 bool SetSend(SendFlags send) override; |
193 bool PauseSend(); | 193 bool PauseSend(); |
194 bool ResumeSend(); | 194 bool ResumeSend(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 bool ChangePlayout(bool playout); | 279 bool ChangePlayout(bool playout); |
280 bool ChangeSend(SendFlags send); | 280 bool ChangeSend(SendFlags send); |
281 bool ChangeSend(int channel, SendFlags send); | 281 bool ChangeSend(int channel, SendFlags send); |
282 void ConfigureSendChannel(int channel); | 282 void ConfigureSendChannel(int channel); |
283 bool ConfigureRecvChannel(int channel); | 283 bool ConfigureRecvChannel(int channel); |
284 bool DeleteChannel(int channel); | 284 bool DeleteChannel(int channel); |
285 bool InConferenceMode() const { | 285 bool InConferenceMode() const { |
286 return options_.conference_mode.GetWithDefaultIfUnset(false); | 286 return options_.conference_mode.GetWithDefaultIfUnset(false); |
287 } | 287 } |
288 bool IsDefaultChannel(int channel_id) const { | 288 bool IsDefaultChannel(int channel_id) const { |
289 return channel_id == voe_channel(); | 289 return channel_id == default_send_channel_id_; |
290 } | 290 } |
291 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); | 291 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); |
292 bool SetSendBitrateInternal(int bps); | 292 bool SetSendBitrateInternal(int bps); |
293 | 293 |
294 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, | 294 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, |
295 const RtpHeaderExtension* extension); | 295 const RtpHeaderExtension* extension); |
296 void RecreateAudioReceiveStreams(); | 296 void RecreateAudioReceiveStreams(); |
297 void AddAudioReceiveStream(uint32_t ssrc); | 297 void AddAudioReceiveStream(uint32_t ssrc); |
298 void RemoveAudioReceiveStream(uint32_t ssrc); | 298 void RemoveAudioReceiveStream(uint32_t ssrc); |
299 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs); | 299 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs); |
300 | 300 |
301 bool SetChannelRecvRtpHeaderExtensions( | 301 bool SetChannelRecvRtpHeaderExtensions( |
302 int channel_id, | 302 int channel_id, |
303 const std::vector<RtpHeaderExtension>& extensions); | 303 const std::vector<RtpHeaderExtension>& extensions); |
304 bool SetChannelSendRtpHeaderExtensions( | 304 bool SetChannelSendRtpHeaderExtensions( |
305 int channel_id, | 305 int channel_id, |
306 const std::vector<RtpHeaderExtension>& extensions); | 306 const std::vector<RtpHeaderExtension>& extensions); |
307 | 307 |
308 rtc::ThreadChecker thread_checker_; | 308 rtc::ThreadChecker thread_checker_; |
309 | 309 |
310 WebRtcVoiceEngine* const engine_; | 310 WebRtcVoiceEngine* const engine_; |
311 const int voe_channel_; | 311 const int default_send_channel_id_; |
312 std::vector<AudioCodec> recv_codecs_; | 312 std::vector<AudioCodec> recv_codecs_; |
313 std::vector<AudioCodec> send_codecs_; | 313 std::vector<AudioCodec> send_codecs_; |
314 rtc::scoped_ptr<webrtc::CodecInst> send_codec_; | 314 rtc::scoped_ptr<webrtc::CodecInst> send_codec_; |
315 bool send_bitrate_setting_; | 315 bool send_bitrate_setting_; |
316 int send_bitrate_bps_; | 316 int send_bitrate_bps_; |
317 AudioOptions options_; | 317 AudioOptions options_; |
318 bool dtmf_allowed_; | 318 bool dtmf_allowed_; |
319 bool desired_playout_; | 319 bool desired_playout_; |
320 bool nack_enabled_; | 320 bool nack_enabled_; |
321 bool playout_; | 321 bool playout_; |
322 bool typing_noise_detected_; | 322 bool typing_noise_detected_; |
323 SendFlags desired_send_; | 323 SendFlags desired_send_; |
324 SendFlags send_; | 324 SendFlags send_; |
325 webrtc::Call* const call_; | 325 webrtc::Call* const call_; |
326 | 326 |
327 // send_channels_ contains the channels which are being used for sending. | 327 // send_channels_ contains the channels which are being used for sending. |
328 // When the default channel (voe_channel) is used for sending, it is | 328 // When the default channel (default_send_channel_id) is used for sending, it |
329 // contained in send_channels_, otherwise not. | 329 // is contained in send_channels_, otherwise not. |
330 ChannelMap send_channels_; | 330 ChannelMap send_channels_; |
331 std::vector<RtpHeaderExtension> send_extensions_; | 331 std::vector<RtpHeaderExtension> send_extensions_; |
332 uint32_t default_receive_ssrc_; | 332 uint32_t default_receive_ssrc_; |
333 // Note the default channel (voe_channel()) can reside in both | 333 // Note the default channel (default_send_channel_id()) can reside in both |
334 // receive_channels_ and send_channels_ in non-conference mode and in that | 334 // receive_channels_ and send_channels_ in non-conference mode and in that |
335 // case it will only be there if a non-zero default_receive_ssrc_ is set. | 335 // case it will only be there if a non-zero default_receive_ssrc_ is set. |
336 ChannelMap receive_channels_; // for multiple sources | 336 ChannelMap receive_channels_; // for multiple sources |
337 std::map<uint32_t, webrtc::AudioReceiveStream*> receive_streams_; | 337 std::map<uint32_t, webrtc::AudioReceiveStream*> receive_streams_; |
338 std::map<uint32_t, StreamParams> receive_stream_params_; | 338 std::map<uint32_t, StreamParams> receive_stream_params_; |
339 // receive_channels_ can be read from WebRtc callback thread. Access from | 339 // receive_channels_ can be read from WebRtc callback thread. Access from |
340 // the WebRtc thread must be synchronized with edits on the worker thread. | 340 // the WebRtc thread must be synchronized with edits on the worker thread. |
341 // Reads on the worker thread are ok. | 341 // Reads on the worker thread are ok. |
342 std::vector<RtpHeaderExtension> receive_extensions_; | 342 std::vector<RtpHeaderExtension> receive_extensions_; |
343 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 343 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
344 | 344 |
345 // Do not lock this on the VoE media processor thread; potential for deadlock | 345 // Do not lock this on the VoE media processor thread; potential for deadlock |
346 // exists. | 346 // exists. |
347 mutable rtc::CriticalSection receive_channels_cs_; | 347 mutable rtc::CriticalSection receive_channels_cs_; |
348 }; | 348 }; |
349 | 349 |
350 } // namespace cricket | 350 } // namespace cricket |
351 | 351 |
352 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ | 352 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ |
OLD | NEW |