2013-07-10 00:45:36 +00:00
|
|
|
/*
|
|
|
|
|
* libjingle
|
|
|
|
|
* Copyright 2004 Google Inc.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
|
*
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
|
|
|
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef TALK_MEDIA_WEBRTCVOICEENGINE_H_
|
|
|
|
|
#define TALK_MEDIA_WEBRTCVOICEENGINE_H_
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <set>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "talk/media/base/rtputils.h"
|
|
|
|
|
#include "talk/media/webrtc/webrtccommon.h"
|
|
|
|
|
#include "talk/media/webrtc/webrtcvoe.h"
|
|
|
|
|
#include "talk/session/media/channel.h"
|
2014-08-13 17:26:08 +00:00
|
|
|
#include "webrtc/base/buffer.h"
|
|
|
|
|
#include "webrtc/base/byteorder.h"
|
|
|
|
|
#include "webrtc/base/logging.h"
|
|
|
|
|
#include "webrtc/base/scoped_ptr.h"
|
|
|
|
|
#include "webrtc/base/stream.h"
|
2015-05-07 14:07:48 +02:00
|
|
|
#include "webrtc/base/thread_checker.h"
|
|
|
|
|
#include "webrtc/call.h"
|
2013-12-05 00:24:06 +00:00
|
|
|
#include "webrtc/common.h"
|
2015-05-11 12:44:23 +02:00
|
|
|
#include "webrtc/config.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace cricket {
|
|
|
|
|
|
|
|
|
|
class AudioDeviceModule;
|
2013-07-26 19:17:59 +00:00
|
|
|
class AudioRenderer;
|
2013-07-10 00:45:36 +00:00
|
|
|
class VoETraceWrapper;
|
|
|
|
|
class VoEWrapper;
|
|
|
|
|
class WebRtcVoiceMediaChannel;
|
|
|
|
|
|
|
|
|
|
// WebRtcVoiceEngine is a class to be used with CompositeMediaEngine.
|
|
|
|
|
// It uses the WebRtc VoiceEngine library for audio handling.
|
|
|
|
|
class WebRtcVoiceEngine
|
|
|
|
|
: public webrtc::VoiceEngineObserver,
|
2015-09-23 12:23:21 +02:00
|
|
|
public webrtc::TraceCallback {
|
2015-05-29 15:05:44 +02:00
|
|
|
friend class WebRtcVoiceMediaChannel;
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
|
|
|
|
WebRtcVoiceEngine();
|
|
|
|
|
// Dependency injection for testing.
|
2015-05-19 11:37:56 +02:00
|
|
|
WebRtcVoiceEngine(VoEWrapper* voe_wrapper, VoETraceWrapper* tracing);
|
2013-07-10 00:45:36 +00:00
|
|
|
~WebRtcVoiceEngine();
|
2014-07-29 17:36:52 +00:00
|
|
|
bool Init(rtc::Thread* worker_thread);
|
2013-07-10 00:45:36 +00:00
|
|
|
void Terminate();
|
|
|
|
|
|
2015-09-15 12:26:33 +02:00
|
|
|
webrtc::VoiceEngine* GetVoE() { return voe()->engine(); }
|
|
|
|
|
VoiceMediaChannel* CreateChannel(webrtc::Call* call,
|
|
|
|
|
const AudioOptions& options);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2013-09-27 23:04:10 +00:00
|
|
|
AudioOptions GetOptions() const { return options_; }
|
|
|
|
|
bool SetOptions(const AudioOptions& options);
|
2013-07-10 00:45:36 +00:00
|
|
|
bool SetDevices(const Device* in_device, const Device* out_device);
|
|
|
|
|
bool GetOutputVolume(int* level);
|
|
|
|
|
bool SetOutputVolume(int level);
|
|
|
|
|
int GetInputLevel();
|
|
|
|
|
|
|
|
|
|
const std::vector<AudioCodec>& codecs();
|
|
|
|
|
bool FindCodec(const AudioCodec& codec);
|
|
|
|
|
bool FindWebRtcCodec(const AudioCodec& codec, webrtc::CodecInst* gcodec);
|
|
|
|
|
|
|
|
|
|
const std::vector<RtpHeaderExtension>& rtp_header_extensions() const;
|
|
|
|
|
|
|
|
|
|
void SetLogging(int min_sev, const char* filter);
|
|
|
|
|
|
|
|
|
|
// For tracking WebRtc channels. Needed because we have to pause them
|
|
|
|
|
// all when switching devices.
|
|
|
|
|
// May only be called by WebRtcVoiceMediaChannel.
|
|
|
|
|
void RegisterChannel(WebRtcVoiceMediaChannel *channel);
|
|
|
|
|
void UnregisterChannel(WebRtcVoiceMediaChannel *channel);
|
|
|
|
|
|
|
|
|
|
// Called by WebRtcVoiceMediaChannel to set a gain offset from
|
|
|
|
|
// the default AGC target level.
|
|
|
|
|
bool AdjustAgcLevel(int delta);
|
|
|
|
|
|
|
|
|
|
VoEWrapper* voe() { return voe_wrapper_.get(); }
|
|
|
|
|
int GetLastEngineError();
|
|
|
|
|
|
2015-05-19 11:37:56 +02:00
|
|
|
// Set the external ADM. This can only be called before Init.
|
|
|
|
|
bool SetAudioDeviceModule(webrtc::AudioDeviceModule* adm);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2013-12-13 00:21:03 +00:00
|
|
|
// Starts AEC dump using existing file.
|
2014-07-29 17:36:52 +00:00
|
|
|
bool StartAecDump(rtc::PlatformFile file);
|
2013-12-13 00:21:03 +00:00
|
|
|
|
2013-12-05 00:24:06 +00:00
|
|
|
// Create a VoiceEngine Channel.
|
|
|
|
|
int CreateMediaVoiceChannel();
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
private:
|
2015-08-26 10:45:53 +02:00
|
|
|
typedef std::vector<WebRtcVoiceMediaChannel*> ChannelList;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
void Construct();
|
|
|
|
|
void ConstructCodecs();
|
2014-11-11 08:38:24 +00:00
|
|
|
bool GetVoeCodec(int index, webrtc::CodecInst* codec);
|
2013-07-10 00:45:36 +00:00
|
|
|
bool InitInternal();
|
|
|
|
|
void SetTraceFilter(int filter);
|
|
|
|
|
void SetTraceOptions(const std::string& options);
|
|
|
|
|
// Applies either options or overrides. Every option that is "set"
|
|
|
|
|
// will be applied. Every option not "set" will be ignored. This
|
|
|
|
|
// allows us to selectively turn on and off different options easily
|
|
|
|
|
// at any time.
|
|
|
|
|
bool ApplyOptions(const AudioOptions& options);
|
2015-05-29 15:05:44 +02:00
|
|
|
// Overrides, when set, take precedence over the options on a
|
|
|
|
|
// per-option basis. For example, if AGC is set in options and AEC
|
|
|
|
|
// is set in overrides, AGC and AEC will be both be set. Overrides
|
|
|
|
|
// can also turn off options. For example, if AGC is set to "on" in
|
|
|
|
|
// options and AGC is set to "off" in overrides, the result is that
|
|
|
|
|
// AGC will be off until different overrides are applied or until
|
|
|
|
|
// the overrides are cleared. Only one set of overrides is present
|
|
|
|
|
// at a time (they do not "stack"). And when the overrides are
|
|
|
|
|
// cleared, the media engine's state reverts back to the options set
|
|
|
|
|
// via SetOptions. This allows us to have both "persistent options"
|
|
|
|
|
// (the normal options) and "temporary options" (overrides).
|
|
|
|
|
bool SetOptionOverrides(const AudioOptions& options);
|
|
|
|
|
bool ClearOptionOverrides();
|
2014-10-10 09:42:53 +00:00
|
|
|
|
|
|
|
|
// webrtc::TraceCallback:
|
2015-03-04 12:58:35 +00:00
|
|
|
void Print(webrtc::TraceLevel level, const char* trace, int length) override;
|
2014-10-10 09:42:53 +00:00
|
|
|
|
|
|
|
|
// webrtc::VoiceEngineObserver:
|
2015-03-04 12:58:35 +00:00
|
|
|
void CallbackOnError(int channel, int errCode) override;
|
2014-10-10 09:42:53 +00:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Given the device type, name, and id, find device id. Return true and
|
|
|
|
|
// set the output parameter rtc_id if successful.
|
|
|
|
|
bool FindWebRtcAudioDeviceId(
|
|
|
|
|
bool is_input, const std::string& dev_name, int dev_id, int* rtc_id);
|
|
|
|
|
bool FindChannelAndSsrc(int channel_num,
|
|
|
|
|
WebRtcVoiceMediaChannel** channel,
|
|
|
|
|
uint32* ssrc) const;
|
|
|
|
|
|
|
|
|
|
void StartAecDump(const std::string& filename);
|
|
|
|
|
void StopAecDump();
|
2013-12-05 00:24:06 +00:00
|
|
|
int CreateVoiceChannel(VoEWrapper* voe);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
static const int kDefaultLogSeverity = rtc::LS_WARNING;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// The primary instance of WebRtc VoiceEngine.
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_ptr<VoEWrapper> voe_wrapper_;
|
|
|
|
|
rtc::scoped_ptr<VoETraceWrapper> tracing_;
|
2013-07-10 00:45:36 +00:00
|
|
|
// The external audio device manager
|
|
|
|
|
webrtc::AudioDeviceModule* adm_;
|
|
|
|
|
int log_filter_;
|
|
|
|
|
std::string log_options_;
|
|
|
|
|
bool is_dumping_aec_;
|
|
|
|
|
std::vector<AudioCodec> codecs_;
|
|
|
|
|
std::vector<RtpHeaderExtension> rtp_header_extensions_;
|
|
|
|
|
ChannelList channels_;
|
|
|
|
|
// channels_ can be read from WebRtc callback thread. We need a lock on that
|
|
|
|
|
// callback as well as the RegisterChannel/UnregisterChannel.
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::CriticalSection channels_cs_;
|
2013-07-10 00:45:36 +00:00
|
|
|
webrtc::AgcConfig default_agc_config_;
|
2013-12-05 00:24:06 +00:00
|
|
|
|
|
|
|
|
webrtc::Config voe_config_;
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool initialized_;
|
|
|
|
|
// See SetOptions and SetOptionOverrides for a description of the
|
|
|
|
|
// difference between options and overrides.
|
|
|
|
|
// options_ are the base options, which combined with the
|
|
|
|
|
// option_overrides_, create the current options being used.
|
|
|
|
|
// options_ is stored so that when option_overrides_ is cleared, we
|
|
|
|
|
// can restore the options_ without the option_overrides.
|
|
|
|
|
AudioOptions options_;
|
|
|
|
|
AudioOptions option_overrides_;
|
|
|
|
|
|
2015-06-09 16:03:13 +02:00
|
|
|
// Cache received extended_filter_aec, delay_agnostic_aec and experimental_ns
|
2015-03-25 22:45:56 +01:00
|
|
|
// values, and apply them in case they are missing in the audio options. We
|
|
|
|
|
// need to do this because SetExtraOptions() will revert to defaults for
|
|
|
|
|
// options which are not provided.
|
2015-06-09 16:03:13 +02:00
|
|
|
Settable<bool> extended_filter_aec_;
|
2015-03-25 22:45:56 +01:00
|
|
|
Settable<bool> delay_agnostic_aec_;
|
2014-08-28 10:52:44 +00:00
|
|
|
Settable<bool> experimental_ns_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses
|
|
|
|
|
// WebRtc Voice Engine.
|
2015-05-07 16:42:08 +02:00
|
|
|
class WebRtcVoiceMediaChannel : public VoiceMediaChannel,
|
|
|
|
|
public webrtc::Transport {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
2015-09-17 16:42:56 +02:00
|
|
|
WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine,
|
|
|
|
|
const AudioOptions& options,
|
|
|
|
|
webrtc::Call* call);
|
2015-05-07 16:05:53 +02:00
|
|
|
~WebRtcVoiceMediaChannel() override;
|
2015-05-07 16:42:08 +02:00
|
|
|
|
|
|
|
|
int voe_channel() const { return voe_channel_; }
|
|
|
|
|
bool valid() const { return voe_channel_ != -1; }
|
2015-09-09 01:36:22 -07:00
|
|
|
const AudioOptions& options() const { return options_; }
|
2015-05-07 16:42:08 +02:00
|
|
|
|
2015-08-07 16:05:34 -07:00
|
|
|
bool SetSendParameters(const AudioSendParameters& params) override;
|
|
|
|
|
bool SetRecvParameters(const AudioRecvParameters& params) override;
|
2015-05-07 16:05:53 +02:00
|
|
|
bool SetPlayout(bool playout) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
bool PausePlayout();
|
|
|
|
|
bool ResumePlayout();
|
2015-05-07 16:05:53 +02:00
|
|
|
bool SetSend(SendFlags send) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
bool PauseSend();
|
|
|
|
|
bool ResumeSend();
|
2015-09-10 01:57:14 -07:00
|
|
|
bool SetAudioSend(uint32 ssrc, bool mute, const AudioOptions* options,
|
|
|
|
|
AudioRenderer* renderer) override;
|
2015-05-07 16:05:53 +02:00
|
|
|
bool AddSendStream(const StreamParams& sp) override;
|
|
|
|
|
bool RemoveSendStream(uint32 ssrc) override;
|
|
|
|
|
bool AddRecvStream(const StreamParams& sp) override;
|
|
|
|
|
bool RemoveRecvStream(uint32 ssrc) override;
|
|
|
|
|
bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) override;
|
|
|
|
|
bool GetActiveStreams(AudioInfo::StreamList* actives) override;
|
|
|
|
|
int GetOutputLevel() override;
|
|
|
|
|
int GetTimeSinceLastTyping() override;
|
|
|
|
|
void SetTypingDetectionParameters(int time_window,
|
|
|
|
|
int cost_per_typing,
|
|
|
|
|
int reporting_threshold,
|
|
|
|
|
int penalty_decay,
|
|
|
|
|
int type_event_delay) override;
|
|
|
|
|
bool SetOutputScaling(uint32 ssrc, double left, double right) override;
|
|
|
|
|
|
|
|
|
|
bool CanInsertDtmf() override;
|
|
|
|
|
bool InsertDtmf(uint32 ssrc, int event, int duration, int flags) override;
|
|
|
|
|
|
|
|
|
|
void OnPacketReceived(rtc::Buffer* packet,
|
|
|
|
|
const rtc::PacketTime& packet_time) override;
|
|
|
|
|
void OnRtcpReceived(rtc::Buffer* packet,
|
|
|
|
|
const rtc::PacketTime& packet_time) override;
|
|
|
|
|
void OnReadyToSend(bool ready) override {}
|
|
|
|
|
bool GetStats(VoiceMediaInfo* info) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
// Gets last reported error from WebRtc voice engine. This should be only
|
|
|
|
|
// called in response a failure.
|
2015-05-07 16:05:53 +02:00
|
|
|
void GetLastMediaError(uint32* ssrc,
|
|
|
|
|
VoiceMediaChannel::Error* error) override;
|
2015-05-07 16:42:08 +02:00
|
|
|
|
|
|
|
|
// implements Transport interface
|
2015-09-17 23:03:57 +02:00
|
|
|
int SendPacket(const void* data, size_t len) override {
|
2015-05-07 16:42:08 +02:00
|
|
|
rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len,
|
|
|
|
|
kMaxRtpPacketLen);
|
|
|
|
|
return VoiceMediaChannel::SendPacket(&packet) ? static_cast<int>(len) : -1;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-17 23:03:57 +02:00
|
|
|
int SendRTCPPacket(const void* data, size_t len) override {
|
2015-05-07 16:42:08 +02:00
|
|
|
rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len,
|
|
|
|
|
kMaxRtpPacketLen);
|
|
|
|
|
return VoiceMediaChannel::SendRtcp(&packet) ? static_cast<int>(len) : -1;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool FindSsrc(int channel_num, uint32* ssrc);
|
|
|
|
|
void OnError(uint32 ssrc, int error);
|
|
|
|
|
|
|
|
|
|
bool sending() const { return send_ != SEND_NOTHING; }
|
2015-08-26 10:45:53 +02:00
|
|
|
int GetReceiveChannelNum(uint32 ssrc) const;
|
|
|
|
|
int GetSendChannelNum(uint32 ssrc) const;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-05-07 16:42:08 +02:00
|
|
|
private:
|
2015-09-17 16:42:56 +02:00
|
|
|
bool SetSendCodecs(const std::vector<AudioCodec>& codecs);
|
|
|
|
|
bool SetSendRtpHeaderExtensions(
|
|
|
|
|
const std::vector<RtpHeaderExtension>& extensions);
|
|
|
|
|
bool SetOptions(const AudioOptions& options);
|
|
|
|
|
bool SetMaxSendBandwidth(int bps);
|
|
|
|
|
bool SetRecvCodecs(const std::vector<AudioCodec>& codecs);
|
|
|
|
|
bool SetRecvRtpHeaderExtensions(
|
|
|
|
|
const std::vector<RtpHeaderExtension>& extensions);
|
2015-09-10 01:57:14 -07:00
|
|
|
bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer);
|
|
|
|
|
bool MuteStream(uint32 ssrc, bool mute);
|
2015-09-17 16:42:56 +02:00
|
|
|
|
2015-05-07 16:42:08 +02:00
|
|
|
WebRtcVoiceEngine* engine() { return engine_; }
|
2013-07-10 00:45:36 +00:00
|
|
|
int GetLastEngineError() { return engine()->GetLastEngineError(); }
|
|
|
|
|
int GetOutputLevel(int channel);
|
|
|
|
|
bool GetRedSendCodec(const AudioCodec& red_codec,
|
|
|
|
|
const std::vector<AudioCodec>& all_codecs,
|
|
|
|
|
webrtc::CodecInst* send_codec);
|
|
|
|
|
bool EnableRtcp(int channel);
|
|
|
|
|
bool ResetRecvCodecs(int channel);
|
|
|
|
|
bool SetPlayout(int channel, bool playout);
|
|
|
|
|
static uint32 ParseSsrc(const void* data, size_t len, bool rtcp);
|
|
|
|
|
static Error WebRtcErrorToChannelError(int err_code);
|
|
|
|
|
|
2014-02-03 16:57:16 +00:00
|
|
|
class WebRtcVoiceChannelRenderer;
|
|
|
|
|
// Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of
|
|
|
|
|
// WebRtcVoiceChannelRenderer will be created for every new stream and
|
|
|
|
|
// will be destroyed when the stream goes away.
|
|
|
|
|
typedef std::map<uint32, WebRtcVoiceChannelRenderer*> ChannelMap;
|
2014-03-06 23:46:59 +00:00
|
|
|
typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool,
|
|
|
|
|
unsigned char);
|
2013-07-26 19:17:59 +00:00
|
|
|
|
2013-08-30 21:24:16 +00:00
|
|
|
void SetNack(int channel, bool nack_enabled);
|
2013-08-05 20:36:57 +00:00
|
|
|
void SetNack(const ChannelMap& channels, bool nack_enabled);
|
2013-07-10 00:45:36 +00:00
|
|
|
bool SetSendCodec(const webrtc::CodecInst& send_codec);
|
2013-08-05 20:36:57 +00:00
|
|
|
bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec);
|
2013-07-10 00:45:36 +00:00
|
|
|
bool ChangePlayout(bool playout);
|
|
|
|
|
bool ChangeSend(SendFlags send);
|
2013-08-05 20:36:57 +00:00
|
|
|
bool ChangeSend(int channel, SendFlags send);
|
|
|
|
|
void ConfigureSendChannel(int channel);
|
2013-10-07 23:32:02 +00:00
|
|
|
bool ConfigureRecvChannel(int channel);
|
2013-08-05 20:36:57 +00:00
|
|
|
bool DeleteChannel(int channel);
|
2013-07-26 19:17:59 +00:00
|
|
|
bool InConferenceMode() const {
|
|
|
|
|
return options_.conference_mode.GetWithDefaultIfUnset(false);
|
|
|
|
|
}
|
2013-08-05 20:36:57 +00:00
|
|
|
bool IsDefaultChannel(int channel_id) const {
|
|
|
|
|
return channel_id == voe_channel();
|
|
|
|
|
}
|
2013-08-30 21:24:16 +00:00
|
|
|
bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs);
|
2014-10-29 02:27:08 +00:00
|
|
|
bool SetSendBitrateInternal(int bps);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2014-03-06 23:46:59 +00:00
|
|
|
bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id,
|
|
|
|
|
const RtpHeaderExtension* extension);
|
2015-09-15 12:26:33 +02:00
|
|
|
void RecreateAudioReceiveStreams();
|
|
|
|
|
void AddAudioReceiveStream(uint32 ssrc);
|
|
|
|
|
void RemoveAudioReceiveStream(uint32 ssrc);
|
2015-08-26 10:45:53 +02:00
|
|
|
bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs);
|
2015-05-07 14:07:48 +02:00
|
|
|
|
2014-05-06 15:54:38 +00:00
|
|
|
bool SetChannelRecvRtpHeaderExtensions(
|
|
|
|
|
int channel_id,
|
|
|
|
|
const std::vector<RtpHeaderExtension>& extensions);
|
|
|
|
|
bool SetChannelSendRtpHeaderExtensions(
|
|
|
|
|
int channel_id,
|
|
|
|
|
const std::vector<RtpHeaderExtension>& extensions);
|
|
|
|
|
|
2015-05-07 14:07:48 +02:00
|
|
|
rtc::ThreadChecker thread_checker_;
|
|
|
|
|
|
2015-09-15 12:26:33 +02:00
|
|
|
WebRtcVoiceEngine* const engine_;
|
2015-05-07 16:42:08 +02:00
|
|
|
const int voe_channel_;
|
2013-07-10 00:45:36 +00:00
|
|
|
std::vector<AudioCodec> recv_codecs_;
|
2013-08-30 21:24:16 +00:00
|
|
|
std::vector<AudioCodec> send_codecs_;
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_ptr<webrtc::CodecInst> send_codec_;
|
2014-10-29 02:27:08 +00:00
|
|
|
bool send_bitrate_setting_;
|
|
|
|
|
int send_bitrate_bps_;
|
2013-07-10 00:45:36 +00:00
|
|
|
AudioOptions options_;
|
|
|
|
|
bool dtmf_allowed_;
|
|
|
|
|
bool desired_playout_;
|
|
|
|
|
bool nack_enabled_;
|
|
|
|
|
bool playout_;
|
2013-09-19 05:49:50 +00:00
|
|
|
bool typing_noise_detected_;
|
2013-07-10 00:45:36 +00:00
|
|
|
SendFlags desired_send_;
|
|
|
|
|
SendFlags send_;
|
2015-09-15 12:26:33 +02:00
|
|
|
webrtc::Call* const call_;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2013-08-05 20:36:57 +00:00
|
|
|
// send_channels_ contains the channels which are being used for sending.
|
|
|
|
|
// When the default channel (voe_channel) is used for sending, it is
|
|
|
|
|
// contained in send_channels_, otherwise not.
|
|
|
|
|
ChannelMap send_channels_;
|
2014-05-06 15:54:38 +00:00
|
|
|
std::vector<RtpHeaderExtension> send_extensions_;
|
2013-07-10 00:45:36 +00:00
|
|
|
uint32 default_receive_ssrc_;
|
2013-07-26 19:17:59 +00:00
|
|
|
// Note the default channel (voe_channel()) can reside in both
|
2013-08-05 20:36:57 +00:00
|
|
|
// receive_channels_ and send_channels_ in non-conference mode and in that
|
|
|
|
|
// case it will only be there if a non-zero default_receive_ssrc_ is set.
|
2013-07-26 19:17:59 +00:00
|
|
|
ChannelMap receive_channels_; // for multiple sources
|
2015-05-07 14:07:48 +02:00
|
|
|
std::map<uint32, webrtc::AudioReceiveStream*> receive_streams_;
|
2015-07-15 08:02:58 -07:00
|
|
|
std::map<uint32, StreamParams> receive_stream_params_;
|
2013-07-26 19:17:59 +00:00
|
|
|
// receive_channels_ can be read from WebRtc callback thread. Access from
|
|
|
|
|
// the WebRtc thread must be synchronized with edits on the worker thread.
|
|
|
|
|
// Reads on the worker thread are ok.
|
2014-05-06 15:54:38 +00:00
|
|
|
std::vector<RtpHeaderExtension> receive_extensions_;
|
2015-05-07 14:07:48 +02:00
|
|
|
std::vector<webrtc::RtpExtension> recv_rtp_extensions_;
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Do not lock this on the VoE media processor thread; potential for deadlock
|
|
|
|
|
// exists.
|
2014-07-29 17:36:52 +00:00
|
|
|
mutable rtc::CriticalSection receive_channels_cs_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace cricket
|
|
|
|
|
|
|
|
|
|
#endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_
|