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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 Settable<bool> extended_filter_aec_; | 275 Settable<bool> extended_filter_aec_; |
276 Settable<bool> delay_agnostic_aec_; | 276 Settable<bool> delay_agnostic_aec_; |
277 Settable<bool> experimental_ns_; | 277 Settable<bool> experimental_ns_; |
278 }; | 278 }; |
279 | 279 |
280 // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses | 280 // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses |
281 // WebRtc Voice Engine. | 281 // WebRtc Voice Engine. |
282 class WebRtcVoiceMediaChannel : public VoiceMediaChannel, | 282 class WebRtcVoiceMediaChannel : public VoiceMediaChannel, |
283 public webrtc::Transport { | 283 public webrtc::Transport { |
284 public: | 284 public: |
285 explicit WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, | 285 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, |
286 webrtc::Call* call); | 286 const AudioOptions& options, |
| 287 webrtc::Call* call); |
287 ~WebRtcVoiceMediaChannel() override; | 288 ~WebRtcVoiceMediaChannel() override; |
288 | 289 |
289 int voe_channel() const { return voe_channel_; } | 290 int voe_channel() const { return voe_channel_; } |
290 bool valid() const { return voe_channel_ != -1; } | 291 bool valid() const { return voe_channel_ != -1; } |
291 const AudioOptions& options() const { return options_; } | 292 const AudioOptions& options() const { return options_; } |
292 | 293 |
293 bool SetSendParameters(const AudioSendParameters& params) override; | 294 bool SetSendParameters(const AudioSendParameters& params) override; |
294 bool SetRecvParameters(const AudioRecvParameters& params) override; | 295 bool SetRecvParameters(const AudioRecvParameters& params) override; |
295 bool SetOptions(const AudioOptions& options) override; | |
296 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs) override; | |
297 bool SetSendCodecs(const std::vector<AudioCodec>& codecs) override; | |
298 bool SetRecvRtpHeaderExtensions( | |
299 const std::vector<RtpHeaderExtension>& extensions) override; | |
300 bool SetSendRtpHeaderExtensions( | |
301 const std::vector<RtpHeaderExtension>& extensions) override; | |
302 bool SetPlayout(bool playout) override; | 296 bool SetPlayout(bool playout) override; |
303 bool PausePlayout(); | 297 bool PausePlayout(); |
304 bool ResumePlayout(); | 298 bool ResumePlayout(); |
305 bool SetSend(SendFlags send) override; | 299 bool SetSend(SendFlags send) override; |
306 bool PauseSend(); | 300 bool PauseSend(); |
307 bool ResumeSend(); | 301 bool ResumeSend(); |
308 bool SetAudioSend(uint32 ssrc, bool mute, const AudioOptions* options, | 302 bool SetAudioSend(uint32 ssrc, bool mute, const AudioOptions* options, |
309 AudioRenderer* renderer) override; | 303 AudioRenderer* renderer) override; |
310 bool AddSendStream(const StreamParams& sp) override; | 304 bool AddSendStream(const StreamParams& sp) override; |
311 bool RemoveSendStream(uint32 ssrc) override; | 305 bool RemoveSendStream(uint32 ssrc) override; |
(...skipping 13 matching lines...) Expand all Loading... |
325 bool SetRingbackTone(const char* buf, int len) override; | 319 bool SetRingbackTone(const char* buf, int len) override; |
326 bool PlayRingbackTone(uint32 ssrc, bool play, bool loop) override; | 320 bool PlayRingbackTone(uint32 ssrc, bool play, bool loop) override; |
327 bool CanInsertDtmf() override; | 321 bool CanInsertDtmf() override; |
328 bool InsertDtmf(uint32 ssrc, int event, int duration, int flags) override; | 322 bool InsertDtmf(uint32 ssrc, int event, int duration, int flags) override; |
329 | 323 |
330 void OnPacketReceived(rtc::Buffer* packet, | 324 void OnPacketReceived(rtc::Buffer* packet, |
331 const rtc::PacketTime& packet_time) override; | 325 const rtc::PacketTime& packet_time) override; |
332 void OnRtcpReceived(rtc::Buffer* packet, | 326 void OnRtcpReceived(rtc::Buffer* packet, |
333 const rtc::PacketTime& packet_time) override; | 327 const rtc::PacketTime& packet_time) override; |
334 void OnReadyToSend(bool ready) override {} | 328 void OnReadyToSend(bool ready) override {} |
335 bool SetMaxSendBandwidth(int bps) override; | |
336 bool GetStats(VoiceMediaInfo* info) override; | 329 bool GetStats(VoiceMediaInfo* info) override; |
337 // Gets last reported error from WebRtc voice engine. This should be only | 330 // Gets last reported error from WebRtc voice engine. This should be only |
338 // called in response a failure. | 331 // called in response a failure. |
339 void GetLastMediaError(uint32* ssrc, | 332 void GetLastMediaError(uint32* ssrc, |
340 VoiceMediaChannel::Error* error) override; | 333 VoiceMediaChannel::Error* error) override; |
341 | 334 |
342 // implements Transport interface | 335 // implements Transport interface |
343 int SendPacket(int channel, const void* data, size_t len) override { | 336 int SendPacket(int channel, const void* data, size_t len) override { |
344 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len, | 337 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len, |
345 kMaxRtpPacketLen); | 338 kMaxRtpPacketLen); |
346 return VoiceMediaChannel::SendPacket(&packet) ? static_cast<int>(len) : -1; | 339 return VoiceMediaChannel::SendPacket(&packet) ? static_cast<int>(len) : -1; |
347 } | 340 } |
348 | 341 |
349 int SendRTCPPacket(int channel, const void* data, size_t len) override { | 342 int SendRTCPPacket(int channel, const void* data, size_t len) override { |
350 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len, | 343 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len, |
351 kMaxRtpPacketLen); | 344 kMaxRtpPacketLen); |
352 return VoiceMediaChannel::SendRtcp(&packet) ? static_cast<int>(len) : -1; | 345 return VoiceMediaChannel::SendRtcp(&packet) ? static_cast<int>(len) : -1; |
353 } | 346 } |
354 | 347 |
355 bool FindSsrc(int channel_num, uint32* ssrc); | 348 bool FindSsrc(int channel_num, uint32* ssrc); |
356 void OnError(uint32 ssrc, int error); | 349 void OnError(uint32 ssrc, int error); |
357 | 350 |
358 bool sending() const { return send_ != SEND_NOTHING; } | 351 bool sending() const { return send_ != SEND_NOTHING; } |
359 int GetReceiveChannelNum(uint32 ssrc) const; | 352 int GetReceiveChannelNum(uint32 ssrc) const; |
360 int GetSendChannelNum(uint32 ssrc) const; | 353 int GetSendChannelNum(uint32 ssrc) const; |
361 | 354 |
362 private: | 355 private: |
| 356 bool SetSendCodecs(const std::vector<AudioCodec>& codecs); |
| 357 bool SetSendRtpHeaderExtensions( |
| 358 const std::vector<RtpHeaderExtension>& extensions); |
| 359 bool SetOptions(const AudioOptions& options); |
| 360 bool SetMaxSendBandwidth(int bps); |
| 361 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs); |
| 362 bool SetRecvRtpHeaderExtensions( |
| 363 const std::vector<RtpHeaderExtension>& extensions); |
363 bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer); | 364 bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer); |
364 bool MuteStream(uint32 ssrc, bool mute); | 365 bool MuteStream(uint32 ssrc, bool mute); |
| 366 |
365 WebRtcVoiceEngine* engine() { return engine_; } | 367 WebRtcVoiceEngine* engine() { return engine_; } |
366 int GetLastEngineError() { return engine()->GetLastEngineError(); } | 368 int GetLastEngineError() { return engine()->GetLastEngineError(); } |
367 int GetOutputLevel(int channel); | 369 int GetOutputLevel(int channel); |
368 bool GetRedSendCodec(const AudioCodec& red_codec, | 370 bool GetRedSendCodec(const AudioCodec& red_codec, |
369 const std::vector<AudioCodec>& all_codecs, | 371 const std::vector<AudioCodec>& all_codecs, |
370 webrtc::CodecInst* send_codec); | 372 webrtc::CodecInst* send_codec); |
371 bool EnableRtcp(int channel); | 373 bool EnableRtcp(int channel); |
372 bool ResetRecvCodecs(int channel); | 374 bool ResetRecvCodecs(int channel); |
373 bool SetPlayout(int channel, bool playout); | 375 bool SetPlayout(int channel, bool playout); |
374 static uint32 ParseSsrc(const void* data, size_t len, bool rtcp); | 376 static uint32 ParseSsrc(const void* data, size_t len, bool rtcp); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 457 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
456 | 458 |
457 // Do not lock this on the VoE media processor thread; potential for deadlock | 459 // Do not lock this on the VoE media processor thread; potential for deadlock |
458 // exists. | 460 // exists. |
459 mutable rtc::CriticalSection receive_channels_cs_; | 461 mutable rtc::CriticalSection receive_channels_cs_; |
460 }; | 462 }; |
461 | 463 |
462 } // namespace cricket | 464 } // namespace cricket |
463 | 465 |
464 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ | 466 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ |
OLD | NEW |