| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 VoEWrapper* voe() { return voe_wrapper_.get(); } | 102 VoEWrapper* voe() { return voe_wrapper_.get(); } |
| 103 int GetLastEngineError(); | 103 int GetLastEngineError(); |
| 104 | 104 |
| 105 // Set the external ADM. This can only be called before Init. | 105 // Set the external ADM. This can only be called before Init. |
| 106 bool SetAudioDeviceModule(webrtc::AudioDeviceModule* adm); | 106 bool SetAudioDeviceModule(webrtc::AudioDeviceModule* adm); |
| 107 | 107 |
| 108 // Starts AEC dump using existing file. | 108 // Starts AEC dump using existing file. |
| 109 bool StartAecDump(rtc::PlatformFile file); | 109 bool StartAecDump(rtc::PlatformFile file); |
| 110 | 110 |
| 111 // Create a VoiceEngine Channel. | |
| 112 int CreateMediaVoiceChannel(); | |
| 113 | |
| 114 private: | 111 private: |
| 115 void Construct(); | 112 void Construct(); |
| 116 void ConstructCodecs(); | 113 void ConstructCodecs(); |
| 117 bool GetVoeCodec(int index, webrtc::CodecInst* codec); | 114 bool GetVoeCodec(int index, webrtc::CodecInst* codec); |
| 118 bool InitInternal(); | 115 bool InitInternal(); |
| 119 void SetTraceFilter(int filter); | 116 void SetTraceFilter(int filter); |
| 120 void SetTraceOptions(const std::string& options); | 117 void SetTraceOptions(const std::string& options); |
| 121 // Every option that is "set" will be applied. Every option not "set" will be | 118 // Every option that is "set" will be applied. Every option not "set" will be |
| 122 // ignored. This allows us to selectively turn on and off different options | 119 // ignored. This allows us to selectively turn on and off different options |
| 123 // easily at any time. | 120 // easily at any time. |
| 124 bool ApplyOptions(const AudioOptions& options); | 121 bool ApplyOptions(const AudioOptions& options); |
| 125 | 122 |
| 126 // webrtc::TraceCallback: | 123 // webrtc::TraceCallback: |
| 127 void Print(webrtc::TraceLevel level, const char* trace, int length) override; | 124 void Print(webrtc::TraceLevel level, const char* trace, int length) override; |
| 128 | 125 |
| 129 // webrtc::VoiceEngineObserver: | 126 // webrtc::VoiceEngineObserver: |
| 130 void CallbackOnError(int channel, int errCode) override; | 127 void CallbackOnError(int channel, int errCode) override; |
| 131 | 128 |
| 132 // Given the device type, name, and id, find device id. Return true and | 129 // Given the device type, name, and id, find device id. Return true and |
| 133 // set the output parameter rtc_id if successful. | 130 // set the output parameter rtc_id if successful. |
| 134 bool FindWebRtcAudioDeviceId( | 131 bool FindWebRtcAudioDeviceId( |
| 135 bool is_input, const std::string& dev_name, int dev_id, int* rtc_id); | 132 bool is_input, const std::string& dev_name, int dev_id, int* rtc_id); |
| 136 bool FindChannelAndSsrc(int channel_num, | 133 bool FindChannelAndSsrc(int channel_num, |
| 137 WebRtcVoiceMediaChannel** channel, | 134 WebRtcVoiceMediaChannel** channel, |
| 138 uint32* ssrc) const; | 135 uint32* ssrc) const; |
| 139 | 136 |
| 140 void StartAecDump(const std::string& filename); | 137 void StartAecDump(const std::string& filename); |
| 141 void StopAecDump(); | 138 void StopAecDump(); |
| 142 int CreateVoiceChannel(VoEWrapper* voe); | 139 int CreateVoiceChannel(); |
| 143 | 140 |
| 144 static const int kDefaultLogSeverity = rtc::LS_WARNING; | 141 static const int kDefaultLogSeverity = rtc::LS_WARNING; |
| 145 | 142 |
| 146 // The primary instance of WebRtc VoiceEngine. | 143 // The primary instance of WebRtc VoiceEngine. |
| 147 rtc::scoped_ptr<VoEWrapper> voe_wrapper_; | 144 rtc::scoped_ptr<VoEWrapper> voe_wrapper_; |
| 148 rtc::scoped_ptr<VoETraceWrapper> tracing_; | 145 rtc::scoped_ptr<VoETraceWrapper> tracing_; |
| 149 // The external audio device manager | 146 // The external audio device manager |
| 150 webrtc::AudioDeviceModule* adm_; | 147 webrtc::AudioDeviceModule* adm_; |
| 151 int log_filter_; | 148 int log_filter_; |
| 152 std::string log_options_; | 149 std::string log_options_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 176 // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses | 173 // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses |
| 177 // WebRtc Voice Engine. | 174 // WebRtc Voice Engine. |
| 178 class WebRtcVoiceMediaChannel : public VoiceMediaChannel, | 175 class WebRtcVoiceMediaChannel : public VoiceMediaChannel, |
| 179 public webrtc::Transport { | 176 public webrtc::Transport { |
| 180 public: | 177 public: |
| 181 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, | 178 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, |
| 182 const AudioOptions& options, | 179 const AudioOptions& options, |
| 183 webrtc::Call* call); | 180 webrtc::Call* call); |
| 184 ~WebRtcVoiceMediaChannel() override; | 181 ~WebRtcVoiceMediaChannel() override; |
| 185 | 182 |
| 186 int voe_channel() const { return voe_channel_; } | |
| 187 bool valid() const { return voe_channel_ != -1; } | |
| 188 const AudioOptions& options() const { return options_; } | 183 const AudioOptions& options() const { return options_; } |
| 189 | 184 |
| 190 bool SetSendParameters(const AudioSendParameters& params) override; | 185 bool SetSendParameters(const AudioSendParameters& params) override; |
| 191 bool SetRecvParameters(const AudioRecvParameters& params) override; | 186 bool SetRecvParameters(const AudioRecvParameters& params) override; |
| 192 bool SetPlayout(bool playout) override; | 187 bool SetPlayout(bool playout) override; |
| 193 bool PausePlayout(); | 188 bool PausePlayout(); |
| 194 bool ResumePlayout(); | 189 bool ResumePlayout(); |
| 195 bool SetSend(SendFlags send) override; | 190 bool SetSend(SendFlags send) override; |
| 196 bool PauseSend(); | 191 bool PauseSend(); |
| 197 bool ResumeSend(); | 192 bool ResumeSend(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 const std::vector<RtpHeaderExtension>& extensions); | 248 const std::vector<RtpHeaderExtension>& extensions); |
| 254 bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer); | 249 bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer); |
| 255 bool MuteStream(uint32 ssrc, bool mute); | 250 bool MuteStream(uint32 ssrc, bool mute); |
| 256 | 251 |
| 257 WebRtcVoiceEngine* engine() { return engine_; } | 252 WebRtcVoiceEngine* engine() { return engine_; } |
| 258 int GetLastEngineError() { return engine()->GetLastEngineError(); } | 253 int GetLastEngineError() { return engine()->GetLastEngineError(); } |
| 259 int GetOutputLevel(int channel); | 254 int GetOutputLevel(int channel); |
| 260 bool GetRedSendCodec(const AudioCodec& red_codec, | 255 bool GetRedSendCodec(const AudioCodec& red_codec, |
| 261 const std::vector<AudioCodec>& all_codecs, | 256 const std::vector<AudioCodec>& all_codecs, |
| 262 webrtc::CodecInst* send_codec); | 257 webrtc::CodecInst* send_codec); |
| 263 bool EnableRtcp(int channel); | |
| 264 bool SetPlayout(int channel, bool playout); | 258 bool SetPlayout(int channel, bool playout); |
| 265 static Error WebRtcErrorToChannelError(int err_code); | 259 static Error WebRtcErrorToChannelError(int err_code); |
| 266 | 260 |
| 267 class WebRtcVoiceChannelRenderer; | 261 class WebRtcVoiceChannelRenderer; |
| 268 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of | 262 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of |
| 269 // WebRtcVoiceChannelRenderer will be created for every new stream and | 263 // WebRtcVoiceChannelRenderer will be created for every new stream and |
| 270 // will be destroyed when the stream goes away. | 264 // will be destroyed when the stream goes away. |
| 271 typedef std::map<uint32, WebRtcVoiceChannelRenderer*> ChannelMap; | 265 typedef std::map<uint32, WebRtcVoiceChannelRenderer*> ChannelMap; |
| 272 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool, | 266 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool, |
| 273 unsigned char); | 267 unsigned char); |
| 274 | 268 |
| 275 void SetNack(int channel, bool nack_enabled); | 269 void SetNack(int channel, bool nack_enabled); |
| 276 void SetNack(const ChannelMap& channels, bool nack_enabled); | 270 void SetNack(const ChannelMap& channels, bool nack_enabled); |
| 277 bool SetSendCodec(const webrtc::CodecInst& send_codec); | 271 bool SetSendCodec(const webrtc::CodecInst& send_codec); |
| 278 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); | 272 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); |
| 279 bool ChangePlayout(bool playout); | 273 bool ChangePlayout(bool playout); |
| 280 bool ChangeSend(SendFlags send); | 274 bool ChangeSend(SendFlags send); |
| 281 bool ChangeSend(int channel, SendFlags send); | 275 bool ChangeSend(int channel, SendFlags send); |
| 282 void ConfigureSendChannel(int channel); | |
| 283 bool ConfigureRecvChannel(int channel); | 276 bool ConfigureRecvChannel(int channel); |
| 277 int CreateChannel(); |
| 284 bool DeleteChannel(int channel); | 278 bool DeleteChannel(int channel); |
| 285 bool IsDefaultChannel(int channel_id) const { | |
| 286 return channel_id == voe_channel(); | |
| 287 } | |
| 288 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); | 279 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); |
| 289 bool SetSendBitrateInternal(int bps); | 280 bool SetSendBitrateInternal(int bps); |
| 290 | 281 |
| 291 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, | 282 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, |
| 292 const RtpHeaderExtension* extension); | 283 const RtpHeaderExtension* extension); |
| 293 void RecreateAudioReceiveStreams(); | 284 void RecreateAudioReceiveStreams(); |
| 294 void AddAudioReceiveStream(uint32 ssrc); | 285 void AddAudioReceiveStream(uint32 ssrc); |
| 295 void RemoveAudioReceiveStream(uint32 ssrc); | 286 void RemoveAudioReceiveStream(uint32 ssrc); |
| 296 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs); | 287 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs); |
| 297 | 288 |
| 298 bool SetChannelRecvRtpHeaderExtensions( | 289 bool SetChannelRecvRtpHeaderExtensions( |
| 299 int channel_id, | 290 int channel_id, |
| 300 const std::vector<RtpHeaderExtension>& extensions); | 291 const std::vector<RtpHeaderExtension>& extensions); |
| 301 bool SetChannelSendRtpHeaderExtensions( | 292 bool SetChannelSendRtpHeaderExtensions( |
| 302 int channel_id, | 293 int channel_id, |
| 303 const std::vector<RtpHeaderExtension>& extensions); | 294 const std::vector<RtpHeaderExtension>& extensions); |
| 304 | 295 |
| 305 rtc::ThreadChecker thread_checker_; | 296 rtc::ThreadChecker thread_checker_; |
| 306 | 297 |
| 307 WebRtcVoiceEngine* const engine_; | 298 WebRtcVoiceEngine* const engine_; |
| 308 const int voe_channel_; | |
| 309 std::vector<AudioCodec> recv_codecs_; | 299 std::vector<AudioCodec> recv_codecs_; |
| 310 std::vector<AudioCodec> send_codecs_; | 300 std::vector<AudioCodec> send_codecs_; |
| 311 rtc::scoped_ptr<webrtc::CodecInst> send_codec_; | 301 rtc::scoped_ptr<webrtc::CodecInst> send_codec_; |
| 312 bool send_bitrate_setting_; | 302 bool send_bitrate_setting_; |
| 313 int send_bitrate_bps_; | 303 int send_bitrate_bps_; |
| 314 AudioOptions options_; | 304 AudioOptions options_; |
| 315 bool dtmf_allowed_; | 305 bool dtmf_allowed_; |
| 316 bool desired_playout_; | 306 bool desired_playout_; |
| 317 bool nack_enabled_; | 307 bool nack_enabled_; |
| 318 bool playout_; | 308 bool playout_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 335 // receive_channels_ can be read from WebRtc callback thread. Access from | 325 // receive_channels_ can be read from WebRtc callback thread. Access from |
| 336 // the WebRtc thread must be synchronized with edits on the worker thread. | 326 // the WebRtc thread must be synchronized with edits on the worker thread. |
| 337 // Reads on the worker thread are ok. | 327 // Reads on the worker thread are ok. |
| 338 std::vector<RtpHeaderExtension> receive_extensions_; | 328 std::vector<RtpHeaderExtension> receive_extensions_; |
| 339 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 329 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
| 340 }; | 330 }; |
| 341 | 331 |
| 342 } // namespace cricket | 332 } // namespace cricket |
| 343 | 333 |
| 344 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ | 334 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ |
| OLD | NEW |