1 // Copyright 2011 The Chromium Authors
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_t* data,
15 size_(size >= 0 ? size : 0),
17 streaming_(streaming) {}
19 InMemoryUrlProtocol::~InMemoryUrlProtocol() = default;
21 int InMemoryUrlProtocol::Read(int size, uint8_t* data) {
22 // Not sure this can happen, but it's unclear from the ffmpeg code, so guard
29 const int64_t available_bytes = size_ - position_;
30 if (available_bytes <= 0)
33 if (size > available_bytes)
34 size = available_bytes;
37 memcpy(data, data_ + position_, size);
44 bool InMemoryUrlProtocol::GetPosition(int64_t* position_out) {
48 *position_out = position_;
52 bool InMemoryUrlProtocol::SetPosition(int64_t position) {
53 if (position < 0 || position > size_)
59 bool InMemoryUrlProtocol::GetSize(int64_t* size_out) {
67 bool InMemoryUrlProtocol::IsStreaming() {