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

Side by Side Diff: media/base/android/test_data_factory.h

Issue 1176993005: Audio and video decoders for MediaCodecPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactored DataFactory into a separate file Created 5 years, 6 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 2015 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_BASE_ANDROID_TEST_DATA_FACTORY_H_
6 #define MEDIA_BASE_ANDROID_TEST_DATA_FACTORY_H_
7
8 #include <stdint.h>
9 #include <vector>
10 #include "base/memory/ref_counted.h"
11 #include "base/time/time.h"
12 #include "media/base/android/demuxer_stream_player_params.h"
13
14 namespace media {
15
16 // TestDataFactory is used in MediaCodecDecoderUnittest and
17 // MediaCodecPlayerUnittest to simulate the audio or video access unit stream.
18 class TestDataFactory : public base::RefCounted<TestDataFactory> {
19 public:
20 // These methods return corresponding demuxer configs.
21 static DemuxerConfigs CreateAudioConfigs(AudioCodec audio_codec,
22 const base::TimeDelta& duration);
23 static DemuxerConfigs CreateVideoConfigs(VideoCodec video_codec,
24 const base::TimeDelta& duration,
25 const gfx::Size& video_size);
26
27 // Constructor calls |LoadPackets| to load packets from files.
28 // Parameters:
29 // file_name_template: the sprintf format string used to generate a file
30 // name for the packet in the form e.g. "h264-AxB-%d"
31 // The |%d| will be replaced by 0, 1, 2, 3.
32 // duration: after the last AU exceeds duration the factory generates EOS
33 // unit and stops.
34 // frame_period: PTS increment between unit.
35 TestDataFactory(const char* file_name_template,
36 const base::TimeDelta& duration,
37 const base::TimeDelta& frame_period);
38 virtual ~TestDataFactory() {}
qinmin 2015/06/18 00:24:40 nit: put this to the .cc file
Tima Vaisburd 2015/06/18 19:34:04 Done.
39
40 // Populates next chunk and the corresponding delay.
41 // Default implementation repeatedly uses |packet_| array in order 0-1-2-3
42 // and monotonically increases timestamps from 0 to |duration_|.
43 // The first unit to exceed |duration_| becomes EOS. The delay is set to 0.
44 virtual void CreateChunk(DemuxerData* chunk, base::TimeDelta* delay);
45
46 base::TimeDelta last_pts() const { return last_pts_; }
47
48 protected:
49 // Called by constructor to load packets from files referred by
50 // |file_name_template|.
51 virtual void LoadPackets(const char* file_name_template);
52
53 // Used to modify the generated access unit by a subclass.
54 virtual void ModifyAccessUnit(int index_in_chunk, AccessUnit* unit) {}
55
56 base::TimeDelta duration_;
57 base::TimeDelta frame_period_;
58 std::vector<uint8_t> packet_[4];
59 base::TimeDelta regular_pts_; // monotonically increasing PTS
60 base::TimeDelta last_pts_; // subclass can modify PTS, maintains the last
61 };
62
63 } // namespace media
64
65 #endif // MEDIA_BASE_ANDROID_TEST_DATA_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698