Theora Playback Library  1.1.0
TheoraDataSource.h
Go to the documentation of this file.
1 /************************************************************************************
2 This source file is part of the Theora Video Playback Library
3 For latest info, see http://libtheoraplayer.googlecode.com
4 *************************************************************************************
5 Copyright (c) 2008-2014 Kresimir Spes (kspes@cateia.com)
6 This program is free software; you can redistribute it and/or modify it under
7 the terms of the BSD license: http://opensource.org/licenses/BSD-3-Clause
8 *************************************************************************************/
9 #ifndef _TheoraDataSource_h
10 #define _TheoraDataSource_h
11 
12 #include <stdint.h>
13 #include <limits.h>
14 #include <string>
15 #include "TheoraExport.h"
16 
24 {
25 public:
26 
27  virtual ~TheoraDataSource();
32  virtual int read(void* output,int nBytes) = 0;
34  virtual std::string repr() = 0;
36  virtual void seek(uint64_t byte_index) = 0;
38  virtual uint64_t size() = 0;
40  virtual uint64_t tell() = 0;
41 };
42 
43 
48 {
49  FILE* mFilePtr;
50  std::string mFilename;
51  uint64_t mSize;
52 
53  void openFile();
54 public:
55  TheoraFileDataSource(std::string filename);
57 
58  int read(void* output,int nBytes);
59  void seek(uint64_t byte_index);
60  std::string repr() { return mFilename; }
61  uint64_t size();
62  uint64_t tell();
63 
64  std::string getFilename() { return mFilename; }
65 };
66 
73 {
74  std::string mFilename;
75  uint64_t mSize, mReadPointer;
76  unsigned char* mData;
77 public:
78  TheoraMemoryFileDataSource(unsigned char* data, long size, const std::string& filename = "memory");
79  TheoraMemoryFileDataSource(std::string filename);
81 
82  int read(void* output,int nBytes);
83  void seek(uint64_t byte_index);
84  std::string repr() { return "MEM:"+mFilename; }
85  uint64_t size();
86  uint64_t tell();
87  std::string getFilename() { return mFilename; }
88 };
89 
90 #endif
std::string repr()
returns a string representation of the DataSource, eg 'File: source.ogg'
Definition: TheoraDataSource.h:84
virtual int read(void *output, int nBytes)=0
std::string repr()
returns a string representation of the DataSource, eg 'File: source.ogg'
Definition: TheoraDataSource.h:60
std::string getFilename()
Definition: TheoraDataSource.h:64
virtual void seek(uint64_t byte_index)=0
position the source pointer to byte_index from the start of the source
Definition: TheoraDataSource.h:72
Definition: TheoraDataSource.h:47
std::string getFilename()
Definition: TheoraDataSource.h:87
virtual uint64_t tell()=0
return the current position of the source pointer
#define TheoraPlayerExport
Definition: TheoraExport.h:25
virtual uint64_t size()=0
return the size of the stream in bytes
Definition: TheoraDataSource.h:23