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

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

Issue 10269022: Add StreamParserBuffer to ChunkDemuxer (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
« no previous file with comments | « no previous file | media/base/stream_parser.h » ('j') | media/base/stream_parser_buffer.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 11
12 namespace media { 12 namespace media {
13 13
14 DataBuffer::DataBuffer(scoped_array<uint8> buffer, int buffer_size) 14 DataBuffer::DataBuffer(scoped_array<uint8> buffer, int buffer_size)
15 : Buffer(base::TimeDelta(), base::TimeDelta()), 15 : Buffer(base::TimeDelta(), base::TimeDelta()),
16 data_(buffer.Pass()), 16 data_(buffer.Pass()),
17 buffer_size_(buffer_size), 17 buffer_size_(buffer_size),
18 data_size_(buffer_size) { 18 data_size_(buffer_size) {
19 } 19 }
20 20
21 DataBuffer::DataBuffer(int buffer_size) 21 DataBuffer::DataBuffer(int buffer_size)
22 : Buffer(base::TimeDelta(), base::TimeDelta()), 22 : Buffer(base::TimeDelta(), base::TimeDelta()),
23 data_(new uint8[buffer_size]),
24 buffer_size_(buffer_size), 23 buffer_size_(buffer_size),
25 data_size_(0) { 24 data_size_(0) {
26 CHECK(data_.get()) << "DataBuffer ctor failed to allocate memory";
27 25
28 // Prevent arbitrary pointers. 26 if (buffer_size > 0) {
29 if (buffer_size == 0) 27 int padding_size = 0;
30 data_.reset(NULL); 28 #if !defined(OS_ANDROID)
29 // FFmpeg assumes all input buffers are padded with this value.
30 padding_size = FF_INPUT_BUFFER_PADDING_SIZE;
31 #endif
32 data_.reset(new uint8[buffer_size + padding_size]),
33 memset(data_.get() + buffer_size, 0, padding_size);
34 }
31 } 35 }
32 36
33 DataBuffer::~DataBuffer() {} 37 DataBuffer::~DataBuffer() {}
34 38
35 scoped_refptr<DataBuffer> DataBuffer::CopyFrom(const uint8* data, 39 scoped_refptr<DataBuffer> DataBuffer::CopyFrom(const uint8* data,
36 int data_size) { 40 int data_size) {
37 int padding_size = 0;
38 #if !defined(OS_ANDROID)
39 // Why FF_INPUT_BUFFER_PADDING_SIZE? FFmpeg assumes all input buffers are
40 // padded with this value.
41 padding_size = FF_INPUT_BUFFER_PADDING_SIZE;
42 #endif
43
44 scoped_refptr<DataBuffer> data_buffer( 41 scoped_refptr<DataBuffer> data_buffer(
acolwell GONE FROM CHROMIUM 2012/05/01 22:08:50 nit: fits on one line now?
vrk (LEFT CHROMIUM) 2012/05/02 17:24:51 Done.
45 new DataBuffer(data_size + padding_size)); 42 new DataBuffer(data_size));
46 memcpy(data_buffer->data_.get(), data, data_size); 43 memcpy(data_buffer->data_.get(), data, data_size);
Ami GONE FROM CHROMIUM 2012/05/01 22:34:16 If you put this in a protected DataBuffer ctor, th
vrk (LEFT CHROMIUM) 2012/05/02 17:24:51 Done.
47 memset(data_buffer->data_.get() + data_size, 0, padding_size);
48 data_buffer->SetDataSize(data_size); 44 data_buffer->SetDataSize(data_size);
Ami GONE FROM CHROMIUM 2012/05/01 22:34:16 Shouldn't the ctor be in charge of this call? (afa
vrk (LEFT CHROMIUM) 2012/05/02 17:24:51 Done.
49 return data_buffer; 45 return data_buffer;
50 } 46 }
51 47
52 const uint8* DataBuffer::GetData() const { 48 const uint8* DataBuffer::GetData() const {
53 return data_.get(); 49 return data_.get();
54 } 50 }
55 51
56 int DataBuffer::GetDataSize() const { 52 int DataBuffer::GetDataSize() const {
57 return data_size_; 53 return data_size_;
58 } 54 }
(...skipping 14 matching lines...) Expand all
73 69
74 int DataBuffer::GetBufferSize() const { 70 int DataBuffer::GetBufferSize() const {
75 return buffer_size_; 71 return buffer_size_;
76 } 72 }
77 73
78 void DataBuffer::SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config) { 74 void DataBuffer::SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config) {
79 decrypt_config_ = decrypt_config.Pass(); 75 decrypt_config_ = decrypt_config.Pass();
80 } 76 }
81 77
82 } // namespace media 78 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/base/stream_parser.h » ('j') | media/base/stream_parser_buffer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698