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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Starts recording an RtcEventLog using an existing file until 10 minutes | 111 // Starts recording an RtcEventLog using an existing file until 10 minutes |
112 // pass or the StopRtcEventLog function is called. | 112 // pass or the StopRtcEventLog function is called. |
113 bool StartRtcEventLog(rtc::PlatformFile file); | 113 bool StartRtcEventLog(rtc::PlatformFile file); |
114 | 114 |
115 // Stops recording the RtcEventLog. | 115 // Stops recording the RtcEventLog. |
116 void StopRtcEventLog(); | 116 void StopRtcEventLog(); |
117 | 117 |
118 // Create a VoiceEngine Channel. | |
119 int CreateMediaVoiceChannel(); | |
120 | |
121 private: | 118 private: |
122 void Construct(); | 119 void Construct(); |
123 void ConstructCodecs(); | 120 void ConstructCodecs(); |
124 bool GetVoeCodec(int index, webrtc::CodecInst* codec); | 121 bool GetVoeCodec(int index, webrtc::CodecInst* codec); |
125 bool InitInternal(); | 122 bool InitInternal(); |
126 void SetTraceFilter(int filter); | 123 void SetTraceFilter(int filter); |
127 void SetTraceOptions(const std::string& options); | 124 void SetTraceOptions(const std::string& options); |
128 // Every option that is "set" will be applied. Every option not "set" will be | 125 // Every option that is "set" will be applied. Every option not "set" will be |
129 // ignored. This allows us to selectively turn on and off different options | 126 // ignored. This allows us to selectively turn on and off different options |
130 // easily at any time. | 127 // easily at any time. |
131 bool ApplyOptions(const AudioOptions& options); | 128 bool ApplyOptions(const AudioOptions& options); |
132 | 129 |
133 // webrtc::TraceCallback: | 130 // webrtc::TraceCallback: |
134 void Print(webrtc::TraceLevel level, const char* trace, int length) override; | 131 void Print(webrtc::TraceLevel level, const char* trace, int length) override; |
135 | 132 |
136 // webrtc::VoiceEngineObserver: | 133 // webrtc::VoiceEngineObserver: |
137 void CallbackOnError(int channel_id, int errCode) override; | 134 void CallbackOnError(int channel_id, int errCode) override; |
138 | 135 |
139 // Given the device type, name, and id, find device id. Return true and | 136 // Given the device type, name, and id, find device id. Return true and |
140 // set the output parameter rtc_id if successful. | 137 // set the output parameter rtc_id if successful. |
141 bool FindWebRtcAudioDeviceId( | 138 bool FindWebRtcAudioDeviceId( |
142 bool is_input, const std::string& dev_name, int dev_id, int* rtc_id); | 139 bool is_input, const std::string& dev_name, int dev_id, int* rtc_id); |
143 | 140 |
144 void StartAecDump(const std::string& filename); | 141 void StartAecDump(const std::string& filename); |
145 void StopAecDump(); | 142 void StopAecDump(); |
146 int CreateVoiceChannel(VoEWrapper* voe); | 143 int CreateVoEChannel(); |
147 | 144 |
148 static const int kDefaultLogSeverity = rtc::LS_WARNING; | 145 static const int kDefaultLogSeverity = rtc::LS_WARNING; |
149 | 146 |
150 // The primary instance of WebRtc VoiceEngine. | 147 // The primary instance of WebRtc VoiceEngine. |
151 rtc::scoped_ptr<VoEWrapper> voe_wrapper_; | 148 rtc::scoped_ptr<VoEWrapper> voe_wrapper_; |
152 rtc::scoped_ptr<VoETraceWrapper> tracing_; | 149 rtc::scoped_ptr<VoETraceWrapper> tracing_; |
153 // The external audio device manager | 150 // The external audio device manager |
154 webrtc::AudioDeviceModule* adm_; | 151 webrtc::AudioDeviceModule* adm_; |
155 int log_filter_; | 152 int log_filter_; |
156 std::string log_options_; | 153 std::string log_options_; |
(...skipping 23 matching lines...) Expand all Loading... |
180 // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses | 177 // WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses |
181 // WebRtc Voice Engine. | 178 // WebRtc Voice Engine. |
182 class WebRtcVoiceMediaChannel : public VoiceMediaChannel, | 179 class WebRtcVoiceMediaChannel : public VoiceMediaChannel, |
183 public webrtc::Transport { | 180 public webrtc::Transport { |
184 public: | 181 public: |
185 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, | 182 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, |
186 const AudioOptions& options, | 183 const AudioOptions& options, |
187 webrtc::Call* call); | 184 webrtc::Call* call); |
188 ~WebRtcVoiceMediaChannel() override; | 185 ~WebRtcVoiceMediaChannel() override; |
189 | 186 |
190 int default_send_channel_id() const { return default_send_channel_id_; } | |
191 bool valid() const { return default_send_channel_id_ != -1; } | |
192 const AudioOptions& options() const { return options_; } | 187 const AudioOptions& options() const { return options_; } |
193 | 188 |
194 bool SetSendParameters(const AudioSendParameters& params) override; | 189 bool SetSendParameters(const AudioSendParameters& params) override; |
195 bool SetRecvParameters(const AudioRecvParameters& params) override; | 190 bool SetRecvParameters(const AudioRecvParameters& params) override; |
196 bool SetPlayout(bool playout) override; | 191 bool SetPlayout(bool playout) override; |
197 bool PausePlayout(); | 192 bool PausePlayout(); |
198 bool ResumePlayout(); | 193 bool ResumePlayout(); |
199 bool SetSend(SendFlags send) override; | 194 bool SetSend(SendFlags send) override; |
200 bool PauseSend(); | 195 bool PauseSend(); |
201 bool ResumeSend(); | 196 bool ResumeSend(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 const std::vector<RtpHeaderExtension>& extensions); | 255 const std::vector<RtpHeaderExtension>& extensions); |
261 bool SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer); | 256 bool SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer); |
262 bool MuteStream(uint32_t ssrc, bool mute); | 257 bool MuteStream(uint32_t ssrc, bool mute); |
263 | 258 |
264 WebRtcVoiceEngine* engine() { return engine_; } | 259 WebRtcVoiceEngine* engine() { return engine_; } |
265 int GetLastEngineError() { return engine()->GetLastEngineError(); } | 260 int GetLastEngineError() { return engine()->GetLastEngineError(); } |
266 int GetOutputLevel(int channel); | 261 int GetOutputLevel(int channel); |
267 bool GetRedSendCodec(const AudioCodec& red_codec, | 262 bool GetRedSendCodec(const AudioCodec& red_codec, |
268 const std::vector<AudioCodec>& all_codecs, | 263 const std::vector<AudioCodec>& all_codecs, |
269 webrtc::CodecInst* send_codec); | 264 webrtc::CodecInst* send_codec); |
270 bool EnableRtcp(int channel); | |
271 bool SetPlayout(int channel, bool playout); | 265 bool SetPlayout(int channel, bool playout); |
272 static Error WebRtcErrorToChannelError(int err_code); | 266 static Error WebRtcErrorToChannelError(int err_code); |
273 | 267 |
274 class WebRtcVoiceChannelRenderer; | 268 class WebRtcVoiceChannelRenderer; |
275 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of | 269 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of |
276 // WebRtcVoiceChannelRenderer will be created for every new stream and | 270 // WebRtcVoiceChannelRenderer will be created for every new stream and |
277 // will be destroyed when the stream goes away. | 271 // will be destroyed when the stream goes away. |
278 typedef std::map<uint32_t, WebRtcVoiceChannelRenderer*> ChannelMap; | 272 typedef std::map<uint32_t, WebRtcVoiceChannelRenderer*> ChannelMap; |
279 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool, | 273 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool, |
280 unsigned char); | 274 unsigned char); |
281 | 275 |
282 void SetNack(int channel, bool nack_enabled); | 276 void SetNack(int channel, bool nack_enabled); |
283 void SetNack(const ChannelMap& channels, bool nack_enabled); | |
284 bool SetSendCodec(const webrtc::CodecInst& send_codec); | |
285 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); | 277 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); |
286 bool ChangePlayout(bool playout); | 278 bool ChangePlayout(bool playout); |
287 bool ChangeSend(SendFlags send); | 279 bool ChangeSend(SendFlags send); |
288 bool ChangeSend(int channel, SendFlags send); | 280 bool ChangeSend(int channel, SendFlags send); |
289 void ConfigureSendChannel(int channel); | |
290 bool ConfigureRecvChannel(int channel); | 281 bool ConfigureRecvChannel(int channel); |
| 282 int CreateVoEChannel(); |
291 bool DeleteChannel(int channel); | 283 bool DeleteChannel(int channel); |
292 bool IsDefaultChannel(int channel_id) const { | |
293 return channel_id == default_send_channel_id_; | |
294 } | |
295 bool IsDefaultRecvStream(uint32_t ssrc) { | 284 bool IsDefaultRecvStream(uint32_t ssrc) { |
296 return default_recv_ssrc_ == static_cast<int64_t>(ssrc); | 285 return default_recv_ssrc_ == static_cast<int64_t>(ssrc); |
297 } | 286 } |
298 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); | 287 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); |
299 bool SetSendBitrateInternal(int bps); | 288 bool SetSendBitrateInternal(int bps); |
300 | 289 |
301 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, | 290 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, |
302 const RtpHeaderExtension* extension); | 291 const RtpHeaderExtension* extension); |
303 void RecreateAudioReceiveStreams(); | 292 void RecreateAudioReceiveStreams(); |
304 void AddAudioReceiveStream(uint32_t ssrc); | 293 void AddAudioReceiveStream(uint32_t ssrc); |
305 void RemoveAudioReceiveStream(uint32_t ssrc); | 294 void RemoveAudioReceiveStream(uint32_t ssrc); |
306 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs); | 295 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs); |
307 | 296 |
308 bool SetChannelRecvRtpHeaderExtensions( | 297 bool SetChannelRecvRtpHeaderExtensions( |
309 int channel_id, | 298 int channel_id, |
310 const std::vector<RtpHeaderExtension>& extensions); | 299 const std::vector<RtpHeaderExtension>& extensions); |
311 bool SetChannelSendRtpHeaderExtensions( | 300 bool SetChannelSendRtpHeaderExtensions( |
312 int channel_id, | 301 int channel_id, |
313 const std::vector<RtpHeaderExtension>& extensions); | 302 const std::vector<RtpHeaderExtension>& extensions); |
314 | 303 |
315 rtc::ThreadChecker thread_checker_; | 304 rtc::ThreadChecker thread_checker_; |
316 | 305 |
317 WebRtcVoiceEngine* const engine_; | 306 WebRtcVoiceEngine* const engine_; |
318 const int default_send_channel_id_; | |
319 std::vector<AudioCodec> recv_codecs_; | 307 std::vector<AudioCodec> recv_codecs_; |
320 std::vector<AudioCodec> send_codecs_; | 308 std::vector<AudioCodec> send_codecs_; |
321 rtc::scoped_ptr<webrtc::CodecInst> send_codec_; | 309 rtc::scoped_ptr<webrtc::CodecInst> send_codec_; |
322 bool send_bitrate_setting_; | 310 bool send_bitrate_setting_; |
323 int send_bitrate_bps_; | 311 int send_bitrate_bps_; |
324 AudioOptions options_; | 312 AudioOptions options_; |
325 bool dtmf_allowed_; | 313 bool dtmf_allowed_; |
326 bool desired_playout_; | 314 bool desired_playout_; |
327 bool nack_enabled_; | 315 bool nack_enabled_; |
328 bool playout_; | 316 bool playout_; |
329 bool typing_noise_detected_; | 317 bool typing_noise_detected_; |
330 SendFlags desired_send_; | 318 SendFlags desired_send_; |
331 SendFlags send_; | 319 SendFlags send_; |
332 webrtc::Call* const call_; | 320 webrtc::Call* const call_; |
333 | 321 |
334 // SSRC of unsignalled receive stream, or -1 if there isn't one. | 322 // SSRC of unsignalled receive stream, or -1 if there isn't one. |
335 int64_t default_recv_ssrc_ = -1; | 323 int64_t default_recv_ssrc_ = -1; |
336 // Volume for unsignalled stream, which may be set before the stream exists. | 324 // Volume for unsignalled stream, which may be set before the stream exists. |
337 double default_recv_volume_ = 1.0; | 325 double default_recv_volume_ = 1.0; |
| 326 // SSRC to use for RTCP receiver reports; default to 1 in case of no signaled |
| 327 // send streams. See: https://code.google.com/p/webrtc/issues/detail?id=4740 |
| 328 uint32_t receiver_reports_ssrc_ = 1; |
338 | 329 |
339 // send_channels_ contains the channels which are being used for sending. | 330 // send_channels_ contains the channels which are being used for sending. |
340 // When the default channel (default_send_channel_id) is used for sending, it | 331 // When the default channel (default_send_channel_id) is used for sending, it |
341 // is contained in send_channels_, otherwise not. | 332 // is contained in send_channels_, otherwise not. |
342 ChannelMap send_channels_; | 333 ChannelMap send_channels_; |
343 std::vector<RtpHeaderExtension> send_extensions_; | 334 std::vector<RtpHeaderExtension> send_extensions_; |
344 ChannelMap receive_channels_; | 335 ChannelMap receive_channels_; |
345 std::map<uint32_t, webrtc::AudioReceiveStream*> receive_streams_; | 336 std::map<uint32_t, webrtc::AudioReceiveStream*> receive_streams_; |
346 std::map<uint32_t, StreamParams> receive_stream_params_; | 337 std::map<uint32_t, StreamParams> receive_stream_params_; |
347 // receive_channels_ can be read from WebRtc callback thread. Access from | 338 // receive_channels_ can be read from WebRtc callback thread. Access from |
348 // the WebRtc thread must be synchronized with edits on the worker thread. | 339 // the WebRtc thread must be synchronized with edits on the worker thread. |
349 // Reads on the worker thread are ok. | 340 // Reads on the worker thread are ok. |
350 std::vector<RtpHeaderExtension> receive_extensions_; | 341 std::vector<RtpHeaderExtension> receive_extensions_; |
351 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 342 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
352 }; | 343 }; |
353 | 344 |
354 } // namespace cricket | 345 } // namespace cricket |
355 | 346 |
356 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ | 347 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ |
OLD | NEW |