| 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 21 matching lines...) Expand all Loading... |
| 32 #include <set> | 32 #include <set> |
| 33 #include <string> | 33 #include <string> |
| 34 #include <vector> | 34 #include <vector> |
| 35 | 35 |
| 36 #include "talk/media/base/rtputils.h" | 36 #include "talk/media/base/rtputils.h" |
| 37 #include "talk/media/webrtc/webrtccommon.h" | 37 #include "talk/media/webrtc/webrtccommon.h" |
| 38 #include "talk/media/webrtc/webrtcvoe.h" | 38 #include "talk/media/webrtc/webrtcvoe.h" |
| 39 #include "talk/session/media/channel.h" | 39 #include "talk/session/media/channel.h" |
| 40 #include "webrtc/audio_state.h" | 40 #include "webrtc/audio_state.h" |
| 41 #include "webrtc/base/buffer.h" | 41 #include "webrtc/base/buffer.h" |
| 42 #include "webrtc/base/byteorder.h" | |
| 43 #include "webrtc/base/logging.h" | |
| 44 #include "webrtc/base/scoped_ptr.h" | 42 #include "webrtc/base/scoped_ptr.h" |
| 45 #include "webrtc/base/stream.h" | 43 #include "webrtc/base/stream.h" |
| 46 #include "webrtc/base/thread_checker.h" | 44 #include "webrtc/base/thread_checker.h" |
| 47 #include "webrtc/call.h" | 45 #include "webrtc/call.h" |
| 48 #include "webrtc/common.h" | 46 #include "webrtc/common.h" |
| 49 #include "webrtc/config.h" | 47 #include "webrtc/config.h" |
| 50 | 48 |
| 51 namespace cricket { | 49 namespace cricket { |
| 52 | 50 |
| 53 class AudioDeviceModule; | 51 class AudioDeviceModule; |
| 54 class AudioRenderer; | 52 class AudioRenderer; |
| 55 class VoETraceWrapper; | |
| 56 class VoEWrapper; | 53 class VoEWrapper; |
| 57 class WebRtcVoiceMediaChannel; | 54 class WebRtcVoiceMediaChannel; |
| 58 | 55 |
| 59 // WebRtcVoiceEngine is a class to be used with CompositeMediaEngine. | 56 // WebRtcVoiceEngine is a class to be used with CompositeMediaEngine. |
| 60 // It uses the WebRtc VoiceEngine library for audio handling. | 57 // It uses the WebRtc VoiceEngine library for audio handling. |
| 61 class WebRtcVoiceEngine final : public webrtc::TraceCallback { | 58 class WebRtcVoiceEngine final : public webrtc::TraceCallback { |
| 62 friend class WebRtcVoiceMediaChannel; | 59 friend class WebRtcVoiceMediaChannel; |
| 63 | 60 |
| 64 public: | 61 public: |
| 65 WebRtcVoiceEngine(); | 62 WebRtcVoiceEngine(); |
| 66 // Dependency injection for testing. | 63 // Dependency injection for testing. |
| 67 WebRtcVoiceEngine(VoEWrapper* voe_wrapper, VoETraceWrapper* tracing); | 64 explicit WebRtcVoiceEngine(VoEWrapper* voe_wrapper); |
| 68 ~WebRtcVoiceEngine(); | 65 ~WebRtcVoiceEngine(); |
| 69 bool Init(rtc::Thread* worker_thread); | 66 bool Init(rtc::Thread* worker_thread); |
| 70 void Terminate(); | 67 void Terminate(); |
| 71 | 68 |
| 72 rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const; | 69 rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const; |
| 73 VoiceMediaChannel* CreateChannel(webrtc::Call* call, | 70 VoiceMediaChannel* CreateChannel(webrtc::Call* call, |
| 74 const AudioOptions& options); | 71 const AudioOptions& options); |
| 75 | 72 |
| 76 AudioOptions GetOptions() const { return options_; } | 73 AudioOptions GetOptions() const { return options_; } |
| 77 bool SetOptions(const AudioOptions& options); | 74 bool SetOptions(const AudioOptions& options); |
| 78 bool SetDevices(const Device* in_device, const Device* out_device); | 75 bool SetDevices(const Device* in_device, const Device* out_device); |
| 79 bool GetOutputVolume(int* level); | 76 bool GetOutputVolume(int* level); |
| 80 bool SetOutputVolume(int level); | 77 bool SetOutputVolume(int level); |
| 81 int GetInputLevel(); | 78 int GetInputLevel(); |
| 82 | 79 |
| 83 const std::vector<AudioCodec>& codecs(); | 80 const std::vector<AudioCodec>& codecs(); |
| 84 bool FindCodec(const AudioCodec& codec); | 81 bool FindCodec(const AudioCodec& codec); |
| 85 bool FindWebRtcCodec(const AudioCodec& codec, webrtc::CodecInst* gcodec); | 82 bool FindWebRtcCodec(const AudioCodec& codec, webrtc::CodecInst* gcodec); |
| 86 | 83 |
| 87 const std::vector<RtpHeaderExtension>& rtp_header_extensions() const; | 84 const std::vector<RtpHeaderExtension>& rtp_header_extensions() const; |
| 88 | 85 |
| 89 void SetLogging(int min_sev, const char* filter); | |
| 90 | |
| 91 // For tracking WebRtc channels. Needed because we have to pause them | 86 // For tracking WebRtc channels. Needed because we have to pause them |
| 92 // all when switching devices. | 87 // all when switching devices. |
| 93 // May only be called by WebRtcVoiceMediaChannel. | 88 // May only be called by WebRtcVoiceMediaChannel. |
| 94 void RegisterChannel(WebRtcVoiceMediaChannel* channel); | 89 void RegisterChannel(WebRtcVoiceMediaChannel* channel); |
| 95 void UnregisterChannel(WebRtcVoiceMediaChannel* channel); | 90 void UnregisterChannel(WebRtcVoiceMediaChannel* channel); |
| 96 | 91 |
| 97 // Called by WebRtcVoiceMediaChannel to set a gain offset from | 92 // Called by WebRtcVoiceMediaChannel to set a gain offset from |
| 98 // the default AGC target level. | 93 // the default AGC target level. |
| 99 bool AdjustAgcLevel(int delta); | 94 bool AdjustAgcLevel(int delta); |
| 100 | 95 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 115 bool StartRtcEventLog(rtc::PlatformFile file); | 110 bool StartRtcEventLog(rtc::PlatformFile file); |
| 116 | 111 |
| 117 // Stops recording the RtcEventLog. | 112 // Stops recording the RtcEventLog. |
| 118 void StopRtcEventLog(); | 113 void StopRtcEventLog(); |
| 119 | 114 |
| 120 private: | 115 private: |
| 121 void Construct(); | 116 void Construct(); |
| 122 void ConstructCodecs(); | 117 void ConstructCodecs(); |
| 123 bool GetVoeCodec(int index, webrtc::CodecInst* codec); | 118 bool GetVoeCodec(int index, webrtc::CodecInst* codec); |
| 124 bool InitInternal(); | 119 bool InitInternal(); |
| 125 void SetTraceFilter(int filter); | |
| 126 void SetTraceOptions(const std::string& options); | |
| 127 // Every option that is "set" will be applied. Every option not "set" will be | 120 // Every option that is "set" will be applied. Every option not "set" will be |
| 128 // ignored. This allows us to selectively turn on and off different options | 121 // ignored. This allows us to selectively turn on and off different options |
| 129 // easily at any time. | 122 // easily at any time. |
| 130 bool ApplyOptions(const AudioOptions& options); | 123 bool ApplyOptions(const AudioOptions& options); |
| 131 | 124 |
| 132 // webrtc::TraceCallback: | 125 // webrtc::TraceCallback: |
| 133 void Print(webrtc::TraceLevel level, const char* trace, int length) override; | 126 void Print(webrtc::TraceLevel level, const char* trace, int length) override; |
| 134 | 127 |
| 135 // Given the device type, name, and id, find device id. Return true and | 128 // Given the device type, name, and id, find device id. Return true and |
| 136 // set the output parameter rtc_id if successful. | 129 // set the output parameter rtc_id if successful. |
| 137 bool FindWebRtcAudioDeviceId( | 130 bool FindWebRtcAudioDeviceId( |
| 138 bool is_input, const std::string& dev_name, int dev_id, int* rtc_id); | 131 bool is_input, const std::string& dev_name, int dev_id, int* rtc_id); |
| 139 | 132 |
| 140 void StartAecDump(const std::string& filename); | 133 void StartAecDump(const std::string& filename); |
| 141 int CreateVoEChannel(); | 134 int CreateVoEChannel(); |
| 142 | 135 |
| 143 static const int kDefaultLogSeverity = rtc::LS_WARNING; | |
| 144 | |
| 145 rtc::ThreadChecker signal_thread_checker_; | 136 rtc::ThreadChecker signal_thread_checker_; |
| 146 rtc::ThreadChecker worker_thread_checker_; | 137 rtc::ThreadChecker worker_thread_checker_; |
| 147 | 138 |
| 148 // The primary instance of WebRtc VoiceEngine. | 139 // The primary instance of WebRtc VoiceEngine. |
| 149 rtc::scoped_ptr<VoEWrapper> voe_wrapper_; | 140 rtc::scoped_ptr<VoEWrapper> voe_wrapper_; |
| 150 rtc::scoped_ptr<VoETraceWrapper> tracing_; | |
| 151 rtc::scoped_refptr<webrtc::AudioState> audio_state_; | 141 rtc::scoped_refptr<webrtc::AudioState> audio_state_; |
| 152 // The external audio device manager | 142 // The external audio device manager |
| 153 webrtc::AudioDeviceModule* adm_ = nullptr; | 143 webrtc::AudioDeviceModule* adm_ = nullptr; |
| 154 int log_filter_; | |
| 155 std::string log_options_; | |
| 156 bool is_dumping_aec_ = false; | 144 bool is_dumping_aec_ = false; |
| 157 std::vector<AudioCodec> codecs_; | 145 std::vector<AudioCodec> codecs_; |
| 158 std::vector<RtpHeaderExtension> rtp_header_extensions_; | 146 std::vector<RtpHeaderExtension> rtp_header_extensions_; |
| 159 std::vector<WebRtcVoiceMediaChannel*> channels_; | 147 std::vector<WebRtcVoiceMediaChannel*> channels_; |
| 160 webrtc::AgcConfig default_agc_config_; | 148 webrtc::AgcConfig default_agc_config_; |
| 161 | 149 |
| 162 webrtc::Config voe_config_; | 150 webrtc::Config voe_config_; |
| 163 | 151 |
| 164 bool initialized_ = false; | 152 bool initialized_ = false; |
| 165 AudioOptions options_; | 153 AudioOptions options_; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 | 292 |
| 305 class WebRtcAudioReceiveStream; | 293 class WebRtcAudioReceiveStream; |
| 306 std::map<uint32_t, WebRtcAudioReceiveStream*> recv_streams_; | 294 std::map<uint32_t, WebRtcAudioReceiveStream*> recv_streams_; |
| 307 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 295 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
| 308 | 296 |
| 309 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcVoiceMediaChannel); | 297 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcVoiceMediaChannel); |
| 310 }; | 298 }; |
| 311 } // namespace cricket | 299 } // namespace cricket |
| 312 | 300 |
| 313 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ | 301 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ |
| OLD | NEW |