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