live
ByteStreamMemoryBufferSource.hh
Go to the documentation of this file.
1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15**********/
16// "liveMedia"
17// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
18// A class for streaming data from a (static) memory buffer, as if it were a file.
19// C++ header
20
21#ifndef _BYTE_STREAM_MEMORY_BUFFER_SOURCE_HH
22#define _BYTE_STREAM_MEMORY_BUFFER_SOURCE_HH
23
24#ifndef _FRAMED_SOURCE_HH
25#include "FramedSource.hh"
26#endif
27
29public:
31 u_int8_t* buffer, u_int64_t bufferSize,
32 Boolean deleteBufferOnClose = True,
33 unsigned preferredFrameSize = 0,
34 unsigned playTimePerFrame = 0);
35 // "preferredFrameSize" == 0 means 'no preference'
36 // "playTimePerFrame" is in microseconds
37
38 u_int64_t bufferSize() const { return fBufferSize; }
39
40 void seekToByteAbsolute(u_int64_t byteNumber, u_int64_t numBytesToStream = 0);
41 // if "numBytesToStream" is >0, then we limit the stream to that number of bytes, before treating it as EOF
42 void seekToByteRelative(int64_t offset, u_int64_t numBytesToStream = 0);
43
44protected:
46 u_int8_t* buffer, u_int64_t bufferSize,
47 Boolean deleteBufferOnClose,
48 unsigned preferredFrameSize,
49 unsigned playTimePerFrame);
50 // called only by createNew()
51
53
54private:
55 // redefined virtual functions:
56 virtual void doGetNextFrame();
57
58private:
59 u_int8_t* fBuffer;
60 u_int64_t fBufferSize;
61 u_int64_t fCurIndex;
65 unsigned fLastPlayTime;
67 u_int64_t fNumBytesToStream; // used iff "fLimitNumBytesToStream" is True
68};
69
70#endif
const Boolean True
Definition: Boolean.hh:31
unsigned char Boolean
Definition: Boolean.hh:25
static ByteStreamMemoryBufferSource * createNew(UsageEnvironment &env, u_int8_t *buffer, u_int64_t bufferSize, Boolean deleteBufferOnClose=True, unsigned preferredFrameSize=0, unsigned playTimePerFrame=0)
void seekToByteRelative(int64_t offset, u_int64_t numBytesToStream=0)
ByteStreamMemoryBufferSource(UsageEnvironment &env, u_int8_t *buffer, u_int64_t bufferSize, Boolean deleteBufferOnClose, unsigned preferredFrameSize, unsigned playTimePerFrame)
void seekToByteAbsolute(u_int64_t byteNumber, u_int64_t numBytesToStream=0)