Valkka  1.6.1
OpenSource Video Management
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
LiveThread Class Reference

Live555, running in a separate thread. More...

#include <livethread.h>

Inheritance diagram for LiveThread:
Inheritance graph
[legend]
Collaboration diagram for LiveThread:
Collaboration graph
[legend]

Public Member Functions

 LiveThread (const char *name, FrameFifoContext fifo_ctx=FrameFifoContext())
 Default constructor. More...
 
void run ()
 Main execution loop is defined here.
 
void preRun ()
 Called before entering the main execution loop, but after creating the thread.
 
void postRun ()
 Called after the main execution loop exits, but before joining the thread.
 
void sendSignal (LiveSignalContext signal_ctx)
 Send a signal to the thread. More...
 
void registerStreamCall (LiveConnectionContext &connection_ctx)
 API method: registers a stream // <pyapi>
 
void deregisterStreamCall (LiveConnectionContext &connection_ctx)
 API method: de-registers a stream // <pyapi>
 
void playStreamCall (LiveConnectionContext &connection_ctx)
 API method: starts playing the stream and feeding frames // <pyapi>
 
void stopStreamCall (LiveConnectionContext &connection_ctx)
 API method: stops playing the stream and feeding frames // <pyapi>
 
void registerOutboundCall (LiveOutboundContext &outbound_ctx)
 API method: register outbound stream // <pyapi>
 
void deregisterOutboundCall (LiveOutboundContext &outbound_ctx)
 API method: deregister outbound stream // <pyapi>
 
void requestStopCall ()
 API method: Like Thread::stopCall() but does not block // <pyapi>
 
FifoFrameFiltergetFrameFilter ()
 API method: get filter for sending frames with live555 // <pyapi>
 
void setRTSPServer (int portnum=8554)
 API method: activate the RTSP server at port portnum // <pyapi>
 
virtual void waitReady ()
 API method: wait until all signals and pending connections are resolved // <pyapi>
 
void testTrigger ()
 See Live streaming.
 
void triggerGotFrames ()
 See Live streaming.
 
- Public Member Functions inherited from Thread
 Thread (const char *name)
 Default constructor. More...
 
 ~Thread ()
 Destructor:not virtual. More...
 
virtual void preJoin ()
 Called before the thread is joined.
 
virtual void postJoin ()
 Called after the thread has been joined.
 
virtual void sendSignal (SignalContext signal_ctx)
 Send a signal to the thread.
 
virtual void sendSignalAndWait (SignalContext signal_ctx)
 Send a signal to the thread and wait for all signals to be executed.
 
void setAffinity (int i)
 API method for setting the thread affinity. More...
 
void startCall ()
 API method: starts the thread.
 
virtual void stopCall ()
 API method: stops the thread. More...
 
virtual void waitStopCall ()
 API method: waits until the thread is joined. More...
 

Static Public Member Functions

static void periodicTask (void *cdata)
 Used to (re)schedule LiveThread methods into the live555 event loop.
 
static void helloWorldEvent (void *clientData)
 For testing/debugging

 
static void frameArrivedEvent (void *clientData)
 For debugging.
 
static void gotFramesEvent (void *clientData)
 Triggered when an empty fifo gets a frame. Schedules readFrameFifoTask. See Live streaming.
 
static void readFrameFifoTask (void *clientData)
 This task registers itself if there are frames in the fifo. More...
 

Protected Member Functions

void handlePending ()
 Try to close streams that were not properly closed (i.e. idling for the tcp socket while closing). Used by LiveThread::periodicTask.
 
void checkAlive ()
 Used by LiveThread::periodicTask.
 
void closePending ()
 Force close all pending connections.
 
void handleSignals ()
 Handle pending signals in the signals queue. Used by LiveThread::periodicTask.
 
void handleFrame (Frame *f)
 Handle incoming frames. See Live streaming.
 
- Protected Member Functions inherited from Thread
void mainRun ()
 Does the preRun, run, postRun sequence.
 
void closeThread ()
 Sends exit signal to the thread, calls join. This method blocks until thread has exited. Set Thread::has_thread to false.
 

