/usr/include/crtmpserver/thelib/streaming/baseinfilestream.h is in crtmpserver-dev 1.0~dfsg-5.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | /*
* Copyright (c) 2010,
* Gavriloaie Eugen-Andrei (shiretu@gmail.com)
*
* This file is part of crtmpserver.
* crtmpserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* crtmpserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with crtmpserver. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _BASEINFILESTREAM_H
#define _BASEINFILESTREAM_H
#include "streaming/baseinstream.h"
#include "mediaformats/mediaframe.h"
#include "protocols/timer/basetimerprotocol.h"
#ifdef HAS_MMAP
#define FileClass MmapFile
#else
#define FileClass File
#endif
/*!
@class BaseInFileStream
@brief
*/
class DLLEXP BaseInFileStream
: public BaseInStream {
private:
class InFileStreamTimer
: public BaseTimerProtocol {
private:
BaseInFileStream *_pInFileStream;
public:
InFileStreamTimer(BaseInFileStream *pInFileStream);
virtual ~InFileStreamTimer();
void ResetStream();
virtual bool TimePeriodElapsed();
};
friend class InFileStreamTimer;
#ifndef HAS_MMAP
static map<string, pair<uint32_t, File *> > _fileCache;
#endif /* HAS_MMAP */
InFileStreamTimer *_pTimer;
FileClass *_pSeekFile;
FileClass *_pFile;
//frame info
uint32_t _totalFrames;
uint32_t _currentFrameIndex;
MediaFrame _currentFrame;
//timing info
uint32_t _totalSentTime;
uint32_t _totalSentTimeBase;
time_t _startFeedingTime;
//buffering info
int32_t _clientSideBufferLength;
IOBuffer _videoBuffer;
IOBuffer _audioBuffer;
//current state info
bool _paused;
bool _audioVideoCodecsSent;
//seek offsets
uint64_t _seekBaseOffset;
uint64_t _framesBaseOffset;
uint64_t _timeToIndexOffset;
//stream capabilities
StreamCapabilities _streamCapabilities;
//when to stop playback
double _playLimit;
public:
BaseInFileStream(BaseProtocol *pProtocol, StreamsManager *pStreamsManager,
uint64_t type, string name);
virtual ~BaseInFileStream();
/*!
@brief Returns the stream capabilities. Specifically, codec and codec related info
*/
virtual StreamCapabilities * GetCapabilities();
/*!
@brief Extracts the complete metadata from partial metadata
@param metaData - the partial metadata containing at least the media file name
*/
static bool ResolveCompleteMetadata(Variant &metaData);
/*!
@brief This will initialize the stream internally.
@param clientSideBufferLength - the client side buffer length expressed in seconds
*/
virtual bool Initialize(int32_t clientSideBufferLength);
/*!
@brief Called when a play command was issued
@param absoluteTimestamp - the timestamp where we want to seek before start the feeding process
*/
virtual bool SignalPlay(double &absoluteTimestamp, double &length);
/*!
@brief Called when a pasue command was issued
*/
virtual bool SignalPause();
/*!
@brief Called when a resume command was issued
*/
virtual bool SignalResume();
/*!
@brief Called when a seek command was issued
@param absoluteTimestamp
*/
virtual bool SignalSeek(double &absoluteTimestamp);
/*!
@brief Called when a stop command was issued
*/
virtual bool SignalStop();
/*!
@brief This is called by the framework. The networking layer signaled the availability for sending data
*/
virtual void ReadyForSend();
protected:
virtual bool BuildFrame(FileClass *pFile, MediaFrame &mediaFrame,
IOBuffer &buffer) = 0;
virtual bool FeedMetaData(FileClass *pFile, MediaFrame &mediaFrame) = 0;
private:
/*!
@brief This will seek to the specified point in time.
@param absoluteTimestamp - the timestamp where we want to seek before start the feeding process
*/
bool InternalSeek(double &absoluteTimestamp);
/*!
@brief This is the function that will actually do the feeding.
@discussion It is called by the framework and it must deliver one frame at a time to all subscribers
*/
virtual bool Feed();
/*!
@brief GetFile function will open a file and will cache it if is a regular file.
@discussion If the file is mmap based file, it will NOT cache it
ReleaseFile will do the opposite: It will close the file if the references
count will reach 0. This always happens in case of mmap file
*/
#ifdef HAS_MMAP
static MmapFile* GetFile(string filePath, uint32_t windowSize);
static void ReleaseFile(MmapFile *pFile);
#else
static File* GetFile(string filePath, uint32_t windowSize);
static void ReleaseFile(File *pFile);
#endif /* HAS_MMAP */
/*!
@brief This function will ensure that the codec packets are sent. Also it preserves the current timings and frame index
*/
bool SendCodecs();
};
#endif /* _BASEINFILESTREAM_H */
|