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

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

Issue 1128383003: Implementation of MediaCodecPlayer stage 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improved state machine diagrams 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()
42 : front_unit(nullptr), configs(nullptr), length(0), has_eos(false) {}
43 };
44
45 AccessUnitQueue();
46 ~AccessUnitQueue();
47
48 // Appends the incoming data to the queue.
49 void PushBack(const DemuxerData& frames);
50
51 // Advances the front position to next unit. Logically the preceding units
52 // does not exist, but they can be physically removed later.
53 void Advance();
54
55 // Clears the queue.
56 void Flush();
57
58 // Looks back for the first key frame and if it exists, sets the current
59 // access unit to it and returns true. Otherwise returns false.
60 bool SkipToKeyFrame();
61
62 // Returns the information about the queue.
63 void GetInfo(Info* info) const;
64
65 private:
66 // Helper method that returns the queue length.
67 int GetLength() const;
qinmin 2015/05/31 20:19:12 The function name and description is misleading. W
Tima Vaisburd 2015/06/01 18:56:52 The second name. However, after having chunks the
68
69 // The queue of data chunks.
70 typedef std::list< scoped_ptr<DemuxerData> > DataChunkQueue;
71 DataChunkQueue chunks_;
72
73 // The chunk that contains the current access unit.
74 DataChunkQueue::iterator current_chunk_;
75
76 // Index of the current access unit within the current chunk.
77 size_t index_in_chunk_;
78
79 // Indicates that a unit with End Of Stream flag has been appended.
80 bool has_eos_;
81
82 // The queue works on two threads.
83 mutable base::Lock lock_;
84
85 DISALLOW_COPY_AND_ASSIGN(AccessUnitQueue);
86 };
87
88 } // namespace media
89
90 #endif // MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698