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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: media/base/android/access_unit_queue.h
diff --git a/media/base/android/access_unit_queue.h b/media/base/android/access_unit_queue.h
new file mode 100644
index 0000000000000000000000000000000000000000..23e732260828be044781b0ebebef48ccec953034
--- /dev/null
+++ b/media/base/android/access_unit_queue.h
@@ -0,0 +1,93 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_
+#define MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_
+
+#include <list>
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/synchronization/lock.h"
+#include "media/base/android/demuxer_stream_player_params.h"
+
+namespace media {
+
+// The queue of incoming data for MediaCodecDecoder.
+//
+// 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.
+// if the type is |kConfigChanged| the access unit itself has no data, but
+// is accompanied with DemuxerConfigs.
+// 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.
+// the Decoder thread that gets the next access unit and eventually removes it
+// from the queue.
+class AccessUnitQueue {
+ public:
+ // Information about the queue state and the access unit at the front.
+ struct Info {
+ // The unit at front. Null if the queue is empty.
+ const AccessUnit* front_unit;
+
+ // Configs for the front unit if it is |kConfigChanged|, null otherwise.
+ const DemuxerConfigs* configs;
+
+ // Number of access units in the queue.
+ int length;
+
+ // 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
+ bool has_eos;
+
+ Info()
+ : front_unit(nullptr), configs(nullptr), length(0), has_eos(false) {}
+ };
+
+ AccessUnitQueue();
+ ~AccessUnitQueue();
+
+ // Appends the incoming data to the queue.
+ void PushBack(const DemuxerData& frames);
+
+ // Advances the front position to next unit. Logically the preceding units
+ // do not exist, but they can be physically removed later.
+ void Advance();
+
+ // Clears the queue.
+ void Flush();
+
+ // Looks back for the first key frame and if it exists, sets the current
+ // 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.
+ bool SkipToKeyFrame();
wolenetz 2015/06/08 21:37:09 nit: s/SkipToKeyFrame()/RewindToLastKeyFrame()/ ?
Tima Vaisburd 2015/06/09 21:29:21 Done.
+
+ // Returns the information about the queue.
+ Info GetInfo() const;
+
+ // For unit tests only.
+ size_t NumChunksForTesting() const { return chunks_.size(); }
+
+ private:
+ // 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.
+ int GetUndecodedAccessUnitLength() const;
+
+ // The queue of data chunks.
+ 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
+ DataChunkQueue chunks_;
+
+ // The chunk that contains the current access unit.
+ DataChunkQueue::iterator current_chunk_;
+
+ // Index of the current access unit within the current chunk.
+ size_t index_in_chunk_;
+
+ // Indicates that a unit with End Of Stream flag has been appended.
+ bool has_eos_;
+
+ // The lock protects all fields together.
+ mutable base::Lock lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(AccessUnitQueue);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_

Powered by Google App Engine
This is Rietveld 408576698