2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-03-01 18:34:25 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef WEBRTC_VOICE_ENGINE_CHANNEL_H
|
|
|
|
|
#define WEBRTC_VOICE_ENGINE_CHANNEL_H
|
|
|
|
|
|
2013-07-31 16:23:37 +00:00
|
|
|
#include "webrtc/common_audio/resampler/include/push_resampler.h"
|
2013-02-12 21:42:18 +00:00
|
|
|
#include "webrtc/common_types.h"
|
|
|
|
|
#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
|
|
|
|
|
#include "webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer_defines.h"
|
2013-05-29 12:12:51 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
|
2013-02-12 21:42:18 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
|
|
|
|
|
#include "webrtc/modules/utility/interface/file_player.h"
|
|
|
|
|
#include "webrtc/modules/utility/interface/file_recorder.h"
|
|
|
|
|
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
|
|
|
|
#include "webrtc/voice_engine/dtmf_inband.h"
|
|
|
|
|
#include "webrtc/voice_engine/dtmf_inband_queue.h"
|
|
|
|
|
#include "webrtc/voice_engine/include/voe_audio_processing.h"
|
|
|
|
|
#include "webrtc/voice_engine/include/voe_network.h"
|
|
|
|
|
#include "webrtc/voice_engine/level_indicator.h"
|
|
|
|
|
#include "webrtc/voice_engine/shared_data.h"
|
|
|
|
|
#include "webrtc/voice_engine/voice_engine_defines.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
#ifdef WEBRTC_DTMF_DETECTION
|
2013-05-21 13:52:32 +00:00
|
|
|
// TelephoneEventDetectionMethods, TelephoneEventObserver
|
|
|
|
|
#include "webrtc/voice_engine/include/voe_dtmf.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace webrtc
|
|
|
|
|
{
|
2013-07-05 14:30:48 +00:00
|
|
|
class CriticalSectionWrapper;
|
|
|
|
|
class ProcessThread;
|
2013-07-16 19:25:04 +00:00
|
|
|
class AudioDeviceModule;
|
2013-07-05 14:30:48 +00:00
|
|
|
class RtpRtcp;
|
2013-07-16 19:25:04 +00:00
|
|
|
class FileWrapper;
|
|
|
|
|
class RtpDump;
|
|
|
|
|
class VoiceEngineObserver;
|
2011-07-07 08:21:25 +00:00
|
|
|
class VoEMediaProcess;
|
2013-07-05 14:30:48 +00:00
|
|
|
class VoERTPObserver;
|
2013-07-16 19:25:04 +00:00
|
|
|
class VoERTCPObserver;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
struct CallStatistics;
|
2012-08-22 08:53:55 +00:00
|
|
|
struct ReportBlock;
|
|
|
|
|
struct SenderInfo;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace voe
|
|
|
|
|
{
|
|
|
|
|
class Statistics;
|
|
|
|
|
class TransmitMixer;
|
|
|
|
|
class OutputMixer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Channel:
|
|
|
|
|
public RtpData,
|
|
|
|
|
public RtpFeedback,
|
|
|
|
|
public RtcpFeedback,
|
|
|
|
|
public FileCallback, // receiving notification from file player & recorder
|
|
|
|
|
public Transport,
|
|
|
|
|
public RtpAudioFeedback,
|
|
|
|
|
public AudioPacketizationCallback, // receive encoded packets from the ACM
|
|
|
|
|
public ACMVADCallback, // receive voice activity from the ACM
|
|
|
|
|
public MixerParticipant // supplies output mixer with audio frames
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
enum {KNumSocketThreads = 1};
|
|
|
|
|
enum {KNumberOfSocketBuffers = 8};
|
|
|
|
|
public:
|
|
|
|
|
virtual ~Channel();
|
2013-04-09 10:09:10 +00:00
|
|
|
static int32_t CreateChannel(Channel*& channel,
|
2013-05-14 08:31:39 +00:00
|
|
|
int32_t channelId,
|
|
|
|
|
uint32_t instanceId);
|
|
|
|
|
Channel(int32_t channelId, uint32_t instanceId);
|
2013-04-09 10:09:10 +00:00
|
|
|
int32_t Init();
|
|
|
|
|
int32_t SetEngineInformation(
|
2011-07-07 08:21:25 +00:00
|
|
|
Statistics& engineStatistics,
|
|
|
|
|
OutputMixer& outputMixer,
|
|
|
|
|
TransmitMixer& transmitMixer,
|
|
|
|
|
ProcessThread& moduleProcessThread,
|
|
|
|
|
AudioDeviceModule& audioDeviceModule,
|
|
|
|
|
VoiceEngineObserver* voiceEngineObserver,
|
|
|
|
|
CriticalSectionWrapper* callbackCritSect);
|
2013-04-09 10:09:10 +00:00
|
|
|
int32_t UpdateLocalTimeStamp();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// API methods
|
|
|
|
|
|
|
|
|
|
// VoEBase
|
2013-04-09 10:09:10 +00:00
|
|
|
int32_t StartPlayout();
|
|
|
|
|
int32_t StopPlayout();
|
|
|
|
|
int32_t StartSend();
|
|
|
|
|
int32_t StopSend();
|
|
|
|
|
int32_t StartReceiving();
|
|
|
|
|
int32_t StopReceiving();
|
|
|
|
|
|
|
|
|
|
int32_t SetNetEQPlayoutMode(NetEqModes mode);
|
|
|
|
|
int32_t GetNetEQPlayoutMode(NetEqModes& mode);
|
|
|
|
|
int32_t SetOnHoldStatus(bool enable, OnHoldModes mode);
|
|
|
|
|
int32_t GetOnHoldStatus(bool& enabled, OnHoldModes& mode);
|
|
|
|
|
int32_t RegisterVoiceEngineObserver(VoiceEngineObserver& observer);
|
|
|
|
|
int32_t DeRegisterVoiceEngineObserver();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
// VoECodec
|
2013-04-09 10:09:10 +00:00
|
|
|
int32_t GetSendCodec(CodecInst& codec);
|
|
|
|
|
int32_t GetRecCodec(CodecInst& codec);
|
|
|
|
|
int32_t SetSendCodec(const CodecInst& codec);
|
|
|
|
|
int32_t SetVADStatus(bool enableVAD, ACMVADMode mode, bool disableDTX);
|
|
|
|
|
int32_t GetVADStatus(bool& enabledVAD, ACMVADMode& mode, bool& disabledDTX);
|
|
|
|
|
int32_t SetRecPayloadType(const CodecInst& codec);
|
|
|
|
|
int32_t GetRecPayloadType(CodecInst& codec);
|
|
|
|
|
int32_t SetAMREncFormat(AmrMode mode);
|
|
|
|
|
int32_t SetAMRDecFormat(AmrMode mode);
|
|
|
|
|
int32_t SetAMRWbEncFormat(AmrMode mode);
|
|
|
|
|
int32_t SetAMRWbDecFormat(AmrMode mode);
|
|
|
|
|
int32_t SetSendCNPayloadType(int type, PayloadFrequencies frequency);
|
|
|
|
|
int32_t SetISACInitTargetRate(int rateBps, bool useFixedFrameSize);
|
|
|
|
|
int32_t SetISACMaxRate(int rateBps);
|
|
|
|
|
int32_t SetISACMaxPayloadSize(int sizeBytes);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2012-12-11 02:15:12 +00:00
|
|
|
// VoE dual-streaming.
|
|
|
|
|
int SetSecondarySendCodec(const CodecInst& codec, int red_payload_type);
|
|
|
|
|
void RemoveSecondarySendCodec();
|
|
|
|
|
int GetSecondarySendCodec(CodecInst* codec);
|
|
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
// VoENetwork
|
2013-04-09 10:09:10 +00:00
|
|
|
int32_t RegisterExternalTransport(Transport& transport);
|
|
|
|
|
int32_t DeRegisterExternalTransport();
|
|
|
|
|
int32_t ReceivedRTPPacket(const int8_t* data, int32_t length);
|
|
|
|
|
int32_t ReceivedRTCPPacket(const int8_t* data, int32_t length);
|
2013-07-16 19:25:04 +00:00
|
|
|
int32_t SetPacketTimeoutNotification(bool enable, int timeoutSeconds);
|
|
|
|
|
int32_t GetPacketTimeoutNotification(bool& enabled, int& timeoutSeconds);
|
|
|
|
|
int32_t RegisterDeadOrAliveObserver(VoEConnectionObserver& observer);
|
|
|
|
|
int32_t DeRegisterDeadOrAliveObserver();
|
|
|
|
|
int32_t SetPeriodicDeadOrAliveStatus(bool enable, int sampleTimeSeconds);
|
|
|
|
|
int32_t GetPeriodicDeadOrAliveStatus(bool& enabled, int& sampleTimeSeconds);
|
2013-03-13 23:20:57 +00:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
// VoEFile
|
2013-05-14 08:31:39 +00:00
|
|
|
int StartPlayingFileLocally(const char* fileName, bool loop,
|
|
|
|
|
FileFormats format,
|
|
|
|
|
int startPosition,
|
|
|
|
|
float volumeScaling,
|
|
|
|
|
int stopPosition,
|
2011-07-07 08:21:25 +00:00
|
|
|
const CodecInst* codecInst);
|
2013-05-14 08:31:39 +00:00
|
|
|
int StartPlayingFileLocally(InStream* stream, FileFormats format,
|
|
|
|
|
int startPosition,
|
|
|
|
|
float volumeScaling,
|
|
|
|
|
int stopPosition,
|
2011-07-07 08:21:25 +00:00
|
|
|
const CodecInst* codecInst);
|
|
|
|
|
int StopPlayingFileLocally();
|
|
|
|
|
int IsPlayingFileLocally() const;
|
2012-06-04 03:26:39 +00:00
|
|
|
int RegisterFilePlayingToMixer();
|
2013-05-14 08:31:39 +00:00
|
|
|
int ScaleLocalFilePlayout(float scale);
|
2011-07-07 08:21:25 +00:00
|
|
|
int GetLocalPlayoutPosition(int& positionMs);
|
2013-05-14 08:31:39 +00:00
|
|
|
int StartPlayingFileAsMicrophone(const char* fileName, bool loop,
|
|
|
|
|
FileFormats format,
|
|
|
|
|
int startPosition,
|
|
|
|
|
float volumeScaling,
|
|
|
|
|
int stopPosition,
|
2011-07-07 08:21:25 +00:00
|
|
|
const CodecInst* codecInst);
|
|
|
|
|
int StartPlayingFileAsMicrophone(InStream* stream,
|
2013-05-14 08:31:39 +00:00
|
|
|
FileFormats format,
|
|
|
|
|
int startPosition,
|
|
|
|
|
float volumeScaling,
|
|
|
|
|
int stopPosition,
|
2011-07-07 08:21:25 +00:00
|
|
|
const CodecInst* codecInst);
|
|
|
|
|
int StopPlayingFileAsMicrophone();
|
|
|
|
|
int IsPlayingFileAsMicrophone() const;
|
2013-05-14 08:31:39 +00:00
|
|
|
int ScaleFileAsMicrophonePlayout(float scale);
|
2011-07-07 08:21:25 +00:00
|
|
|
int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst);
|
|
|
|
|
int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst);
|
|
|
|
|
int StopRecordingPlayout();
|
|
|
|
|
|
|
|
|
|
void SetMixWithMicStatus(bool mix);
|
|
|
|
|
|
|
|
|
|
// VoEExternalMediaProcessing
|
|
|
|
|
int RegisterExternalMediaProcessing(ProcessingTypes type,
|
|
|
|
|
VoEMediaProcess& processObject);
|
|
|
|
|
int DeRegisterExternalMediaProcessing(ProcessingTypes type);
|
2012-12-12 23:00:29 +00:00
|
|
|
int SetExternalMixing(bool enabled);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
// VoEVolumeControl
|
2013-04-09 10:09:10 +00:00
|
|
|
int GetSpeechOutputLevel(uint32_t& level) const;
|
|
|
|
|
int GetSpeechOutputLevelFullRange(uint32_t& level) const;
|
2013-05-14 08:31:39 +00:00
|
|
|
int SetMute(bool enable);
|
2011-07-07 08:21:25 +00:00
|
|
|
bool Mute() const;
|
|
|
|
|
int SetOutputVolumePan(float left, float right);
|
|
|
|
|
int GetOutputVolumePan(float& left, float& right) const;
|
|
|
|
|
int SetChannelOutputVolumeScaling(float scaling);
|
|
|
|
|
int GetChannelOutputVolumeScaling(float& scaling) const;
|
|
|
|
|
|
|
|
|
|
// VoECallReport
|
|
|
|
|
void ResetDeadOrAliveCounters();
|
|
|
|
|
int ResetRTCPStatistics();
|
|
|
|
|
int GetRoundTripTimeSummary(StatVal& delaysMs) const;
|
|
|
|
|
int GetDeadOrAliveCounters(int& countDead, int& countAlive) const;
|
|
|
|
|
|
|
|
|
|
// VoENetEqStats
|
|
|
|
|
int GetNetworkStatistics(NetworkStatistics& stats);
|
|
|
|
|
|
|
|
|
|
// VoEVideoSync
|
2013-04-11 20:23:35 +00:00
|
|
|
bool GetDelayEstimate(int* jitter_buffer_delay_ms,
|
|
|
|
|
int* playout_buffer_delay_ms) const;
|
2013-05-22 20:39:43 +00:00
|
|
|
int least_required_delay_ms() const { return least_required_delay_ms_; }
|
2013-02-12 21:42:18 +00:00
|
|
|
int SetInitialPlayoutDelay(int delay_ms);
|
2011-07-07 08:21:25 +00:00
|
|
|
int SetMinimumPlayoutDelay(int delayMs);
|
|
|
|
|
int GetPlayoutTimestamp(unsigned int& timestamp);
|
2013-04-11 20:23:35 +00:00
|
|
|
void UpdatePlayoutTimestamp(bool rtcp);
|
2011-07-07 08:21:25 +00:00
|
|
|
int SetInitTimestamp(unsigned int timestamp);
|
|
|
|
|
int SetInitSequenceNumber(short sequenceNumber);
|
|
|
|
|
|
|
|
|
|
// VoEVideoSyncExtended
|
2013-07-16 19:25:04 +00:00
|
|
|
int GetRtpRtcp(RtpRtcp* &rtpRtcpModule) const;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
// VoEEncryption
|
|
|
|
|
int RegisterExternalEncryption(Encryption& encryption);
|
|
|
|
|
int DeRegisterExternalEncryption();
|
|
|
|
|
|
|
|
|
|
// VoEDtmf
|
|
|
|
|
int SendTelephoneEventOutband(unsigned char eventCode, int lengthMs,
|
|
|
|
|
int attenuationDb, bool playDtmfEvent);
|
|
|
|
|
int SendTelephoneEventInband(unsigned char eventCode, int lengthMs,
|
|
|
|
|
int attenuationDb, bool playDtmfEvent);
|
|
|
|
|
int SetDtmfPlayoutStatus(bool enable);
|
|
|
|
|
bool DtmfPlayoutStatus() const;
|
|
|
|
|
int SetSendTelephoneEventPayloadType(unsigned char type);
|
|
|
|
|
int GetSendTelephoneEventPayloadType(unsigned char& type);
|
|
|
|
|
|
|
|
|
|
// VoEAudioProcessingImpl
|
|
|
|
|
int UpdateRxVadDetection(AudioFrame& audioFrame);
|
|
|
|
|
int RegisterRxVadObserver(VoERxVadCallback &observer);
|
|
|
|
|
int DeRegisterRxVadObserver();
|
|
|
|
|
int VoiceActivityIndicator(int &activity);
|
|
|
|
|
#ifdef WEBRTC_VOICE_ENGINE_AGC
|
2013-05-14 08:31:39 +00:00
|
|
|
int SetRxAgcStatus(bool enable, AgcModes mode);
|
2011-07-07 08:21:25 +00:00
|
|
|
int GetRxAgcStatus(bool& enabled, AgcModes& mode);
|
2013-05-14 08:31:39 +00:00
|
|
|
int SetRxAgcConfig(AgcConfig config);
|
2011-07-07 08:21:25 +00:00
|
|
|
int GetRxAgcConfig(AgcConfig& config);
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef WEBRTC_VOICE_ENGINE_NR
|
2013-05-14 08:31:39 +00:00
|
|
|
int SetRxNsStatus(bool enable, NsModes mode);
|
2011-07-07 08:21:25 +00:00
|
|
|
int GetRxNsStatus(bool& enabled, NsModes& mode);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// VoERTP_RTCP
|
|
|
|
|
int RegisterRTPObserver(VoERTPObserver& observer);
|
|
|
|
|
int DeRegisterRTPObserver();
|
|
|
|
|
int RegisterRTCPObserver(VoERTCPObserver& observer);
|
|
|
|
|
int DeRegisterRTCPObserver();
|
|
|
|
|
int SetLocalSSRC(unsigned int ssrc);
|
|
|
|
|
int GetLocalSSRC(unsigned int& ssrc);
|
|
|
|
|
int GetRemoteSSRC(unsigned int& ssrc);
|
|
|
|
|
int GetRemoteCSRCs(unsigned int arrCSRC[15]);
|
|
|
|
|
int SetRTPAudioLevelIndicationStatus(bool enable, unsigned char ID);
|
|
|
|
|
int GetRTPAudioLevelIndicationStatus(bool& enable, unsigned char& ID);
|
|
|
|
|
int SetRTCPStatus(bool enable);
|
|
|
|
|
int GetRTCPStatus(bool& enabled);
|
|
|
|
|
int SetRTCP_CNAME(const char cName[256]);
|
|
|
|
|
int GetRTCP_CNAME(char cName[256]);
|
|
|
|
|
int GetRemoteRTCP_CNAME(char cName[256]);
|
|
|
|
|
int GetRemoteRTCPData(unsigned int& NTPHigh, unsigned int& NTPLow,
|
|
|
|
|
unsigned int& timestamp,
|
|
|
|
|
unsigned int& playoutTimestamp, unsigned int* jitter,
|
|
|
|
|
unsigned short* fractionLost);
|
2013-05-14 08:31:39 +00:00
|
|
|
int SendApplicationDefinedRTCPPacket(unsigned char subType,
|
2011-07-07 08:21:25 +00:00
|
|
|
unsigned int name, const char* data,
|
|
|
|
|
unsigned short dataLengthInBytes);
|
|
|
|
|
int GetRTPStatistics(unsigned int& averageJitterMs,
|
|
|
|
|
unsigned int& maxJitterMs,
|
|
|
|
|
unsigned int& discardedPackets);
|
2012-08-22 08:53:55 +00:00
|
|
|
int GetRemoteRTCPSenderInfo(SenderInfo* sender_info);
|
|
|
|
|
int GetRemoteRTCPReportBlocks(std::vector<ReportBlock>* report_blocks);
|
2011-07-07 08:21:25 +00:00
|
|
|
int GetRTPStatistics(CallStatistics& stats);
|
|
|
|
|
int SetFECStatus(bool enable, int redPayloadtype);
|
|
|
|
|
int GetFECStatus(bool& enabled, int& redPayloadtype);
|
2013-06-05 15:33:20 +00:00
|
|
|
void SetNACKStatus(bool enable, int maxNumberOfPackets);
|
2011-07-07 08:21:25 +00:00
|
|
|
int StartRTPDump(const char fileNameUTF8[1024], RTPDirections direction);
|
|
|
|
|
int StopRTPDump(RTPDirections direction);
|
|
|
|
|
bool RTPDumpIsActive(RTPDirections direction);
|
|
|
|
|
int InsertExtraRTPPacket(unsigned char payloadType, bool markerBit,
|
|
|
|
|
const char* payloadData,
|
|
|
|
|
unsigned short payloadSize);
|
2012-12-12 21:31:41 +00:00
|
|
|
uint32_t LastRemoteTimeStamp() { return _lastRemoteTimeStamp; }
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// From AudioPacketizationCallback in the ACM
|
2013-04-09 10:09:10 +00:00
|
|
|
int32_t SendData(FrameType frameType,
|
|
|
|
|
uint8_t payloadType,
|
|
|
|
|
uint32_t timeStamp,
|
|
|
|
|
const uint8_t* payloadData,
|
|
|
|
|
uint16_t payloadSize,
|
|
|
|
|
const RTPFragmentationHeader* fragmentation);
|
2011-07-07 08:21:25 +00:00
|
|
|
// From ACMVADCallback in the ACM
|
2013-04-09 10:09:10 +00:00
|
|
|
int32_t InFrameType(int16_t frameType);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
public:
|
2013-05-14 08:31:39 +00:00
|
|
|
int32_t OnRxVadDetected(int vadDecision);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// From RtpData in the RTP/RTCP module
|
2013-04-09 10:09:10 +00:00
|
|
|
int32_t OnReceivedPayloadData(const uint8_t* payloadData,
|
2013-05-14 08:31:39 +00:00
|
|
|
uint16_t payloadSize,
|
2013-04-09 10:09:10 +00:00
|
|
|
const WebRtcRTPHeader* rtpHeader);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// From RtpFeedback in the RTP/RTCP module
|
2013-04-09 10:09:10 +00:00
|
|
|
int32_t OnInitializeDecoder(
|
2013-05-14 08:31:39 +00:00
|
|
|
int32_t id,
|
|
|
|
|
int8_t payloadType,
|
2012-03-01 18:34:25 +00:00
|
|
|
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
2013-05-14 08:31:39 +00:00
|
|
|
int frequency,
|
|
|
|
|
uint8_t channels,
|
|
|
|
|
uint32_t rate);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-14 08:31:39 +00:00
|
|
|
void OnPacketTimeout(int32_t id);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-14 08:31:39 +00:00
|
|
|
void OnReceivedPacket(int32_t id, RtpRtcpPacketType packetType);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-14 08:31:39 +00:00
|
|
|
void OnPeriodicDeadOrAlive(int32_t id,
|
|
|
|
|
RTPAliveType alive);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-14 08:31:39 +00:00
|
|
|
void OnIncomingSSRCChanged(int32_t id,
|
2013-07-15 21:08:27 +00:00
|
|
|
uint32_t SSRC);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-14 08:31:39 +00:00
|
|
|
void OnIncomingCSRCChanged(int32_t id,
|
|
|
|
|
uint32_t CSRC, bool added);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// From RtcpFeedback in the RTP/RTCP module
|
2013-05-14 08:31:39 +00:00
|
|
|
void OnApplicationDataReceived(int32_t id,
|
|
|
|
|
uint8_t subType,
|
|
|
|
|
uint32_t name,
|
|
|
|
|
uint16_t length,
|
2013-04-09 10:09:10 +00:00
|
|
|
const uint8_t* data);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// From RtpAudioFeedback in the RTP/RTCP module
|
2013-05-14 08:31:39 +00:00
|
|
|
void OnReceivedTelephoneEvent(int32_t id,
|
|
|
|
|
uint8_t event,
|
|
|
|
|
bool endOfEvent);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-05-14 08:31:39 +00:00
|
|
|
void OnPlayTelephoneEvent(int32_t id,
|
|
|
|
|
uint8_t event,
|
|
|
|
|
uint16_t lengthMs,
|
|
|
|
|
uint8_t volume);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// From Transport (called by the RTP/RTCP module)
|
|
|
|
|
int SendPacket(int /*channel*/, const void *data, int len);
|
|
|
|
|
int SendRTCPPacket(int /*channel*/, const void *data, int len);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// From MixerParticipant
|
2013-05-14 08:31:39 +00:00
|
|
|
int32_t GetAudioFrame(int32_t id, AudioFrame& audioFrame);
|
|
|
|
|
int32_t NeededFrequency(int32_t id);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// From MonitorObserver
|
|
|
|
|
void OnPeriodicProcess();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
// From FileCallback
|
2013-05-14 08:31:39 +00:00
|
|
|
void PlayNotification(int32_t id,
|
|
|
|
|
uint32_t durationMs);
|
|
|
|
|
void RecordNotification(int32_t id,
|
|
|
|
|
uint32_t durationMs);
|
|
|
|
|
void PlayFileEnded(int32_t id);
|
|
|
|
|
void RecordFileEnded(int32_t id);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
public:
|
2013-04-09 10:09:10 +00:00
|
|
|
uint32_t InstanceId() const
|
2011-07-07 08:21:25 +00:00
|
|
|
{
|
|
|
|
|
return _instanceId;
|
2011-11-28 16:31:28 +00:00
|
|
|
}
|
2013-04-09 10:09:10 +00:00
|
|
|
int32_t ChannelId() const
|
2011-07-07 08:21:25 +00:00
|
|
|
{
|
|
|
|
|
return _channelId;
|
2011-11-28 16:31:28 +00:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
bool Playing() const
|
|
|
|
|
{
|
|
|
|
|
return _playing;
|
2011-11-28 16:31:28 +00:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
bool Sending() const
|
|
|
|
|
{
|
2011-11-28 16:31:28 +00:00
|
|
|
// A lock is needed because |_sending| is accessed by both
|
|
|
|
|
// TransmitMixer::PrepareDemux() and StartSend()/StopSend(), which
|
|
|
|
|
// are called by different threads.
|
2012-03-07 08:12:21 +00:00
|
|
|
CriticalSectionScoped cs(&_callbackCritSect);
|
2011-07-07 08:21:25 +00:00
|
|
|
return _sending;
|
2011-11-28 16:31:28 +00:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
bool Receiving() const
|
|
|
|
|
{
|
|
|
|
|
return _receiving;
|
2011-11-28 16:31:28 +00:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
bool ExternalTransport() const
|
|
|
|
|
{
|
|
|
|
|
return _externalTransport;
|
2011-11-28 16:31:28 +00:00
|
|
|
}
|
2012-12-12 23:00:29 +00:00
|
|
|
bool ExternalMixing() const
|
|
|
|
|
{
|
|
|
|
|
return _externalMixing;
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
bool OutputIsOnHold() const
|
|
|
|
|
{
|
|
|
|
|
return _outputIsOnHold;
|
2011-11-28 16:31:28 +00:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
bool InputIsOnHold() const
|
|
|
|
|
{
|
|
|
|
|
return _inputIsOnHold;
|
2011-11-28 16:31:28 +00:00
|
|
|
}
|
2011-08-19 22:56:22 +00:00
|
|
|
RtpRtcp* RtpRtcpModulePtr() const
|
2011-07-07 08:21:25 +00:00
|
|
|
{
|
2012-05-11 11:08:54 +00:00
|
|
|
return _rtpRtcpModule.get();
|
2011-11-28 16:31:28 +00:00
|
|
|
}
|
2013-04-09 10:09:10 +00:00
|
|
|
int8_t OutputEnergyLevel() const
|
2011-07-07 08:21:25 +00:00
|
|
|
{
|
|
|
|
|
return _outputAudioLevel.Level();
|
2011-11-28 16:31:28 +00:00
|
|
|
}
|
2013-04-09 10:09:10 +00:00
|
|
|
uint32_t Demultiplex(const AudioFrame& audioFrame);
|
2013-07-31 16:23:37 +00:00
|
|
|
// Demultiplex the data to the channel's |_audioFrame|. The difference
|
|
|
|
|
// between this method and the overloaded method above is that |audio_data|
|
|
|
|
|
// does not go through transmit_mixer and APM.
|
|
|
|
|
void Demultiplex(const int16_t* audio_data,
|
2013-07-31 16:27:42 +00:00
|
|
|
int sample_rate,
|
2013-07-31 16:23:37 +00:00
|
|
|
int number_of_frames,
|
2013-07-31 16:27:42 +00:00
|
|
|
int number_of_channels);
|
2013-04-09 10:09:10 +00:00
|
|
|
uint32_t PrepareEncodeAndSend(int mixingFrequency);
|
|
|
|
|
uint32_t EncodeAndSend();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
private:
|
2013-06-07 01:43:12 +00:00
|
|
|
int ResendPackets(const uint16_t* sequence_numbers, int length);
|
2011-07-07 08:21:25 +00:00
|
|
|
int InsertInbandDtmfTone();
|
2013-05-14 08:31:39 +00:00
|
|
|
int32_t MixOrReplaceAudioWithFile(int mixingFrequency);
|
|
|
|
|
int32_t MixAudioWithFile(AudioFrame& audioFrame, int mixingFrequency);
|
2011-07-07 08:21:25 +00:00
|
|
|
void UpdateDeadOrAliveCounters(bool alive);
|
2013-04-09 10:09:10 +00:00
|
|
|
int32_t SendPacketRaw(const void *data, int len, bool RTCP);
|
2013-04-11 20:23:35 +00:00
|
|
|
void UpdatePacketDelay(uint32_t timestamp,
|
|
|
|
|
uint16_t sequenceNumber);
|
2011-07-07 08:21:25 +00:00
|
|
|
void RegisterReceiveCodecsToRTPModule();
|
|
|
|
|
int ApmProcessRx(AudioFrame& audioFrame);
|
|
|
|
|
|
2012-12-11 02:15:12 +00:00
|
|
|
int SetRedPayloadType(int red_payload_type);
|
2011-07-07 08:21:25 +00:00
|
|
|
private:
|
|
|
|
|
CriticalSectionWrapper& _fileCritSect;
|
|
|
|
|
CriticalSectionWrapper& _callbackCritSect;
|
2013-04-09 10:09:10 +00:00
|
|
|
uint32_t _instanceId;
|
|
|
|
|
int32_t _channelId;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
private:
|
2013-05-29 12:12:51 +00:00
|
|
|
scoped_ptr<RtpHeaderParser> rtp_header_parser_;
|
2012-05-11 11:08:54 +00:00
|
|
|
scoped_ptr<RtpRtcp> _rtpRtcpModule;
|
2011-07-07 08:21:25 +00:00
|
|
|
AudioCodingModule& _audioCodingModule;
|
|
|
|
|
RtpDump& _rtpDumpIn;
|
|
|
|
|
RtpDump& _rtpDumpOut;
|
|
|
|
|
private:
|
|
|
|
|
AudioLevel _outputAudioLevel;
|
|
|
|
|
bool _externalTransport;
|
|
|
|
|
AudioFrame _audioFrame;
|
2013-07-31 16:23:37 +00:00
|
|
|
scoped_array<int16_t> mono_recording_audio_;
|
|
|
|
|
// Resampler is used when input data is stereo while codec is mono.
|
|
|
|
|
PushResampler input_resampler_;
|
2013-04-09 10:09:10 +00:00
|
|
|
uint8_t _audioLevel_dBov;
|
2011-07-07 08:21:25 +00:00
|
|
|
FilePlayer* _inputFilePlayerPtr;
|
|
|
|
|
FilePlayer* _outputFilePlayerPtr;
|
|
|
|
|
FileRecorder* _outputFileRecorderPtr;
|
2011-08-08 08:18:44 +00:00
|
|
|
int _inputFilePlayerId;
|
|
|
|
|
int _outputFilePlayerId;
|
|
|
|
|
int _outputFileRecorderId;
|
2011-07-07 08:21:25 +00:00
|
|
|
bool _inputFilePlaying;
|
|
|
|
|
bool _outputFilePlaying;
|
|
|
|
|
bool _outputFileRecording;
|
|
|
|
|
DtmfInbandQueue _inbandDtmfQueue;
|
|
|
|
|
DtmfInband _inbandDtmfGenerator;
|
|
|
|
|
bool _inputExternalMedia;
|
2011-08-03 12:40:23 +00:00
|
|
|
bool _outputExternalMedia;
|
2011-07-07 08:21:25 +00:00
|
|
|
VoEMediaProcess* _inputExternalMediaCallbackPtr;
|
|
|
|
|
VoEMediaProcess* _outputExternalMediaCallbackPtr;
|
2013-04-09 10:09:10 +00:00
|
|
|
uint8_t* _encryptionRTPBufferPtr;
|
|
|
|
|
uint8_t* _decryptionRTPBufferPtr;
|
|
|
|
|
uint8_t* _encryptionRTCPBufferPtr;
|
|
|
|
|
uint8_t* _decryptionRTCPBufferPtr;
|
|
|
|
|
uint32_t _timeStamp;
|
|
|
|
|
uint8_t _sendTelephoneEventPayloadType;
|
2013-04-11 20:23:35 +00:00
|
|
|
uint32_t playout_timestamp_rtp_;
|
|
|
|
|
uint32_t playout_timestamp_rtcp_;
|
|
|
|
|
uint32_t playout_delay_ms_;
|
2013-04-09 10:09:10 +00:00
|
|
|
uint32_t _numberOfDiscardedPackets;
|
Merge r4374 from stable to trunk.
r4374 was mistakenly committed to stable, so this is to re-merge back to trunk.
Store the sequence number in StopSend() and resume it in StartSend().
When restarting the microphone device, we call StopSend() first, then
StartSend() later. Since we reset sequence number in StopSend(), it sometimes
causes libSRTP to complain about packets being replayed. Libjingle work around
it by caching the sequence number in WebRtcVoiceEngine.cc, and call
SetInitSequenceNumber() to resume the sequence number before StartSend().Store the sequence number in StopSend() and resume it in StartSend().
When restarting the microphone device, we call StopSend() first, then
StartSend() later. Since we reset sequence number in StopSend(), it sometimes
causes libSRTP to complain about packets being replayed. Libjingle work around
it by caching the sequence number in WebRtcVoiceEngine.cc, and call
SetInitSequenceNumber() to resume the sequence number before StartSend().
This patch fixes this problem by storing the sequence number in StopSend(), and
resume it in StartSend(). So that we can remove the workaround in libjingle.
BUG=2102
R=tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/1922004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@4451 4adac7df-926f-26a2-2b94-8c16560cd09d
2013-07-31 16:30:19 +00:00
|
|
|
uint16_t send_sequence_number_;
|
2013-04-11 20:23:35 +00:00
|
|
|
|
|
|
|
|
private:
|
2011-07-07 08:21:25 +00:00
|
|
|
// uses
|
|
|
|
|
Statistics* _engineStatisticsPtr;
|
|
|
|
|
OutputMixer* _outputMixerPtr;
|
|
|
|
|
TransmitMixer* _transmitMixerPtr;
|
|
|
|
|
ProcessThread* _moduleProcessThreadPtr;
|
|
|
|
|
AudioDeviceModule* _audioDeviceModulePtr;
|
|
|
|
|
VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base
|
|
|
|
|
CriticalSectionWrapper* _callbackCritSectPtr; // owned by base
|
|
|
|
|
Transport* _transportPtr; // WebRtc socket or external transport
|
|
|
|
|
Encryption* _encryptionPtr; // WebRtc SRTP or external encryption
|
2011-11-15 16:57:56 +00:00
|
|
|
scoped_ptr<AudioProcessing> _rtpAudioProc;
|
2011-07-07 08:21:25 +00:00
|
|
|
AudioProcessing* _rxAudioProcessingModulePtr; // far end AudioProcessing
|
|
|
|
|
VoERxVadCallback* _rxVadObserverPtr;
|
2013-04-09 10:09:10 +00:00
|
|
|
int32_t _oldVadDecision;
|
|
|
|
|
int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise
|
2011-07-07 08:21:25 +00:00
|
|
|
VoERTPObserver* _rtpObserverPtr;
|
|
|
|
|
VoERTCPObserver* _rtcpObserverPtr;
|
|
|
|
|
private:
|
|
|
|
|
// VoEBase
|
|
|
|
|
bool _outputIsOnHold;
|
|
|
|
|
bool _externalPlayout;
|
2012-12-12 23:00:29 +00:00
|
|
|
bool _externalMixing;
|
2011-07-07 08:21:25 +00:00
|
|
|
bool _inputIsOnHold;
|
|
|
|
|
bool _playing;
|
|
|
|
|
bool _sending;
|
|
|
|
|
bool _receiving;
|
|
|
|
|
bool _mixFileWithMicrophone;
|
|
|
|
|
bool _rtpObserver;
|
|
|
|
|
bool _rtcpObserver;
|
|
|
|
|
// VoEVolumeControl
|
|
|
|
|
bool _mute;
|
|
|
|
|
float _panLeft;
|
|
|
|
|
float _panRight;
|
|
|
|
|
float _outputGain;
|
|
|
|
|
// VoEEncryption
|
|
|
|
|
bool _encrypting;
|
|
|
|
|
bool _decrypting;
|
|
|
|
|
// VoEDtmf
|
|
|
|
|
bool _playOutbandDtmfEvent;
|
|
|
|
|
bool _playInbandDtmfEvent;
|
|
|
|
|
// VoeRTP_RTCP
|
2013-04-09 10:09:10 +00:00
|
|
|
uint8_t _extraPayloadType;
|
2011-07-07 08:21:25 +00:00
|
|
|
bool _insertExtraRTPPacket;
|
|
|
|
|
bool _extraMarkerBit;
|
2013-04-09 10:09:10 +00:00
|
|
|
uint32_t _lastLocalTimeStamp;
|
2012-12-12 21:31:41 +00:00
|
|
|
uint32_t _lastRemoteTimeStamp;
|
2013-04-09 10:09:10 +00:00
|
|
|
int8_t _lastPayloadType;
|
2011-07-07 08:21:25 +00:00
|
|
|
bool _includeAudioLevelIndication;
|
|
|
|
|
// VoENetwork
|
|
|
|
|
bool _rtpPacketTimedOut;
|
|
|
|
|
bool _rtpPacketTimeOutIsEnabled;
|
2013-04-09 10:09:10 +00:00
|
|
|
uint32_t _rtpTimeOutSeconds;
|
2011-07-07 08:21:25 +00:00
|
|
|
bool _connectionObserver;
|
|
|
|
|
VoEConnectionObserver* _connectionObserverPtr;
|
2013-04-09 10:09:10 +00:00
|
|
|
uint32_t _countAliveDetections;
|
|
|
|
|
uint32_t _countDeadDetections;
|
2011-07-07 08:21:25 +00:00
|
|
|
AudioFrame::SpeechType _outputSpeechType;
|
|
|
|
|
// VoEVideoSync
|
2013-04-11 20:23:35 +00:00
|
|
|
uint32_t _average_jitter_buffer_delay_us;
|
2013-05-22 20:39:43 +00:00
|
|
|
int least_required_delay_ms_;
|
2013-04-09 10:09:10 +00:00
|
|
|
uint32_t _previousTimestamp;
|
|
|
|
|
uint16_t _recPacketDelayMs;
|
2011-07-07 08:21:25 +00:00
|
|
|
// VoEAudioProcessing
|
|
|
|
|
bool _RxVadDetection;
|
|
|
|
|
bool _rxApmIsEnabled;
|
|
|
|
|
bool _rxAgcIsEnabled;
|
|
|
|
|
bool _rxNsIsEnabled;
|
|
|
|
|
};
|
|
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace voe
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
#endif // WEBRTC_VOICE_ENGINE_CHANNEL_H
|