Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Side by Side Diff: media/base/data_buffer.cc

Issue 10228017: Add initial implementation of SourceBufferStream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/logging.h" 5 #include "base/logging.h"
6 #include "media/base/data_buffer.h" 6 #include "media/base/data_buffer.h"
7 #include "media/base/decrypt_config.h" 7 #include "media/base/decrypt_config.h"
8 #if !defined(OS_ANDROID) 8 #if !defined(OS_ANDROID)
9 #include "media/ffmpeg/ffmpeg_common.h" 9 #include "media/ffmpeg/ffmpeg_common.h"
10 #endif 10 #endif
(...skipping 12 matching lines...) Expand all
23 data_(new uint8[buffer_size]), 23 data_(new uint8[buffer_size]),
24 buffer_size_(buffer_size), 24 buffer_size_(buffer_size),
25 data_size_(0) { 25 data_size_(0) {
26 CHECK(data_.get()) << "DataBuffer ctor failed to allocate memory"; 26 CHECK(data_.get()) << "DataBuffer ctor failed to allocate memory";
27 27
28 // Prevent arbitrary pointers. 28 // Prevent arbitrary pointers.
29 if (buffer_size == 0) 29 if (buffer_size == 0)
30 data_.reset(NULL); 30 data_.reset(NULL);
31 } 31 }
32 32
33 DataBuffer::DataBuffer(int buffer_size, bool is_keyframe)
34 : Buffer(base::TimeDelta(), base::TimeDelta(), is_keyframe),
35 data_(new uint8[buffer_size]),
36 buffer_size_(buffer_size),
37 data_size_(0) {
38 CHECK(data_.get()) << "DataBuffer ctor failed to allocate memory";
39
40 // Prevent arbitrary pointers.
41 if (buffer_size == 0)
42 data_.reset(NULL);
43 }
44
33 DataBuffer::~DataBuffer() {} 45 DataBuffer::~DataBuffer() {}
34 46
35 scoped_refptr<DataBuffer> DataBuffer::CopyFrom(const uint8* data, 47 scoped_refptr<DataBuffer> DataBuffer::CopyFrom(const uint8* data,
36 int data_size) { 48 int data_size) {
37 int padding_size = 0; 49 int padding_size = 0;
38 #if !defined(OS_ANDROID) 50 #if !defined(OS_ANDROID)
39 // Why FF_INPUT_BUFFER_PADDING_SIZE? FFmpeg assumes all input buffers are 51 // Why FF_INPUT_BUFFER_PADDING_SIZE? FFmpeg assumes all input buffers are
40 // padded with this value. 52 // padded with this value.
41 padding_size = FF_INPUT_BUFFER_PADDING_SIZE; 53 padding_size = FF_INPUT_BUFFER_PADDING_SIZE;
42 #endif 54 #endif
(...skipping 30 matching lines...) Expand all
73 85
74 int DataBuffer::GetBufferSize() const { 86 int DataBuffer::GetBufferSize() const {
75 return buffer_size_; 87 return buffer_size_;
76 } 88 }
77 89
78 void DataBuffer::SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config) { 90 void DataBuffer::SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config) {
79 decrypt_config_ = decrypt_config.Pass(); 91 decrypt_config_ = decrypt_config.Pass();
80 } 92 }
81 93
82 } // namespace media 94 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698