Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1009)

Unified Diff: webrtc/voice_engine/channel.h

Issue 2665693002: Moves channel-dependent audio input processing to separate encoder task queue (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/voice_engine/channel.h
diff --git a/webrtc/voice_engine/channel.h b/webrtc/voice_engine/channel.h
index 62adc5bdff58dc8db53ad99d4b3d191dcf5133e3..f36fc5ee49d78873c971302e7cb8c3eadb2216e9 100644
--- a/webrtc/voice_engine/channel.h
+++ b/webrtc/voice_engine/channel.h
@@ -166,8 +166,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);
@@ -394,16 +394,34 @@ class Channel
bool ExternalMixing() const { return _externalMixing; }
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(
+ std::unique_ptr<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.
@@ -424,6 +442,8 @@ class Channel
void OnIncomingFractionLoss(int fraction_lost);
private:
+ class ProcessAndEncodeAudioTask;
+
bool ReceivePacket(const uint8_t* packet,
size_t packet_length,
const RTPHeader& header,
@@ -434,7 +454,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();
@@ -472,7 +492,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_;
@@ -515,6 +534,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_;
int32_t _sendFrameType; // Send data is voice, 1-voice, 0-otherwise

Powered by Google App Engine
This is Rietveld 408576698