| Index: webrtc/voice_engine/channel.h
|
| diff --git a/webrtc/voice_engine/channel.h b/webrtc/voice_engine/channel.h
|
| index 68d022d4d1fec4725acfda3b791cd5d6eab8ecff..c0ac046c003a5b12ab1ed19bb404d6affbdb7a60 100644
|
| --- a/webrtc/voice_engine/channel.h
|
| +++ b/webrtc/voice_engine/channel.h
|
| @@ -28,6 +28,7 @@
|
| #include "webrtc/modules/rtp_rtcp/include/remote_ntp_time_estimator.h"
|
| #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
|
| #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
|
| +#include "webrtc/voice_engine/audio_frame_pool.h"
|
| #include "webrtc/voice_engine/audio_level.h"
|
| #include "webrtc/voice_engine/file_player.h"
|
| #include "webrtc/voice_engine/file_recorder.h"
|
| @@ -157,8 +158,8 @@ class Channel
|
| ProcessThread& moduleProcessThread,
|
| AudioDeviceModule& audioDeviceModule,
|
| VoiceEngineObserver* voiceEngineObserver,
|
| - rtc::CriticalSection* callbackCritSect);
|
| - int32_t UpdateLocalTimeStamp();
|
| + rtc::CriticalSection* callbackCritSect,
|
| + rtc::TaskQueue* encoder_queue);
|
|
|
| void SetSink(std::unique_ptr<AudioSinkInterface> sink);
|
|
|
| @@ -352,16 +353,36 @@ class Channel
|
| }
|
| RtpRtcp* RtpRtcpModulePtr() const { return _rtpRtcpModule.get(); }
|
| int8_t OutputEnergyLevel() const { return _outputAudioLevel.Level(); }
|
| - uint32_t Demultiplex(const AudioFrame& audioFrame);
|
| - // 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,
|
| - int sample_rate,
|
| - size_t number_of_frames,
|
| - size_t number_of_channels);
|
| - uint32_t PrepareEncodeAndSend(int mixingFrequency);
|
| - uint32_t EncodeAndSend();
|
| +
|
| + // ProcessAndEncodeAudio() creates an audio frame copy and posts a task
|
| + // on the shared encoder task queue, wich in turn calls (on the queue)
|
| + // ProcessAndEncodeAudioOnTaskQueue() where the actual processing of the
|
| + // audio takes place. The processing mainly consists of encoding and preparing
|
| + // the result for sending by adding it to a send queue.
|
| + // The main reason for using a task queue here is to release the native,
|
| + // OS-specific, audio capture thread as soon as possible to ensure that it
|
| + // can go back to sleep and be prepared to deliver an new captured audio
|
| + // packet.
|
| + void ProcessAndEncodeAudio(const AudioFrame& audio_input);
|
| +
|
| + // This version of ProcessAndEncodeAudio() is used by PushCaptureData() in
|
| + // VoEBase and the audio in |audio_data| has not been subject to any APM
|
| + // processing. Some extra steps are therfore needed when building up the
|
| + // audio frame copy before using the same task as in the default call to
|
| + // ProcessAndEncodeAudio(const AudioFrame& audio_input).
|
| + void ProcessAndEncodeAudio(const int16_t* audio_data,
|
| + int sample_rate,
|
| + size_t number_of_frames,
|
| + size_t number_of_channels);
|
| +
|
| + // Called on the encoder task queue when a new input audio frame is ready
|
| + // for encoding.
|
| + void ProcessAndEncodeAudioOnTaskQueue(AudioFrame* audio_input);
|
| +
|
| + // Internal helper methods used by ProcessAndEncodeAudioOnTaskQueue().
|
| + // Both are called on the encoder task queue.
|
| + uint32_t PrepareEncodeAndSend(AudioFrame* audio_input);
|
| + uint32_t EncodeAndSend(AudioFrame* audio_input);
|
|
|
| // Associate to a send channel.
|
| // Used for obtaining RTT for a receive-only channel.
|
| @@ -382,6 +403,8 @@ class Channel
|
| void OnIncomingFractionLoss(int fraction_lost);
|
|
|
| private:
|
| + class ProcessAndEncodeAudioTask;
|
| +
|
| bool InputMute() const;
|
| bool OnRtpPacketWithHeader(const uint8_t* received_packet,
|
| size_t length,
|
| @@ -396,7 +419,7 @@ class Channel
|
| bool IsPacketInOrder(const RTPHeader& header) const;
|
| bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const;
|
| int ResendPackets(const uint16_t* sequence_numbers, int length);
|
| - int32_t MixOrReplaceAudioWithFile(int mixingFrequency);
|
| + int32_t MixOrReplaceAudioWithFile(AudioFrame* audio_frame);
|
| int32_t MixAudioWithFile(AudioFrame& audioFrame, int mixingFrequency);
|
| void UpdatePlayoutTimestamp(bool rtcp);
|
| void RegisterReceiveCodecsToRTPModule();
|
| @@ -434,7 +457,6 @@ class Channel
|
| std::unique_ptr<AudioSinkInterface> audio_sink_;
|
| AudioLevel _outputAudioLevel;
|
| bool _externalTransport;
|
| - AudioFrame _audioFrame;
|
| // Downsamples to the codec rate if necessary.
|
| PushResampler<int16_t> input_resampler_;
|
| std::unique_ptr<FilePlayer> input_file_player_;
|
| @@ -473,6 +495,7 @@ class Channel
|
| AudioDeviceModule* _audioDeviceModulePtr;
|
| VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base
|
| rtc::CriticalSection* _callbackCritSectPtr; // owned by base
|
| + rtc::TaskQueue* encoder_queue_;
|
| Transport* _transportPtr; // WebRtc socket or external transport
|
| RmsLevel rms_level_;
|
| bool input_mute_ GUARDED_BY(volume_settings_critsect_);
|
| @@ -504,6 +527,10 @@ class Channel
|
| std::unique_ptr<RtpPacketSenderProxy> rtp_packet_sender_proxy_;
|
| std::unique_ptr<RateLimiter> retransmission_rate_limiter_;
|
|
|
| + // Pool of preallocated audio frames for temporary storage of recorded audio
|
| + // to be encoded on the encoder queue.
|
| + AudioFramePool audio_frame_pool_;
|
| +
|
| // TODO(ossu): Remove once GetAudioDecoderFactory() is no longer needed.
|
| rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
|
|
|
|
|