Add explicit |forceOnlineSignin| to user pod status
[chromium-blink-merge.git] / media / base / stream_parser_buffer.cc
blobe5cc9795c0318ca7e3e485fb4c553fb9cae0fa58
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"
10 namespace media {
12 static bool HasNestedFadeOutPreroll(
13 const std::vector<scoped_refptr<StreamParserBuffer> >& fade_out_preroll) {
14 for (size_t i = 0; i < fade_out_preroll.size(); ++i) {
15 if (!fade_out_preroll[i]->GetFadeOutPreroll().empty())
16 return true;
18 return false;
21 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CreateEOSBuffer() {
22 return make_scoped_refptr(new StreamParserBuffer(NULL, 0, NULL, 0, false));
25 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CopyFrom(
26 const uint8* data, int data_size, bool is_keyframe) {
27 return make_scoped_refptr(
28 new StreamParserBuffer(data, data_size, NULL, 0, is_keyframe));
31 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CopyFrom(
32 const uint8* data, int data_size,
33 const uint8* side_data, int side_data_size, bool is_keyframe) {
34 return make_scoped_refptr(
35 new StreamParserBuffer(data, data_size, side_data, side_data_size,
36 is_keyframe));
39 base::TimeDelta StreamParserBuffer::GetDecodeTimestamp() const {
40 if (decode_timestamp_ == kNoTimestamp())
41 return timestamp();
42 return decode_timestamp_;
45 void StreamParserBuffer::SetDecodeTimestamp(const base::TimeDelta& timestamp) {
46 decode_timestamp_ = timestamp;
49 StreamParserBuffer::StreamParserBuffer(const uint8* data, int data_size,
50 const uint8* side_data,
51 int side_data_size, bool is_keyframe)
52 : DecoderBuffer(data, data_size, side_data, side_data_size),
53 is_keyframe_(is_keyframe),
54 decode_timestamp_(kNoTimestamp()),
55 config_id_(kInvalidConfigId) {
56 // TODO(scherkus): Should DataBuffer constructor accept a timestamp and
57 // 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.
59 if (data) {
60 set_duration(kNoTimestamp());
64 StreamParserBuffer::~StreamParserBuffer() {
67 int StreamParserBuffer::GetConfigId() const {
68 return config_id_;
71 void StreamParserBuffer::SetConfigId(int config_id) {
72 config_id_ = config_id;
75 const std::vector<scoped_refptr<StreamParserBuffer> >&
76 StreamParserBuffer::GetFadeOutPreroll() const {
77 return fade_out_preroll_;
80 void StreamParserBuffer::SetFadeOutPreroll(
81 const std::vector<scoped_refptr<StreamParserBuffer> >& fade_out_preroll) {
82 DCHECK(!HasNestedFadeOutPreroll(fade_out_preroll));
83 fade_out_preroll_ = fade_out_preroll;
86 } // namespace media