Protected Attributes

LiveFifo infifo
 A FrameFifo for incoming frames.
 
FifoFrameFilter infilter
 A FrameFilter for writing incoming frames.
 
std::deque< LiveSignalContextsignal_fifo
 Redefinition of signal fifo (Thread::signal_fifo becomes hidden)
 
TaskScheduler * scheduler
 Live555 event loop TaskScheduler.
 
UsageEnvironment * env
 Live555 UsageEnvironment identifying the event loop.
 
char eventLoopWatchVariable
 Modifying this, kills the Live555 event loop.
 
std::vector< Connection * > slots_
 A constant sized vector. Book-keeping of the connections (RTSP or SDP) currently active in the live555 thread. Organized in "slots".
 
std::vector< Outbound * > out_slots_
 Book-keeping for the outbound connections.
 
std::list< Connection * > pending
 Incoming connections pending for closing.
 
bool exit_requested
 Exit asap.
 
EventTriggerId event_trigger_id_hello_world
 
EventTriggerId event_trigger_id_frame_arrived
 
EventTriggerId event_trigger_id_got_frames
 
int fc
 debugging: incoming frame counter
 
UserAuthenticationDatabase * authDB
 
RTSPServer * server
 
- Protected Attributes inherited from Thread
std::string name
 Name of the thread.
 
bool has_thread
 true if thread has been started
 
bool stop_requested
 
bool thread_joined
 
std::mutex start_mutex
 Mutex protecting start_condition.
 
std::condition_variable start_condition
 Notified when the thread has been started.
 
std::mutex mutex
 Mutex protecting the condition variable and signal queue.
 
std::condition_variable condition
 Condition variable for the signal queue (triggered when all signals processed). Not necessarily used by all subclasses.
 
std::mutex loop_mutex
 Protects thread's main execution loop (if necessary)
 
std::deque< SignalContextsignal_fifo
 Signal queue (fifo). Redefine in child classes.
 
bool loop
 Use this boolean to control if the main loop in Thread:run should exit.
 
int core_id
 
pthread_attr_t thread_attr
 Thread attributes, pthread_* way.
 
cpu_set_t cpuset
 
pthread_t internal_thread
 

Private Member Functions

int safeGetSlot (SlotNumber slot, Connection *&con)
 
int safeGetOutboundSlot (SlotNumber slot, Outbound *&outbound)
 
void registerStream (LiveConnectionContext &connection_ctx)
 
void deregisterStream (LiveConnectionContext &connection_ctx)
 
void playStream (LiveConnectionContext &connection_ctx)
 
void registerOutbound (LiveOutboundContext &outbound_ctx)
 
void deregisterOutbound (LiveOutboundContext &outbound_ctx)
 
void stopStream (LiveConnectionContext &connection_ctx)
 

Additional Inherited Members

- Static Protected Member Functions inherited from Thread
static void * mainRun_ (void *p)
 

Detailed Description

Live555, running in a separate thread.

This class implements a "producer" thread that outputs frames into a FrameFilter (see multithreading)

This Thread has its own running Live555 event loop. It registers a callback into the Live555 event loop which checks periodically for signals send to the thread. Signals to this thread are sent using the LiveThread::sendSignal method.

API methods take as parameter either LiveConnectionContext or LiveOutboundContext instances that identify the stream (type, address, slot number, etc.)

Constructor & Destructor Documentation

◆ LiveThread()

LiveThread::LiveThread ( const char *  name,
FrameFifoContext  fifo_ctx = FrameFifoContext() 
)

Default constructor.

Parameters
nameThread name
n_max_slotsMaximum number of connections (each Connection instance is placed in a slot)

Member Function Documentation

◆ readFrameFifoTask()

void LiveThread::readFrameFifoTask ( void *  clientData)
static

This task registers itself if there are frames in the fifo.

◆ sendSignal()

void LiveThread::sendSignal ( LiveSignalContext  signal_ctx)

Send a signal to the thread.


The documentation for this class was generated from the following files: