TSDuck v3.38-3675
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::InputSwitcher Class Reference

Implementation of the input plugin switcher. More...

#include <tsInputSwitcher.h>

Inheritance diagram for ts::InputSwitcher:
Collaboration diagram for ts::InputSwitcher:

Public Member Functions

 InputSwitcher (const InputSwitcherArgs &args, Report &report)
 Full session constructor.
 
 InputSwitcher (Report &report)
 Constructor.
 
 ~InputSwitcher ()
 Destructor.
 
void callEventHandlers (const PluginEventContext &context) const
 Invoke all event handlers for a given event.
 
size_t currentInput ()
 Get the index of the current input plugin.
 
bool isStarted () const
 Check if the input switcher is started.
 
void nextInput ()
 Switch to the next input plugin.
 
void previousInput ()
 Switch to the previous input plugin.
 
void registerEventHandler (PluginEventHandlerInterface *handler, const Criteria &criteria=Criteria::Any)
 Register an event handler.
 
Reportreport () const
 Get a reference to the report object for the input switcher.
 
void setInput (size_t pluginIndex)
 Switch to another input plugin.
 
bool start (const InputSwitcherArgs &args)
 Start the input switcher session.
 
void stop ()
 Stop the input switcher.
 
bool success () const
 Check if the session, when completely run in the constructor, was successful.
 
void unregisterEventHandler (PluginEventHandlerInterface *handler=nullptr)
 Unregister all occurences of an event handler.
 
void waitForTermination ()
 Suspend the calling thread until input switcher is completed.
 

Detailed Description

Implementation of the input plugin switcher.

This class is used by the tsswitch utility. It can also be used in other applications to switch between input plugins.

Constructor & Destructor Documentation

◆ InputSwitcher() [1/2]

ts::InputSwitcher::InputSwitcher ( Report report)

Constructor.

This constructor does not start the session.

Parameters
[in,out]reportWhere to report errors, logs, etc. This object will be used concurrently by all plugin execution threads. Consequently, it must be thread-safe. For performance reasons, it should be asynchronous (see for instance class AsyncReport).

◆ ~InputSwitcher()

ts::InputSwitcher::~InputSwitcher ( )

Destructor.

It waits for termination of the session if it is running.

◆ InputSwitcher() [2/2]

ts::InputSwitcher::InputSwitcher ( const InputSwitcherArgs args,
Report report 
)

Full session constructor.

The complete input switching session is performed in this constructor. The constructor returns only when the input switcher session terminates or fails tp start.

Parameters
[in]argsArguments and options.
[in,out]reportWhere to report errors, logs, etc. This object will be used concurrently by all plugin execution threads. Consequently, it must be thread-safe. For performance reasons, it should be asynchronous (see for instance class AsyncReport).

Member Function Documentation

◆ report()

Report & ts::InputSwitcher::report ( ) const
inline

Get a reference to the report object for the input switcher.

Returns
A reference to the report object for the input switcher.

◆ start()

bool ts::InputSwitcher::start ( const InputSwitcherArgs args)

Start the input switcher session.

Parameters
[in]argsArguments and options.
Returns
True on success, false on failure to start.

◆ isStarted()

bool ts::InputSwitcher::isStarted ( ) const
inline

Check if the input switcher is started.

Returns
True if the input switcher is in progress, false otherwise.

◆ setInput()

void ts::InputSwitcher::setInput ( size_t  pluginIndex)

Switch to another input plugin.

Parameters
[in]pluginIndexIndex of the new input plugin.

◆ currentInput()

size_t ts::InputSwitcher::currentInput ( )

Get the index of the current input plugin.

Returns
The index of the current input plugin.

◆ success()

bool ts::InputSwitcher::success ( ) const
inline

Check if the session, when completely run in the constructor, was successful.

Returns
True on success, false on failure to start.

◆ registerEventHandler()

void ts::PluginEventHandlerRegistry::registerEventHandler ( PluginEventHandlerInterface handler,
const Criteria criteria = Criteria::Any 
)
inherited

Register an event handler.

Note: calling this function while executing a plugin event hander does nothing.

Parameters
[in]handlerThe event handler to register.
[in]criteriaThe criteria for which the handler is to be called.

◆ unregisterEventHandler()

void ts::PluginEventHandlerRegistry::unregisterEventHandler ( PluginEventHandlerInterface handler = nullptr)
inherited

Unregister all occurences of an event handler.

Note: calling this function while executing a plugin event hander does nothing. This is typically used in the destructor of an event handler.

Parameters
[in]handlerThe event handler to unregister. When null, all events are unregistered.

◆ callEventHandlers()

void ts::PluginEventHandlerRegistry::callEventHandlers ( const PluginEventContext context) const
inherited

Invoke all event handlers for a given event.

Parameters
[in]contextEvent context.

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