- add sources.
[platform/framework/web/crosswalk.git] / src / media / base / stream_parser_buffer.cc
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.
4
5 #include "media/base/stream_parser_buffer.h"
6
7 #include "base/logging.h"
8 #include "media/base/buffers.h"
9
10 namespace media {
11
12 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CreateEOSBuffer() {
13   return make_scoped_refptr(new StreamParserBuffer(NULL, 0, NULL, 0, false));
14 }
15
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));
20 }
21
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,
27                              is_keyframe));
28 }
29
30 base::TimeDelta StreamParserBuffer::GetDecodeTimestamp() const {
31   if (decode_timestamp_ == kNoTimestamp())
32     return timestamp();
33   return decode_timestamp_;
34 }
35
36 void StreamParserBuffer::SetDecodeTimestamp(const base::TimeDelta& timestamp) {
37   decode_timestamp_ = timestamp;
38 }
39
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.
50   if (data) {
51     set_duration(kNoTimestamp());
52   }
53 }
54
55 StreamParserBuffer::~StreamParserBuffer() {
56 }
57
58 int StreamParserBuffer::GetConfigId() const {
59   return config_id_;
60 }
61
62 void StreamParserBuffer::SetConfigId(int config_id) {
63   config_id_ = config_id;
64 }
65
66 }  // namespace media