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

Unified Diff: remoting/codec/audio_encoder_opus.h

Issue 11189047: Add opus audio codec support in remoting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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: remoting/codec/audio_encoder_opus.h
diff --git a/remoting/codec/audio_encoder_opus.h b/remoting/codec/audio_encoder_opus.h
new file mode 100644
index 0000000000000000000000000000000000000000..80a1e0237faead930b9d665584897c077853cfeb
--- /dev/null
+++ b/remoting/codec/audio_encoder_opus.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_CODEC_AUDIO_ENCODER_OPUS_H_
+#define REMOTING_CODEC_AUDIO_ENCODER_OPUS_H_
+
+#include "remoting/codec/audio_encoder.h"
+
+#include "remoting/proto/audio.pb.h"
+
+struct OpusEncoder;
+
+namespace media {
+class AudioBus;
+class MultiChannelResampler;
+} // namespace media
+
+namespace remoting {
+
+class AudioPacket;
+
+class AudioEncoderOpus : public AudioEncoder {
+ public:
+ AudioEncoderOpus();
+ virtual ~AudioEncoderOpus();
+
+ // AudioEncoder interface.
+ virtual scoped_ptr<AudioPacket> Encode(
+ scoped_ptr<AudioPacket> packet) OVERRIDE;
+
+ private:
+ void InitEncoder();
+ void DestroyEncoder();
+ bool ResetForPacket(AudioPacket* packet);
+
+ void ResamplerRead(media::AudioBus* audio_bus);
+
+ int sampling_rate_;
+ AudioPacket::Channels channels_;
+ OpusEncoder* encoder_;
+
+ int frame_size_;
+ scoped_ptr<media::MultiChannelResampler> resampler_;
+ scoped_array<char> resample_buffer_;
+
+ // Used to pass packet to the ResamplerRead() callback.
+ const char* resampling_data_;
+ int resampling_data_size_;
+ int resampling_data_pos_;
+
+ // Left-over unencoded samples from the previous AudioPacket.
+ scoped_array<int16> leftover_buffer_;
Wez 2012/10/19 01:51:32 nit: Rather than a separate |leftover_buffer_|, wh
Sergey Ulanov 2012/10/19 20:54:30 We need to handle the case when we receive a seque
+ int leftover_buffer_size_;
+ int leftover_samples_;
+
+ DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_CODEC_AUDIO_ENCODER_OPUS_H_

Powered by Google App Engine
This is Rietveld 408576698