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

Side by Side Diff: media/filters/buffer_url_protocol.cc

Issue 7203002: Adding ChunkDemuxer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments Created 9 years, 6 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
(Empty)
1 // Copyright (c) 2011 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/filters/buffer_url_protocol.h"
6
7 namespace media {
8
9 BufferUrlProtocol::BufferUrlProtocol(const uint8* buf, int size,
10 bool streaming)
11 : buf_(buf),
12 size_(size),
13 offset_(0),
14 streaming_(streaming) {
15 }
16
17 BufferUrlProtocol::~BufferUrlProtocol() {}
18
19 int BufferUrlProtocol::Read(int size, uint8* data) {
20 int bytes_to_copy = size;
21 int bytes_left = size_ - offset_;
22
23 if (bytes_to_copy > bytes_left)
24 bytes_to_copy = bytes_left;
25
26 if (bytes_to_copy == 0)
27 return 0;
28
29 memcpy(data, buf_ + offset_, bytes_to_copy);
30 offset_ += bytes_to_copy;
31
32 return bytes_to_copy;
33 }
34
35 bool BufferUrlProtocol::GetPosition(int64* position_out) {
36 *position_out = offset_;
37 return true;
38 }
39
40 bool BufferUrlProtocol::SetPosition(int64 position) {
41 if (position < 0 || position >= size_)
42 return false;
43
44 offset_ = position;
45 return true;
46 }
47
48 bool BufferUrlProtocol::GetSize(int64* size_out) {
49 *size_out = size_;
50 return true;
51 }
52
53 bool BufferUrlProtocol::IsStreaming() { return streaming_; }
54
55 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698