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

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

Issue 11993002: Tighten up media::DecoderBuffer API contract for end of stream buffers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | media/base/decoder_buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
9
8 #include "base/memory/aligned_memory.h" 10 #include "base/memory/aligned_memory.h"
9 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
11 #include "base/time.h" 13 #include "base/time.h"
12 #include "build/build_config.h" 14 #include "build/build_config.h"
13 #include "media/base/media_export.h" 15 #include "media/base/media_export.h"
14 16
15 namespace media { 17 namespace media {
16 18
17 class DecryptConfig; 19 class DecryptConfig;
(...skipping 18 matching lines...) Expand all
36 }; 38 };
37 39
38 // Allocates buffer with |size| >= 0. Buffer will be padded and aligned 40 // Allocates buffer with |size| >= 0. Buffer will be padded and aligned
39 // as necessary. 41 // as necessary.
40 explicit DecoderBuffer(int size); 42 explicit DecoderBuffer(int size);
41 43
42 // Create a DecoderBuffer whose |data_| is copied from |data|. Buffer will be 44 // Create a DecoderBuffer whose |data_| is copied from |data|. Buffer will be
43 // padded and aligned as necessary. |data| must not be NULL and |size| >= 0. 45 // padded and aligned as necessary. |data| must not be NULL and |size| >= 0.
44 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size); 46 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size);
45 47
46 // Create a DecoderBuffer indicating we've reached end of stream. GetData() 48 // Create a DecoderBuffer indicating we've reached end of stream.
47 // and GetWritableData() will return NULL and GetDataSize() will return 0. 49 //
50 // Calling any method other than IsEndOfStream() on the resulting buffer
51 // is disallowed.
xhwang 2013/01/17 23:55:13 This means the caller/user of a DecoderBuffer shou
scherkus (not reviewing) 2013/01/18 00:06:36 Done + DataBuffer.
48 static scoped_refptr<DecoderBuffer> CreateEOSBuffer(); 52 static scoped_refptr<DecoderBuffer> CreateEOSBuffer();
49 53
50 base::TimeDelta GetTimestamp() const; 54 base::TimeDelta GetTimestamp() const;
51 void SetTimestamp(const base::TimeDelta& timestamp); 55 void SetTimestamp(const base::TimeDelta& timestamp);
52 56
53 base::TimeDelta GetDuration() const; 57 base::TimeDelta GetDuration() const;
54 void SetDuration(const base::TimeDelta& duration); 58 void SetDuration(const base::TimeDelta& duration);
55 59
56 const uint8* GetData() const; 60 const uint8* GetData() const;
57 uint8* GetWritableData() const; 61 uint8* GetWritableData() const;
58 62
59 int GetDataSize() const; 63 int GetDataSize() const;
60 64
61 const DecryptConfig* GetDecryptConfig() const; 65 const DecryptConfig* GetDecryptConfig() const;
62 void SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config); 66 void SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config);
63 67
64 // If there's no data in this buffer, it represents end of stream. 68 // If there's no data in this buffer, it represents end of stream.
65 bool IsEndOfStream() const; 69 bool IsEndOfStream() const;
66 70
71 // Returns a human-readable string describing |*this|.
72 std::string AsHumanReadableString();
73
67 protected: 74 protected:
68 friend class base::RefCountedThreadSafe<DecoderBuffer>; 75 friend class base::RefCountedThreadSafe<DecoderBuffer>;
69 76
70 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer 77 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer
71 // will be padded and aligned as necessary. If |data| is NULL then |data_| is 78 // will be padded and aligned as necessary. If |data| is NULL then |data_| is
72 // set to NULL and |buffer_size_| to 0. 79 // set to NULL and |buffer_size_| to 0.
73 DecoderBuffer(const uint8* data, int size); 80 DecoderBuffer(const uint8* data, int size);
74 virtual ~DecoderBuffer(); 81 virtual ~DecoderBuffer();
75 82
76 private: 83 private:
77 base::TimeDelta timestamp_; 84 base::TimeDelta timestamp_;
78 base::TimeDelta duration_; 85 base::TimeDelta duration_;
79 86
80 int size_; 87 int size_;
81 scoped_ptr<uint8, base::ScopedPtrAlignedFree> data_; 88 scoped_ptr<uint8, base::ScopedPtrAlignedFree> data_;
82 scoped_ptr<DecryptConfig> decrypt_config_; 89 scoped_ptr<DecryptConfig> decrypt_config_;
83 90
84 // Constructor helper method for memory allocations. 91 // Constructor helper method for memory allocations.
85 void Initialize(); 92 void Initialize();
86 93
87 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); 94 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer);
88 }; 95 };
89 96
90 } // namespace media 97 } // namespace media
91 98
92 #endif // MEDIA_BASE_DECODER_BUFFER_H_ 99 #endif // MEDIA_BASE_DECODER_BUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/decoder_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698