OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // |
11 // Timestamps are derived directly from the encoded media file and are commonly | 11 // Timestamps are derived directly from the encoded media file and are commonly |
12 // known as the presentation timestamp (PTS). Durations are a best-guess and | 12 // known as the presentation timestamp (PTS). Durations are a best-guess and |
13 // are usually derived from the sample/frame rate of the media file. | 13 // are usually derived from the sample/frame rate of the media file. |
14 // | 14 // |
15 // Due to encoding and transmission errors, it is not guaranteed that timestamps | 15 // Due to encoding and transmission errors, it is not guaranteed that timestamps |
16 // arrive in a monotonically increasing order nor that the next timestamp will | 16 // arrive in a monotonically increasing order nor that the next timestamp will |
17 // be equal to the previous timestamp plus the duration. | 17 // be equal to the previous timestamp plus the duration. |
18 // | 18 // |
19 // In the ideal scenario for a 25fps movie, buffers are timestamped as followed: | 19 // In the ideal scenario for a 25fps movie, buffers are timestamped as followed: |
20 // | 20 // |
21 // Buffer0 Buffer1 Buffer2 ... BufferN | 21 // Buffer0 Buffer1 Buffer2 ... BufferN |
22 // Timestamp: 0us 40000us 80000us ... (N*40000)us | 22 // Timestamp: 0us 40000us 80000us ... (N*40000)us |
23 // Duration*: 40000us 40000us 40000us ... 40000us | 23 // Duration*: 40000us 40000us 40000us ... 40000us |
24 // | 24 // |
25 // *25fps = 0.04s per frame = 40000us per frame | 25 // *25fps = 0.04s per frame = 40000us per frame |
26 | 26 |
27 #ifndef MEDIA_BASE_BUFFERS_H_ | 27 #ifndef MEDIA_BASE_BUFFERS_H_ |
28 #define MEDIA_BASE_BUFFERS_H_ | 28 #define MEDIA_BASE_BUFFERS_H_ |
29 | 29 |
30 #include "base/basictypes.h" | |
31 #include "base/logging.h" | 30 #include "base/logging.h" |
32 #include "base/ref_counted.h" | 31 #include "base/ref_counted.h" |
33 #include "base/time.h" | 32 #include "base/time.h" |
34 | 33 |
35 namespace media { | 34 namespace media { |
36 | 35 |
37 class StreamSample : public base::RefCountedThreadSafe<StreamSample> { | 36 class StreamSample : public base::RefCountedThreadSafe<StreamSample> { |
38 public: | 37 public: |
39 // Returns the timestamp of this buffer in microseconds. | 38 // Returns the timestamp of this buffer in microseconds. |
40 virtual base::TimeDelta GetTimestamp() const = 0; | 39 virtual base::TimeDelta GetTimestamp() const = 0; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 private: | 175 private: |
177 OwnerType* owner_; | 176 OwnerType* owner_; |
178 scoped_refptr<BufferType> buffer_; | 177 scoped_refptr<BufferType> buffer_; |
179 | 178 |
180 DISALLOW_COPY_AND_ASSIGN(AssignableBuffer); | 179 DISALLOW_COPY_AND_ASSIGN(AssignableBuffer); |
181 }; | 180 }; |
182 | 181 |
183 } // namespace media | 182 } // namespace media |
184 | 183 |
185 #endif // MEDIA_BASE_BUFFERS_H_ | 184 #endif // MEDIA_BASE_BUFFERS_H_ |
OLD | NEW |