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 #include "media/base/stream_parser_buffer.h" | 5 #include "media/base/stream_parser_buffer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/base/buffers.h" | 8 #include "media/base/buffers.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
11 | 11 |
12 static bool HasNestedFadeOutPreroll( | 12 static bool HasNestedFadeOutPreroll( |
13 const std::vector<scoped_refptr<StreamParserBuffer> >& fade_out_preroll) { | 13 const std::vector<scoped_refptr<StreamParserBuffer> >& fade_out_preroll) { |
14 for (size_t i = 0; i < fade_out_preroll.size(); ++i) { | 14 for (size_t i = 0; i < fade_out_preroll.size(); ++i) { |
15 if (!fade_out_preroll[i]->GetFadeOutPreroll().empty()) | 15 if (!fade_out_preroll[i]->GetFadeOutPreroll().empty()) |
16 return true; | 16 return true; |
17 } | 17 } |
18 return false; | 18 return false; |
19 } | 19 } |
20 | 20 |
21 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CreateEOSBuffer() { | 21 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CreateEOSBuffer() { |
22 return make_scoped_refptr(new StreamParserBuffer(NULL, 0, NULL, 0, false)); | 22 return make_scoped_refptr(new StreamParserBuffer(NULL, 0, NULL, 0, false, |
23 kAudio /* meaningless */)); | |
xhwang
2014/01/29 08:04:50
see above about the possibility of using UNKNOWN f
wolenetz
2014/02/05 02:49:53
Done.
| |
23 } | 24 } |
24 | 25 |
25 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CopyFrom( | 26 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CopyFrom( |
26 const uint8* data, int data_size, bool is_keyframe) { | 27 const uint8* data, int data_size, bool is_keyframe, Type type) { |
27 return make_scoped_refptr( | 28 return make_scoped_refptr( |
28 new StreamParserBuffer(data, data_size, NULL, 0, is_keyframe)); | 29 new StreamParserBuffer(data, data_size, NULL, 0, is_keyframe, type)); |
29 } | 30 } |
30 | 31 |
31 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CopyFrom( | 32 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CopyFrom( |
32 const uint8* data, int data_size, | 33 const uint8* data, int data_size, |
33 const uint8* side_data, int side_data_size, bool is_keyframe) { | 34 const uint8* side_data, int side_data_size, bool is_keyframe, Type type) { |
34 return make_scoped_refptr( | 35 return make_scoped_refptr( |
35 new StreamParserBuffer(data, data_size, side_data, side_data_size, | 36 new StreamParserBuffer(data, data_size, side_data, side_data_size, |
36 is_keyframe)); | 37 is_keyframe, type)); |
37 } | 38 } |
38 | 39 |
39 base::TimeDelta StreamParserBuffer::GetDecodeTimestamp() const { | 40 base::TimeDelta StreamParserBuffer::GetDecodeTimestamp() const { |
40 if (decode_timestamp_ == kNoTimestamp()) | 41 if (decode_timestamp_ == kNoTimestamp()) |
41 return timestamp(); | 42 return timestamp(); |
42 return decode_timestamp_; | 43 return decode_timestamp_; |
43 } | 44 } |
44 | 45 |
45 void StreamParserBuffer::SetDecodeTimestamp(const base::TimeDelta& timestamp) { | 46 void StreamParserBuffer::SetDecodeTimestamp(const base::TimeDelta& timestamp) { |
46 decode_timestamp_ = timestamp; | 47 decode_timestamp_ = timestamp; |
47 } | 48 } |
48 | 49 |
49 StreamParserBuffer::StreamParserBuffer(const uint8* data, int data_size, | 50 StreamParserBuffer::StreamParserBuffer(const uint8* data, int data_size, |
50 const uint8* side_data, | 51 const uint8* side_data, |
51 int side_data_size, bool is_keyframe) | 52 int side_data_size, bool is_keyframe, |
53 Type type) | |
52 : DecoderBuffer(data, data_size, side_data, side_data_size), | 54 : DecoderBuffer(data, data_size, side_data, side_data_size), |
53 is_keyframe_(is_keyframe), | 55 is_keyframe_(is_keyframe), |
54 decode_timestamp_(kNoTimestamp()), | 56 decode_timestamp_(kNoTimestamp()), |
55 config_id_(kInvalidConfigId) { | 57 config_id_(kInvalidConfigId), |
58 type_(type), | |
59 text_track_number_(-1) { | |
56 // TODO(scherkus): Should DataBuffer constructor accept a timestamp and | 60 // TODO(scherkus): Should DataBuffer constructor accept a timestamp and |
57 // duration to force clients to set them? Today they end up being zero which | 61 // duration to force clients to set them? Today they end up being zero which |
58 // is both a common and valid value and could lead to bugs. | 62 // is both a common and valid value and could lead to bugs. |
59 if (data) { | 63 if (data) { |
60 set_duration(kNoTimestamp()); | 64 set_duration(kNoTimestamp()); |
61 } | 65 } |
62 } | 66 } |
63 | 67 |
64 StreamParserBuffer::~StreamParserBuffer() { | 68 StreamParserBuffer::~StreamParserBuffer() { |
65 } | 69 } |
(...skipping 11 matching lines...) Expand all Loading... | |
77 return fade_out_preroll_; | 81 return fade_out_preroll_; |
78 } | 82 } |
79 | 83 |
80 void StreamParserBuffer::SetFadeOutPreroll( | 84 void StreamParserBuffer::SetFadeOutPreroll( |
81 const std::vector<scoped_refptr<StreamParserBuffer> >& fade_out_preroll) { | 85 const std::vector<scoped_refptr<StreamParserBuffer> >& fade_out_preroll) { |
82 DCHECK(!HasNestedFadeOutPreroll(fade_out_preroll)); | 86 DCHECK(!HasNestedFadeOutPreroll(fade_out_preroll)); |
83 fade_out_preroll_ = fade_out_preroll; | 87 fade_out_preroll_ = fade_out_preroll; |
84 } | 88 } |
85 | 89 |
86 } // namespace media | 90 } // namespace media |
OLD | NEW |