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

Unified Diff: media/base/android/access_unit_queue.cc

Issue 1128383003: Implementation of MediaCodecPlayer stage 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unneeded changed to MediaPlayerAndroid, style guide compliance 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.cc
diff --git a/media/base/android/access_unit_queue.cc b/media/base/android/access_unit_queue.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d1c804611764852817a3b992485a6b642778ddaf
--- /dev/null
+++ b/media/base/android/access_unit_queue.cc
@@ -0,0 +1,111 @@
+// 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.
+
+#include "base/logging.h"
+
qinmin 2015/05/14 19:52:57 remove empty line
Tima Vaisburd 2015/05/15 00:12:39 Done.
+#include "media/base/android/access_unit_queue.h"
+#include "media/base/demuxer_stream.h"
+
+//#include "base/tvlog.h"
qinmin 2015/05/14 19:52:57 remove unused include
Tima Vaisburd 2015/05/15 00:12:39 Done.
+
+namespace media {
+
+AccessUnitQueue::AccessUnitQueue() : has_eos_(false) {}
+
+AccessUnitQueue::~AccessUnitQueue() {}
+
+void AccessUnitQueue::PushBack(const DemuxerData& data) {
+ // TODO(timav): The lock is expensive here because it lasts
+ // for the whole duration of data copying. We need to figure out
+ // whet to do with this.
+ base::AutoLock lock(lock_);
+
+ for (const AccessUnit& unit : data.access_units) {
+ access_units_.push_back(unit);
+ if (unit.is_end_of_stream || unit.data.empty()) {
+ DVLOG(1) << "AccessUnitQueue::" << __FUNCTION__ << ": EOS detected";
+ has_eos_ = true;
+ }
+ }
+
+ // We assume that the rule "one DemuxerConfigs for one AU
+ // with |kConfigChanged|" holds and do not check anything.
+ for (const DemuxerConfigs& conf : data.demuxer_configs)
+ demuxer_configs_.push_back(conf);
+}
+
+void AccessUnitQueue::PopFront() {
+ base::AutoLock lock(lock_);
+
+ if (access_units_.front().status == DemuxerStream::kConfigChanged)
+ demuxer_configs_.pop_front();
+
+ if (access_units_.front().is_end_of_stream)
+ has_eos_ = false; // assume there os only one AU with EOS
+
+ access_units_.pop_front();
+}
+
+void AccessUnitQueue::Flush() {
+ base::AutoLock lock(lock_);
+
+ access_units_.clear();
+ demuxer_configs_.clear();
+ has_eos_ = false;
+}
+
+bool AccessUnitQueue::SkipToKeyFrame() {
+ // Media thread
+ base::AutoLock lock(lock_);
+ // We assume there cannot be |demuxer_configs_| elements for non-key frames.
+
+ std::deque<AccessUnit>::iterator it;
+ for (it = access_units_.begin(); it!= access_units_.end(); ++it) {
+ if (it->is_key_frame) {
+ access_units_.erase(access_units_.begin(), it);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void AccessUnitQueue::GetInfo(Info* info) const {
+ base::AutoLock lock(lock_);
+
+ info->length = access_units_.size();
+ info->has_eos = has_eos_;
+ if (info->length > 0) {
+ info->front_unit = &access_units_.front();
+ info->configs =
+ (info->front_unit->status == DemuxerStream::kConfigChanged) ?
+ &demuxer_configs_.front() : nullptr;
+ } else {
+ info->front_unit = nullptr;
+ info->configs = nullptr;
+ }
+}
+
+bool AccessUnitQueue::HasEOS() const {
+ base::AutoLock lock(lock_);
+
+ return has_eos_;
+}
+
+int AccessUnitQueue::Length() const {
+ base::AutoLock lock(lock_);
+
+ return access_units_.size();
+}
+
+} // namespace media
+
+std::ostream& operator<<(std::ostream& os, const media::AccessUnit& au) {
+ os << "status:" << au.status
+ << (au.is_end_of_stream ? " EOS" : "")
+ << (au.is_key_frame ? " KEY_FRAME" : "")
+ << " pts:" << au.timestamp
+ << " size:" << au.data.size();
+ return os;
+}

Powered by Google App Engine
This is Rietveld 408576698