Ticker API to manage mediastreamer2 graphs.
More...
|
MSTicker * | ms_ticker_new (void) |
|
MSTicker * | ms_ticker_new_with_params (const MSTickerParams *params) |
|
void | ms_ticker_set_name (MSTicker *ticker, const char *name) |
|
void | ms_ticker_set_priority (MSTicker *ticker, MSTickerPrio prio) |
|
int | ms_ticker_attach (MSTicker *ticker, MSFilter *f) |
|
int | ms_ticker_attach_multiple (MSTicker *ticker, MSFilter *f,...) |
|
int | ms_ticker_detach (MSTicker *ticker, MSFilter *f) |
|
void | ms_ticker_destroy (MSTicker *ticker) |
|
void | ms_ticker_set_time_func (MSTicker *ticker, MSTickerTimeFunc func, void *user_data) |
|
void | ms_ticker_set_tick_func (MSTicker *ticker, MSTickerTickFunc func, void *user_data) |
|
void | ms_ticker_print_graphs (MSTicker *ticker) |
|
float | ms_ticker_get_average_load (MSTicker *ticker) |
|
void | ms_ticker_get_last_late_tick (MSTicker *ticker, MSTickerLateEvent *ev) |
|
uint64_t | ms_ticker_round (uint64_t ms) |
|
void | ms_ticker_set_synchronizer (MSTicker *ticker, MSTickerSynchronizer *ts) |
|
MSTickerSynchronizer * | ms_ticker_synchronizer_new (void) |
|
double | ms_ticker_synchronizer_set_external_time (MSTickerSynchronizer *ts, const MSTimeSpec *time) |
|
double | ms_ticker_synchronizer_update (MSTickerSynchronizer *ts, uint64_t nb_samples, unsigned int sample_rate) |
|
uint64_t | ms_ticker_synchronizer_get_corrected_time (MSTickerSynchronizer *ts) |
|
void | ms_ticker_synchronizer_resync (MSTickerSynchronizer *ts) |
|
void | ms_ticker_synchronizer_destroy (MSTickerSynchronizer *ts) |
|
Ticker API to manage mediastreamer2 graphs.
Describes the ticker API. The ticker is the thread responsible for scheduling audio & video processing for one or several filter graphs.
◆ MSTicker
Structure for ticker object.
◆ MSTickerSynchronizer
Structure for ticker synchronizer object.
◆ MSTickerTickFunc
Function pointer for method waiting next tick from an external source.
It shall return the number of late milliseconds, if this value is known.
◆ MSTickerTimeFunc
Function pointer for method getting time in miliseconds from an external source.
◆ _MSTickerPrio
Enum for ticker priority
Enumerator |
---|
MS_TICKER_PRIO_NORMAL | the default OS priority for threads
|
MS_TICKER_PRIO_HIGH | Increased priority: done by setpriority() or sched_setschedparams() with SCHED_RR on linux/MacOS
|
MS_TICKER_PRIO_REALTIME | Topmost priority, running SCHED_FIFO on linux
|
◆ ms_ticker_attach()
Attach a chain of filters to a ticker. The processing chain will be executed until ms_ticker_detach will be called.
- Parameters
-
Returns: 0 if successfull, -1 otherwise.
◆ ms_ticker_attach_multiple()
Attach a chain of filters to a ticker. The processing chain will be executed until ms_ticker_detach will be called. This variadic can be used to attach multiple chains in a single call. The argument list MUST be NULL terminated.
- Parameters
-
Returns: 0 if successfull, -1 otherwise.
◆ ms_ticker_destroy()
void ms_ticker_destroy |
( |
MSTicker * |
ticker | ) |
|
Destroy a ticker.
- Parameters
-
◆ ms_ticker_detach()
Dettach a chain of filters to a ticker. The processing chain will no more be executed.
- Parameters
-
Returns: 0 if successfull, -1 otherwise.
◆ ms_ticker_get_average_load()
float ms_ticker_get_average_load |
( |
MSTicker * |
ticker | ) |
|
Get the average load of the ticker. It is expressed as the ratio between real time spent in processing all graphs for a tick divided by the tick interval (default is 10 ms). This value is averaged over several ticks to get consistent and useful value. A load greater than 100% clearly means that the ticker is over loaded and runs late.
◆ ms_ticker_get_last_late_tick()
Get last late tick event description.
- Parameters
-
ticker | the MSTicker |
ev | a MSTickerLaterEvent structure that will be filled in return by the ticker. |
◆ ms_ticker_new()
Create a ticker that will be used to start and stop a graph.
Returns: MSTicker * if successfull, NULL otherwise.
◆ ms_ticker_new_with_params()
Create a ticker that will be used to start and stop a graph.
Returns: MSTicker * if successfull, NULL otherwise.
◆ ms_ticker_print_graphs()
void ms_ticker_print_graphs |
( |
MSTicker * |
ticker | ) |
|
Print on stdout all filters of a ticker. (INTERNAL: DO NOT USE)
- Parameters
-
◆ ms_ticker_round()
uint64_t ms_ticker_round |
( |
uint64_t |
ms | ) |
|
Round a time in milliseconds to the internal ticker interval.
- Parameters
-
[in] | ms | The time in milliseconds to round |
- Returns
- The rounded time in milliseconds
◆ ms_ticker_set_name()
void ms_ticker_set_name |
( |
MSTicker * |
ticker, |
|
|
const char * |
name |
|
) |
| |
Set a name to the ticker (used for logging)
◆ ms_ticker_set_priority()
void ms_ticker_set_priority |
( |
MSTicker * |
ticker, |
|
|
MSTickerPrio |
prio |
|
) |
| |
Deprecated: Set priority to the ticker
◆ ms_ticker_set_synchronizer()
Set the MSTickerSynchronizer for a MSTicker.
- Parameters
-
ticker | A MSTicker object to synchronize |
ts | A MSTickerSynchronizer to use for synchronization of the ticker |
◆ ms_ticker_set_tick_func()
Override MSTicker's ticking function. This can be used to control the ticker from an external ticking source, for example an interrupt, an event on a file descriptor, etc. WARNING: this must not be used in conjunction with ms_ticker_set_time_func().
- Parameters
-
ticker | A MSTicker object. |
func | A replacement method waiting the next tick. |
user_data | Any pointer to user private data. |
◆ ms_ticker_set_time_func()
Override MSTicker's time function. This can be used to control the ticker from an external time provider, for example the clock of a sound card. WARNING: this must not be used in conjunction with ms_ticker_set_tick_func().
- Parameters
-
ticker | A MSTicker object. |
func | A replacement method for calculating "current time" |
user_data | Any pointer to user private data. |
◆ ms_ticker_synchronizer_destroy()
Destroy a ticker synchronizer.
- Parameters
-
◆ ms_ticker_synchronizer_get_corrected_time()
Get the corrected current time following the set external times.
- Parameters
-
- Returns
- A corrected current time.
◆ ms_ticker_synchronizer_new()
Create a ticker synchronizer.
- Returns
- MSTickerSynchronizer object if successfull, NULL otherwise.
◆ ms_ticker_synchronizer_resync()
Ask the ticker synchronizer to resynchronize. Use this when you are aware of an overrun/underrun and you think that the next update will report an errouneous sample count.
- Parameters
-
- Returns
- A corrected current time.
◆ ms_ticker_synchronizer_set_external_time()
double ms_ticker_synchronizer_set_external_time |
( |
MSTickerSynchronizer * |
ts, |
|
|
const MSTimeSpec * |
time |
|
) |
| |
Set the current external time.
- Parameters
-
- Returns
- Average skew.
◆ ms_ticker_synchronizer_update()
double ms_ticker_synchronizer_update |
( |
MSTickerSynchronizer * |
ts, |
|
|
uint64_t |
nb_samples, |
|
|
unsigned int |
sample_rate |
|
) |
| |
Update the ticker synchronizer state
- Parameters
-
ts | A MSTickerSynchronizer object |
nb_samples | The number of samples since the processing started |
sample_rate | The sample rate of the stream |