OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/logging.h" | 30 #include "base/basictypes.h" |
31 #include "base/ref_counted.h" | 31 #include "base/ref_counted.h" |
32 #include "base/time.h" | 32 #include "base/time.h" |
33 | 33 |
34 namespace media { | 34 namespace media { |
35 | 35 |
36 class StreamSample : public base::RefCountedThreadSafe<StreamSample> { | 36 class StreamSample : public base::RefCountedThreadSafe<StreamSample> { |
37 public: | 37 public: |
38 // Constant timestamp value to indicate an invalid or missing timestamp. | 38 // Constant timestamp value to indicate an invalid or missing timestamp. |
39 static const base::TimeDelta kInvalidTimestamp; | 39 static const base::TimeDelta kInvalidTimestamp; |
40 | 40 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 // Returns the size of the underlying buffer. | 118 // Returns the size of the underlying buffer. |
119 virtual size_t GetBufferSize() const = 0; | 119 virtual size_t GetBufferSize() const = 0; |
120 | 120 |
121 protected: | 121 protected: |
122 virtual ~WritableBuffer() {} | 122 virtual ~WritableBuffer() {} |
123 }; | 123 }; |
124 | 124 |
125 } // namespace media | 125 } // namespace media |
126 | 126 |
127 #endif // MEDIA_BASE_BUFFERS_H_ | 127 #endif // MEDIA_BASE_BUFFERS_H_ |
OLD | NEW |