| OLD | NEW |
| 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 // Defines a base class for representing timestamped media data. Every buffer | 5 // Defines a base class for representing timestamped media data. Every buffer |
| 6 // contains a timestamp in microseconds describing the relative position of | 6 // contains a timestamp in microseconds describing the relative position of |
| 7 // the buffer within the media stream, and the duration in microseconds for | 7 // the buffer within the media stream, and the duration in microseconds for |
| 8 // the length of time the buffer will be rendered. | 8 // the length of time the buffer will be rendered. |
| 9 // | 9 // |
| 10 // Timestamps are derived directly from the encoded media file and are commonly | 10 // Timestamps are derived directly from the encoded media file and are commonly |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #ifndef MEDIA_BASE_BUFFERS_H_ | 26 #ifndef MEDIA_BASE_BUFFERS_H_ |
| 27 #define MEDIA_BASE_BUFFERS_H_ | 27 #define MEDIA_BASE_BUFFERS_H_ |
| 28 | 28 |
| 29 #include "base/basictypes.h" | 29 #include "base/basictypes.h" |
| 30 #include "base/memory/ref_counted.h" | 30 #include "base/memory/ref_counted.h" |
| 31 #include "base/time.h" | 31 #include "base/time.h" |
| 32 #include "media/base/media_export.h" | 32 #include "media/base/media_export.h" |
| 33 | 33 |
| 34 namespace media { | 34 namespace media { |
| 35 | 35 |
| 36 class DecryptConfig; | |
| 37 | |
| 38 // Indicates an invalid or missing timestamp. | 36 // Indicates an invalid or missing timestamp. |
| 39 MEDIA_EXPORT extern inline base::TimeDelta kNoTimestamp() { | 37 MEDIA_EXPORT extern inline base::TimeDelta kNoTimestamp() { |
| 40 return base::TimeDelta::FromMicroseconds(kint64min); | 38 return base::TimeDelta::FromMicroseconds(kint64min); |
| 41 } | 39 } |
| 42 | 40 |
| 43 // Represents an infinite stream duration. | 41 // Represents an infinite stream duration. |
| 44 MEDIA_EXPORT extern inline base::TimeDelta kInfiniteDuration() { | 42 MEDIA_EXPORT extern inline base::TimeDelta kInfiniteDuration() { |
| 45 return base::TimeDelta::FromMicroseconds(kint64max); | 43 return base::TimeDelta::FromMicroseconds(kint64max); |
| 46 } | 44 } |
| 47 | 45 |
| 48 class MEDIA_EXPORT Buffer : public base::RefCountedThreadSafe<Buffer> { | 46 class MEDIA_EXPORT Buffer : public base::RefCountedThreadSafe<Buffer> { |
| 49 public: | 47 public: |
| 50 // Returns a read only pointer to the buffer data. | 48 // Returns a read only pointer to the buffer data. |
| 51 virtual const uint8* GetData() const = 0; | 49 virtual const uint8* GetData() const = 0; |
| 52 | 50 |
| 53 // Returns the size of valid data in bytes. | 51 // Returns the size of valid data in bytes. |
| 54 virtual int GetDataSize() const = 0; | 52 virtual int GetDataSize() const = 0; |
| 55 | 53 |
| 56 // If there's no data in this buffer, it represents end of stream. | 54 // If there's no data in this buffer, it represents end of stream. |
| 57 bool IsEndOfStream() const; | 55 bool IsEndOfStream() const; |
| 58 | 56 |
| 59 // Return DecryptConfig if buffer is encrypted, or NULL otherwise. | |
| 60 virtual const DecryptConfig* GetDecryptConfig() const; | |
| 61 | |
| 62 base::TimeDelta GetTimestamp() const { | 57 base::TimeDelta GetTimestamp() const { |
| 63 return timestamp_; | 58 return timestamp_; |
| 64 } | 59 } |
| 65 void SetTimestamp(const base::TimeDelta& timestamp) { | 60 void SetTimestamp(const base::TimeDelta& timestamp) { |
| 66 timestamp_ = timestamp; | 61 timestamp_ = timestamp; |
| 67 } | 62 } |
| 68 | 63 |
| 69 base::TimeDelta GetDuration() const { | 64 base::TimeDelta GetDuration() const { |
| 70 return duration_; | 65 return duration_; |
| 71 } | 66 } |
| 72 void SetDuration(const base::TimeDelta& duration) { | 67 void SetDuration(const base::TimeDelta& duration) { |
| 73 duration_ = duration; | 68 duration_ = duration; |
| 74 } | 69 } |
| 75 | 70 |
| 76 protected: | 71 protected: |
| 77 friend class base::RefCountedThreadSafe<Buffer>; | 72 friend class base::RefCountedThreadSafe<Buffer>; |
| 78 Buffer(base::TimeDelta timestamp, base::TimeDelta duration); | 73 Buffer(base::TimeDelta timestamp, base::TimeDelta duration); |
| 79 virtual ~Buffer(); | 74 virtual ~Buffer(); |
| 80 | 75 |
| 81 private: | 76 private: |
| 82 base::TimeDelta timestamp_; | 77 base::TimeDelta timestamp_; |
| 83 base::TimeDelta duration_; | 78 base::TimeDelta duration_; |
| 84 | 79 |
| 85 DISALLOW_COPY_AND_ASSIGN(Buffer); | 80 DISALLOW_COPY_AND_ASSIGN(Buffer); |
| 86 }; | 81 }; |
| 87 | 82 |
| 88 } // namespace media | 83 } // namespace media |
| 89 | 84 |
| 90 #endif // MEDIA_BASE_BUFFERS_H_ | 85 #endif // MEDIA_BASE_BUFFERS_H_ |
| OLD | NEW |