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

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

Issue 1162203009: Access unit queue for MediaCodecPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments, some questions. 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 should be accessed on the Media thread that puts the incoming data
23 // in and on the Decoder thread that gets the next access unit and eventually
24 // removes it 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 End Of Stream has been added to the queue. Cleared by Flush().
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, resets the length to zeto and clears EOS condition.
55 void Flush();
56
57 // Looks back for the first key frame starting from the current one (i.e.
58 // the look-back is inclusive of the current front position).
59 // If the key frame exists, sets the current access unit to it and returns
60 // true. Otherwise returns false.
61 bool RewindToLastKeyFrame();
62
63 // Returns the information about the queue.
64 Info GetInfo() const;
65
66 // For unit tests only.
wolenetz 2015/06/11 19:21:21 nit: mark as not thread-safe in comment?
Tima Vaisburd 2015/06/11 20:54:09 Done.
67 size_t NumChunksForTesting() const { return chunks_.size(); }
68 void SetHistorySizeForTesting(size_t number_of_history_chunks);
69
70 private:
71 // Returns the amount of access units between the current one and the end,
72 // incuding current. Logically these are units that has not been consumed.
wolenetz 2015/06/11 19:21:21 nit: s/has/have/
Tima Vaisburd 2015/06/11 20:54:09 Done.
73 int GetUnconsumedAccessUnitLength() const;
74
75 // The queue of data chunks.
76 typedef std::list<scoped_ptr<DemuxerData>> DataChunkQueue;
77 DataChunkQueue chunks_;
78
79 // The chunk that contains the current access unit.
80 DataChunkQueue::iterator current_chunk_;
81
82 // Index of the current access unit within the current chunk.
83 size_t index_in_chunk_;
84
85 // Amount of chunks before the |current_chunk_| that's kept for history.
86 size_t history_chunks_amount_;
87
88 // Indicates that a unit with End Of Stream flag has been appended.
89 bool has_eos_;
90
91 // The lock protects all fields together.
92 mutable base::Lock lock_;
93
94 DISALLOW_COPY_AND_ASSIGN(AccessUnitQueue);
95 };
96
97 } // namespace media
98
99 #endif // MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698