| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_ | 5 #ifndef MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_ |
| 6 #define MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_ | 6 #define MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 const AccessUnit* front_unit; | 33 const AccessUnit* front_unit; |
| 34 | 34 |
| 35 // Configs for the front unit if it is |kConfigChanged|, null otherwise. | 35 // Configs for the front unit if it is |kConfigChanged|, null otherwise. |
| 36 // The same validity rule applies: this pointer is only valid till the next | 36 // The same validity rule applies: this pointer is only valid till the next |
| 37 // Advance() or Flush() call, and |configs| is owned by the queue itself. | 37 // Advance() or Flush() call, and |configs| is owned by the queue itself. |
| 38 const DemuxerConfigs* configs; | 38 const DemuxerConfigs* configs; |
| 39 | 39 |
| 40 // Number of access units in the queue. | 40 // Number of access units in the queue. |
| 41 int length; | 41 int length; |
| 42 | 42 |
| 43 // Number of access units in the queue excluding config units. |
| 44 int data_length; |
| 45 |
| 43 // Whether End Of Stream has been added to the queue. Cleared by Flush(). | 46 // Whether End Of Stream has been added to the queue. Cleared by Flush(). |
| 44 bool has_eos; | 47 bool has_eos; |
| 45 | 48 |
| 46 Info() : front_unit(nullptr), configs(nullptr), length(0), has_eos(false) {} | 49 Info() : front_unit(nullptr), configs(nullptr), length(0), has_eos(false) {} |
| 47 }; | 50 }; |
| 48 | 51 |
| 49 AccessUnitQueue(); | 52 AccessUnitQueue(); |
| 50 ~AccessUnitQueue(); | 53 ~AccessUnitQueue(); |
| 51 | 54 |
| 52 // Appends the incoming data to the queue. | 55 // Appends the incoming data to the queue. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 68 // Returns the information about the queue. | 71 // Returns the information about the queue. |
| 69 // The result is invalidated by the following Advance() or Flush call. | 72 // The result is invalidated by the following Advance() or Flush call. |
| 70 // There must be only one |Info| consumer at a time. | 73 // There must be only one |Info| consumer at a time. |
| 71 Info GetInfo() const; | 74 Info GetInfo() const; |
| 72 | 75 |
| 73 // For unit tests only. These methods are not thread safe. | 76 // For unit tests only. These methods are not thread safe. |
| 74 size_t NumChunksForTesting() const { return chunks_.size(); } | 77 size_t NumChunksForTesting() const { return chunks_.size(); } |
| 75 void SetHistorySizeForTesting(size_t number_of_history_chunks); | 78 void SetHistorySizeForTesting(size_t number_of_history_chunks); |
| 76 | 79 |
| 77 private: | 80 private: |
| 78 // Returns the amount of access units between the current one and the end, | 81 // Returns the total number of access units (total_length) and the number of |
| 79 // incuding current. Logically these are units that have not been consumed. | 82 // units excluding configiration change requests (data_length). The number is |
| 80 int GetUnconsumedAccessUnitLength() const; | 83 // calculated between the current one and the end, incuding the current. |
| 84 // Logically these are units that have not been consumed. |
| 85 void GetUnconsumedAccessUnitLength(int* total_length, int* data_length) const; |
| 81 | 86 |
| 82 // The queue of data chunks. It owns the chunks. | 87 // The queue of data chunks. It owns the chunks. |
| 83 typedef std::list<DemuxerData*> DataChunkQueue; | 88 typedef std::list<DemuxerData*> DataChunkQueue; |
| 84 DataChunkQueue chunks_; | 89 DataChunkQueue chunks_; |
| 85 | 90 |
| 86 // The chunk that contains the current access unit. | 91 // The chunk that contains the current access unit. |
| 87 DataChunkQueue::iterator current_chunk_; | 92 DataChunkQueue::iterator current_chunk_; |
| 88 | 93 |
| 89 // Index of the current access unit within the current chunk. | 94 // Index of the current access unit within the current chunk. |
| 90 size_t index_in_chunk_; | 95 size_t index_in_chunk_; |
| 91 | 96 |
| 92 // Amount of chunks before the |current_chunk_| that's kept for history. | 97 // Amount of chunks before the |current_chunk_| that's kept for history. |
| 93 size_t history_chunks_amount_; | 98 size_t history_chunks_amount_; |
| 94 | 99 |
| 95 // Indicates that a unit with End Of Stream flag has been appended. | 100 // Indicates that a unit with End Of Stream flag has been appended. |
| 96 bool has_eos_; | 101 bool has_eos_; |
| 97 | 102 |
| 98 // The lock protects all fields together. | 103 // The lock protects all fields together. |
| 99 mutable base::Lock lock_; | 104 mutable base::Lock lock_; |
| 100 | 105 |
| 101 DISALLOW_COPY_AND_ASSIGN(AccessUnitQueue); | 106 DISALLOW_COPY_AND_ASSIGN(AccessUnitQueue); |
| 102 }; | 107 }; |
| 103 | 108 |
| 104 } // namespace media | 109 } // namespace media |
| 105 | 110 |
| 106 #endif // MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_ | 111 #endif // MEDIA_BASE_ANDROID_ACCESS_UNIT_QUEUE_H_ |
| OLD | NEW |