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_id, int errCode) override; | 127 void CallbackOnError(int channel_id, 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 | 133 |
137 void StartAecDump(const std::string& filename); | 134 void StartAecDump(const std::string& filename); |
138 void StopAecDump(); | 135 void StopAecDump(); |
139 int CreateVoiceChannel(VoEWrapper* voe); | 136 int CreateVoEChannel(); |
140 | 137 |
141 static const int kDefaultLogSeverity = rtc::LS_WARNING; | 138 static const int kDefaultLogSeverity = rtc::LS_WARNING; |
142 | 139 |
143 // The primary instance of WebRtc VoiceEngine. | 140 // The primary instance of WebRtc VoiceEngine. |
144 rtc::scoped_ptr<VoEWrapper> voe_wrapper_; | 141 rtc::scoped_ptr<VoEWrapper> voe_wrapper_; |
145 rtc::scoped_ptr<VoETraceWrapper> tracing_; | 142 rtc::scoped_ptr<VoETraceWrapper> tracing_; |
146 // The external audio device manager | 143 // The external audio device manager |
147 webrtc::AudioDeviceModule* adm_; | 144 webrtc::AudioDeviceModule* adm_; |
148 int log_filter_; | 145 int log_filter_; |
149 std::string log_options_; | 146 std::string log_options_; |
(...skipping 23 matching lines...) Expand all Loading... | |
173 // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses | 170 // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses |
174 // WebRtc Voice Engine. | 171 // WebRtc Voice Engine. |
175 class WebRtcVoiceMediaChannel : public VoiceMediaChannel, | 172 class WebRtcVoiceMediaChannel : public VoiceMediaChannel, |
176 public webrtc::Transport { | 173 public webrtc::Transport { |
177 public: | 174 public: |
178 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, | 175 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, |
179 const AudioOptions& options, | 176 const AudioOptions& options, |
180 webrtc::Call* call); | 177 webrtc::Call* call); |
181 ~WebRtcVoiceMediaChannel() override; | 178 ~WebRtcVoiceMediaChannel() override; |
182 | 179 |
183 int default_send_channel_id() const { return default_send_channel_id_; } | |
184 bool valid() const { return default_send_channel_id_ != -1; } | |
185 const AudioOptions& options() const { return options_; } | 180 const AudioOptions& options() const { return options_; } |
186 | 181 |
187 bool SetSendParameters(const AudioSendParameters& params) override; | 182 bool SetSendParameters(const AudioSendParameters& params) override; |
188 bool SetRecvParameters(const AudioRecvParameters& params) override; | 183 bool SetRecvParameters(const AudioRecvParameters& params) override; |
189 bool SetPlayout(bool playout) override; | 184 bool SetPlayout(bool playout) override; |
190 bool PausePlayout(); | 185 bool PausePlayout(); |
191 bool ResumePlayout(); | 186 bool ResumePlayout(); |
192 bool SetSend(SendFlags send) override; | 187 bool SetSend(SendFlags send) override; |
193 bool PauseSend(); | 188 bool PauseSend(); |
194 bool ResumeSend(); | 189 bool ResumeSend(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 const std::vector<RtpHeaderExtension>& extensions); | 246 const std::vector<RtpHeaderExtension>& extensions); |
252 bool SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer); | 247 bool SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer); |
253 bool MuteStream(uint32_t ssrc, bool mute); | 248 bool MuteStream(uint32_t ssrc, bool mute); |
254 | 249 |
255 WebRtcVoiceEngine* engine() { return engine_; } | 250 WebRtcVoiceEngine* engine() { return engine_; } |
256 int GetLastEngineError() { return engine()->GetLastEngineError(); } | 251 int GetLastEngineError() { return engine()->GetLastEngineError(); } |
257 int GetOutputLevel(int channel); | 252 int GetOutputLevel(int channel); |
258 bool GetRedSendCodec(const AudioCodec& red_codec, | 253 bool GetRedSendCodec(const AudioCodec& red_codec, |
259 const std::vector<AudioCodec>& all_codecs, | 254 const std::vector<AudioCodec>& all_codecs, |
260 webrtc::CodecInst* send_codec); | 255 webrtc::CodecInst* send_codec); |
261 bool EnableRtcp(int channel); | |
262 bool SetPlayout(int channel, bool playout); | 256 bool SetPlayout(int channel, bool playout); |
263 static Error WebRtcErrorToChannelError(int err_code); | 257 static Error WebRtcErrorToChannelError(int err_code); |
264 | 258 |
265 class WebRtcVoiceChannelRenderer; | 259 class WebRtcVoiceChannelRenderer; |
266 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of | 260 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of |
267 // WebRtcVoiceChannelRenderer will be created for every new stream and | 261 // WebRtcVoiceChannelRenderer will be created for every new stream and |
268 // will be destroyed when the stream goes away. | 262 // will be destroyed when the stream goes away. |
269 typedef std::map<uint32_t, WebRtcVoiceChannelRenderer*> ChannelMap; | 263 typedef std::map<uint32_t, WebRtcVoiceChannelRenderer*> ChannelMap; |
270 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool, | 264 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool, |
271 unsigned char); | 265 unsigned char); |
272 | 266 |
273 void SetNack(int channel, bool nack_enabled); | 267 void SetNack(int channel, bool nack_enabled); |
274 void SetNack(const ChannelMap& channels, bool nack_enabled); | |
275 bool SetSendCodec(const webrtc::CodecInst& send_codec); | 268 bool SetSendCodec(const webrtc::CodecInst& send_codec); |
276 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); | 269 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); |
277 bool ChangePlayout(bool playout); | 270 bool ChangePlayout(bool playout); |
278 bool ChangeSend(SendFlags send); | 271 bool ChangeSend(SendFlags send); |
279 bool ChangeSend(int channel, SendFlags send); | 272 bool ChangeSend(int channel, SendFlags send); |
280 void ConfigureSendChannel(int channel); | |
281 bool ConfigureRecvChannel(int channel); | 273 bool ConfigureRecvChannel(int channel); |
274 int CreateVoEChannel(); | |
282 bool DeleteChannel(int channel); | 275 bool DeleteChannel(int channel); |
283 bool IsDefaultChannel(int channel_id) const { | |
284 return channel_id == default_send_channel_id_; | |
285 } | |
286 bool IsDefaultRecvStream(uint32_t ssrc) { | 276 bool IsDefaultRecvStream(uint32_t ssrc) { |
287 return default_recv_ssrc_ == static_cast<int64_t>(ssrc); | 277 return default_recv_ssrc_ == static_cast<int64_t>(ssrc); |
288 } | 278 } |
289 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); | 279 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); |
290 bool SetSendBitrateInternal(int bps); | 280 bool SetSendBitrateInternal(int bps); |
291 | 281 |
292 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, | 282 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, |
293 const RtpHeaderExtension* extension); | 283 const RtpHeaderExtension* extension); |
294 void RecreateAudioReceiveStreams(); | 284 void RecreateAudioReceiveStreams(); |
295 void AddAudioReceiveStream(uint32_t ssrc); | 285 void AddAudioReceiveStream(uint32_t ssrc); |
296 void RemoveAudioReceiveStream(uint32_t ssrc); | 286 void RemoveAudioReceiveStream(uint32_t ssrc); |
297 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs); | 287 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs); |
298 | 288 |
299 bool SetChannelRecvRtpHeaderExtensions( | 289 bool SetChannelRecvRtpHeaderExtensions( |
300 int channel_id, | 290 int channel_id, |
301 const std::vector<RtpHeaderExtension>& extensions); | 291 const std::vector<RtpHeaderExtension>& extensions); |
302 bool SetChannelSendRtpHeaderExtensions( | 292 bool SetChannelSendRtpHeaderExtensions( |
303 int channel_id, | 293 int channel_id, |
304 const std::vector<RtpHeaderExtension>& extensions); | 294 const std::vector<RtpHeaderExtension>& extensions); |
305 | 295 |
306 rtc::ThreadChecker thread_checker_; | 296 rtc::ThreadChecker thread_checker_; |
307 | 297 |
308 WebRtcVoiceEngine* const engine_; | 298 WebRtcVoiceEngine* const engine_; |
309 const int default_send_channel_id_; | |
310 std::vector<AudioCodec> recv_codecs_; | 299 std::vector<AudioCodec> recv_codecs_; |
311 std::vector<AudioCodec> send_codecs_; | 300 std::vector<AudioCodec> send_codecs_; |
312 rtc::scoped_ptr<webrtc::CodecInst> send_codec_; | 301 rtc::scoped_ptr<webrtc::CodecInst> send_codec_; |
313 bool send_bitrate_setting_; | 302 bool send_bitrate_setting_; |
314 int send_bitrate_bps_; | 303 int send_bitrate_bps_; |
315 AudioOptions options_; | 304 AudioOptions options_; |
316 bool dtmf_allowed_; | 305 bool dtmf_allowed_; |
317 bool desired_playout_; | 306 bool desired_playout_; |
318 bool nack_enabled_; | 307 bool nack_enabled_; |
319 bool playout_; | 308 bool playout_; |
320 bool typing_noise_detected_; | 309 bool typing_noise_detected_; |
321 SendFlags desired_send_; | 310 SendFlags desired_send_; |
322 SendFlags send_; | 311 SendFlags send_; |
323 webrtc::Call* const call_; | 312 webrtc::Call* const call_; |
324 | 313 |
325 // SSRC of unsignalled receive stream, or -1 if there isn't one. | 314 // SSRC of unsignalled receive stream, or -1 if there isn't one. |
326 int64_t default_recv_ssrc_ = -1; | 315 int64_t default_recv_ssrc_ = -1; |
327 // Volume for unsignalled stream, which may be set before the stream exists. | 316 // Volume for unsignalled stream, which may be set before the stream exists. |
328 double default_recv_volume_ = 1.0; | 317 double default_recv_volume_ = 1.0; |
329 | 318 |
319 uint32_t first_send_ssrc_ = -1; | |
pthatcher1
2015/10/15 05:15:04
Can you comment more on what this means and when i
the sun
2015/10/15 12:07:12
Done.
| |
320 | |
330 // send_channels_ contains the channels which are being used for sending. | 321 // send_channels_ contains the channels which are being used for sending. |
331 // When the default channel (default_send_channel_id) is used for sending, it | 322 // When the default channel (default_send_channel_id) is used for sending, it |
332 // is contained in send_channels_, otherwise not. | 323 // is contained in send_channels_, otherwise not. |
333 ChannelMap send_channels_; | 324 ChannelMap send_channels_; |
334 std::vector<RtpHeaderExtension> send_extensions_; | 325 std::vector<RtpHeaderExtension> send_extensions_; |
335 ChannelMap receive_channels_; | 326 ChannelMap receive_channels_; |
336 std::map<uint32_t, webrtc::AudioReceiveStream*> receive_streams_; | 327 std::map<uint32_t, webrtc::AudioReceiveStream*> receive_streams_; |
337 std::map<uint32_t, StreamParams> receive_stream_params_; | 328 std::map<uint32_t, StreamParams> receive_stream_params_; |
338 // receive_channels_ can be read from WebRtc callback thread. Access from | 329 // receive_channels_ can be read from WebRtc callback thread. Access from |
339 // the WebRtc thread must be synchronized with edits on the worker thread. | 330 // the WebRtc thread must be synchronized with edits on the worker thread. |
340 // Reads on the worker thread are ok. | 331 // Reads on the worker thread are ok. |
341 std::vector<RtpHeaderExtension> receive_extensions_; | 332 std::vector<RtpHeaderExtension> receive_extensions_; |
342 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 333 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
343 }; | 334 }; |
344 | 335 |
345 } // namespace cricket | 336 } // namespace cricket |
346 | 337 |
347 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ | 338 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ |
OLD | NEW |