Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Unified Diff: media/base/decoder_buffer.h

Issue 10447035: Introducing DecoderBuffer and general Buffer cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Buffer Bonanza! Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/decoder_buffer.h
diff --git a/media/base/decoder_buffer.h b/media/base/decoder_buffer.h
new file mode 100644
index 0000000000000000000000000000000000000000..5822da2d726295e6bc7d1293b9db75af8a4b0f34
--- /dev/null
+++ b/media/base/decoder_buffer.h
@@ -0,0 +1,66 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// A specialized buffer for interfacing with audio / video decoders.
+//
+// Specifically ensures that data is aligned and padded as necessary by the
+// underlying decoding framework. On desktop platforms this means memory is
+// allocated using FFmpeg with particular alignment and padding requirements.
+//
+// Also includes decoder specific functionality for decryption.
+
+#ifndef MEDIA_BASE_DECODER_BUFFER_H_
+#define MEDIA_BASE_DECODER_BUFFER_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "media/base/buffers.h"
+#include "media/base/decrypt_config.h"
+#if !defined(OS_ANDROID)
+#include "media/ffmpeg/ffmpeg_common.h"
scherkus (not reviewing) 2012/05/26 01:36:32 this header file should only be included by .cc fi
DaleCurtis 2012/05/29 21:17:01 Done.
+#endif
+
+namespace media {
+
+class MEDIA_EXPORT DecoderBuffer : public Buffer {
+ public:
+ // Allocates buffer of size |buffer_size|. If |buffer_size| is 0, |data_| is
+ // set to a NULL ptr. Buffer will be padded and aligned as needed for decode.
+ explicit DecoderBuffer(int buffer_size);
+
+ // Create a DataBuffer whose |data_| is copied from |data|. Buffer will be
+ // padded and aligned as needed for decode.
+ static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size);
+
+ // Buffer implementation.
+ virtual const uint8* GetData() const OVERRIDE;
+ virtual int GetDataSize() const OVERRIDE;
+
+ // Returns a read-write pointer to the buffer data.
+ virtual uint8* GetWritableData();
+
+ virtual const DecryptConfig* GetDecryptConfig() const;
+ virtual void SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config);
+
+ protected:
+ DecoderBuffer(const uint8* data, int size);
+ virtual ~DecoderBuffer();
+
+ private:
+ int buffer_size_;
+#if !defined(OS_ANDROID)
+ scoped_ptr_malloc<uint8, ScopedPtrAVFree> data_;
+#else
+ scoped_array<uint8> data_;
+#endif
+ scoped_ptr<DecryptConfig> decrypt_config_;
+
+ // Constructor helper method for memory allocations.
+ void Initialize();
+
+ DISALLOW_COPY_AND_ASSIGN(DecoderBuffer);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_DECODER_BUFFER_H_

Powered by Google App Engine
This is Rietveld 408576698