summaryrefslogtreecommitdiffstats
path: root/remoting/codec
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-12 20:28:21 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-12 20:28:21 +0000
commit0d6b9de51ecd62d56c52c5a5f1d8fa782a1f0873 (patch)
treed317abdb14fba65b06c498dbc62011450d8ebe56 /remoting/codec
parent65ec6e7c262e144a70d7ac5279ea52eb67dcd035 (diff)
downloadchromium_src-0d6b9de51ecd62d56c52c5a5f1d8fa782a1f0873.zip
chromium_src-0d6b9de51ecd62d56c52c5a5f1d8fa782a1f0873.tar.gz
chromium_src-0d6b9de51ecd62d56c52c5a5f1d8fa782a1f0873.tar.bz2
Remove obsolete audio codecs and channel configurations.
We always use Opus for audio. Removed Speex audio codec. Also removed non-multiplexed channel configurations for control, event and audio channels. R=wez@chromium.org Review URL: https://codereview.chromium.org/24041005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/codec')
-rw-r--r--remoting/codec/audio_decoder.cc3
-rw-r--r--remoting/codec/audio_decoder_speex.cc119
-rw-r--r--remoting/codec/audio_decoder_speex.h41
-rw-r--r--remoting/codec/audio_encoder_speex.cc133
-rw-r--r--remoting/codec/audio_encoder_speex.h42
5 files changed, 0 insertions, 338 deletions
diff --git a/remoting/codec/audio_decoder.cc b/remoting/codec/audio_decoder.cc
index 94c30b4..26e13eb 100644
--- a/remoting/codec/audio_decoder.cc
+++ b/remoting/codec/audio_decoder.cc
@@ -6,7 +6,6 @@
#include "base/logging.h"
#include "remoting/codec/audio_decoder_opus.h"
-#include "remoting/codec/audio_decoder_speex.h"
#include "remoting/codec/audio_decoder_verbatim.h"
#include "remoting/protocol/session_config.h"
@@ -20,8 +19,6 @@ scoped_ptr<AudioDecoder> AudioDecoder::CreateAudioDecoder(
return scoped_ptr<AudioDecoder>(new AudioDecoderVerbatim());
} else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) {
return scoped_ptr<AudioDecoder>(new AudioDecoderOpus());
- } else if (audio_config.codec == protocol::ChannelConfig::CODEC_SPEEX) {
- return scoped_ptr<AudioDecoder>(new AudioDecoderSpeex());
}
NOTIMPLEMENTED();
diff --git a/remoting/codec/audio_decoder_speex.cc b/remoting/codec/audio_decoder_speex.cc
deleted file mode 100644
index 31bdcd4..0000000
--- a/remoting/codec/audio_decoder_speex.cc
+++ /dev/null
@@ -1,119 +0,0 @@
-// 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.
-
-#include "remoting/codec/audio_decoder_speex.h"
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/logging.h"
-#include "base/stl_util.h"
-#include "remoting/proto/audio.pb.h"
-#include "third_party/speex/include/speex/speex_callbacks.h"
-#include "third_party/speex/include/speex/speex_stereo.h"
-
-namespace remoting {
-
-namespace {
-
-// Hosts will never generate more than 100 frames in a single packet.
-const int kMaxFramesPerPacket = 100;
-
-} // namespace
-
-AudioDecoderSpeex::AudioDecoderSpeex() {
- // Create and initialize the Speex structures.
- speex_bits_.reset(new SpeexBits());
- speex_bits_init(speex_bits_.get());
- speex_state_ = speex_decoder_init(&speex_wb_mode);
-
- // Create and initialize the Speex stereo state.
- speex_stereo_state_ = speex_stereo_state_init();
-
- // Create and initialize the stereo callback.
- speex_callback_.reset(new SpeexCallback());
- speex_callback_->callback_id = SPEEX_INBAND_STEREO;
- speex_callback_->func = speex_std_stereo_request_handler;
- speex_callback_->data = speex_stereo_state_;
-
- int result;
-
- // Turn on perceptual enhancer, which will make the audio sound better,
- // at the price of further distorting the decoded samples.
- int enhancer = 1;
- result = speex_decoder_ctl(speex_state_, SPEEX_SET_ENH, &enhancer);
- CHECK_EQ(result, 0);
-
- // Get the frame size, so that we know the size of output when we decode
- // frame by frame.
- result = speex_decoder_ctl(speex_state_,
- SPEEX_GET_FRAME_SIZE,
- &speex_frame_size_);
- CHECK_EQ(result, 0);
-
- // Set the stereo callback, so that the Speex decoder can get the intensity
- // stereo information.
- result = speex_decoder_ctl(speex_state_,
- SPEEX_SET_HANDLER,
- speex_callback_.get());
- CHECK_EQ(result, 0);
-}
-
-AudioDecoderSpeex::~AudioDecoderSpeex() {
- speex_stereo_state_destroy(speex_stereo_state_);
- speex_decoder_destroy(speex_state_);
- speex_bits_destroy(speex_bits_.get());
-}
-
-scoped_ptr<AudioPacket> AudioDecoderSpeex::Decode(
- scoped_ptr<AudioPacket> packet) {
- if ((packet->encoding() != AudioPacket::ENCODING_SPEEX) ||
- (packet->bytes_per_sample() != AudioPacket::BYTES_PER_SAMPLE_2) ||
- (packet->sampling_rate() == AudioPacket::SAMPLING_RATE_INVALID) ||
- (packet->channels() != AudioPacket::CHANNELS_STEREO)) {
- LOG(WARNING) << "Received an unsupported packet.";
- return scoped_ptr<AudioPacket>();
- }
- if (packet->data_size() > kMaxFramesPerPacket) {
- LOG(WARNING) << "Received an packet with too many frames.";
- return scoped_ptr<AudioPacket>();
- }
-
- // Create a new packet of decoded data.
- scoped_ptr<AudioPacket> decoded_packet(new AudioPacket());
- decoded_packet->set_encoding(AudioPacket::ENCODING_RAW);
- decoded_packet->set_sampling_rate(packet->sampling_rate());
- decoded_packet->set_bytes_per_sample(packet->bytes_per_sample());
- decoded_packet->set_channels(packet->channels());
-
- std::string* decoded_data = decoded_packet->add_data();
- decoded_data->resize(packet->data_size() *
- speex_frame_size_ *
- packet->bytes_per_sample() *
- packet->channels());
- int16* samples = reinterpret_cast<int16*>(string_as_array(decoded_data));
-
- for (int i = 0; i < packet->data_size(); ++i) {
- // Read the bytes into the bits structure.
- speex_bits_read_from(speex_bits_.get(),
- string_as_array(packet->mutable_data(i)),
- packet->data(i).size());
-
- // Decode the frame and store it in the buffer.
- int status = speex_decode_int(speex_state_, speex_bits_.get(), samples);
- if (status < 0) {
- LOG(ERROR) << "Error in decoding Speex data.";
- return scoped_ptr<AudioPacket>();
- }
- // Transform mono to stereo.
- speex_decode_stereo_int(samples, speex_frame_size_, speex_stereo_state_);
-
- samples += (speex_frame_size_ * packet->channels());
- }
-
- return decoded_packet.Pass();
-}
-
-} // namespace remoting
diff --git a/remoting/codec/audio_decoder_speex.h b/remoting/codec/audio_decoder_speex.h
deleted file mode 100644
index 55b97c7..0000000
--- a/remoting/codec/audio_decoder_speex.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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_DECODER_SPEEX_H_
-#define REMOTING_CODEC_AUDIO_DECODER_SPEEX_H_
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "remoting/codec/audio_decoder.h"
-
-struct SpeexBits;
-struct SpeexCallback;
-struct SpeexStereoState;
-
-namespace remoting {
-
-class AudioPacket;
-
-class AudioDecoderSpeex : public AudioDecoder {
- public:
- AudioDecoderSpeex();
- virtual ~AudioDecoderSpeex();
-
- // AudioDecoder implementation.
- virtual scoped_ptr<AudioPacket> Decode(
- scoped_ptr<AudioPacket> packet) OVERRIDE;
-
- private:
- scoped_ptr<SpeexBits> speex_bits_;
- void* speex_state_;
- int speex_frame_size_;
- SpeexStereoState* speex_stereo_state_;
- scoped_ptr<SpeexCallback> speex_callback_;
-
- DISALLOW_COPY_AND_ASSIGN(AudioDecoderSpeex);
-};
-
-} // namespace remoting
-
-#endif // REMOTING_CODEC_AUDIO_DECODER_SPEEX_H_
diff --git a/remoting/codec/audio_encoder_speex.cc b/remoting/codec/audio_encoder_speex.cc
deleted file mode 100644
index 3adb366..0000000
--- a/remoting/codec/audio_encoder_speex.cc
+++ /dev/null
@@ -1,133 +0,0 @@
-// 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.
-
-#include "remoting/codec/audio_encoder_speex.h"
-
-#include <string>
-#include <sstream>
-
-#include "base/basictypes.h"
-#include "base/logging.h"
-#include "base/stl_util.h"
-#include "remoting/proto/audio.pb.h"
-#include "third_party/speex/include/speex/speex_callbacks.h"
-#include "third_party/speex/include/speex/speex_stereo.h"
-
-namespace {
-// A quality of 8 in wide band mode corresponds to 27,800 bits per second.
-const int kSpeexHighQuality = 8;
-const int kEncodedDataBufferSize = 0xFF;
-} // namespace
-
-namespace remoting {
-
-AudioEncoderSpeex::AudioEncoderSpeex()
- : leftover_frames_(0) {
- // Create and initialize the Speex structures.
- speex_bits_.reset(new SpeexBits());
- speex_bits_init(speex_bits_.get());
- speex_state_ = speex_encoder_init(&speex_wb_mode);
-
- // Set the encoding quality.
- int quality = kSpeexHighQuality;
- speex_encoder_ctl(speex_state_, SPEEX_SET_QUALITY, &quality);
-
- // Get the frame size and construct the input buffer accordingly.
- int result = speex_encoder_ctl(speex_state_,
- SPEEX_GET_FRAME_SIZE,
- &speex_frame_size_);
- CHECK_EQ(result, 0);
-
- leftover_buffer_.reset(
- new int16[speex_frame_size_ * AudioPacket::CHANNELS_STEREO]);
-}
-
-AudioEncoderSpeex::~AudioEncoderSpeex() {
- speex_encoder_destroy(speex_state_);
- speex_bits_destroy(speex_bits_.get());
-}
-
-scoped_ptr<AudioPacket> AudioEncoderSpeex::Encode(
- scoped_ptr<AudioPacket> packet) {
- DCHECK_EQ(AudioPacket::ENCODING_RAW, packet->encoding());
- DCHECK_EQ(1, packet->data_size());
- DCHECK_EQ(AudioPacket::BYTES_PER_SAMPLE_2, packet->bytes_per_sample());
- DCHECK_NE(AudioPacket::SAMPLING_RATE_INVALID, packet->sampling_rate());
- DCHECK_EQ(AudioPacket::CHANNELS_STEREO, packet->channels());
-
- int frames_left =
- packet->data(0).size() / packet->bytes_per_sample() / packet->channels();
- const int16* next_sample =
- reinterpret_cast<const int16*>(packet->data(0).data());
-
- // Create a new packet of encoded data.
- scoped_ptr<AudioPacket> encoded_packet(new AudioPacket());
- encoded_packet->set_encoding(AudioPacket::ENCODING_SPEEX);
- encoded_packet->set_sampling_rate(packet->sampling_rate());
- encoded_packet->set_bytes_per_sample(packet->bytes_per_sample());
- encoded_packet->set_channels(packet->channels());
-
- while (leftover_frames_ + frames_left >= speex_frame_size_) {
- int16* unencoded_buffer = NULL;
- int frames_consumed = 0;
-
- if (leftover_frames_ > 0) {
- unencoded_buffer = leftover_buffer_.get();
- frames_consumed = speex_frame_size_ - leftover_frames_;
-
- memcpy(leftover_buffer_.get() + leftover_frames_ * packet->channels(),
- next_sample,
- frames_consumed * packet->bytes_per_sample() * packet->channels());
-
- leftover_frames_ = 0;
- } else {
- unencoded_buffer = const_cast<int16*>(next_sample);
- frames_consumed = speex_frame_size_;
- }
-
- // Transform stereo to mono.
- speex_encode_stereo_int(unencoded_buffer,
- speex_frame_size_,
- speex_bits_.get());
-
- // Encode the frame, treating all samples as integers.
- speex_encode_int(speex_state_,
- unencoded_buffer,
- speex_bits_.get());
-
- next_sample += frames_consumed * packet->channels();
- frames_left -= frames_consumed;
-
- std::string* new_data = encoded_packet->add_data();
- new_data->resize(speex_bits_nbytes(speex_bits_.get()));
-
- // Copy the encoded data from the bits structure into the buffer.
- int bytes_written = speex_bits_write(speex_bits_.get(),
- string_as_array(new_data),
- new_data->size());
-
- // Expect that the bytes are all written.
- DCHECK_EQ(bytes_written, static_cast<int>(new_data->size()));
-
- // Reset the bits structure for this frame.
- speex_bits_reset(speex_bits_.get());
- }
-
- // Store the leftover samples.
- if (frames_left > 0) {
- CHECK_LE(leftover_frames_ + frames_left, speex_frame_size_);
- memcpy(leftover_buffer_.get() + leftover_frames_ * packet->channels(),
- next_sample,
- frames_left * packet->bytes_per_sample() * packet->channels());
- leftover_frames_ += frames_left;
- }
-
- // Return NULL if there's nothing in the packet.
- if (encoded_packet->data_size() == 0)
- return scoped_ptr<AudioPacket>();
-
- return encoded_packet.Pass();
-}
-
-} // namespace remoting
diff --git a/remoting/codec/audio_encoder_speex.h b/remoting/codec/audio_encoder_speex.h
deleted file mode 100644
index 9cbdf59..0000000
--- a/remoting/codec/audio_encoder_speex.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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_SPEEX_H_
-#define REMOTING_CODEC_AUDIO_ENCODER_SPEEX_H_
-
-#include <list>
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "remoting/codec/audio_encoder.h"
-
-struct SpeexBits;
-
-namespace remoting {
-
-class AudioPacket;
-
-class AudioEncoderSpeex : public AudioEncoder {
- public:
- AudioEncoderSpeex();
- virtual ~AudioEncoderSpeex();
-
- // AudioEncoder implementation.
- virtual scoped_ptr<AudioPacket> Encode(
- scoped_ptr<AudioPacket> packet) OVERRIDE;
-
- private:
- scoped_ptr<SpeexBits> speex_bits_;
- void* speex_state_;
- int speex_frame_size_;
-
- scoped_ptr<int16[]> leftover_buffer_;
- // We may have some left-over unencoded frames from the previous AudioPacket.
- int leftover_frames_;
-
- DISALLOW_COPY_AND_ASSIGN(AudioEncoderSpeex);
-};
-
-} // namespace remoting
-
-#endif // REMOTING_CODEC_AUDIO_ENCODER_SPEEX_H_