The goal of the setPosition() API is to abort the current data being streamed, flush the AV data pipeline and begin streaming from the specified target position as quickly as possible. Note that Rialto's client may call setPosition() whilst a previous seek is in progress and must handle this gracefully, flushing the pipelines and rendering AV from the most recently requested position as soon as possible.
Note that setPosition() may be called by a client before the call to play() to set the start position of playback (default is 0) but this should be processed in the same way.
setPosition() can be used only in Rialto C++ interface. Rialto GStreamer uses setSourcePosition for seeking.
@startuml autonumber box "Container" #LightGreen participant GStreamer_client participant rialtoClient end box box "Platform" #LightBlue participant rialtoServer participant GStreamer_server end box note over Cobalt, GStreamer_client The Rialto's client should abort any pending needData() requests before calling setPosition and ignore any needData() requests received before the SEEK_DONE event as they will be stale. ** TODO - document this in the API header file ** end note GStreamer_client -> rialtoClient: setPosition(pipeline_session, position) rialtoClient -> rialtoClient: clear local cache of any active data requests for pipeline session rialtoClient -> rialtoServer: setPosition(pipeline_session, position) rialtoServer -/ rialtoClient: notifyPlaybackState(pipeline_session, PLAYBACK_STATE_SEEKING) rialtoClient -/ GStreamer_client: notifyPlaybackState(pipeline_session, PLAYBACK_STATE_SEEKING) rialtoServer -> rialtoServer: store position as "target position" for sample fulfilment algorithm rialtoServer -> rialtoServer: stop sending new need data requests rialtoServer -> rialtoServer: clear local cache of any active data requests for pipeline session rialtoServer -> rialtoServer: clear buffered samples for pipeline session rialtoServer -> GStreamer_server: gst_element_seek(pipeline, position, GST_SEEK_FLAG_FLUSH) note left Use of the FLUSH flag ensures the pipeline is flushed when call returns **TODO - is this correct or do we need** **to wait for ASYNC_DONE** end note GStreamer_server --> rialtoServer: rialtoServer --> rialtoClient: rialtoClient --> GStreamer_client: opt Seek initiated successfully rialtoServer -/ rialtoClient: notifyPlaybackState(pipeline_session, PLAYBACK_STATE_SEEK_DONE) rialtoClient -/ GStreamer_client: notifyPlaybackState(pipeline_session, PLAYBACK_STATE_SEEK_DONE) else Error initiating seek rialtoServer -/ rialtoClient: notifyPlaybackState(pipeline_session, PLAYBACK_STATE_FAILURE) rialtoClient -/ GStreamer_client: notifyPlaybackState(pipeline_session, PLAYBACK_STATE_FAILURE) end rialtoServer -> rialtoServer: trigger need data for all attached sources ref over GStreamer_client, rialtoServer Start requesting samples as for regular playback end ref @enduml |
@startuml autonumber box "Container" #LightGreen participant Application participant GStreamer_client participant rialtoClient end box box "Platform" #LightBlue participant rialtoServer participant GStreamer_server end box Application -> GStreamer_client: gst_element_send_event(sink, gst_event_new_segment(position)) GStreamer_client --> Application: GStreamer_client -> rialtoClient: setSourcePosition(sourceId, position) rialtoClient -> rialtoServer: setSourcePosition(sourceId, position) rialtoServer -> GStreamer_server: gst_segment_new() GStreamer_server --> rialtoServer: segment rialtoServer -> GStreamer_server: gst_segment_init(segment, GST_FORMAT_TIME) GStreamer_server --> rialtoServer: rialtoServer -> GStreamer_server: gst_segment_do_seek(segment, current_playback_rate, position) GStreamer_server --> rialtoServer: rialtoServer -> GStreamer_server: gst_base_src_new_segment(source, segment) GStreamer_server --> rialtoServer: rialtoServer -> GStreamer_server: gst_segment_free(segment) GStreamer_server --> rialtoServer: rialtoServer -> rialtoServer: Erase EOS info rialtoServer -> rialtoServer: Trigger NeedData for source rialtoServer --> rialtoClient: rialtoClient --> GStreamer_client: @enduml |
@startuml autonumber box "Container" #LightGreen participant Application participant GStreamer_client participant rialtoClient end box box "Platform" #LightBlue participant rialtoServer participant GStreamer_server end box note over GStreamer_client The Rialto's client should abort any pending needData() requests before calling flush and ignore any needData() requests received before the sourceFlushed event as they will be stale. ** TODO - document this in the API header file ** end note Application -> GStreamer_client: gst_element_send_event(sink, gst_event_new_flush_start()) GStreamer_client --> Application: Application -> GStreamer_client: gst_element_send_event(sink, gst_event_new_flush_stop(resetTime)) GStreamer_client -> rialtoClient: flush(sourceId, resetTime) rialtoClient -> rialtoClient: clear local cache of any active data requests for flushed source rialtoClient -> rialtoServer: flush(sourceId, resetTime) rialtoServer -> rialtoServer: stop sending new need data requests for flushed source rialtoServer -> rialtoServer: clear local cache of any active data requests for flushed source rialtoServer -> rialtoServer: clear buffered samples for flushed source rialtoServer -> GStreamer_server: gst_element_send_event(source, gst_event_new_flush_start()) GStreamer_server --> rialtoServer: rialtoServer -> GStreamer_server: gst_element_send_event(source, gst_event_new_flush_stop(resetTime)) GStreamer_server --> rialtoServer: rialtoServer -> rialtoServer: Erase EOS info rialtoServer --> rialtoClient: rialtoClient --> GStreamer_client: GStreamer_client --> Application: rialtoServer -/ rialtoClient: notifySourceFlushed(sourceId) rialtoClient -/ GStreamer_client: notifySourceFlushed(sourceId) ref over GStreamer_client, rialtoServer Start requesting samples as for regular playback end ref @enduml |