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

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 unused media_codec_player_state.h and .cc 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 "media/base/android/access_unit_queue.h"
6
7 #include "base/logging.h"
8 #include "media/base/demuxer_stream.h"
9
10 namespace media {
11
12 AccessUnitQueue::AccessUnitQueue() : has_eos_(false) {}
13
14 AccessUnitQueue::~AccessUnitQueue() {}
15
16 void AccessUnitQueue::PushBack(const DemuxerData& data) {
17 // TODO(timav): The lock is expensive here because it lasts
18 // for the whole duration of data copying. We need to figure out
19 // whet to do with this.
wolenetz 2015/05/19 21:58:37 nit: s/whet/what/
Tima Vaisburd 2015/05/22 22:48:54 Done.
20
21 // Media thread
wolenetz 2015/05/19 21:58:37 nit: here and elsewhere, might be good to have DCH
Tima Vaisburd 2015/05/22 22:48:54 I tried to do it everywhere in higher-level classe
22 base::AutoLock lock(lock_);
23
wolenetz 2015/05/19 21:58:37 nit: should probably do some DCHECK sanity here li
Tima Vaisburd 2015/05/22 22:48:54 Done.
24 for (const AccessUnit& unit : data.access_units) {
25 access_units_.push_back(unit);
26 if (unit.is_end_of_stream) {
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)
wolenetz 2015/05/19 21:58:36 Hmm. Seems simple enough to DCHECK(data.demuxer_co
Tima Vaisburd 2015/05/22 22:48:54 Done.
35 demuxer_configs_.push_back(conf);
36 }
37
38 void AccessUnitQueue::PopFront() {
39 // Decoder thread
40 base::AutoLock lock(lock_);
41
42 if (access_units_.front().status == DemuxerStream::kConfigChanged)
43 demuxer_configs_.pop_front();
44
45 if (access_units_.front().is_end_of_stream)
46 has_eos_ = false; // assume there os only one AU with EOS
wolenetz 2015/05/19 21:58:37 hmm. Once EOS has been consumed from the queue, do
Tima Vaisburd 2015/05/22 22:48:54 The idea was to self-clean after the last access u
47
48 access_units_.pop_front();
49 }
50
51 void AccessUnitQueue::Flush() {
52 // Media thread
53 base::AutoLock lock(lock_);
54
55 access_units_.clear();
56 demuxer_configs_.clear();
57 has_eos_ = false;
58 }
59
60 bool AccessUnitQueue::SkipToKeyFrame() {
61 // Media thread
62 base::AutoLock lock(lock_);
63 // We assume there cannot be |demuxer_configs_| elements for non-key frames.
64
65 std::deque<AccessUnit>::iterator it;
66 for (it = access_units_.begin(); it!= access_units_.end(); ++it) {
67 if (it->is_key_frame) {
68 access_units_.erase(access_units_.begin(), it);
69 return true;
70 }
71 }
72
73 return false;
74 }
75
76 void AccessUnitQueue::GetInfo(Info* info) const {
wolenetz 2015/05/19 21:58:37 nit: do we need this Peek-like method, or can PopF
Tima Vaisburd 2015/05/22 22:48:54 I think we do. The Android MediaCodec might return
77 // Media thread, Decoder thread
78 base::AutoLock lock(lock_);
79
80 info->length = access_units_.size();
81 info->has_eos = has_eos_;
82 info->front_unit = nullptr;
83 info->configs = nullptr;
84
85 if (info->length > 0) {
86 info->front_unit = &access_units_.front();
87 if (access_units_.front().status == DemuxerStream::kConfigChanged)
88 info->configs = &demuxer_configs_.front();
wolenetz 2015/05/19 21:58:36 Sanity check that we have a config to return, plea
Tima Vaisburd 2015/05/22 22:48:54 Done.
89 }
90 }
91
92 } // namespace media
93
94 std::ostream& operator<<(std::ostream& os, const media::AccessUnit& au) {
95 os << "status:" << au.status
96 << (au.is_end_of_stream ? " EOS" : "")
97 << (au.is_key_frame ? " KEY_FRAME" : "")
98 << " pts:" << au.timestamp
99 << " size:" << au.data.size();
100 return os;
101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698