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"
7 #include "media/ffmpeg/ffmpeg_common.h"
11 InMemoryUrlProtocol::InMemoryUrlProtocol(const uint8* data, int64 size,
14 size_(size >= 0 ? size : 0),
16 streaming_(streaming) {
19 InMemoryUrlProtocol::~InMemoryUrlProtocol() {}
21 int InMemoryUrlProtocol::Read(int size, uint8* data) {
25 int64 available_bytes = size_ - position_;
26 if (size > available_bytes)
27 size = available_bytes;
30 memcpy(data, data_ + position_, size);
37 bool InMemoryUrlProtocol::GetPosition(int64* position_out) {
41 *position_out = position_;
45 bool InMemoryUrlProtocol::SetPosition(int64 position) {
46 if (position < 0 || position > size_)
52 bool InMemoryUrlProtocol::GetSize(int64* size_out) {
60 bool InMemoryUrlProtocol::IsStreaming() {