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

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

Issue 1176993005: Audio and video decoders for MediaCodecPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests for video decoder, video decoder now reports current time. 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_ACCESS_UNIT_QUEUE_H_
6 #define MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_
7
8 #include <list>
9
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/synchronization/lock.h"
13 #include "media/base/android/demuxer_stream_player_params.h"
14
15 namespace media {
16
17 // The queue of incoming data for MediaCodecDecoder.
18 //
19 // The data comes in the form of access units. Each access unit has a type,
20 // if the type is |kConfigChanged| the access unit itself has no data, but
21 // is accompanied with DemuxerConfigs.
22 // The queue is accessed on the Media thread that puts the incoming data in and
23 // the Decoder thread that gets the next access unit and eventually removes it
24 // from the queue.
25 class AccessUnitQueue {
26 public:
27 // Information about the queue state and the access unit at the front.
28 struct Info {
29 // The unit at front. Null if the queue is empty.
30 const AccessUnit* front_unit;
31
32 // Configs for the front unit if it is |kConfigChanged|, null otherwise.
33 const DemuxerConfigs* configs;
34
35 // Number of access units in the queue.
36 int length;
37
38 // Whether the queue contains End Of Stream.
39 bool has_eos;
40
41 Info() : front_unit(nullptr), configs(nullptr), length(0), has_eos(false) {}
42 };
43
44 AccessUnitQueue();
45 ~AccessUnitQueue();
46
47 // Appends the incoming data to the queue.
48 void PushBack(const DemuxerData& frames);
49
50 // Advances the front position to next unit. Logically the preceding units
51 // do not exist, but they can be physically removed later.
52 void Advance();
53
54 // Clears the queue.
55 void Flush();
56
57 // Looks back for the first key frame and if it exists, sets the current
58 // access unit to it and returns true. Otherwise returns false.
59 bool SkipToKeyFrame();
60
61 // Returns the information about the queue.
62 Info GetInfo() const;
63
64 // For unit tests only.
65 size_t NumChunksForTesting() const { return chunks_.size(); }
66
67 private:
68 // Returns the amount of access units that has not been passed to decoder yet.
69 int GetUndecodedAccessUnitLength() const;
70
71 // The queue of data chunks.
72 typedef std::list<scoped_ptr<DemuxerData>> DataChunkQueue;
73 DataChunkQueue chunks_;
74
75 // The chunk that contains the current access unit.
76 DataChunkQueue::iterator current_chunk_;
77
78 // Index of the current access unit within the current chunk.
79 size_t index_in_chunk_;
80
81 // Indicates that a unit with End Of Stream flag has been appended.
82 bool has_eos_;
83
84 // The lock protects all fields together.
85 mutable base::Lock lock_;
86
87 DISALLOW_COPY_AND_ASSIGN(AccessUnitQueue);
88 };
89
90 } // namespace media
91
92 #endif // MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698