![]() |
TSDuck
v3.35-3218
MPEG Transport Stream Toolkit
|
Base class for threads executing a tsp plugin. More...
Public Member Functions | |
PluginThread (Report *report, const UString &appName, PluginType type, const PluginOptions &options, const ThreadAttributes &attributes) | |
Constructor. More... | |
virtual | ~PluginThread () override |
Destructor. | |
virtual bool | aborting () const override |
Check for aborting application. More... | |
BitRate | bitrate () const |
Get the current input bitrate in bits/seconds. More... | |
BitRateConfidence | bitrateConfidence () const |
Get the plugin bitrate confidence. More... | |
bool | debug () const |
Check if debugging is active. More... | |
void | debug (const UChar *fmt, std::initializer_list< ArgMixIn > args) |
Report a debug message with a printf-like interface. More... | |
void | debug (const UString &fmt, std::initializer_list< ArgMixIn > args) |
Report a debug message with a printf-like interface. More... | |
void | debug (const UString &msg) |
Report a debug message. More... | |
void | error (const UChar *fmt, std::initializer_list< ArgMixIn > args) |
Report an error message with a printf-like interface. More... | |
void | error (const UString &fmt, std::initializer_list< ArgMixIn > args) |
Report an error message with a printf-like interface. More... | |
void | error (const UString &msg) |
Report an error message. More... | |
void | fatal (const UChar *fmt, std::initializer_list< ArgMixIn > args) |
Report a fatal error message with a printf-like interface. More... | |
void | fatal (const UString &fmt, std::initializer_list< ArgMixIn > args) |
Report a fatal error message with a printf-like interface. More... | |
void | fatal (const UString &msg) |
Report a fatal error message. More... | |
void | getAttributes (ThreadAttributes &attributes) |
Get a copy of the attributes of the thread. More... | |
UString | getTypeName () const |
Get an implementation-specific name of the object class. More... | |
bool | gotErrors () const |
Check if errors (or worse) were reported through this object. More... | |
void | info (const UChar *fmt, std::initializer_list< ArgMixIn > args) |
Report an informational message with a printf-like interface. More... | |
void | info (const UString &fmt, std::initializer_list< ArgMixIn > args) |
Report an informational message with a printf-like interface. More... | |
void | info (const UString &msg) |
Report an informational message. More... | |
bool | isCurrentThread () const |
Check if the caller is running in the context of this thread. More... | |
virtual void | jointTerminate ()=0 |
Signaling "joint termination". More... | |
virtual void | log (int severity, const UChar *fmt, std::initializer_list< ArgMixIn > args) |
Report a message with an explicit severity and a printf-like interface. More... | |
virtual void | log (int severity, const UString &fmt, std::initializer_list< ArgMixIn > args) |
Report a message with an explicit severity and a printf-like interface. More... | |
virtual void | log (int severity, const UString &msg) |
Report a message with an explicit severity. More... | |
virtual void | main ()=0 |
This hook is invoked in the context of the thread. More... | |
int | maxSeverity () const |
Get maximum severity level. More... | |
virtual Plugin * | plugin () const override |
Access the shared library through the plugin interface. More... | |
virtual size_t | pluginCount () const =0 |
Get the number of plugins in the processing chain. More... | |
virtual size_t | pluginIndex () const =0 |
Get the plugin index in the processing chain. More... | |
virtual UString | pluginName () const override |
Get the plugin name. More... | |
PacketCounter | pluginPackets () const |
Get total number of packets previously processed in the plugin object. More... | |
virtual void | raiseMaxSeverity (int level) |
Raise maximum severity level. More... | |
bool | realtime () const |
Check if the current plugin environment should use defaults for real-time. More... | |
void | resetErrors () |
Reset the error indicator. More... | |
bool | setAttributes (const ThreadAttributes &attributes) |
Set new attributes to the thread. More... | |
void | setLogName (const UString &name) |
Set the plugin name as displayed in log messages. More... | |
virtual void | setMaxSeverity (int level) |
Set maximum severity level. More... | |
void | setPacketTimeout (MilliSecond timeout) |
Set a timeout for the reception of packets by the current plugin. More... | |
void | setReport (Report *rep) |
Change the report object. More... | |
void | severe (const UChar *fmt, std::initializer_list< ArgMixIn > args) |
Report a severe error message with a printf-like interface. More... | |
void | severe (const UString &fmt, std::initializer_list< ArgMixIn > args) |
Report a severe error message with a printf-like interface. More... | |
void | severe (const UString &msg) |
Report a severe error message. More... | |
virtual void | signalPluginEvent (uint32_t event_code, Object *plugin_data=nullptr) const =0 |
Signal a plugin event. More... | |
bool | start () |
Start the thread. More... | |
virtual bool | thisJointTerminated () const =0 |
Check if the calling plugin has already declared "joint termination". More... | |
PacketCounter | totalPacketsInThread () const |
Get total number of packets in the execution of the plugin thread. More... | |
virtual bool | useJointTermination () const =0 |
Check if the calling plugin uses "joint termination". More... | |
virtual void | useJointTermination (bool on)=0 |
Activates or deactivates "joint termination". More... | |
bool | verbose () const |
Check if verbose reporting is active. More... | |
void | verbose (const UChar *fmt, std::initializer_list< ArgMixIn > args) |
Report a verbose message with a printf-like interface. More... | |
void | verbose (const UString &fmt, std::initializer_list< ArgMixIn > args) |
Report a verbose message with a printf-like interface. More... | |
void | verbose (const UString &msg) |
Report a verbose message. More... | |
bool | waitForTermination () |
Wait for thread termination. More... | |
void | warning (const UChar *fmt, std::initializer_list< ArgMixIn > args) |
Report a warning message with a printf-like interface. More... | |
void | warning (const UString &fmt, std::initializer_list< ArgMixIn > args) |
Report a warning message with a printf-like interface. More... | |
void | warning (const UString &msg) |
Report a warning message. More... | |
Static Public Member Functions | |
static void | Yield () |
Yield execution of the current thread. More... | |
Static Public Attributes | |
static const size_t | STACK_SIZE_OVERHEAD = 32 * 1024 |
Plugin stack size overhead. More... | |
Protected Member Functions | |
void | addNonPluginPackets (size_t incr) |
Account for more processed packets in this plugin thread, but excluded from plugin object. More... | |
void | addPluginPackets (size_t incr) |
Account for more processed packets in this plugin object. More... | |
void | restartPluginSession () |
Restart accounting for plugin session. More... | |
void | setTypeName (const UString &name=UString()) |
Set the type name. More... | |
virtual void | writeLog (int severity, const UString &msg) override |
Actual message reporting method. More... | |
Protected Attributes | |
volatile int | _max_severity |
Debug level is accessible to subclasses. | |
volatile bool | _tsp_aborting |
TSP is currently aborting. | |
BitRate | _tsp_bitrate |
TSP input bitrate. | |
BitRateConfidence | _tsp_bitrate_confidence |
TSP input bitrate confidence. | |
MilliSecond | _tsp_timeout |
Timeout when waiting for packets (infinite by default). | |
bool | _use_realtime |
The plugin should use realtime defaults. | |
Base class for threads executing a tsp plugin.
The subclasses shall implement the TSP interface.
ts::PluginThread::PluginThread | ( | Report * | report, |
const UString & | appName, | ||
PluginType | type, | ||
const PluginOptions & | options, | ||
const ThreadAttributes & | attributes | ||
) |
Constructor.
[in,out] | report | Initial report object. The report object is used to forward messages which are sent to this PluginThread instance (PluginThread is a subclass of Report through TSP). |
[in] | appName | Application name, for help messages. |
[in] | type | Plugin type. |
[in] | options | Command line options for this plugin. |
[in] | attributes | Creation attributes for the thread executing this plugin. |
|
inline |
Change the report object.
[in] | rep | Address of new report instance. |
|
inline |
Set the plugin name as displayed in log messages.
By default, used the real plugin name.
[in] | name | The name to use in log messages. When empty, revert to the real plugin name. |
|
overridevirtual |
Get the plugin name.
Implements ts::TSP.
|
overridevirtual |
Access the shared library through the plugin interface.
Implements ts::TSP.
|
overrideprotectedvirtual |
Actual message reporting method.
Must be implemented in actual classes. The method is called only when a message passed the severity filter. It is not necessary to recheck severity inside the method.
[in] | severity | Message severity. |
[in] | msg | Message text. |
Implements ts::Report.
|
inherited |
Set new attributes to the thread.
New attributes can be set as long as the thread is not started, i.e. as long as start() is not invoked.
[in] | attributes | New attributes to set. |
|
inherited |
Get a copy of the attributes of the thread.
[out] | attributes | Attributes of the thread. |
|
inherited |
Get an implementation-specific name of the object class.
|
inherited |
Start the thread.
The operating system thread is created and started. The code which is executed in the context of this thread is in the method main().
|
inherited |
Wait for thread termination.
The thread which invokes this method is blocked until the execution of this thread object completes.
Only one waiter thread is allowed. If several threads concurrently invoke waitForTermination() on the same Thread object, only the first one will wait. The method waitForTermination() returns an error to all other threads.
This method is automatically invoked in the destructor. Thus, when a Thread object is declared in a control block and the thread has been started, the end of the control block hangs as long as the thread is not terminated. If the thread has not been started, however, the destructor does not wait (otherwise it would hang for ever).
Important: When a subclass of Thread has non-static members, its destructor shall invoke waitForTermination(). Thus, it prevents its members from being destructed until the thread terminates. If the destructor of the subclass does not invoke waitForTermination() and the Thread object goes out of scope before the termination of the thread, the subclass part of the object is destroyed. Any attempt to access non-static members from the main() method in the context of the thread will give unexpected results. Most of the time, this will result in an error similar to "pure virtual method called". To avoid this:
Do not use this method if the thread was created with the delete when terminated flag (ts::ThreadAttributes::setDeleteWhenTerminated).
|
inherited |
Check if the caller is running in the context of this thread.
|
pure virtualinherited |
This hook is invoked in the context of the thread.
Concrete thread classes shall implement this pure virtual method. This method is invoked in the context of the created thread when it is started.
|
staticinherited |
Yield execution of the current thread.
Execution is passed to another thread, if any is waiting for execution. This should not change the behaviour of correctly-written applications.
Set the type name.
[in] | name | The type name to set. If empty, the subclass type name is used. |
|
inlineinherited |
Get the current input bitrate in bits/seconds.
|
inlineinherited |
Get the plugin bitrate confidence.
|
pure virtualinherited |
Get the plugin index in the processing chain.
|
pure virtualinherited |
Get the number of plugins in the processing chain.
|
inlineinherited |
Get total number of packets previously processed in the plugin object.
For input and output plugins, this is the number of successfully read or written packets. For processor plugins, this is the number of packets which were submitted to the plugin object (ie. excluding previously dropped packets but including packets which were dropped by the current plugin).
|
inlineinherited |
Get total number of packets in the execution of the plugin thread.
This includes the number of extra stuffing or dropped packets.
|
inlineinherited |
Check if the current plugin environment should use defaults for real-time.
|
inlineinherited |
Set a timeout for the reception of packets by the current plugin.
For input plugins, this is the timeout for the availability of free space in input buffer.
When the timeout is triggered, the method handlePacketTimeout() is invoked in the plugin. If the method returns true, the application continues waiting for packets. If the method returns false, the plugin is aborted.
[in] | timeout | Maximum number of milliseconds to wait for packets in the buffer. The default timeout is infinite. |
|
overridevirtualinherited |
Check for aborting application.
The plugin may invoke this method to check if the application is aborting for some reason (user interrupt for instance).
Implements ts::AbortInterface.
|
pure virtualinherited |
Signal a plugin event.
If the application has registered plugin events for this kind of events, they will be invoked.
[in] | event_code | A plugin-defined 32-bit code describing the event type. There is no predefined list of event codes. Plugin should define their own codes. |
[in] | plugin_data | Address of optional plugin-specific data. It can be a null pointer. Each plugin may defined subclasses of Object to pass specific data to application handlers which are aware of this plugin. |
|
pure virtualinherited |
Activates or deactivates "joint termination".
This method activates or deactivates "joint termination" for the calling plugin. It should be invoked during the plugin's start().
[in] | on | True to activate or false to deactivate joint termination. |
|
pure virtualinherited |
Check if the calling plugin uses "joint termination".
|
pure virtualinherited |
Signaling "joint termination".
This method is used by the plugin to declare that its execution is potentially terminated in the context of "joint termination". After invoking this method, any packet which is processed by the plugin may be ignored by tsp.
|
pure virtualinherited |
Check if the calling plugin has already declared "joint termination".
|
inlineprotectedinherited |
Account for more processed packets in this plugin object.
[in] | incr | Add this number of processed packets in the plugin object. |
|
inlineprotectedinherited |
Account for more processed packets in this plugin thread, but excluded from plugin object.
[in] | incr | Add this number of processed packets in the plugin thread. |
|
inlineprotectedinherited |
Restart accounting for plugin session.
Typically invoked when the plugin is restarted.
|
virtualinherited |
Set maximum severity level.
Messages with higher severities are not reported.
[in] | level | Set report to that level. |
Reimplemented in ts::ReportWithPrefix.
|
virtualinherited |
Raise maximum severity level.
[in] | level | Set report at least to that level. |
Reimplemented in ts::Args.
|
inlineinherited |
Get maximum severity level.
|
inlineinherited |
Check if debugging is active.
|
inlineinherited |
Report a debug message.
[in] | msg | Message text. |
|
inlineinherited |
Report a debug message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a debug message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Check if verbose reporting is active.
|
inlineinherited |
Report a verbose message.
[in] | msg | Message text. |
|
inlineinherited |
Report a verbose message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a verbose message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
virtualinherited |
Report a message with an explicit severity.
This method is the central reporting point. If filters the severity and drops the message if severity is higher than maxSeverity().
Subclasses should override writeLog() to implement a specific reporting device. It is not necessary to override log() unless the subclass needs to implement a different severity filtering policy.
[in] | severity | Message severity. |
[in] | msg | Message text. |
|
virtualinherited |
Report a message with an explicit severity and a printf-like interface.
[in] | severity | Message severity. |
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
virtualinherited |
Report a message with an explicit severity and a printf-like interface.
[in] | severity | Message severity. |
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a fatal error message.
[in] | msg | Message text. |
|
inlineinherited |
Report a fatal error message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a fatal error message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a severe error message.
[in] | msg | Message text. |
|
inlineinherited |
Report a severe error message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a severe error message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report an error message.
[in] | msg | Message text. |
|
inlineinherited |
Report an error message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report an error message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a warning message.
[in] | msg | Message text. |
|
inlineinherited |
Report a warning message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a warning message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report an informational message.
[in] | msg | Message text. |
Report an informational message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report an informational message with a printf-like interface.
[in] | fmt | Format string with embedded '%' sequences. |
[in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Check if errors (or worse) were reported through this object.
|
inlineinherited |
Reset the error indicator.
|
static |
Plugin stack size overhead.
Each plugin defines its own usage of the stack. The PluginThread class and its subclasses have their own additional stack usage.