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

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: 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,
wolenetz 2015/06/08 21:37:09 nit: s/, if/. If/
Tima Vaisburd 2015/06/09 21:29:21 Done.
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
wolenetz 2015/06/08 21:37:09 Are these assumptions checked in the .cc? If not (
Tima Vaisburd 2015/06/09 21:29:21 No, the assumptions are not checked, and I change
wolenetz 2015/06/11 19:21:20 Acknowledged.
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.
wolenetz 2015/06/08 21:37:09 End of Stream is somewhat ephemeral: a web app cou
Tima Vaisburd 2015/06/09 21:29:21 If you consider this class separately, I do not se
wolenetz 2015/06/11 19:21:20 Blocking any input after EOS (with some DCHECK or
Tima Vaisburd 2015/06/11 20:54:08 I did the block. I'm not sure what to DCHECK thoug
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 // do 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.
wolenetz 2015/06/08 21:37:09 nit: Is the queue unmodified if the current "front
Tima Vaisburd 2015/06/09 21:29:21 Inclusive. I changed the comment.
60 bool SkipToKeyFrame();
wolenetz 2015/06/08 21:37:09 nit: s/SkipToKeyFrame()/RewindToLastKeyFrame()/ ?
Tima Vaisburd 2015/06/09 21:29:21 Done.
61
62 // Returns the information about the queue.
63 Info GetInfo() const;
64
65 // For unit tests only.
66 size_t NumChunksForTesting() const { return chunks_.size(); }
67
68 private:
69 // Returns the amount of access units that has not been passed to decoder yet.
wolenetz 2015/06/08 21:37:09 nit: This class doesn't pass to a decoder, so shou
Tima Vaisburd 2015/06/09 21:29:21 Done.
70 int GetUndecodedAccessUnitLength() const;
71
72 // The queue of data chunks.
73 typedef std::list<scoped_ptr<DemuxerData>> DataChunkQueue;
wolenetz 2015/06/08 21:37:09 This doesn't look right to me. See "I want to use
Tima Vaisburd 2015/06/09 21:29:21 Interesting. There is a lot of examples of using u
wolenetz 2015/06/11 19:21:20 I don't think scoped_ptr can be a unique_ptr repla
Tima Vaisburd 2015/06/11 20:54:08 I went with raw pointer, the decoder seems to prov
Tima Vaisburd 2015/06/11 21:32:04 aside: Exactly this makes me believe that invalid
74 DataChunkQueue chunks_;
75
76 // The chunk that contains the current access unit.
77 DataChunkQueue::iterator current_chunk_;
78
79 // Index of the current access unit within the current chunk.
80 size_t index_in_chunk_;
81
82 // Indicates that a unit with End Of Stream flag has been appended.
83 bool has_eos_;
84
85 // The lock protects all fields together.
86 mutable base::Lock lock_;
87
88 DISALLOW_COPY_AND_ASSIGN(AccessUnitQueue);
89 };
90
91 } // namespace media
92
93 #endif // MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698