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

Unified 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: Comments, better Listener callbacks, removed unused includes Created 5 years, 7 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..9c21bba86f25533ed51e826a3746cebde031abb2
--- /dev/null
+++ b/media/base/android/access_unit_queue.h
@@ -0,0 +1,87 @@
+// 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 <deque>
+
+#include "base/macros.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 queue is accessed on the Media thread that puts the incoming
+// data in and 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 it's front AccessUnit
+ struct Info {
+ // The unit at front
+ const AccessUnit* front_unit;
+
+ // New configs at front.
+ // If |front_unit| is defined, |configs| is null, and vice versa.
+ const DemuxerConfigs* configs;
+
+ // Current size of the queue.
+ int length;
+
+ // Whether the queue containd End Of Stream.
+ bool has_eos;
+
+ Info()
+ : front_unit(nullptr), configs(nullptr), length(0), has_eos(false) {}
+ };
+
+ AccessUnitQueue();
+ virtual ~AccessUnitQueue();
+
+ // Appends the incoming data to the queue.
+ void PushBack(const DemuxerData& frames);
+
+ // Removes one access unit from the front.
+ void PopFront();
+
+ // Clears the queue
+ void Flush();
+
+ // Looks for the first key frame and if it exists,
+ // removes prior frames and returns true. If it does not
+ // exist returns false.
+ bool SkipToKeyFrame();
+
+ // Returns the information about the queue.
+ void GetInfo(Info* info) const;
+
+ private:
+ // The queue of access units
+ std::deque<AccessUnit> access_units_;
+
+ // The queue of corresponding configurations.
+ // Some access units has the state set to |kConfigChanged|,
+ // these units have no data and no PTS, and for each there is
+ // one entry in |demuxer_configs_|
+ std::deque<DemuxerConfigs> demuxer_configs_;
+
+ // Indicates that a unit with End Of Stream flag
+ // has been appended to the queue.
+ bool has_eos_;
+
+ // The queue works on two threads.
+ mutable base::Lock lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(AccessUnitQueue);
+};
+
+} // namespace media
+
+// For logging
+std::ostream& operator<<(std::ostream& os, const media::AccessUnit& au);
+
+#endif // MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_

Powered by Google App Engine
This is Rietveld 408576698