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 #ifndef MEDIA_BASE_STREAM_PARSER_BUFFER_H_ | 5 #ifndef MEDIA_BASE_STREAM_PARSER_BUFFER_H_ |
6 #define MEDIA_BASE_STREAM_PARSER_BUFFER_H_ | 6 #define MEDIA_BASE_STREAM_PARSER_BUFFER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "media/base/decoder_buffer.h" | 10 #include "media/base/decoder_buffer.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } | 53 } |
54 | 54 |
55 DecodeTimestamp operator+(const base::TimeDelta& rhs) const { | 55 DecodeTimestamp operator+(const base::TimeDelta& rhs) const { |
56 return DecodeTimestamp(ts_ + rhs); | 56 return DecodeTimestamp(ts_ + rhs); |
57 } | 57 } |
58 | 58 |
59 DecodeTimestamp operator-(const base::TimeDelta& rhs) const { | 59 DecodeTimestamp operator-(const base::TimeDelta& rhs) const { |
60 return DecodeTimestamp(ts_ - rhs); | 60 return DecodeTimestamp(ts_ - rhs); |
61 } | 61 } |
62 | 62 |
63 int64 operator/(const base::TimeDelta& rhs) const { | 63 int64_t operator/(const base::TimeDelta& rhs) const { return ts_ / rhs; } |
64 return ts_ / rhs; | |
65 } | |
66 | 64 |
67 static DecodeTimestamp FromSecondsD(double seconds) { | 65 static DecodeTimestamp FromSecondsD(double seconds) { |
68 return DecodeTimestamp(base::TimeDelta::FromSecondsD(seconds)); | 66 return DecodeTimestamp(base::TimeDelta::FromSecondsD(seconds)); |
69 } | 67 } |
70 | 68 |
71 static DecodeTimestamp FromMilliseconds(int64 milliseconds) { | 69 static DecodeTimestamp FromMilliseconds(int64_t milliseconds) { |
72 return DecodeTimestamp(base::TimeDelta::FromMilliseconds(milliseconds)); | 70 return DecodeTimestamp(base::TimeDelta::FromMilliseconds(milliseconds)); |
73 } | 71 } |
74 | 72 |
75 static DecodeTimestamp FromMicroseconds(int64 microseconds) { | 73 static DecodeTimestamp FromMicroseconds(int64_t microseconds) { |
76 return DecodeTimestamp(base::TimeDelta::FromMicroseconds(microseconds)); | 74 return DecodeTimestamp(base::TimeDelta::FromMicroseconds(microseconds)); |
77 } | 75 } |
78 | 76 |
79 // This method is used to explicitly call out when presentation timestamps | 77 // This method is used to explicitly call out when presentation timestamps |
80 // are being converted to a decode timestamp. | 78 // are being converted to a decode timestamp. |
81 static DecodeTimestamp FromPresentationTime(base::TimeDelta timestamp) { | 79 static DecodeTimestamp FromPresentationTime(base::TimeDelta timestamp) { |
82 return DecodeTimestamp(timestamp); | 80 return DecodeTimestamp(timestamp); |
83 } | 81 } |
84 | 82 |
85 double InSecondsF() const { return ts_.InSecondsF(); } | 83 double InSecondsF() const { return ts_.InSecondsF(); } |
86 int64 InMilliseconds() const { return ts_.InMilliseconds(); } | 84 int64_t InMilliseconds() const { return ts_.InMilliseconds(); } |
87 int64 InMicroseconds() const { return ts_.InMicroseconds(); } | 85 int64_t InMicroseconds() const { return ts_.InMicroseconds(); } |
88 | 86 |
89 // TODO(acolwell): Remove once all the hacks are gone. This method is called | 87 // TODO(acolwell): Remove once all the hacks are gone. This method is called |
90 // by hacks where a decode time is being used as a presentation time. | 88 // by hacks where a decode time is being used as a presentation time. |
91 base::TimeDelta ToPresentationTime() const { return ts_; } | 89 base::TimeDelta ToPresentationTime() const { return ts_; } |
92 | 90 |
93 private: | 91 private: |
94 explicit DecodeTimestamp(base::TimeDelta timestamp) : ts_(timestamp) { } | 92 explicit DecodeTimestamp(base::TimeDelta timestamp) : ts_(timestamp) { } |
95 | 93 |
96 base::TimeDelta ts_; | 94 base::TimeDelta ts_; |
97 }; | 95 }; |
98 | 96 |
99 MEDIA_EXPORT extern inline DecodeTimestamp kNoDecodeTimestamp() { | 97 MEDIA_EXPORT extern inline DecodeTimestamp kNoDecodeTimestamp() { |
100 return DecodeTimestamp::FromPresentationTime(kNoTimestamp()); | 98 return DecodeTimestamp::FromPresentationTime(kNoTimestamp()); |
101 } | 99 } |
102 | 100 |
103 class MEDIA_EXPORT StreamParserBuffer : public DecoderBuffer { | 101 class MEDIA_EXPORT StreamParserBuffer : public DecoderBuffer { |
104 public: | 102 public: |
105 // Value used to signal an invalid decoder config ID. | 103 // Value used to signal an invalid decoder config ID. |
106 enum { kInvalidConfigId = -1 }; | 104 enum { kInvalidConfigId = -1 }; |
107 | 105 |
108 typedef DemuxerStream::Type Type; | 106 typedef DemuxerStream::Type Type; |
109 typedef StreamParser::TrackId TrackId; | 107 typedef StreamParser::TrackId TrackId; |
110 | 108 |
111 static scoped_refptr<StreamParserBuffer> CreateEOSBuffer(); | 109 static scoped_refptr<StreamParserBuffer> CreateEOSBuffer(); |
112 | 110 |
113 static scoped_refptr<StreamParserBuffer> CopyFrom( | 111 static scoped_refptr<StreamParserBuffer> CopyFrom(const uint8_t* data, |
114 const uint8* data, int data_size, bool is_key_frame, Type type, | 112 int data_size, |
115 TrackId track_id); | 113 bool is_key_frame, |
116 static scoped_refptr<StreamParserBuffer> CopyFrom( | 114 Type type, |
117 const uint8* data, int data_size, | 115 TrackId track_id); |
118 const uint8* side_data, int side_data_size, bool is_key_frame, Type type, | 116 static scoped_refptr<StreamParserBuffer> CopyFrom(const uint8_t* data, |
119 TrackId track_id); | 117 int data_size, |
| 118 const uint8_t* side_data, |
| 119 int side_data_size, |
| 120 bool is_key_frame, |
| 121 Type type, |
| 122 TrackId track_id); |
120 | 123 |
121 // Decode timestamp. If not explicitly set, or set to kNoTimestamp(), the | 124 // Decode timestamp. If not explicitly set, or set to kNoTimestamp(), the |
122 // value will be taken from the normal timestamp. | 125 // value will be taken from the normal timestamp. |
123 DecodeTimestamp GetDecodeTimestamp() const; | 126 DecodeTimestamp GetDecodeTimestamp() const; |
124 void SetDecodeTimestamp(DecodeTimestamp timestamp); | 127 void SetDecodeTimestamp(DecodeTimestamp timestamp); |
125 | 128 |
126 // Gets/sets the ID of the decoder config associated with this buffer. | 129 // Gets/sets the ID of the decoder config associated with this buffer. |
127 int GetConfigId() const; | 130 int GetConfigId() const; |
128 void SetConfigId(int config_id); | 131 void SetConfigId(int config_id); |
129 | 132 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 175 |
173 void set_timestamp(base::TimeDelta timestamp) override; | 176 void set_timestamp(base::TimeDelta timestamp) override; |
174 | 177 |
175 bool is_duration_estimated() const { return is_duration_estimated_; } | 178 bool is_duration_estimated() const { return is_duration_estimated_; } |
176 | 179 |
177 void set_is_duration_estimated(bool is_estimated) { | 180 void set_is_duration_estimated(bool is_estimated) { |
178 is_duration_estimated_ = is_estimated; | 181 is_duration_estimated_ = is_estimated; |
179 } | 182 } |
180 | 183 |
181 private: | 184 private: |
182 StreamParserBuffer(const uint8* data, int data_size, | 185 StreamParserBuffer(const uint8_t* data, |
183 const uint8* side_data, int side_data_size, | 186 int data_size, |
184 bool is_key_frame, Type type, | 187 const uint8_t* side_data, |
| 188 int side_data_size, |
| 189 bool is_key_frame, |
| 190 Type type, |
185 TrackId track_id); | 191 TrackId track_id); |
186 ~StreamParserBuffer() override; | 192 ~StreamParserBuffer() override; |
187 | 193 |
188 DecodeTimestamp decode_timestamp_; | 194 DecodeTimestamp decode_timestamp_; |
189 int config_id_; | 195 int config_id_; |
190 Type type_; | 196 Type type_; |
191 TrackId track_id_; | 197 TrackId track_id_; |
192 BufferQueue splice_buffers_; | 198 BufferQueue splice_buffers_; |
193 scoped_refptr<StreamParserBuffer> preroll_buffer_; | 199 scoped_refptr<StreamParserBuffer> preroll_buffer_; |
194 bool is_duration_estimated_; | 200 bool is_duration_estimated_; |
195 | 201 |
196 DISALLOW_COPY_AND_ASSIGN(StreamParserBuffer); | 202 DISALLOW_COPY_AND_ASSIGN(StreamParserBuffer); |
197 }; | 203 }; |
198 | 204 |
199 } // namespace media | 205 } // namespace media |
200 | 206 |
201 #endif // MEDIA_BASE_STREAM_PARSER_BUFFER_H_ | 207 #endif // MEDIA_BASE_STREAM_PARSER_BUFFER_H_ |
OLD | NEW |