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 DemuxerStream::UNKNOWN, 0)); |
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, |
| 28 TrackId track_id) { |
27 return make_scoped_refptr( | 29 return make_scoped_refptr( |
28 new StreamParserBuffer(data, data_size, NULL, 0, is_keyframe)); | 30 new StreamParserBuffer(data, data_size, NULL, 0, is_keyframe, type, |
| 31 track_id)); |
29 } | 32 } |
30 | 33 |
31 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CopyFrom( | 34 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CopyFrom( |
32 const uint8* data, int data_size, | 35 const uint8* data, int data_size, |
33 const uint8* side_data, int side_data_size, bool is_keyframe) { | 36 const uint8* side_data, int side_data_size, |
| 37 bool is_keyframe, Type type, TrackId track_id) { |
34 return make_scoped_refptr( | 38 return make_scoped_refptr( |
35 new StreamParserBuffer(data, data_size, side_data, side_data_size, | 39 new StreamParserBuffer(data, data_size, side_data, side_data_size, |
36 is_keyframe)); | 40 is_keyframe, type, track_id)); |
37 } | 41 } |
38 | 42 |
39 base::TimeDelta StreamParserBuffer::GetDecodeTimestamp() const { | 43 base::TimeDelta StreamParserBuffer::GetDecodeTimestamp() const { |
40 if (decode_timestamp_ == kNoTimestamp()) | 44 if (decode_timestamp_ == kNoTimestamp()) |
41 return timestamp(); | 45 return timestamp(); |
42 return decode_timestamp_; | 46 return decode_timestamp_; |
43 } | 47 } |
44 | 48 |
45 void StreamParserBuffer::SetDecodeTimestamp(const base::TimeDelta& timestamp) { | 49 void StreamParserBuffer::SetDecodeTimestamp(const base::TimeDelta& timestamp) { |
46 decode_timestamp_ = timestamp; | 50 decode_timestamp_ = timestamp; |
47 } | 51 } |
48 | 52 |
49 StreamParserBuffer::StreamParserBuffer(const uint8* data, int data_size, | 53 StreamParserBuffer::StreamParserBuffer(const uint8* data, int data_size, |
50 const uint8* side_data, | 54 const uint8* side_data, |
51 int side_data_size, bool is_keyframe) | 55 int side_data_size, bool is_keyframe, |
| 56 Type type, TrackId track_id) |
52 : DecoderBuffer(data, data_size, side_data, side_data_size), | 57 : DecoderBuffer(data, data_size, side_data, side_data_size), |
53 is_keyframe_(is_keyframe), | 58 is_keyframe_(is_keyframe), |
54 decode_timestamp_(kNoTimestamp()), | 59 decode_timestamp_(kNoTimestamp()), |
55 config_id_(kInvalidConfigId) { | 60 config_id_(kInvalidConfigId), |
| 61 type_(type), |
| 62 track_id_(track_id) { |
56 // TODO(scherkus): Should DataBuffer constructor accept a timestamp and | 63 // TODO(scherkus): Should DataBuffer constructor accept a timestamp and |
57 // duration to force clients to set them? Today they end up being zero which | 64 // 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. | 65 // is both a common and valid value and could lead to bugs. |
59 if (data) { | 66 if (data) { |
60 set_duration(kNoTimestamp()); | 67 set_duration(kNoTimestamp()); |
61 } | 68 } |
62 } | 69 } |
63 | 70 |
64 StreamParserBuffer::~StreamParserBuffer() { | 71 StreamParserBuffer::~StreamParserBuffer() { |
65 } | 72 } |
(...skipping 11 matching lines...) Expand all Loading... |
77 return fade_out_preroll_; | 84 return fade_out_preroll_; |
78 } | 85 } |
79 | 86 |
80 void StreamParserBuffer::SetFadeOutPreroll( | 87 void StreamParserBuffer::SetFadeOutPreroll( |
81 const std::vector<scoped_refptr<StreamParserBuffer> >& fade_out_preroll) { | 88 const std::vector<scoped_refptr<StreamParserBuffer> >& fade_out_preroll) { |
82 DCHECK(!HasNestedFadeOutPreroll(fade_out_preroll)); | 89 DCHECK(!HasNestedFadeOutPreroll(fade_out_preroll)); |
83 fade_out_preroll_ = fade_out_preroll; | 90 fade_out_preroll_ = fade_out_preroll; |
84 } | 91 } |
85 | 92 |
86 } // namespace media | 93 } // namespace media |
OLD | NEW |