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

Unified Diff: media/filters/audio_decoder_test.h

Issue 1727953005: Enable AudioDecoder unit tests on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added media.gyp changes Created 4 years, 10 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: media/filters/audio_decoder_test.h
diff --git a/media/filters/audio_decoder_test.h b/media/filters/audio_decoder_test.h
new file mode 100644
index 0000000000000000000000000000000000000000..8492267a4f19c15f3ce588ff9073b68e6d0b35aa
--- /dev/null
+++ b/media/filters/audio_decoder_test.h
@@ -0,0 +1,109 @@
+// Copyright 2016 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 MEDIA_FILTERS_AUDIO_DECODER_TEST_H_
+#define MEDIA_FILTERS_AUDIO_DECODER_TEST_H_
+
+#include <stdint.h>
+
+#include <deque>
+#include <ostream>
+#include <string>
+
+#include "base/macros.h"
+#include "base/message_loop/message_loop.h"
+#include "base/time/time.h"
+#include "media/base/audio_decoder.h"
+#include "media/base/audio_decoder_config.h"
+#include "media/base/channel_layout.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace media {
+
+enum AudioDecoderType {
+ FFMPEG,
+ OPUS,
+};
+
+struct DecodedBufferExpectations {
+ const int64_t timestamp;
+ const int64_t duration;
+ const char* hash;
+};
+
+struct DecoderTestData {
+ const AudioDecoderType decoder_type;
+ const AudioCodec codec;
+ const char* filename;
+ const DecodedBufferExpectations* expectations;
+ const int first_packet_pts;
+ const int samples_per_second;
+ const ChannelLayout channel_layout;
+};
+
+// Tells gtest how to print our DecoderTestData structure.
+inline std::ostream& operator<<(std::ostream& os, const DecoderTestData& data) {
+ return os << data.filename;
+}
+
+class AudioBuffer;
+class AudioFileReader;
+class DecoderBuffer;
+class InMemoryUrlProtocol;
+
+class AudioDecoderTest : public testing::TestWithParam<DecoderTestData> {
+ public:
+ AudioDecoderTest();
+
+ virtual ~AudioDecoderTest() override;
+
+ protected:
+ void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer);
+ void WaitForDecodeResponse();
+ void SendEndOfStream();
+ void Initialize();
+ void InitializeDecoder(const AudioDecoderConfig& config);
+ void InitializeDecoderWithResult(const AudioDecoderConfig& config,
+ bool success);
+ void Decode();
+ void Reset();
+ void Seek(base::TimeDelta seek_time);
+ void OnDecoderOutput(const scoped_refptr<AudioBuffer>& buffer);
+ void DecodeFinished(AudioDecoder::Status status);
+ void ResetFinished();
+
+ // Generates an MD5 hash of the audio signal. Should not be used for checks
+ // across platforms as audio varies slightly across platforms.
+ std::string GetDecodedAudioMD5(size_t i);
+ void ExpectDecodedAudio(size_t i, const std::string& exact_hash);
+
+ size_t decoded_audio_size() const { return decoded_audio_.size(); }
+ base::TimeDelta start_timestamp() const { return start_timestamp_; }
+ const scoped_refptr<AudioBuffer>& decoded_audio(size_t i) {
+ return decoded_audio_[i];
+ }
+ AudioDecoder::Status last_decode_status() const {
+ return last_decode_status_;
+ }
+
+ private:
+ base::MessageLoop message_loop_;
+ scoped_refptr<DecoderBuffer> data_;
+ scoped_ptr<InMemoryUrlProtocol> protocol_;
+ scoped_ptr<AudioFileReader> reader_;
+
+ scoped_ptr<AudioDecoder> decoder_;
+ bool pending_decode_;
+ bool pending_reset_;
+ AudioDecoder::Status last_decode_status_;
+
+ std::deque<scoped_refptr<AudioBuffer>> decoded_audio_;
+ base::TimeDelta start_timestamp_;
+
+ DISALLOW_COPY_AND_ASSIGN(AudioDecoderTest);
+};
+
+} // namespace media
+
+#endif // MEDIA_FILTERS_AUDIO_DECODER_TEST_H_

Powered by Google App Engine
This is Rietveld 408576698