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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 // webrtc::VoiceEngineObserver: | 129 // webrtc::VoiceEngineObserver: |
130 void CallbackOnError(int channel, int errCode) override; | 130 void CallbackOnError(int channel, int errCode) override; |
131 | 131 |
132 // Given the device type, name, and id, find device id. Return true and | 132 // Given the device type, name, and id, find device id. Return true and |
133 // set the output parameter rtc_id if successful. | 133 // set the output parameter rtc_id if successful. |
134 bool FindWebRtcAudioDeviceId( | 134 bool FindWebRtcAudioDeviceId( |
135 bool is_input, const std::string& dev_name, int dev_id, int* rtc_id); | 135 bool is_input, const std::string& dev_name, int dev_id, int* rtc_id); |
136 bool FindChannelAndSsrc(int channel_num, | 136 bool FindChannelAndSsrc(int channel_num, |
137 WebRtcVoiceMediaChannel** channel, | 137 WebRtcVoiceMediaChannel** channel, |
138 uint32* ssrc) const; | 138 uint32_t* ssrc) const; |
139 | 139 |
140 void StartAecDump(const std::string& filename); | 140 void StartAecDump(const std::string& filename); |
141 void StopAecDump(); | 141 void StopAecDump(); |
142 int CreateVoiceChannel(VoEWrapper* voe); | 142 int CreateVoiceChannel(VoEWrapper* voe); |
143 | 143 |
144 static const int kDefaultLogSeverity = rtc::LS_WARNING; | 144 static const int kDefaultLogSeverity = rtc::LS_WARNING; |
145 | 145 |
146 // The primary instance of WebRtc VoiceEngine. | 146 // The primary instance of WebRtc VoiceEngine. |
147 rtc::scoped_ptr<VoEWrapper> voe_wrapper_; | 147 rtc::scoped_ptr<VoEWrapper> voe_wrapper_; |
148 rtc::scoped_ptr<VoETraceWrapper> tracing_; | 148 rtc::scoped_ptr<VoETraceWrapper> tracing_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 const AudioOptions& options() const { return options_; } | 188 const AudioOptions& options() const { return options_; } |
189 | 189 |
190 bool SetSendParameters(const AudioSendParameters& params) override; | 190 bool SetSendParameters(const AudioSendParameters& params) override; |
191 bool SetRecvParameters(const AudioRecvParameters& params) override; | 191 bool SetRecvParameters(const AudioRecvParameters& params) override; |
192 bool SetPlayout(bool playout) override; | 192 bool SetPlayout(bool playout) override; |
193 bool PausePlayout(); | 193 bool PausePlayout(); |
194 bool ResumePlayout(); | 194 bool ResumePlayout(); |
195 bool SetSend(SendFlags send) override; | 195 bool SetSend(SendFlags send) override; |
196 bool PauseSend(); | 196 bool PauseSend(); |
197 bool ResumeSend(); | 197 bool ResumeSend(); |
198 bool SetAudioSend(uint32 ssrc, bool enable, const AudioOptions* options, | 198 bool SetAudioSend(uint32_t ssrc, |
| 199 bool enable, |
| 200 const AudioOptions* options, |
199 AudioRenderer* renderer) override; | 201 AudioRenderer* renderer) override; |
200 bool AddSendStream(const StreamParams& sp) override; | 202 bool AddSendStream(const StreamParams& sp) override; |
201 bool RemoveSendStream(uint32 ssrc) override; | 203 bool RemoveSendStream(uint32_t ssrc) override; |
202 bool AddRecvStream(const StreamParams& sp) override; | 204 bool AddRecvStream(const StreamParams& sp) override; |
203 bool RemoveRecvStream(uint32 ssrc) override; | 205 bool RemoveRecvStream(uint32_t ssrc) override; |
204 bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) override; | 206 bool SetRemoteRenderer(uint32_t ssrc, AudioRenderer* renderer) override; |
205 bool GetActiveStreams(AudioInfo::StreamList* actives) override; | 207 bool GetActiveStreams(AudioInfo::StreamList* actives) override; |
206 int GetOutputLevel() override; | 208 int GetOutputLevel() override; |
207 int GetTimeSinceLastTyping() override; | 209 int GetTimeSinceLastTyping() override; |
208 void SetTypingDetectionParameters(int time_window, | 210 void SetTypingDetectionParameters(int time_window, |
209 int cost_per_typing, | 211 int cost_per_typing, |
210 int reporting_threshold, | 212 int reporting_threshold, |
211 int penalty_decay, | 213 int penalty_decay, |
212 int type_event_delay) override; | 214 int type_event_delay) override; |
213 bool SetOutputScaling(uint32 ssrc, double left, double right) override; | 215 bool SetOutputScaling(uint32_t ssrc, double left, double right) override; |
214 | 216 |
215 bool CanInsertDtmf() override; | 217 bool CanInsertDtmf() override; |
216 bool InsertDtmf(uint32 ssrc, int event, int duration, int flags) override; | 218 bool InsertDtmf(uint32_t ssrc, int event, int duration, int flags) override; |
217 | 219 |
218 void OnPacketReceived(rtc::Buffer* packet, | 220 void OnPacketReceived(rtc::Buffer* packet, |
219 const rtc::PacketTime& packet_time) override; | 221 const rtc::PacketTime& packet_time) override; |
220 void OnRtcpReceived(rtc::Buffer* packet, | 222 void OnRtcpReceived(rtc::Buffer* packet, |
221 const rtc::PacketTime& packet_time) override; | 223 const rtc::PacketTime& packet_time) override; |
222 void OnReadyToSend(bool ready) override {} | 224 void OnReadyToSend(bool ready) override {} |
223 bool GetStats(VoiceMediaInfo* info) override; | 225 bool GetStats(VoiceMediaInfo* info) override; |
224 | 226 |
225 // implements Transport interface | 227 // implements Transport interface |
226 bool SendRtp(const uint8_t* data, | 228 bool SendRtp(const uint8_t* data, |
227 size_t len, | 229 size_t len, |
228 const webrtc::PacketOptions& options) override { | 230 const webrtc::PacketOptions& options) override { |
229 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len, | 231 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len, |
230 kMaxRtpPacketLen); | 232 kMaxRtpPacketLen); |
231 return VoiceMediaChannel::SendPacket(&packet); | 233 return VoiceMediaChannel::SendPacket(&packet); |
232 } | 234 } |
233 | 235 |
234 bool SendRtcp(const uint8_t* data, size_t len) override { | 236 bool SendRtcp(const uint8_t* data, size_t len) override { |
235 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len, | 237 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len, |
236 kMaxRtpPacketLen); | 238 kMaxRtpPacketLen); |
237 return VoiceMediaChannel::SendRtcp(&packet); | 239 return VoiceMediaChannel::SendRtcp(&packet); |
238 } | 240 } |
239 | 241 |
240 bool FindSsrc(int channel_num, uint32* ssrc); | 242 bool FindSsrc(int channel_num, uint32_t* ssrc); |
241 void OnError(uint32 ssrc, int error); | 243 void OnError(uint32_t ssrc, int error); |
242 | 244 |
243 int GetReceiveChannelNum(uint32 ssrc) const; | 245 int GetReceiveChannelNum(uint32_t ssrc) const; |
244 int GetSendChannelNum(uint32 ssrc) const; | 246 int GetSendChannelNum(uint32_t ssrc) const; |
245 | 247 |
246 private: | 248 private: |
247 bool SetSendCodecs(const std::vector<AudioCodec>& codecs); | 249 bool SetSendCodecs(const std::vector<AudioCodec>& codecs); |
248 bool SetSendRtpHeaderExtensions( | 250 bool SetSendRtpHeaderExtensions( |
249 const std::vector<RtpHeaderExtension>& extensions); | 251 const std::vector<RtpHeaderExtension>& extensions); |
250 bool SetOptions(const AudioOptions& options); | 252 bool SetOptions(const AudioOptions& options); |
251 bool SetMaxSendBandwidth(int bps); | 253 bool SetMaxSendBandwidth(int bps); |
252 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs); | 254 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs); |
253 bool SetRecvRtpHeaderExtensions( | 255 bool SetRecvRtpHeaderExtensions( |
254 const std::vector<RtpHeaderExtension>& extensions); | 256 const std::vector<RtpHeaderExtension>& extensions); |
255 bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer); | 257 bool SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer); |
256 bool MuteStream(uint32 ssrc, bool mute); | 258 bool MuteStream(uint32_t ssrc, bool mute); |
257 | 259 |
258 WebRtcVoiceEngine* engine() { return engine_; } | 260 WebRtcVoiceEngine* engine() { return engine_; } |
259 int GetLastEngineError() { return engine()->GetLastEngineError(); } | 261 int GetLastEngineError() { return engine()->GetLastEngineError(); } |
260 int GetOutputLevel(int channel); | 262 int GetOutputLevel(int channel); |
261 bool GetRedSendCodec(const AudioCodec& red_codec, | 263 bool GetRedSendCodec(const AudioCodec& red_codec, |
262 const std::vector<AudioCodec>& all_codecs, | 264 const std::vector<AudioCodec>& all_codecs, |
263 webrtc::CodecInst* send_codec); | 265 webrtc::CodecInst* send_codec); |
264 bool EnableRtcp(int channel); | 266 bool EnableRtcp(int channel); |
265 bool ResetRecvCodecs(int channel); | 267 bool ResetRecvCodecs(int channel); |
266 bool SetPlayout(int channel, bool playout); | 268 bool SetPlayout(int channel, bool playout); |
267 static uint32 ParseSsrc(const void* data, size_t len, bool rtcp); | 269 static uint32_t ParseSsrc(const void* data, size_t len, bool rtcp); |
268 static Error WebRtcErrorToChannelError(int err_code); | 270 static Error WebRtcErrorToChannelError(int err_code); |
269 | 271 |
270 class WebRtcVoiceChannelRenderer; | 272 class WebRtcVoiceChannelRenderer; |
271 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of | 273 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of |
272 // WebRtcVoiceChannelRenderer will be created for every new stream and | 274 // WebRtcVoiceChannelRenderer will be created for every new stream and |
273 // will be destroyed when the stream goes away. | 275 // will be destroyed when the stream goes away. |
274 typedef std::map<uint32, WebRtcVoiceChannelRenderer*> ChannelMap; | 276 typedef std::map<uint32_t, WebRtcVoiceChannelRenderer*> ChannelMap; |
275 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool, | 277 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool, |
276 unsigned char); | 278 unsigned char); |
277 | 279 |
278 void SetNack(int channel, bool nack_enabled); | 280 void SetNack(int channel, bool nack_enabled); |
279 void SetNack(const ChannelMap& channels, bool nack_enabled); | 281 void SetNack(const ChannelMap& channels, bool nack_enabled); |
280 bool SetSendCodec(const webrtc::CodecInst& send_codec); | 282 bool SetSendCodec(const webrtc::CodecInst& send_codec); |
281 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); | 283 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec); |
282 bool ChangePlayout(bool playout); | 284 bool ChangePlayout(bool playout); |
283 bool ChangeSend(SendFlags send); | 285 bool ChangeSend(SendFlags send); |
284 bool ChangeSend(int channel, SendFlags send); | 286 bool ChangeSend(int channel, SendFlags send); |
285 void ConfigureSendChannel(int channel); | 287 void ConfigureSendChannel(int channel); |
286 bool ConfigureRecvChannel(int channel); | 288 bool ConfigureRecvChannel(int channel); |
287 bool DeleteChannel(int channel); | 289 bool DeleteChannel(int channel); |
288 bool InConferenceMode() const { | 290 bool InConferenceMode() const { |
289 return options_.conference_mode.GetWithDefaultIfUnset(false); | 291 return options_.conference_mode.GetWithDefaultIfUnset(false); |
290 } | 292 } |
291 bool IsDefaultChannel(int channel_id) const { | 293 bool IsDefaultChannel(int channel_id) const { |
292 return channel_id == voe_channel(); | 294 return channel_id == voe_channel(); |
293 } | 295 } |
294 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); | 296 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs); |
295 bool SetSendBitrateInternal(int bps); | 297 bool SetSendBitrateInternal(int bps); |
296 | 298 |
297 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, | 299 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, |
298 const RtpHeaderExtension* extension); | 300 const RtpHeaderExtension* extension); |
299 void RecreateAudioReceiveStreams(); | 301 void RecreateAudioReceiveStreams(); |
300 void AddAudioReceiveStream(uint32 ssrc); | 302 void AddAudioReceiveStream(uint32_t ssrc); |
301 void RemoveAudioReceiveStream(uint32 ssrc); | 303 void RemoveAudioReceiveStream(uint32_t ssrc); |
302 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs); | 304 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs); |
303 | 305 |
304 bool SetChannelRecvRtpHeaderExtensions( | 306 bool SetChannelRecvRtpHeaderExtensions( |
305 int channel_id, | 307 int channel_id, |
306 const std::vector<RtpHeaderExtension>& extensions); | 308 const std::vector<RtpHeaderExtension>& extensions); |
307 bool SetChannelSendRtpHeaderExtensions( | 309 bool SetChannelSendRtpHeaderExtensions( |
308 int channel_id, | 310 int channel_id, |
309 const std::vector<RtpHeaderExtension>& extensions); | 311 const std::vector<RtpHeaderExtension>& extensions); |
310 | 312 |
311 rtc::ThreadChecker thread_checker_; | 313 rtc::ThreadChecker thread_checker_; |
(...skipping 13 matching lines...) Expand all Loading... |
325 bool typing_noise_detected_; | 327 bool typing_noise_detected_; |
326 SendFlags desired_send_; | 328 SendFlags desired_send_; |
327 SendFlags send_; | 329 SendFlags send_; |
328 webrtc::Call* const call_; | 330 webrtc::Call* const call_; |
329 | 331 |
330 // send_channels_ contains the channels which are being used for sending. | 332 // send_channels_ contains the channels which are being used for sending. |
331 // When the default channel (voe_channel) is used for sending, it is | 333 // When the default channel (voe_channel) is used for sending, it is |
332 // contained in send_channels_, otherwise not. | 334 // contained in send_channels_, otherwise not. |
333 ChannelMap send_channels_; | 335 ChannelMap send_channels_; |
334 std::vector<RtpHeaderExtension> send_extensions_; | 336 std::vector<RtpHeaderExtension> send_extensions_; |
335 uint32 default_receive_ssrc_; | 337 uint32_t default_receive_ssrc_; |
336 // Note the default channel (voe_channel()) can reside in both | 338 // Note the default channel (voe_channel()) can reside in both |
337 // receive_channels_ and send_channels_ in non-conference mode and in that | 339 // receive_channels_ and send_channels_ in non-conference mode and in that |
338 // case it will only be there if a non-zero default_receive_ssrc_ is set. | 340 // case it will only be there if a non-zero default_receive_ssrc_ is set. |
339 ChannelMap receive_channels_; // for multiple sources | 341 ChannelMap receive_channels_; // for multiple sources |
340 std::map<uint32, webrtc::AudioReceiveStream*> receive_streams_; | 342 std::map<uint32_t, webrtc::AudioReceiveStream*> receive_streams_; |
341 std::map<uint32, StreamParams> receive_stream_params_; | 343 std::map<uint32_t, StreamParams> receive_stream_params_; |
342 // receive_channels_ can be read from WebRtc callback thread. Access from | 344 // receive_channels_ can be read from WebRtc callback thread. Access from |
343 // the WebRtc thread must be synchronized with edits on the worker thread. | 345 // the WebRtc thread must be synchronized with edits on the worker thread. |
344 // Reads on the worker thread are ok. | 346 // Reads on the worker thread are ok. |
345 std::vector<RtpHeaderExtension> receive_extensions_; | 347 std::vector<RtpHeaderExtension> receive_extensions_; |
346 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 348 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
347 | 349 |
348 // Do not lock this on the VoE media processor thread; potential for deadlock | 350 // Do not lock this on the VoE media processor thread; potential for deadlock |
349 // exists. | 351 // exists. |
350 mutable rtc::CriticalSection receive_channels_cs_; | 352 mutable rtc::CriticalSection receive_channels_cs_; |
351 }; | 353 }; |
352 | 354 |
353 } // namespace cricket | 355 } // namespace cricket |
354 | 356 |
355 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ | 357 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ |
OLD | NEW |