OLD | NEW |
(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 #ifndef MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_ |
| 6 #define MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_ |
| 7 |
| 8 #include <deque> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/synchronization/lock.h" |
| 12 #include "media/base/android/demuxer_stream_player_params.h" |
| 13 |
| 14 namespace media { |
| 15 |
| 16 // The queue of incoming data for MediaCodecDecoder. |
| 17 // |
| 18 // The data comes in the form of access units. Each access unit has a type, |
| 19 // if the type is |kConfigChanged| the access unit itself has no data, but |
| 20 // is accompanied with DemuxerConfigs. |
| 21 // The queue is accessed on the Media thread that puts the incoming data in and |
| 22 // the Decoder thread that gets the next access unit and eventually removes it |
| 23 // from the queue. |
| 24 class AccessUnitQueue { |
| 25 public: |
| 26 // Information about the queue state and the access unit at the front. |
| 27 struct Info { |
| 28 // The unit at front. Null if the queue is empty. |
| 29 const AccessUnit* front_unit; |
| 30 |
| 31 // Configs for the front unit if it is |kConfigChanged|, null otherwise. |
| 32 const DemuxerConfigs* configs; |
| 33 |
| 34 // Number of access units in the queue. |
| 35 int length; |
| 36 |
| 37 // Whether the queue contains End Of Stream. |
| 38 bool has_eos; |
| 39 |
| 40 Info() |
| 41 : front_unit(nullptr), configs(nullptr), length(0), has_eos(false) {} |
| 42 }; |
| 43 |
| 44 AccessUnitQueue(); |
| 45 ~AccessUnitQueue(); |
| 46 |
| 47 // Appends the incoming data to the queue. |
| 48 void PushBack(const DemuxerData& frames); |
| 49 |
| 50 // Removes one access unit from the front. |
| 51 void PopFront(); |
| 52 |
| 53 // Clears the queue |
| 54 void Flush(); |
| 55 |
| 56 // Looks for the first key frame and if it exists, removes prior frames and |
| 57 // returns true. If it does not exist returns false. |
| 58 bool SkipToKeyFrame(); |
| 59 |
| 60 // Returns the information about the queue. |
| 61 void GetInfo(Info* info) const; |
| 62 |
| 63 private: |
| 64 // The queue of access units |
| 65 std::deque<AccessUnit> access_units_; |
| 66 |
| 67 // The queue of corresponding configurations. Some access units has the state |
| 68 // set to |kConfigChanged|, these units have no data and no PTS, and for each |
| 69 // there is one entry in |demuxer_configs_|. |
| 70 std::deque<DemuxerConfigs> demuxer_configs_; |
| 71 |
| 72 // Indicates that a unit with End Of Stream flag has been appended. |
| 73 bool has_eos_; |
| 74 |
| 75 // The queue works on two threads. |
| 76 mutable base::Lock lock_; |
| 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(AccessUnitQueue); |
| 79 }; |
| 80 |
| 81 } // namespace media |
| 82 |
| 83 #endif // MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_ |
OLD | NEW |