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
3 // found in the LICENSE file.
5 #include "media/base/stream_parser_buffer.h"
7 #include "base/logging.h"
8 #include "media/base/buffers.h"
12 scoped_refptr
<StreamParserBuffer
> StreamParserBuffer::CreateEOSBuffer() {
13 return make_scoped_refptr(new StreamParserBuffer(NULL
, 0, NULL
, 0, false));
16 scoped_refptr
<StreamParserBuffer
> StreamParserBuffer::CopyFrom(
17 const uint8
* data
, int data_size
, bool is_keyframe
) {
18 return make_scoped_refptr(
19 new StreamParserBuffer(data
, data_size
, NULL
, 0, is_keyframe
));
22 scoped_refptr
<StreamParserBuffer
> StreamParserBuffer::CopyFrom(
23 const uint8
* data
, int data_size
,
24 const uint8
* side_data
, int side_data_size
, bool is_keyframe
) {
25 return make_scoped_refptr(
26 new StreamParserBuffer(data
, data_size
, side_data
, side_data_size
,
30 base::TimeDelta
StreamParserBuffer::GetDecodeTimestamp() const {
31 if (decode_timestamp_
== kNoTimestamp())
33 return decode_timestamp_
;
36 void StreamParserBuffer::SetDecodeTimestamp(const base::TimeDelta
& timestamp
) {
37 decode_timestamp_
= timestamp
;
40 StreamParserBuffer::StreamParserBuffer(const uint8
* data
, int data_size
,
41 const uint8
* side_data
,
42 int side_data_size
, bool is_keyframe
)
43 : DecoderBuffer(data
, data_size
, side_data
, side_data_size
),
44 is_keyframe_(is_keyframe
),
45 decode_timestamp_(kNoTimestamp()),
46 config_id_(kInvalidConfigId
) {
47 // TODO(scherkus): Should DataBuffer constructor accept a timestamp and
48 // duration to force clients to set them? Today they end up being zero which
49 // is both a common and valid value and could lead to bugs.
51 set_duration(kNoTimestamp());
55 StreamParserBuffer::~StreamParserBuffer() {
58 int StreamParserBuffer::GetConfigId() const {
62 void StreamParserBuffer::SetConfigId(int config_id
) {
63 config_id_
= config_id
;