OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // A specialized buffer for interfacing with audio / video decoders. |
| 6 // |
| 7 // Specifically ensures that data is aligned and padded as necessary by the |
| 8 // underlying decoding framework. On desktop platforms this means memory is |
| 9 // allocated using FFmpeg with particular alignment and padding requirements. |
| 10 // |
| 11 // Also includes decoder specific functionality for decryption. |
| 12 |
| 13 #ifndef MEDIA_BASE_DECODER_BUFFER_H_ |
| 14 #define MEDIA_BASE_DECODER_BUFFER_H_ |
| 15 |
| 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "media/base/buffers.h" |
| 18 #include "media/base/decrypt_config.h" |
| 19 |
| 20 namespace media { |
| 21 |
| 22 class MEDIA_EXPORT DecoderBuffer : public Buffer { |
| 23 public: |
| 24 // Allocates buffer of size |buffer_size| >= 0. Buffer will be padded and |
| 25 // aligned as necessary. |
| 26 explicit DecoderBuffer(int buffer_size); |
| 27 |
| 28 // Create a DecoderBuffer whose |data_| is copied from |data|. Buffer will be |
| 29 // padded and aligned as necessary. |data| must not be NULL and |size| >= 0. |
| 30 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size); |
| 31 |
| 32 // Create a DecoderBuffer indicating we've reached end of stream. GetData() |
| 33 // and GetWritableData() will return NULL and GetDataSize() will return 0. |
| 34 static scoped_refptr<DecoderBuffer> CreateEOSBuffer(); |
| 35 |
| 36 // Buffer implementation. |
| 37 virtual const uint8* GetData() const OVERRIDE; |
| 38 virtual int GetDataSize() const OVERRIDE; |
| 39 |
| 40 // Returns a read-write pointer to the buffer data. |
| 41 virtual uint8* GetWritableData(); |
| 42 |
| 43 virtual const DecryptConfig* GetDecryptConfig() const; |
| 44 virtual void SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config); |
| 45 |
| 46 protected: |
| 47 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer |
| 48 // will be padded and aligned as necessary. If |data| is NULL then |data_| is |
| 49 // set to NULL and |buffer_size_| to 0. |
| 50 DecoderBuffer(const uint8* data, int size); |
| 51 virtual ~DecoderBuffer(); |
| 52 |
| 53 private: |
| 54 int buffer_size_; |
| 55 uint8* data_; |
| 56 scoped_ptr<DecryptConfig> decrypt_config_; |
| 57 |
| 58 // Constructor helper method for memory allocations. |
| 59 void Initialize(); |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); |
| 62 }; |
| 63 |
| 64 } // namespace media |
| 65 |
| 66 #endif // MEDIA_BASE_DECODER_BUFFER_H_ |
OLD | NEW |