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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses | 176 // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses |
177 // WebRtc Voice Engine. | 177 // WebRtc Voice Engine. |
178 class WebRtcVoiceMediaChannel : public VoiceMediaChannel, | 178 class WebRtcVoiceMediaChannel : public VoiceMediaChannel, |
179 public webrtc::Transport { | 179 public webrtc::Transport { |
180 public: | 180 public: |
181 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, | 181 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, |
182 const AudioOptions& options, | 182 const AudioOptions& options, |
183 webrtc::Call* call); | 183 webrtc::Call* call); |
184 ~WebRtcVoiceMediaChannel() override; | 184 ~WebRtcVoiceMediaChannel() override; |
185 | 185 |
186 int voe_channel() const { return voe_channel_; } | 186 int voe_channel() const { return voe_channel_; } |
pthatcher1
2015/10/02 02:33:31
Can you rename this default_channel_id() or defaul
the sun
2015/10/02 11:34:20
Done.
| |
187 bool valid() const { return voe_channel_ != -1; } | 187 bool valid() const { return voe_channel_ != -1; } |
188 const AudioOptions& options() const { return options_; } | 188 const AudioOptions& options() const { return options_; } |
189 | 189 |
190 bool SetSendParameters(const AudioSendParameters& params) override; | 190 bool SetSendParameters(const AudioSendParameters& params) override; |
191 bool SetRecvParameters(const AudioRecvParameters& params) override; | 191 bool SetRecvParameters(const AudioRecvParameters& params) override; |
192 bool SetPlayout(bool playout) override; | 192 bool SetPlayout(bool playout) override; |
193 bool PausePlayout(); | 193 bool PausePlayout(); |
194 bool ResumePlayout(); | 194 bool ResumePlayout(); |
195 bool SetSend(SendFlags send) override; | 195 bool SetSend(SendFlags send) override; |
196 bool PauseSend(); | 196 bool PauseSend(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 void OnError(uint32 ssrc, int error); | 239 void OnError(uint32 ssrc, int error); |
240 | 240 |
241 int GetReceiveChannelNum(uint32 ssrc) const; | 241 int GetReceiveChannelNum(uint32 ssrc) const; |
242 int GetSendChannelNum(uint32 ssrc) const; | 242 int GetSendChannelNum(uint32 ssrc) const; |
243 | 243 |
244 private: | 244 private: |
245 bool SetSendCodecs(const std::vector<AudioCodec>& codecs); | 245 bool SetSendCodecs(const std::vector<AudioCodec>& codecs); |
246 bool SetSendRtpHeaderExtensions( | 246 bool SetSendRtpHeaderExtensions( |
247 const std::vector<RtpHeaderExtension>& extensions); | 247 const std::vector<RtpHeaderExtension>& extensions); |
248 bool SetOptions(const AudioOptions& options); | 248 bool SetOptions(const AudioOptions& options); |
249 bool SetRecvOptions(int channel_id); | |
249 bool SetMaxSendBandwidth(int bps); | 250 bool SetMaxSendBandwidth(int bps); |
250 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs); | 251 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs); |
251 bool SetRecvRtpHeaderExtensions( | 252 bool SetRecvRtpHeaderExtensions( |
252 const std::vector<RtpHeaderExtension>& extensions); | 253 const std::vector<RtpHeaderExtension>& extensions); |
253 bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer); | 254 bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer); |
254 bool MuteStream(uint32 ssrc, bool mute); | 255 bool MuteStream(uint32 ssrc, bool mute); |
255 | 256 |
256 WebRtcVoiceEngine* engine() { return engine_; } | 257 WebRtcVoiceEngine* engine() { return engine_; } |
257 int GetLastEngineError() { return engine()->GetLastEngineError(); } | 258 int GetLastEngineError() { return engine()->GetLastEngineError(); } |
258 int GetOutputLevel(int channel); | 259 int GetOutputLevel(int channel); |
259 bool GetRedSendCodec(const AudioCodec& red_codec, | 260 bool GetRedSendCodec(const AudioCodec& red_codec, |
260 const std::vector<AudioCodec>& all_codecs, | 261 const std::vector<AudioCodec>& all_codecs, |
261 webrtc::CodecInst* send_codec); | 262 webrtc::CodecInst* send_codec); |
262 bool EnableRtcp(int channel); | 263 bool EnableRtcp(int channel); |
263 bool ResetRecvCodecs(int channel); | |
264 bool SetPlayout(int channel, bool playout); | 264 bool SetPlayout(int channel, bool playout); |
265 static uint32 ParseSsrc(const void* data, size_t len, bool rtcp); | |
266 static Error WebRtcErrorToChannelError(int err_code); | 265 static Error WebRtcErrorToChannelError(int err_code); |
267 | 266 |
268 class WebRtcVoiceChannelRenderer; | 267 class WebRtcVoiceChannelRenderer; |
269 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of | 268 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of |
270 // WebRtcVoiceChannelRenderer will be created for every new stream and | 269 // WebRtcVoiceChannelRenderer will be created for every new stream and |
271 // will be destroyed when the stream goes away. | 270 // will be destroyed when the stream goes away. |
272 typedef std::map<uint32, WebRtcVoiceChannelRenderer*> ChannelMap; | 271 typedef std::map<uint32, WebRtcVoiceChannelRenderer*> ChannelMap; |
273 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool, | 272 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool, |
274 unsigned char); | 273 unsigned char); |
275 | 274 |
276 void SetNack(int channel, bool nack_enabled); | 275 void SetNack(int channel, bool nack_enabled); |
277 void SetNack(const ChannelMap& channels, bool nack_enabled); | 276 void SetNack(const ChannelMap& channels, bool nack_enabled); |
278 bool SetSendCodec(const webrtc::CodecInst& send_codec); | 277 bool SetSendCodec(const webrtc::CodecInst& send_codec); |
279 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); | 278 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); |
280 bool ChangePlayout(bool playout); | 279 bool ChangePlayout(bool playout); |
281 bool ChangeSend(SendFlags send); | 280 bool ChangeSend(SendFlags send); |
282 bool ChangeSend(int channel, SendFlags send); | 281 bool ChangeSend(int channel, SendFlags send); |
283 void ConfigureSendChannel(int channel); | 282 void ConfigureSendChannel(int channel); |
284 bool ConfigureRecvChannel(int channel); | 283 bool ConfigureRecvChannel(int channel); |
285 bool DeleteChannel(int channel); | 284 bool DeleteChannel(int channel); |
286 bool InConferenceMode() const { | |
287 return options_.conference_mode.GetWithDefaultIfUnset(false); | |
288 } | |
289 bool IsDefaultChannel(int channel_id) const { | 285 bool IsDefaultChannel(int channel_id) const { |
290 return channel_id == voe_channel(); | 286 return channel_id == voe_channel(); |
291 } | 287 } |
292 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); | 288 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); |
293 bool SetSendBitrateInternal(int bps); | 289 bool SetSendBitrateInternal(int bps); |
294 | 290 |
295 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, | 291 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, |
296 const RtpHeaderExtension* extension); | 292 const RtpHeaderExtension* extension); |
297 void RecreateAudioReceiveStreams(); | 293 void RecreateAudioReceiveStreams(); |
298 void AddAudioReceiveStream(uint32 ssrc); | 294 void AddAudioReceiveStream(uint32 ssrc); |
299 void RemoveAudioReceiveStream(uint32 ssrc); | 295 void RemoveAudioReceiveStream(uint32 ssrc); |
300 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs); | 296 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs); |
301 | 297 |
302 bool SetChannelRecvRtpHeaderExtensions( | 298 bool SetChannelRecvRtpHeaderExtensions( |
303 int channel_id, | 299 int channel_id, |
304 const std::vector<RtpHeaderExtension>& extensions); | 300 const std::vector<RtpHeaderExtension>& extensions); |
305 bool SetChannelSendRtpHeaderExtensions( | 301 bool SetChannelSendRtpHeaderExtensions( |
306 int channel_id, | 302 int channel_id, |
307 const std::vector<RtpHeaderExtension>& extensions); | 303 const std::vector<RtpHeaderExtension>& extensions); |
308 | 304 |
309 rtc::ThreadChecker thread_checker_; | 305 rtc::ThreadChecker thread_checker_; |
310 | 306 |
311 WebRtcVoiceEngine* const engine_; | 307 WebRtcVoiceEngine* const engine_; |
312 const int voe_channel_; | 308 const int voe_channel_; |
pthatcher1
2015/10/02 02:33:31
Can you rename this default_channel_id_ or default
the sun
2015/10/02 11:34:20
Done.
| |
313 std::vector<AudioCodec> recv_codecs_; | 309 std::vector<AudioCodec> recv_codecs_; |
314 std::vector<AudioCodec> send_codecs_; | 310 std::vector<AudioCodec> send_codecs_; |
315 rtc::scoped_ptr<webrtc::CodecInst> send_codec_; | 311 rtc::scoped_ptr<webrtc::CodecInst> send_codec_; |
316 bool send_bitrate_setting_; | 312 bool send_bitrate_setting_; |
317 int send_bitrate_bps_; | 313 int send_bitrate_bps_; |
318 AudioOptions options_; | 314 AudioOptions options_; |
319 bool dtmf_allowed_; | 315 bool dtmf_allowed_; |
320 bool desired_playout_; | 316 bool desired_playout_; |
321 bool nack_enabled_; | 317 bool nack_enabled_; |
322 bool playout_; | 318 bool playout_; |
323 bool typing_noise_detected_; | 319 bool typing_noise_detected_; |
324 SendFlags desired_send_; | 320 SendFlags desired_send_; |
325 SendFlags send_; | 321 SendFlags send_; |
326 webrtc::Call* const call_; | 322 webrtc::Call* const call_; |
327 | 323 |
324 uint32_t default_recv_ssrc_; | |
325 int default_recv_channel_id_; | |
pthatcher1
2015/10/02 02:33:31
Why do we store the default_recv_channel_id_ when
the sun
2015/10/02 11:34:20
You're right; I was using it as a flag anyway.
| |
326 | |
328 // send_channels_ contains the channels which are being used for sending. | 327 // send_channels_ contains the channels which are being used for sending. |
329 // When the default channel (voe_channel) is used for sending, it is | 328 // When the default channel (voe_channel) is used for sending, it is |
330 // contained in send_channels_, otherwise not. | 329 // contained in send_channels_, otherwise not. |
331 ChannelMap send_channels_; | 330 ChannelMap send_channels_; |
332 std::vector<RtpHeaderExtension> send_extensions_; | 331 std::vector<RtpHeaderExtension> send_extensions_; |
333 uint32 default_receive_ssrc_; | 332 ChannelMap receive_channels_; |
334 // Note the default channel (voe_channel()) can reside in both | |
335 // receive_channels_ and send_channels_ in non-conference mode and in that | |
336 // case it will only be there if a non-zero default_receive_ssrc_ is set. | |
337 ChannelMap receive_channels_; // for multiple sources | |
338 std::map<uint32, webrtc::AudioReceiveStream*> receive_streams_; | 333 std::map<uint32, webrtc::AudioReceiveStream*> receive_streams_; |
339 std::map<uint32, StreamParams> receive_stream_params_; | 334 std::map<uint32, StreamParams> receive_stream_params_; |
340 // receive_channels_ can be read from WebRtc callback thread. Access from | 335 // receive_channels_ can be read from WebRtc callback thread. Access from |
341 // the WebRtc thread must be synchronized with edits on the worker thread. | 336 // the WebRtc thread must be synchronized with edits on the worker thread. |
342 // Reads on the worker thread are ok. | 337 // Reads on the worker thread are ok. |
343 std::vector<RtpHeaderExtension> receive_extensions_; | 338 std::vector<RtpHeaderExtension> receive_extensions_; |
344 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 339 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
345 | |
346 // Do not lock this on the VoE media processor thread; potential for deadlock | |
347 // exists. | |
348 mutable rtc::CriticalSection receive_channels_cs_; | |
349 }; | 340 }; |
350 | 341 |
351 } // namespace cricket | 342 } // namespace cricket |
352 | 343 |
353 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ | 344 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ |
OLD | NEW |