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.
5 #include "media/filters/in_memory_url_protocol.h"
9 InMemoryUrlProtocol::InMemoryUrlProtocol(const uint8
* data
, int64 size
,
12 size_(size
>= 0 ? size
: 0),
14 streaming_(streaming
) {
17 InMemoryUrlProtocol::~InMemoryUrlProtocol() {}
19 int InMemoryUrlProtocol::Read(int size
, uint8
* data
) {
20 int available_bytes
= size_
- position_
;
21 if (size
> available_bytes
)
22 size
= available_bytes
;
24 memcpy(data
, data_
+ position_
, size
);
29 bool InMemoryUrlProtocol::GetPosition(int64
* position_out
) {
33 *position_out
= position_
;
37 bool InMemoryUrlProtocol::SetPosition(int64 position
) {
38 if (position
< 0 || position
> size_
)
44 bool InMemoryUrlProtocol::GetSize(int64
* size_out
) {
52 bool InMemoryUrlProtocol::IsStreaming() {