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

Side by Side Diff: media/base/android/au_queue.cc

Issue 1128383003: Implementation of MediaCodecPlayer stage 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed stop procedure, fixed compilation 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
7 #include "media/base/android/au_queue.h"
8 #include "media/base/demuxer_stream.h"
9
10 //#include "base/tvlog.h"
qinmin 2015/05/12 23:58:22 remove unused includes
timav 2015/05/13 01:05:17 I need them for testing. I will remove them last t
11
12 namespace media {
13
14 AUQueue::AUQueue()
15 : has_eos_(false)
qinmin 2015/05/12 23:58:22 the ctor can squeeze a single line
Tima Vaisburd 2015/05/13 22:51:46 Done.
wolenetz 2015/05/19 21:58:36 In general, "git cl format" is your friend :)
16 {}
17
18 AUQueue::~AUQueue()
19 {}
qinmin 2015/05/12 23:58:22 move {} to the previous line
Tima Vaisburd 2015/05/13 22:51:46 Done.
20
21 void AUQueue::PushBack(const DemuxerData& data) {
22 base::AutoLock lock(lock_);
qinmin 2015/05/12 23:58:22 the lock is pretty expensive here as data will be
timav 2015/05/13 01:05:17 I used std::deque for simplicity as a temporary so
Tima Vaisburd 2015/05/13 22:51:47 Added TODO item
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) << "AUQueue::" << __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 AUQueue::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 AUQueue::Flush() {
51 base::AutoLock lock(lock_);
52
53 access_units_.clear();
54 demuxer_configs_.clear();
55 has_eos_ = false;
56 }
57
58 bool AUQueue::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) {
qinmin 2015/05/12 23:58:22 doesn't this skip all the access units that haven'
timav 2015/05/13 01:05:17 I think I misunderstood what SetCurrentFrameToPrev
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 AUQueue::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 AUQueue::HasEOS() const {
91 base::AutoLock lock(lock_);
92
93 return has_eos_;
94 }
95
96 int AUQueue::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