diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-12 20:28:21 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-12 20:28:21 +0000 |
commit | 0d6b9de51ecd62d56c52c5a5f1d8fa782a1f0873 (patch) | |
tree | d317abdb14fba65b06c498dbc62011450d8ebe56 | |
parent | 65ec6e7c262e144a70d7ac5279ea52eb67dcd035 (diff) | |
download | chromium_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
-rw-r--r-- | remoting/codec/audio_decoder.cc | 3 | ||||
-rw-r--r-- | remoting/codec/audio_decoder_speex.cc | 119 | ||||
-rw-r--r-- | remoting/codec/audio_decoder_speex.h | 41 | ||||
-rw-r--r-- | remoting/codec/audio_encoder_speex.cc | 133 | ||||
-rw-r--r-- | remoting/codec/audio_encoder_speex.h | 42 | ||||
-rw-r--r-- | remoting/host/client_session.cc | 7 | ||||
-rw-r--r-- | remoting/protocol/session_config.cc | 26 | ||||
-rw-r--r-- | remoting/remoting.gyp | 5 |
8 files changed, 5 insertions, 371 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_ diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc index 45439f4..6d424244 100644 --- a/remoting/host/client_session.cc +++ b/remoting/host/client_session.cc @@ -10,7 +10,6 @@ #include "remoting/base/capabilities.h" #include "remoting/codec/audio_encoder.h" #include "remoting/codec/audio_encoder_opus.h" -#include "remoting/codec/audio_encoder_speex.h" #include "remoting/codec/audio_encoder_verbatim.h" #include "remoting/codec/video_encoder.h" #include "remoting/codec/video_encoder_verbatim.h" @@ -433,7 +432,7 @@ scoped_ptr<VideoEncoder> ClientSession::CreateVideoEncoder( return scoped_ptr<VideoEncoder>(new remoting::VideoEncoderVp8()); } - NOTIMPLEMENTED(); + NOTREACHED(); return scoped_ptr<VideoEncoder>(); } @@ -444,13 +443,11 @@ scoped_ptr<AudioEncoder> ClientSession::CreateAudioEncoder( if (audio_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim()); - } else if (audio_config.codec == protocol::ChannelConfig::CODEC_SPEEX) { - return scoped_ptr<AudioEncoder>(new AudioEncoderSpeex()); } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); } - NOTIMPLEMENTED(); + NOTREACHED(); return scoped_ptr<AudioEncoder>(); } diff --git a/remoting/protocol/session_config.cc b/remoting/protocol/session_config.cc index de1ddc3..7e3100a 100644 --- a/remoting/protocol/session_config.cc +++ b/remoting/protocol/session_config.cc @@ -48,10 +48,10 @@ bool SessionConfig::SupportsCapabilities() const { // static SessionConfig SessionConfig::ForTest() { SessionConfig result; - result.set_control_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, + result.set_control_config(ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, kControlStreamVersionNoCapabilities, ChannelConfig::CODEC_UNDEFINED)); - result.set_event_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, + result.set_event_config(ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, kDefaultStreamVersion, ChannelConfig::CODEC_UNDEFINED)); result.set_video_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, @@ -59,7 +59,7 @@ SessionConfig SessionConfig::ForTest() { ChannelConfig::CODEC_VP8)); result.set_audio_config(ChannelConfig(ChannelConfig::TRANSPORT_NONE, kDefaultStreamVersion, - ChannelConfig::CODEC_VERBATIM)); + ChannelConfig::CODEC_UNDEFINED)); return result; } @@ -184,20 +184,12 @@ scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateDefault() { ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, kControlStreamVersionNoCapabilities, ChannelConfig::CODEC_UNDEFINED)); - result->mutable_control_configs()->push_back( - ChannelConfig(ChannelConfig::TRANSPORT_STREAM, - kControlStreamVersionNoCapabilities, - ChannelConfig::CODEC_UNDEFINED)); // Event channel. result->mutable_event_configs()->push_back( ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, kDefaultStreamVersion, ChannelConfig::CODEC_UNDEFINED)); - result->mutable_event_configs()->push_back( - ChannelConfig(ChannelConfig::TRANSPORT_STREAM, - kDefaultStreamVersion, - ChannelConfig::CODEC_UNDEFINED)); // Video channel. result->mutable_video_configs()->push_back( @@ -210,18 +202,6 @@ scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateDefault() { ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, kDefaultStreamVersion, ChannelConfig::CODEC_OPUS)); - result->mutable_audio_configs()->push_back( - ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, - kDefaultStreamVersion, - ChannelConfig::CODEC_SPEEX)); - result->mutable_audio_configs()->push_back( - ChannelConfig(ChannelConfig::TRANSPORT_STREAM, - kDefaultStreamVersion, - ChannelConfig::CODEC_SPEEX)); - result->mutable_audio_configs()->push_back( - ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, - kDefaultStreamVersion, - ChannelConfig::CODEC_VERBATIM)); result->mutable_audio_configs()->push_back(ChannelConfig::None()); return result.Pass(); diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 7422eae..a464532 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -2441,7 +2441,6 @@ '../third_party/libyuv/libyuv.gyp:libyuv', '../third_party/opus/opus.gyp:opus', '../third_party/protobuf/protobuf.gyp:protobuf_lite', - '../third_party/speex/speex.gyp:libspeex', '../media/media.gyp:media', '../media/media.gyp:shared_memory_support', 'remoting_jingle_glue', @@ -2498,15 +2497,11 @@ 'codec/audio_decoder.h', 'codec/audio_decoder_opus.cc', 'codec/audio_decoder_opus.h', - 'codec/audio_decoder_speex.cc', - 'codec/audio_decoder_speex.h', 'codec/audio_decoder_verbatim.cc', 'codec/audio_decoder_verbatim.h', 'codec/audio_encoder.h', 'codec/audio_encoder_opus.cc', 'codec/audio_encoder_opus.h', - 'codec/audio_encoder_speex.cc', - 'codec/audio_encoder_speex.h', 'codec/audio_encoder_verbatim.cc', 'codec/audio_encoder_verbatim.h', 'codec/video_decoder.h', |