live
ByteStreamFileSource.hh
Go to the documentation of this file.
1 /**********
2 This library is free software; you can redistribute it and/or modify it under
3 the terms of the GNU Lesser General Public License as published by the
4 Free Software Foundation; either version 3 of the License, or (at your
5 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6 
7 This library is distributed in the hope that it will be useful, but WITHOUT
8 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10 more details.
11 
12 You should have received a copy of the GNU Lesser General Public License
13 along with this library; if not, write to the Free Software Foundation, Inc.,
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 **********/
16 // "liveMedia"
17 // Copyright (c) 1996-2021 Live Networks, Inc. All rights reserved.
18 // A file source that is a plain byte stream (rather than frames)
19 // C++ header
20 
21 #ifndef _BYTE_STREAM_FILE_SOURCE_HH
22 #define _BYTE_STREAM_FILE_SOURCE_HH
23 
24 #ifndef _FRAMED_FILE_SOURCE_HH
25 #include "FramedFileSource.hh"
26 #endif
27 
29 public:
31  char const* fileName,
32  unsigned preferredFrameSize = 0,
33  unsigned playTimePerFrame = 0);
34  // "preferredFrameSize" == 0 means 'no preference'
35  // "playTimePerFrame" is in microseconds
36 
38  FILE* fid,
39  unsigned preferredFrameSize = 0,
40  unsigned playTimePerFrame = 0);
41  // an alternative version of "createNew()" that's used if you already have
42  // an open file.
43 
44  u_int64_t fileSize() const { return fFileSize; }
45  // 0 means zero-length, unbounded, or unknown
46 
47  void seekToByteAbsolute(u_int64_t byteNumber, u_int64_t numBytesToStream = 0);
48  // if "numBytesToStream" is >0, then we limit the stream to that number of bytes, before treating it as EOF
49  void seekToByteRelative(int64_t offset, u_int64_t numBytesToStream = 0);
50  void seekToEnd(); // to force EOF handling on the next read
51 
52 protected:
54  FILE* fid,
55  unsigned preferredFrameSize,
56  unsigned playTimePerFrame);
57  // called only by createNew()
58 
60 
61  static void fileReadableHandler(ByteStreamFileSource* source, int mask);
63 
64 private:
65  // redefined virtual functions:
66  virtual void doGetNextFrame();
67  virtual void doStopGettingFrames();
68 
69 protected:
70  u_int64_t fFileSize;
71 
72 private:
76  unsigned fLastPlayTime;
79  u_int64_t fNumBytesToStream; // used iff "fLimitNumBytesToStream" is True
80 };
81 
82 #endif
unsigned char Boolean
Definition: Boolean.hh:25
static ByteStreamFileSource * createNew(UsageEnvironment &env, FILE *fid, unsigned preferredFrameSize=0, unsigned playTimePerFrame=0)
void seekToByteRelative(int64_t offset, u_int64_t numBytesToStream=0)
virtual ~ByteStreamFileSource()
ByteStreamFileSource(UsageEnvironment &env, FILE *fid, unsigned preferredFrameSize, unsigned playTimePerFrame)
virtual void doStopGettingFrames()
void seekToByteAbsolute(u_int64_t byteNumber, u_int64_t numBytesToStream=0)
static void fileReadableHandler(ByteStreamFileSource *source, int mask)
u_int64_t fileSize() const
virtual void doGetNextFrame()
static ByteStreamFileSource * createNew(UsageEnvironment &env, char const *fileName, unsigned preferredFrameSize=0, unsigned playTimePerFrame=0)