Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_DECODER_BUFFER_H_ | 5 #ifndef MEDIA_BASE_DECODER_BUFFER_H_ |
| 6 #define MEDIA_BASE_DECODER_BUFFER_H_ | 6 #define MEDIA_BASE_DECODER_BUFFER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | |
| 9 | 10 |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/memory/aligned_memory.h" | 12 #include "base/memory/aligned_memory.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 16 #include "media/base/decrypt_config.h" | 17 #include "media/base/decrypt_config.h" |
| 17 #include "media/base/media_export.h" | 18 #include "media/base/media_export.h" |
| 18 | 19 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 } | 127 } |
| 127 | 128 |
| 128 // If there's no data in this buffer, it represents end of stream. | 129 // If there's no data in this buffer, it represents end of stream. |
| 129 bool end_of_stream() const { | 130 bool end_of_stream() const { |
| 130 return data_ == NULL; | 131 return data_ == NULL; |
| 131 } | 132 } |
| 132 | 133 |
| 133 // Returns a human-readable string describing |*this|. | 134 // Returns a human-readable string describing |*this|. |
| 134 std::string AsHumanReadableString(); | 135 std::string AsHumanReadableString(); |
| 135 | 136 |
| 137 // Utility function to create side data item for decoder buffer. | |
| 138 template<typename T> | |
| 139 static void MakeSideData(T id_begin, T id_end, | |
|
acolwell GONE FROM CHROMIUM
2013/10/24 18:57:51
This doesn't belong here. This class is format ind
Matthew Heaney (Chromium)
2013/10/25 03:05:38
Done.
| |
| 140 T settings_begin, T settings_end, | |
| 141 std::vector<uint8>* side_data); | |
| 142 | |
| 136 protected: | 143 protected: |
| 137 friend class base::RefCountedThreadSafe<DecoderBuffer>; | 144 friend class base::RefCountedThreadSafe<DecoderBuffer>; |
| 138 | 145 |
| 139 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer | 146 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer |
| 140 // will be padded and aligned as necessary. If |data| is NULL then |data_| is | 147 // will be padded and aligned as necessary. If |data| is NULL then |data_| is |
| 141 // set to NULL and |buffer_size_| to 0. | 148 // set to NULL and |buffer_size_| to 0. |
| 142 DecoderBuffer(const uint8* data, int size, | 149 DecoderBuffer(const uint8* data, int size, |
| 143 const uint8* side_data, int side_data_size); | 150 const uint8* side_data, int side_data_size); |
| 144 virtual ~DecoderBuffer(); | 151 virtual ~DecoderBuffer(); |
| 145 | 152 |
| 146 private: | 153 private: |
| 147 base::TimeDelta timestamp_; | 154 base::TimeDelta timestamp_; |
| 148 base::TimeDelta duration_; | 155 base::TimeDelta duration_; |
| 149 | 156 |
| 150 int size_; | 157 int size_; |
| 151 scoped_ptr<uint8, base::ScopedPtrAlignedFree> data_; | 158 scoped_ptr<uint8, base::ScopedPtrAlignedFree> data_; |
| 152 int side_data_size_; | 159 int side_data_size_; |
| 153 scoped_ptr<uint8, base::ScopedPtrAlignedFree> side_data_; | 160 scoped_ptr<uint8, base::ScopedPtrAlignedFree> side_data_; |
| 154 scoped_ptr<DecryptConfig> decrypt_config_; | 161 scoped_ptr<DecryptConfig> decrypt_config_; |
| 155 base::TimeDelta discard_padding_; | 162 base::TimeDelta discard_padding_; |
| 156 | 163 |
| 157 // Constructor helper method for memory allocations. | 164 // Constructor helper method for memory allocations. |
| 158 void Initialize(); | 165 void Initialize(); |
| 159 | 166 |
| 160 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); | 167 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); |
| 161 }; | 168 }; |
| 162 | 169 |
| 163 } // namespace media | 170 } // namespace media |
| 164 | 171 |
| 172 template<typename T> | |
| 173 inline void media::DecoderBuffer::MakeSideData( | |
| 174 T id_begin, T id_end, | |
| 175 T settings_begin, T settings_end, | |
| 176 std::vector<uint8>* side_data) { | |
| 177 // The DecoderBuffer only supports a single side data item. In the case of | |
| 178 // a WebVTT cue, we can have potentially two side data items. In order to | |
| 179 // avoid disrupting DecoderBuffer any more than we need to, we copy both | |
| 180 // side data items onto a single one, and terminate each with a NUL marker. | |
| 181 side_data->clear(); | |
| 182 side_data->insert(side_data->end(), id_begin, id_end); | |
| 183 side_data->push_back(0); | |
| 184 side_data->insert(side_data->end(), settings_begin, settings_end); | |
| 185 side_data->push_back(0); | |
| 186 } | |
| 187 | |
| 165 #endif // MEDIA_BASE_DECODER_BUFFER_H_ | 188 #endif // MEDIA_BASE_DECODER_BUFFER_H_ |
| OLD | NEW |