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

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

Issue 113611: Handle end of stream for media... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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/data_buffer_unittest.cc » ('j') | media/filters/video_thread.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008-2009 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 // Defines various types of timestamped media buffers used for transporting 5 // Defines various types of timestamped media buffers used for transporting
6 // data between filters. Every buffer contains a timestamp in microseconds 6 // data between filters. Every buffer contains a timestamp in microseconds
7 // describing the relative position of the buffer within the media stream, and 7 // describing the relative position of the buffer within the media stream, and
8 // the duration in microseconds for the length of time the buffer will be 8 // the duration in microseconds for the length of time the buffer will be
9 // rendered. 9 // rendered.
10 // 10 //
(...skipping 27 matching lines...) Expand all
38 // Returns the timestamp of this buffer in microseconds. 38 // Returns the timestamp of this buffer in microseconds.
39 base::TimeDelta GetTimestamp() const { 39 base::TimeDelta GetTimestamp() const {
40 return timestamp_; 40 return timestamp_;
41 } 41 }
42 42
43 // Returns the duration of this buffer in microseconds. 43 // Returns the duration of this buffer in microseconds.
44 base::TimeDelta GetDuration() const { 44 base::TimeDelta GetDuration() const {
45 return duration_; 45 return duration_;
46 } 46 }
47 47
48 // Indicates that the sample is the last one in the stream. 48 // Indicates that the sample is the last one in the stream. This method is
49 bool IsEndOfStream() const { 49 // pure virtual so implementors can decide when to declare end of stream
50 return end_of_stream_; 50 // depending on specific data.
51 } 51 virtual bool IsEndOfStream() const = 0;
52 52
53 // Indicates that this sample is discontinuous from the previous one, for 53 // Indicates that this sample is discontinuous from the previous one, for
54 // example, following a seek. 54 // example, following a seek.
55 bool IsDiscontinuous() const { 55 bool IsDiscontinuous() const {
56 return discontinuous_; 56 return discontinuous_;
57 } 57 }
58 58
59 // Sets the timestamp of this buffer in microseconds. 59 // Sets the timestamp of this buffer in microseconds.
60 void SetTimestamp(const base::TimeDelta& timestamp) { 60 void SetTimestamp(const base::TimeDelta& timestamp) {
61 timestamp_ = timestamp; 61 timestamp_ = timestamp;
62 } 62 }
63 63
64 // Sets the duration of this buffer in microseconds. 64 // Sets the duration of this buffer in microseconds.
65 void SetDuration(const base::TimeDelta& duration) { 65 void SetDuration(const base::TimeDelta& duration) {
66 duration_ = duration; 66 duration_ = duration;
67 } 67 }
68 68
69 // Sets the value returned by IsEndOfStream().
70 void SetEndOfStream(bool end_of_stream) {
71 end_of_stream_ = end_of_stream;
72 }
73
74 // Sets the value returned by IsDiscontinuous(). 69 // Sets the value returned by IsDiscontinuous().
75 void SetDiscontinuous(bool discontinuous) { 70 void SetDiscontinuous(bool discontinuous) {
76 discontinuous_ = discontinuous; 71 discontinuous_ = discontinuous;
77 } 72 }
78 73
79 protected: 74 protected:
80 friend class base::RefCountedThreadSafe<StreamSample>; 75 friend class base::RefCountedThreadSafe<StreamSample>;
81 StreamSample() 76 StreamSample()
82 : end_of_stream_(false), 77 : discontinuous_(false) {
83 discontinuous_(false) {
84 } 78 }
85 virtual ~StreamSample() {} 79 virtual ~StreamSample() {}
86 80
87 base::TimeDelta timestamp_; 81 base::TimeDelta timestamp_;
88 base::TimeDelta duration_; 82 base::TimeDelta duration_;
89 bool end_of_stream_;
90 bool discontinuous_; 83 bool discontinuous_;
91 84
92 private: 85 private:
93 DISALLOW_COPY_AND_ASSIGN(StreamSample); 86 DISALLOW_COPY_AND_ASSIGN(StreamSample);
94 }; 87 };
95 88
96 89
97 class Buffer : public StreamSample { 90 class Buffer : public StreamSample {
98 public: 91 public:
99 // Returns a read only pointer to the buffer data. 92 // Returns a read only pointer to the buffer data.
100 virtual const uint8* GetData() const = 0; 93 virtual const uint8* GetData() const = 0;
101 94
102 // Returns the size of valid data in bytes. 95 // Returns the size of valid data in bytes.
103 virtual size_t GetDataSize() const = 0; 96 virtual size_t GetDataSize() const = 0;
97
98 // If there's no data in this buffer, it represents end of stream.
99 virtual bool IsEndOfStream() const { return GetData() == NULL; }
104 }; 100 };
105 101
106 102
107 class WritableBuffer : public Buffer { 103 class WritableBuffer : public Buffer {
108 public: 104 public:
109 // Returns a read-write pointer to the buffer data. When this method is 105 // Returns a read-write pointer to the buffer data. When this method is
110 // called, any pointers previously returned from this method are invalid, and 106 // called, any pointers previously returned from this method are invalid, and
111 // any data previously written to the buffer is invalid. The buffer size 107 // any data previously written to the buffer is invalid. The buffer size
112 // is guaranteed to be at least the size of |buffer_size|. The size 108 // is guaranteed to be at least the size of |buffer_size|. The size
113 // that the GetDataSize() method will return is set to |buffer_size|. 109 // that the GetDataSize() method will return is set to |buffer_size|.
(...skipping 22 matching lines...) Expand all
136 // http://www.fourcc.org/rgb.php 132 // http://www.fourcc.org/rgb.php
137 // http://www.fourcc.org/yuv.php 133 // http://www.fourcc.org/yuv.php
138 enum Format { 134 enum Format {
139 RGB555, // 16bpp RGB packed 5:5:5 135 RGB555, // 16bpp RGB packed 5:5:5
140 RGB565, // 16bpp RGB packed 5:6:5 136 RGB565, // 16bpp RGB packed 5:6:5
141 RGB24, // 24bpp RGB packed 8:8:8 137 RGB24, // 24bpp RGB packed 8:8:8
142 RGB32, // 32bpp RGB packed with extra byte 8:8:8 138 RGB32, // 32bpp RGB packed with extra byte 8:8:8
143 RGBA, // 32bpp RGBA packed 8:8:8:8 139 RGBA, // 32bpp RGBA packed 8:8:8:8
144 YV12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples 140 YV12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples
145 YV16, // 16bpp YVU planar 1x1 Y, 2x1 VU samples 141 YV16, // 16bpp YVU planar 1x1 Y, 2x1 VU samples
142 EMPTY, // An empty frame.
146 }; 143 };
147 144
148 // Surface format. 145 // Surface format.
149 Format format; 146 Format format;
150 147
151 // Width and height of surface. 148 // Width and height of surface.
152 size_t width; 149 size_t width;
153 size_t height; 150 size_t height;
154 151
155 // Number of planes, typically 1 for packed RGB formats and 3 for planar 152 // Number of planes, typically 1 for packed RGB formats and 3 for planar
(...skipping 13 matching lines...) Expand all
169 class VideoFrame : public StreamSample { 166 class VideoFrame : public StreamSample {
170 public: 167 public:
171 // Locks the underlying surface and fills out the given VideoSurface and 168 // Locks the underlying surface and fills out the given VideoSurface and
172 // returns true if successful, false otherwise. Any additional calls to Lock 169 // returns true if successful, false otherwise. Any additional calls to Lock
173 // will fail. 170 // will fail.
174 virtual bool Lock(VideoSurface* surface) = 0; 171 virtual bool Lock(VideoSurface* surface) = 0;
175 172
176 // Unlocks the underlying surface, the VideoSurface acquired from Lock is no 173 // Unlocks the underlying surface, the VideoSurface acquired from Lock is no
177 // longer guaranteed to be valid. 174 // longer guaranteed to be valid.
178 virtual void Unlock() = 0; 175 virtual void Unlock() = 0;
176
177 virtual bool IsEndOfStream() const = 0;
179 }; 178 };
180 179
181 } // namespace media 180 } // namespace media
182 181
183 #endif // MEDIA_BASE_BUFFERS_H_ 182 #endif // MEDIA_BASE_BUFFERS_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/data_buffer_unittest.cc » ('j') | media/filters/video_thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698