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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_FILTERS_AUDIO_DECODER_TEST_H_
6 #define MEDIA_FILTERS_AUDIO_DECODER_TEST_H_
7
8 #include <stdint.h>
9
10 #include <deque>
11 #include <ostream>
12 #include <string>
13
14 #include "base/macros.h"
15 #include "base/message_loop/message_loop.h"
16 #include "base/time/time.h"
17 #include "media/base/audio_decoder.h"
18 #include "media/base/audio_decoder_config.h"
19 #include "media/base/channel_layout.h"
20 #include "testing/gtest/include/gtest/gtest.h"
21
22 namespace media {
23
24 enum AudioDecoderType {
25 FFMPEG,
26 OPUS,
27 };
28
29 struct DecodedBufferExpectations {
30 const int64_t timestamp;
31 const int64_t duration;
32 const char* hash;
33 };
34
35 struct DecoderTestData {
36 const AudioDecoderType decoder_type;
37 const AudioCodec codec;
38 const char* filename;
39 const DecodedBufferExpectations* expectations;
40 const int first_packet_pts;
41 const int samples_per_second;
42 const ChannelLayout channel_layout;
43 };
44
45 // Tells gtest how to print our DecoderTestData structure.
46 inline std::ostream& operator<<(std::ostream& os, const DecoderTestData& data) {
47 return os << data.filename;
48 }
49
50 class AudioBuffer;
51 class AudioFileReader;
52 class DecoderBuffer;
53 class InMemoryUrlProtocol;
54
55 class AudioDecoderTest : public testing::TestWithParam<DecoderTestData> {
56 public:
57 AudioDecoderTest();
58
59 virtual ~AudioDecoderTest() override;
60
61 protected:
62 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer);
63 void WaitForDecodeResponse();
64 void SendEndOfStream();
65 void Initialize();
66 void InitializeDecoder(const AudioDecoderConfig& config);
67 void InitializeDecoderWithResult(const AudioDecoderConfig& config,
68 bool success);
69 void Decode();
70 void Reset();
71 void Seek(base::TimeDelta seek_time);
72 void OnDecoderOutput(const scoped_refptr<AudioBuffer>& buffer);
73 void DecodeFinished(AudioDecoder::Status status);
74 void ResetFinished();
75
76 // Generates an MD5 hash of the audio signal. Should not be used for checks
77 // across platforms as audio varies slightly across platforms.
78 std::string GetDecodedAudioMD5(size_t i);
79 void ExpectDecodedAudio(size_t i, const std::string& exact_hash);
80
81 size_t decoded_audio_size() const { return decoded_audio_.size(); }
82 base::TimeDelta start_timestamp() const { return start_timestamp_; }
83 const scoped_refptr<AudioBuffer>& decoded_audio(size_t i) {
84 return decoded_audio_[i];
85 }
86 AudioDecoder::Status last_decode_status() const {
87 return last_decode_status_;
88 }
89
90 private:
91 base::MessageLoop message_loop_;
92 scoped_refptr<DecoderBuffer> data_;
93 scoped_ptr<InMemoryUrlProtocol> protocol_;
94 scoped_ptr<AudioFileReader> reader_;
95
96 scoped_ptr<AudioDecoder> decoder_;
97 bool pending_decode_;
98 bool pending_reset_;
99 AudioDecoder::Status last_decode_status_;
100
101 std::deque<scoped_refptr<AudioBuffer>> decoded_audio_;
102 base::TimeDelta start_timestamp_;
103
104 DISALLOW_COPY_AND_ASSIGN(AudioDecoderTest);
105 };
106
107 } // namespace media
108
109 #endif // MEDIA_FILTERS_AUDIO_DECODER_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698