Implement new dsl_pipeline_buffering_message_handler_add/remove services
rjhowell44 opened this issue · 0 comments
When using non-live streaming sources, the application needs to be notified of buffering-messages received on the bus. See the GStreamer stream-buffering for complete information.
A new callback typedef and callback add/remove services will be added to the Pipeline API.
Once the callback is added to the Pipeline and dsl_pipeline_play is called, the bus-watch manager will call the callback each time a buffering message is received. The application should Pause the Pipeline (if playing) when a buffering message with percent < 100% is received and resume playback once a message with percent == 100% is received.
Using Python for example.
Python example of callback to pause/play on buffering start/stop
##
# Function to be called when a buffering-message is received on the Pipeline bus.
##
def buffering_message_handler(source, percent, client_data):
global buffering
if percent == 100:
print('playing pipeline - buffering complete at 100 % for Source', source)
dsl_pipeline_play('pipeline')
buffering = False
else:
if not buffering:
print('pausing pipeline - buffering starting at ', percent,
'% for Source', source)
dsl_pipeline_pause('pipeline')
buffering = True
New callback typedef
/**
* @brief callback typedef for a client listener function. Once added to a Pipeline,
* the function will be called on receipt of a buffering message on the Pipeline bus.
* @param[in] source name of the element or component that is the source of the message
* @param[in] percent buffering. 100% means buffering is done.
* @param[in] client_data opaque pointer to client's data
*/
typedef void (*dsl_buffering_message_handler_cb)(const wchar_t* source,
uint percent, void* client_data);
New add/remove handler services
/**
* @brief Adds a callback to be notified when a buffering message is received by
* the Pipeline's bus-watcher. The callback is called from the mainloop context
* allowing clients to Pause non-live Pipelines while buffering.
* @param[in] name name of the pipeline to update
* @param[in] handler pointer to the client's callback function to add
* @param[in] client_data opaque pointer to client data passed back to the
* handler function.
* @return DSL_RESULT_SUCCESS on success, DSL_RESULT_PIPELINE_RESULT on failure.
*/
DslReturnType dsl_pipeline_buffering_message_handler_add(const wchar_t* name,
dsl_buffering_message_handler_cb handler, void* client_data);
/**
* @brief Removes a callback previously added with
* dsl_pipeline_buffering_message_handler_add
* @param[in] name name of the pipeline to update
* @param[in] handler pointer to the client's callback function to remove
* @return DSL_RESULT_SUCCESS on success, DSL_RESULT_PIPELINE_RESULT on failure.
*/
DslReturnType dsl_pipeline_buffering_message_handler_remove(const wchar_t* name,
dsl_buffering_message_handler_cb handler);