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#ifndef MEDIA_FILTERS_IN_MEMORY_URL_PROTOCOL_H_ 6#define MEDIA_FILTERS_IN_MEMORY_URL_PROTOCOL_H_ 7 8#include "base/basictypes.h" 9#include "base/compiler_specific.h" 10#include "media/filters/ffmpeg_glue.h" 11 12namespace media { 13 14// Simple FFmpegURLProtocol that reads from a buffer. 15// NOTE: This object does not copy the buffer so the 16// buffer pointer passed into the constructor 17// needs to remain valid for the entire lifetime of 18// this object. 19class MEDIA_EXPORT InMemoryUrlProtocol : public FFmpegURLProtocol { 20 public: 21 InMemoryUrlProtocol(const uint8* buf, int64 size, bool streaming); 22 virtual ~InMemoryUrlProtocol(); 23 24 // FFmpegURLProtocol methods. 25 virtual int Read(int size, uint8* data) OVERRIDE; 26 virtual bool GetPosition(int64* position_out) OVERRIDE; 27 virtual bool SetPosition(int64 position) OVERRIDE; 28 virtual bool GetSize(int64* size_out) OVERRIDE; 29 virtual bool IsStreaming() OVERRIDE; 30 31 private: 32 const uint8* data_; 33 int64 size_; 34 int64 position_; 35 bool streaming_; 36 37 DISALLOW_IMPLICIT_CONSTRUCTORS(InMemoryUrlProtocol); 38}; 39 40} // namespace media 41 42#endif // MEDIA_FILTERS_IN_MEMORY_URL_PROTOCOL_H_ 43