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

Side by Side Diff: media/base/decoder_buffer.h

Issue 17408005: Refactored DecoderBuffer to use unix_hacker_style naming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@localrefactor
Patch Set: Created 7 years, 5 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 unified diff | Download patch
OLDNEW
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 9
10 #include "base/memory/aligned_memory.h" 10 #include "base/memory/aligned_memory.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "media/base/media_export.h" 15 #include "media/base/media_export.h"
16 16
17 namespace media { 17 namespace media {
18 18
19 class DecryptConfig; 19 class DecryptConfig;
20 20
21 // A specialized buffer for interfacing with audio / video decoders. 21 // A specialized buffer for interfacing with audio / video decoders.
22 // 22 //
23 // Specifically ensures that data is aligned and padded as necessary by the 23 // Specifically ensures that data is aligned and padded as necessary by the
24 // underlying decoding framework. On desktop platforms this means memory is 24 // underlying decoding framework. On desktop platforms this means memory is
25 // allocated using FFmpeg with particular alignment and padding requirements. 25 // allocated using FFmpeg with particular alignment and padding requirements.
26 // 26 //
27 // Also includes decoder specific functionality for decryption. 27 // Also includes decoder specific functionality for decryption.
28 // 28 //
29 // NOTE: It is illegal to call any method when IsEndOfStream() is true. 29 // NOTE: It is illegal to call any method when end_of_stream() is true.
30 class MEDIA_EXPORT DecoderBuffer 30 class MEDIA_EXPORT DecoderBuffer
31 : public base::RefCountedThreadSafe<DecoderBuffer> { 31 : public base::RefCountedThreadSafe<DecoderBuffer> {
32 public: 32 public:
33 enum { 33 enum {
34 kPaddingSize = 16, 34 kPaddingSize = 16,
35 #if defined(ARCH_CPU_ARM_FAMILY) 35 #if defined(ARCH_CPU_ARM_FAMILY)
36 kAlignmentSize = 16 36 kAlignmentSize = 16
37 #else 37 #else
38 kAlignmentSize = 32 38 kAlignmentSize = 32
39 #endif 39 #endif
40 }; 40 };
41 41
42 // Allocates buffer with |size| >= 0. Buffer will be padded and aligned 42 // Allocates buffer with |size| >= 0. Buffer will be padded and aligned
43 // as necessary. 43 // as necessary.
44 explicit DecoderBuffer(int size); 44 explicit DecoderBuffer(int size);
45 45
46 // Create a DecoderBuffer whose |data_| is copied from |data|. Buffer will be 46 // Create a DecoderBuffer whose |data_| is copied from |data|. Buffer will be
47 // padded and aligned as necessary. |data| must not be NULL and |size| >= 0. 47 // padded and aligned as necessary. |data| must not be NULL and |size| >= 0.
48 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size); 48 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size);
49 49
50 // Create a DecoderBuffer whose |data_| is copied from |data| and |side_data_| 50 // Create a DecoderBuffer whose |data_| is copied from |data| and |side_data_|
51 // is copied from |side_data|. Buffers will be padded and aligned as necessary 51 // is copied from |side_data|. Buffers will be padded and aligned as necessary
52 // Data pointers must not be NULL and sizes must be >= 0. 52 // Data pointers must not be NULL and sizes must be >= 0.
53 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size, 53 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size,
54 const uint8* side_data, 54 const uint8* side_data,
55 int side_data_size); 55 int side_data_size);
56 56
57 // Create a DecoderBuffer indicating we've reached end of stream. 57 // Create a DecoderBuffer indicating we've reached end of stream.
58 // 58 //
59 // Calling any method other than IsEndOfStream() on the resulting buffer 59 // Calling any method other than end_of_stream() on the resulting buffer
60 // is disallowed. 60 // is disallowed.
61 static scoped_refptr<DecoderBuffer> CreateEOSBuffer(); 61 static scoped_refptr<DecoderBuffer> CreateEOSBuffer();
62 62
63 base::TimeDelta GetTimestamp() const; 63 base::TimeDelta timestamp() const;
scherkus (not reviewing) 2013/07/08 23:30:35 these should all be inline as discussed in https:
Ty Overby 2013/07/09 00:50:30 Done.
64 void SetTimestamp(const base::TimeDelta& timestamp); 64 void set_timestamp(const base::TimeDelta& timestamp);
65 65
66 base::TimeDelta GetDuration() const; 66 base::TimeDelta duration() const;
67 void SetDuration(const base::TimeDelta& duration); 67 void set_duration(const base::TimeDelta& duration);
68 68
69 const uint8* GetData() const; 69 const uint8* data() const;
70 uint8* GetWritableData() const; 70 uint8* writable_data() const;
71 71
72 int GetDataSize() const; 72 int data_size() const;
73 73
74 const uint8* GetSideData() const; 74 const uint8* side_data() const;
75 int GetSideDataSize() const; 75 int side_data_size() const;
76 76
77 const DecryptConfig* GetDecryptConfig() const; 77 const DecryptConfig* decrypt_config() const;
78 void SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config); 78 void set_decrypt_config(scoped_ptr<DecryptConfig> decrypt_config);
79 79
80 // If there's no data in this buffer, it represents end of stream. 80 // If there's no data in this buffer, it represents end of stream.
81 bool IsEndOfStream() const; 81 bool end_of_stream() const;
82 82
83 // Returns a human-readable string describing |*this|. 83 // Returns a human-readable string describing |*this|.
84 std::string AsHumanReadableString(); 84 std::string AsHumanReadableString();
85 85
86 protected: 86 protected:
87 friend class base::RefCountedThreadSafe<DecoderBuffer>; 87 friend class base::RefCountedThreadSafe<DecoderBuffer>;
88 88
89 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer 89 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer
90 // will be padded and aligned as necessary. If |data| is NULL then |data_| is 90 // will be padded and aligned as necessary. If |data| is NULL then |data_| is
91 // set to NULL and |buffer_size_| to 0. 91 // set to NULL and |buffer_size_| to 0.
(...skipping 13 matching lines...) Expand all
105 105
106 // Constructor helper method for memory allocations. 106 // Constructor helper method for memory allocations.
107 void Initialize(); 107 void Initialize();
108 108
109 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); 109 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer);
110 }; 110 };
111 111
112 } // namespace media 112 } // namespace media
113 113
114 #endif // MEDIA_BASE_DECODER_BUFFER_H_ 114 #endif // MEDIA_BASE_DECODER_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698