| 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 queue is accessed on the Media thread that puts the incoming |
| 19 // data in and the Decoder thread that gets the next access unit and |
| 20 // eventually removes it from the queue. |
| 21 class AccessUnitQueue { |
| 22 public: |
| 23 // Information about the queue state and it's front AccessUnit |
| 24 struct Info { |
| 25 // The unit at front |
| 26 const AccessUnit* front_unit; |
| 27 |
| 28 // New configs at front. |
| 29 // If |front_unit| is defined, |configs| is null, and vice versa. |
| 30 const DemuxerConfigs* configs; |
| 31 |
| 32 // Current size of the queue. |
| 33 int length; |
| 34 |
| 35 // Whether the queue containd End Of Stream. |
| 36 bool has_eos; |
| 37 |
| 38 Info() |
| 39 : front_unit(nullptr), configs(nullptr), length(0), has_eos(false) {} |
| 40 }; |
| 41 |
| 42 AccessUnitQueue(); |
| 43 virtual ~AccessUnitQueue(); |
| 44 |
| 45 // Appends the incoming data to the queue. |
| 46 void PushBack(const DemuxerData& frames); |
| 47 |
| 48 // Removes one access unit from the front. |
| 49 void PopFront(); |
| 50 |
| 51 // Clears the queue |
| 52 void Flush(); |
| 53 |
| 54 // Looks for the first key frame and if it exists, |
| 55 // removes prior frames and returns true. If it does not |
| 56 // exist returns false. |
| 57 bool SkipToKeyFrame(); |
| 58 |
| 59 // Returns the information about the queue. |
| 60 void GetInfo(Info* info) const; |
| 61 |
| 62 private: |
| 63 // The queue of access units |
| 64 std::deque<AccessUnit> access_units_; |
| 65 |
| 66 // The queue of corresponding configurations. |
| 67 // Some access units has the state set to |kConfigChanged|, |
| 68 // these units have no data and no PTS, and for each there is |
| 69 // one entry in |demuxer_configs_| |
| 70 std::deque<DemuxerConfigs> demuxer_configs_; |
| 71 |
| 72 // Indicates that a unit with End Of Stream flag |
| 73 // has been appended to the queue. |
| 74 bool has_eos_; |
| 75 |
| 76 // The queue works on two threads. |
| 77 mutable base::Lock lock_; |
| 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(AccessUnitQueue); |
| 80 }; |
| 81 |
| 82 } // namespace media |
| 83 |
| 84 // For logging |
| 85 std::ostream& operator<<(std::ostream& os, const media::AccessUnit& au); |
| 86 |
| 87 #endif // MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_ |
| OLD | NEW |