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

Side by Side 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 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 #include "base/logging.h"
6
qinmin 2015/05/14 19:52:57 remove empty line
Tima Vaisburd 2015/05/15 00:12:39 Done.
7 #include "media/base/android/access_unit_queue.h"
8 #include "media/base/demuxer_stream.h"
9
10 //#include "base/tvlog.h"
qinmin 2015/05/14 19:52:57 remove unused include
Tima Vaisburd 2015/05/15 00:12:39 Done.
11
12 namespace media {
13
14 AccessUnitQueue::AccessUnitQueue() : has_eos_(false) {}
15
16 AccessUnitQueue::~AccessUnitQueue() {}
17
18 void AccessUnitQueue::PushBack(const DemuxerData& data) {
19 // TODO(timav): The lock is expensive here because it lasts
20 // for the whole duration of data copying. We need to figure out
21 // whet to do with this.
22 base::AutoLock lock(lock_);
23
24 for (const AccessUnit& unit : data.access_units) {
25 access_units_.push_back(unit);
26 if (unit.is_end_of_stream || unit.data.empty()) {
27 DVLOG(1) << "AccessUnitQueue::" << __FUNCTION__ << ": EOS detected";
28 has_eos_ = true;
29 }
30 }
31
32 // We assume that the rule "one DemuxerConfigs for one AU
33 // with |kConfigChanged|" holds and do not check anything.
34 for (const DemuxerConfigs& conf : data.demuxer_configs)
35 demuxer_configs_.push_back(conf);
36 }
37
38 void AccessUnitQueue::PopFront() {
39 base::AutoLock lock(lock_);
40
41 if (access_units_.front().status == DemuxerStream::kConfigChanged)
42 demuxer_configs_.pop_front();
43
44 if (access_units_.front().is_end_of_stream)
45 has_eos_ = false; // assume there os only one AU with EOS
46
47 access_units_.pop_front();
48 }
49
50 void AccessUnitQueue::Flush() {
51 base::AutoLock lock(lock_);
52
53 access_units_.clear();
54 demuxer_configs_.clear();
55 has_eos_ = false;
56 }
57
58 bool AccessUnitQueue::SkipToKeyFrame() {
59 // Media thread
60 base::AutoLock lock(lock_);
61 // We assume there cannot be |demuxer_configs_| elements for non-key frames.
62
63 std::deque<AccessUnit>::iterator it;
64 for (it = access_units_.begin(); it!= access_units_.end(); ++it) {
65 if (it->is_key_frame) {
66 access_units_.erase(access_units_.begin(), it);
67 return true;
68 }
69 }
70
71 return false;
72 }
73
74 void AccessUnitQueue::GetInfo(Info* info) const {
75 base::AutoLock lock(lock_);
76
77 info->length = access_units_.size();
78 info->has_eos = has_eos_;
79 if (info->length > 0) {
80 info->front_unit = &access_units_.front();
81 info->configs =
82 (info->front_unit->status == DemuxerStream::kConfigChanged) ?
83 &demuxer_configs_.front() : nullptr;
84 } else {
85 info->front_unit = nullptr;
86 info->configs = nullptr;
87 }
88 }
89
90 bool AccessUnitQueue::HasEOS() const {
91 base::AutoLock lock(lock_);
92
93 return has_eos_;
94 }
95
96 int AccessUnitQueue::Length() const {
97 base::AutoLock lock(lock_);
98
99 return access_units_.size();
100 }
101
102 } // namespace media
103
104 std::ostream& operator<<(std::ostream& os, const media::AccessUnit& au) {
105 os << "status:" << au.status
106 << (au.is_end_of_stream ? " EOS" : "")
107 << (au.is_key_frame ? " KEY_FRAME" : "")
108 << " pts:" << au.timestamp
109 << " size:" << au.data.size();
110 return os;
111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698