Valkka  1.6.1
OpenSource Video Management
filestream.h
Go to the documentation of this file.
1 #ifndef filestream_HEADER_GUARD
2 #define filestream_HEADER_GUARD
3 /*
4  * filestream.h :
5  *
6  * (c) Copyright 2017-2024 Sampsa Riikonen
7  *
8  * Authors: Sampsa Riikonen <sampsa.riikonen@iki.fi>
9  *
10  * This file is part of the Valkka library.
11  *
12  * Valkka is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License as
14  * published by the Free Software Foundation, either version 3 of the
15  * License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>
24  *
25  */
26 
36 #include "frame.h"
37 #include "thread.h"
38 #include "framefilter.h"
39 #include "logging.h"
40 #include "tools.h"
41 
42 
43 
97 class AbstractFileStream { // <pyapi>
98 
99 public: // <pyapi>
103  AbstractFileStream(); // <pyapi>
104  virtual ~AbstractFileStream(); // <pyapi>
105 
106 protected:
107  long int reftime;
113 
114 public: // getters
115  AbstractFileState getState() {return this->state;}
116 
117 public:
118  void setRefMstime(long int ms_streamtime_);
119  void play();
120  void stop();
121  long int update(long int mstimestamp);
122 
123  virtual void seek(long int ms_streamtime_);
124  virtual long int pullNextFrame();
125 }; // <pyapi>
126 
127 
136 class AbstractFileThread : public Thread { // <pyapi>
137 
138 public: // <pyapi>
144  AbstractFileThread(const char* name, FrameFifoContext fifo_ctx=FrameFifoContext(10)); // <pyapi>
145  virtual ~AbstractFileThread(); // <pyapi>
146 
147 protected: // frame input
150 
151 protected:
152  virtual void preRun();
153  virtual void postRun();
154  virtual void run();
155 }; // <pyapi>
156 
157 
158 
159 
160 
161 #endif
A general class for on-disk stored streams.
Definition: filestream.h:97
long int frame_mstimestamp_
Timestamp of previous frame sent, -1 means there was no previous frame (underscore means stream time)
Definition: filestream.h:109
long int target_mstimestamp_
Where the stream would like to be (underscore means stream time)
Definition: filestream.h:108
BasicFrame out_frame
BasicFrame payload that's passed on to the filterchain.
Definition: filestream.h:112
AbstractFileState state
Decribes the FileStream state: errors, stopped, playing, etc.
Definition: filestream.h:110
AbstractFileStream()
Default constructor.
Definition: filestream.cpp:38
Frame * next_frame
Pointer to the next frame about to be presented.
Definition: filestream.h:111
void play()
Start playing the stream.
Definition: filestream.cpp:51
void stop()
Stop playing the strem.
Definition: filestream.cpp:57
void setRefMstime(long int ms_streamtime_)
Creates a correspondence with the current wallclock time and a desider stream time,...
Definition: filestream.cpp:46
long int reftime
Relation between the stream time and wallclock time. See Presention timing and playing.
Definition: filestream.h:107
virtual void seek(long int ms_streamtime_)
Seek to a desider stream time.
Definition: filestream.cpp:83
virtual long int pullNextFrame()
Tries to achieve FileStream::target_mstimestamp_ . Sends frames whose timestamps are less than that t...
Definition: filestream.cpp:114
long int update(long int mstimestamp)
Tries to achieve mstimestamp: calculates FileStream::target_mstimestamp_ and calls pullNextFrame....
Definition: filestream.cpp:62
This class uses AbstractFileStream(s)
Definition: filestream.h:136
FrameFifo infifo
Incoming frames are read from here.
Definition: filestream.h:148
AbstractFileThread(const char *name, FrameFifoContext fifo_ctx=FrameFifoContext(10))
Default constructor.
Definition: filestream.cpp:192
virtual void preRun()
Called before entering the main execution loop, but after creating the thread.
Definition: filestream.cpp:229
virtual void run()
Main execution loop is defined here.
Definition: filestream.cpp:226
FifoFrameFilter infilter
Write incoming frames here.
Definition: filestream.h:149
virtual void postRun()
Called after the main execution loop exits, but before joining the thread.
Definition: filestream.cpp:232
Custom payload Frame.
Definition: frame.h:166
Passes frames to a FrameFifo.
Definition: framefilter.h:530
A thread-safe combination of a fifo (first-in-first-out) queue and an associated stack.
Definition: framefifo.h:83
Frame: An abstract queueable class.
Definition: frame.h:112
A class for multithreading with a signaling system.
Definition: thread.h:87
std::string name
Name of the thread.
Definition: thread.h:116
Frame classes.
Definition of FrameFilter and derived classes for various purposes.
AbstractFileState
Describes the state of a stream.
Definition: threadsignal.h:43
Logging utilities.
Describes the stack structure and fifo behaviour for a FrameFifo.
Definition: framefifo.h:56
Base class for multithreading.
Auxiliary routines.