Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(672)

Side by Side Diff: talk/media/webrtc/webrtcvoiceengine.h

Issue 1269863005: MediaController/Call instantiation. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 public: 94 public:
95 WebRtcVoiceEngine(); 95 WebRtcVoiceEngine();
96 // Dependency injection for testing. 96 // Dependency injection for testing.
97 WebRtcVoiceEngine(VoEWrapper* voe_wrapper, VoETraceWrapper* tracing); 97 WebRtcVoiceEngine(VoEWrapper* voe_wrapper, VoETraceWrapper* tracing);
98 ~WebRtcVoiceEngine(); 98 ~WebRtcVoiceEngine();
99 bool Init(rtc::Thread* worker_thread); 99 bool Init(rtc::Thread* worker_thread);
100 void Terminate(); 100 void Terminate();
101 101
102 int GetCapabilities(); 102 int GetCapabilities();
103 VoiceMediaChannel* CreateChannel(const AudioOptions& options); 103 webrtc::VoiceEngine* GetVoE() { return voe()->engine(); }
104 VoiceMediaChannel* CreateChannel(webrtc::Call* call,
105 const AudioOptions& options);
104 106
105 AudioOptions GetOptions() const { return options_; } 107 AudioOptions GetOptions() const { return options_; }
106 bool SetOptions(const AudioOptions& options); 108 bool SetOptions(const AudioOptions& options);
107 bool SetDelayOffset(int offset); 109 bool SetDelayOffset(int offset);
108 bool SetDevices(const Device* in_device, const Device* out_device); 110 bool SetDevices(const Device* in_device, const Device* out_device);
109 bool GetOutputVolume(int* level); 111 bool GetOutputVolume(int* level);
110 bool SetOutputVolume(int level); 112 bool SetOutputVolume(int level);
111 int GetInputLevel(); 113 int GetInputLevel();
112 bool SetLocalMonitor(bool enable); 114 bool SetLocalMonitor(bool enable);
113 115
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 Settable<bool> extended_filter_aec_; 275 Settable<bool> extended_filter_aec_;
274 Settable<bool> delay_agnostic_aec_; 276 Settable<bool> delay_agnostic_aec_;
275 Settable<bool> experimental_ns_; 277 Settable<bool> experimental_ns_;
276 }; 278 };
277 279
278 // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses 280 // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses
279 // WebRtc Voice Engine. 281 // WebRtc Voice Engine.
280 class WebRtcVoiceMediaChannel : public VoiceMediaChannel, 282 class WebRtcVoiceMediaChannel : public VoiceMediaChannel,
281 public webrtc::Transport { 283 public webrtc::Transport {
282 public: 284 public:
283 explicit WebRtcVoiceMediaChannel(WebRtcVoiceEngine *engine); 285 explicit WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine,
286 webrtc::Call* call);
284 ~WebRtcVoiceMediaChannel() override; 287 ~WebRtcVoiceMediaChannel() override;
285 288
286 int voe_channel() const { return voe_channel_; } 289 int voe_channel() const { return voe_channel_; }
287 bool valid() const { return voe_channel_ != -1; } 290 bool valid() const { return voe_channel_ != -1; }
288 291
289 bool SetSendParameters(const AudioSendParameters& params) override; 292 bool SetSendParameters(const AudioSendParameters& params) override;
290 bool SetRecvParameters(const AudioRecvParameters& params) override; 293 bool SetRecvParameters(const AudioRecvParameters& params) override;
291 bool SetOptions(const AudioOptions& options) override; 294 bool SetOptions(const AudioOptions& options) override;
292 bool GetOptions(AudioOptions* options) const override { 295 bool GetOptions(AudioOptions* options) const override {
293 *options = options_; 296 *options = options_;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 return VoiceMediaChannel::SendRtcp(&packet) ? static_cast<int>(len) : -1; 355 return VoiceMediaChannel::SendRtcp(&packet) ? static_cast<int>(len) : -1;
353 } 356 }
354 357
355 bool FindSsrc(int channel_num, uint32* ssrc); 358 bool FindSsrc(int channel_num, uint32* ssrc);
356 void OnError(uint32 ssrc, int error); 359 void OnError(uint32 ssrc, int error);
357 360
358 bool sending() const { return send_ != SEND_NOTHING; } 361 bool sending() const { return send_ != SEND_NOTHING; }
359 int GetReceiveChannelNum(uint32 ssrc) const; 362 int GetReceiveChannelNum(uint32 ssrc) const;
360 int GetSendChannelNum(uint32 ssrc) const; 363 int GetSendChannelNum(uint32 ssrc) const;
361 364
362 void SetCall(webrtc::Call* call);
363
364 private: 365 private:
365 WebRtcVoiceEngine* engine() { return engine_; } 366 WebRtcVoiceEngine* engine() { return engine_; }
366 int GetLastEngineError() { return engine()->GetLastEngineError(); } 367 int GetLastEngineError() { return engine()->GetLastEngineError(); }
367 int GetOutputLevel(int channel); 368 int GetOutputLevel(int channel);
368 bool GetRedSendCodec(const AudioCodec& red_codec, 369 bool GetRedSendCodec(const AudioCodec& red_codec,
369 const std::vector<AudioCodec>& all_codecs, 370 const std::vector<AudioCodec>& all_codecs,
370 webrtc::CodecInst* send_codec); 371 webrtc::CodecInst* send_codec);
371 bool EnableRtcp(int channel); 372 bool EnableRtcp(int channel);
372 bool ResetRecvCodecs(int channel); 373 bool ResetRecvCodecs(int channel);
373 bool SetPlayout(int channel, bool playout); 374 bool SetPlayout(int channel, bool playout);
(...skipping 22 matching lines...) Expand all
396 return options_.conference_mode.GetWithDefaultIfUnset(false); 397 return options_.conference_mode.GetWithDefaultIfUnset(false);
397 } 398 }
398 bool IsDefaultChannel(int channel_id) const { 399 bool IsDefaultChannel(int channel_id) const {
399 return channel_id == voe_channel(); 400 return channel_id == voe_channel();
400 } 401 }
401 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); 402 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs);
402 bool SetSendBitrateInternal(int bps); 403 bool SetSendBitrateInternal(int bps);
403 404
404 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, 405 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id,
405 const RtpHeaderExtension* extension); 406 const RtpHeaderExtension* extension);
406 void TryAddAudioRecvStream(uint32 ssrc); 407 void RecreateAudioReceiveStreams();
407 void TryRemoveAudioRecvStream(uint32 ssrc); 408 void AddAudioReceiveStream(uint32 ssrc);
409 void RemoveAudioReceiveStream(uint32 ssrc);
408 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs); 410 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs);
409 411
410 bool SetChannelRecvRtpHeaderExtensions( 412 bool SetChannelRecvRtpHeaderExtensions(
411 int channel_id, 413 int channel_id,
412 const std::vector<RtpHeaderExtension>& extensions); 414 const std::vector<RtpHeaderExtension>& extensions);
413 bool SetChannelSendRtpHeaderExtensions( 415 bool SetChannelSendRtpHeaderExtensions(
414 int channel_id, 416 int channel_id,
415 const std::vector<RtpHeaderExtension>& extensions); 417 const std::vector<RtpHeaderExtension>& extensions);
416 418
417 rtc::ThreadChecker thread_checker_; 419 rtc::ThreadChecker thread_checker_;
418 420
419 WebRtcVoiceEngine* engine_; 421 WebRtcVoiceEngine* const engine_;
pthatcher1 2015/09/09 07:27:43 Why WebRtcVoiceEngine const engine_; Instead of
pbos-webrtc 2015/09/09 07:58:46 Pointer is const and doesn't change, but the objec
the sun 2015/09/09 08:24:51 The first one declares that the *pointer* is const
420 const int voe_channel_; 422 const int voe_channel_;
421 rtc::scoped_ptr<WebRtcSoundclipStream> ringback_tone_; 423 rtc::scoped_ptr<WebRtcSoundclipStream> ringback_tone_;
422 std::set<int> ringback_channels_; // channels playing ringback 424 std::set<int> ringback_channels_; // channels playing ringback
423 std::vector<AudioCodec> recv_codecs_; 425 std::vector<AudioCodec> recv_codecs_;
424 std::vector<AudioCodec> send_codecs_; 426 std::vector<AudioCodec> send_codecs_;
425 rtc::scoped_ptr<webrtc::CodecInst> send_codec_; 427 rtc::scoped_ptr<webrtc::CodecInst> send_codec_;
426 bool send_bitrate_setting_; 428 bool send_bitrate_setting_;
427 int send_bitrate_bps_; 429 int send_bitrate_bps_;
428 AudioOptions options_; 430 AudioOptions options_;
429 bool dtmf_allowed_; 431 bool dtmf_allowed_;
430 bool desired_playout_; 432 bool desired_playout_;
431 bool nack_enabled_; 433 bool nack_enabled_;
432 bool playout_; 434 bool playout_;
433 bool typing_noise_detected_; 435 bool typing_noise_detected_;
434 SendFlags desired_send_; 436 SendFlags desired_send_;
435 SendFlags send_; 437 SendFlags send_;
436 webrtc::Call* call_; 438 webrtc::Call* const call_;
437 439
438 // send_channels_ contains the channels which are being used for sending. 440 // send_channels_ contains the channels which are being used for sending.
439 // When the default channel (voe_channel) is used for sending, it is 441 // When the default channel (voe_channel) is used for sending, it is
440 // contained in send_channels_, otherwise not. 442 // contained in send_channels_, otherwise not.
441 ChannelMap send_channels_; 443 ChannelMap send_channels_;
442 std::vector<RtpHeaderExtension> send_extensions_; 444 std::vector<RtpHeaderExtension> send_extensions_;
443 uint32 default_receive_ssrc_; 445 uint32 default_receive_ssrc_;
444 // Note the default channel (voe_channel()) can reside in both 446 // Note the default channel (voe_channel()) can reside in both
445 // receive_channels_ and send_channels_ in non-conference mode and in that 447 // receive_channels_ and send_channels_ in non-conference mode and in that
446 // case it will only be there if a non-zero default_receive_ssrc_ is set. 448 // case it will only be there if a non-zero default_receive_ssrc_ is set.
447 ChannelMap receive_channels_; // for multiple sources 449 ChannelMap receive_channels_; // for multiple sources
448 std::map<uint32, webrtc::AudioReceiveStream*> receive_streams_; 450 std::map<uint32, webrtc::AudioReceiveStream*> receive_streams_;
449 std::map<uint32, StreamParams> receive_stream_params_; 451 std::map<uint32, StreamParams> receive_stream_params_;
450 // receive_channels_ can be read from WebRtc callback thread. Access from 452 // receive_channels_ can be read from WebRtc callback thread. Access from
451 // the WebRtc thread must be synchronized with edits on the worker thread. 453 // the WebRtc thread must be synchronized with edits on the worker thread.
452 // Reads on the worker thread are ok. 454 // Reads on the worker thread are ok.
453 std::vector<RtpHeaderExtension> receive_extensions_; 455 std::vector<RtpHeaderExtension> receive_extensions_;
454 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; 456 std::vector<webrtc::RtpExtension> recv_rtp_extensions_;
455 457
456 // Do not lock this on the VoE media processor thread; potential for deadlock 458 // Do not lock this on the VoE media processor thread; potential for deadlock
457 // exists. 459 // exists.
458 mutable rtc::CriticalSection receive_channels_cs_; 460 mutable rtc::CriticalSection receive_channels_cs_;
459 }; 461 };
460 462
461 } // namespace cricket 463 } // namespace cricket
462 464
463 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ 465 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698