| Index: media/base/android/au_queue.cc
|
| diff --git a/media/base/android/au_queue.cc b/media/base/android/au_queue.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6be3d522dbc273522457cdaa7d7dcbd715a9152d
|
| --- /dev/null
|
| +++ b/media/base/android/au_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"
|
| +
|
| +#include "media/base/android/au_queue.h"
|
| +#include "media/base/demuxer_stream.h"
|
| +
|
| +//#include "base/tvlog.h"
|
| +
|
| +namespace media {
|
| +
|
| +AUQueue::AUQueue()
|
| + : has_eos_(false)
|
| +{}
|
| +
|
| +AUQueue::~AUQueue()
|
| +{}
|
| +
|
| +void AUQueue::PushBack(const DemuxerData& data) {
|
| + 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) << "AUQueue::" << __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 AUQueue::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 AUQueue::Flush() {
|
| + base::AutoLock lock(lock_);
|
| +
|
| + access_units_.clear();
|
| + demuxer_configs_.clear();
|
| + has_eos_ = false;
|
| +}
|
| +
|
| +bool AUQueue::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 AUQueue::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 AUQueue::HasEOS() const {
|
| + base::AutoLock lock(lock_);
|
| +
|
| + return has_eos_;
|
| +}
|
| +
|
| +int AUQueue::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;
|
| +}
|
|
|