diff options
author | kxing@chromium.org <kxing@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-21 16:42:30 +0000 |
---|---|---|
committer | kxing@chromium.org <kxing@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-21 16:42:30 +0000 |
commit | 922ecc32c5f8f0f87ac121f7ff5523e18da5d976 (patch) | |
tree | 46986181b7bc4aeff4786275eeaccf6da31b3235 /remoting/codec | |
parent | d335fb395a4b57c7b307b0421e26cde7b4f6c301 (diff) | |
download | chromium_src-922ecc32c5f8f0f87ac121f7ff5523e18da5d976.zip chromium_src-922ecc32c5f8f0f87ac121f7ff5523e18da5d976.tar.gz chromium_src-922ecc32c5f8f0f87ac121f7ff5523e18da5d976.tar.bz2 |
Added more error checking for audio packets.
BUG=
Review URL: https://chromiumcodereview.appspot.com/10823420
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152578 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/codec')
-rw-r--r-- | remoting/codec/audio_decoder.h | 2 | ||||
-rw-r--r-- | remoting/codec/audio_decoder_verbatim.cc | 4 | ||||
-rw-r--r-- | remoting/codec/audio_encoder_verbatim.cc | 3 |
3 files changed, 8 insertions, 1 deletions
diff --git a/remoting/codec/audio_decoder.h b/remoting/codec/audio_decoder.h index 72eedf2..f5088bc 100644 --- a/remoting/codec/audio_decoder.h +++ b/remoting/codec/audio_decoder.h @@ -22,6 +22,8 @@ class AudioDecoder { virtual ~AudioDecoder() {} + // Returns the decoded packet. If the packet is invalid, then a NULL + // scoped_ptr is returned. virtual scoped_ptr<AudioPacket> Decode(scoped_ptr<AudioPacket> packet) = 0; }; diff --git a/remoting/codec/audio_decoder_verbatim.cc b/remoting/codec/audio_decoder_verbatim.cc index 903cb3f..e8143fa 100644 --- a/remoting/codec/audio_decoder_verbatim.cc +++ b/remoting/codec/audio_decoder_verbatim.cc @@ -21,7 +21,9 @@ scoped_ptr<AudioPacket> AudioDecoderVerbatim::Decode( if ((packet->encoding() != AudioPacket::ENCODING_RAW) || (packet->data_size() != 1) || (packet->sampling_rate() == AudioPacket::SAMPLING_RATE_INVALID) || - (packet->bytes_per_sample() == AudioPacket::BYTES_PER_SAMPLE_INVALID)) { + (packet->bytes_per_sample() != AudioPacket::BYTES_PER_SAMPLE_2) || + (packet->channels() != AudioPacket::CHANNELS_STEREO)) { + LOG(WARNING) << "Verbatim decoder received an invalid packet."; return scoped_ptr<AudioPacket>(); } return packet.Pass(); diff --git a/remoting/codec/audio_encoder_verbatim.cc b/remoting/codec/audio_encoder_verbatim.cc index 52e578a..696035e 100644 --- a/remoting/codec/audio_encoder_verbatim.cc +++ b/remoting/codec/audio_encoder_verbatim.cc @@ -17,6 +17,9 @@ scoped_ptr<AudioPacket> AudioEncoderVerbatim::Encode( scoped_ptr<AudioPacket> packet) { DCHECK_EQ(AudioPacket::ENCODING_RAW, packet->encoding()); DCHECK_EQ(1, packet->data_size()); + DCHECK_NE(AudioPacket::SAMPLING_RATE_INVALID, packet->sampling_rate()); + DCHECK_NE(AudioPacket::BYTES_PER_SAMPLE_INVALID, packet->bytes_per_sample()); + DCHECK_NE(AudioPacket::CHANNELS_INVALID, packet->channels()); return packet.Pass(); } |