mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 00:06:36 +00:00
adaptivedemux2: Add most recent data time and offset helper
Add a field to the DownloadRequest that reports the most recent time at which data arrived. Update it in the DownloadHelper. Add a method to retrieve the GST_BUFFER_OFFSET() for the DownloadRequest's data buffer (if any). Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
This commit is contained in:
parent
40938c8853
commit
5192181ef5
3 changed files with 26 additions and 7 deletions
|
@ -309,19 +309,20 @@ on_read_ready (GObject * source, GAsyncResult * result, gpointer user_data)
|
|||
}
|
||||
}
|
||||
|
||||
if (request->download_start_time == GST_CLOCK_TIME_NONE) {
|
||||
GST_LOG ("Got first data for URI %s", request->uri);
|
||||
request->download_start_time = now;
|
||||
}
|
||||
|
||||
if (gst_buffer != NULL) {
|
||||
/* Unsent means cancellation is in progress, so don't override
|
||||
* the state. Otherwise make sure it is LOADING */
|
||||
if (request->state != DOWNLOAD_REQUEST_STATE_UNSENT)
|
||||
request->state = DOWNLOAD_REQUEST_STATE_LOADING;
|
||||
|
||||
GST_LOG ("Adding %u bytes to buffer",
|
||||
(guint) (gst_buffer_get_size (gst_buffer)));
|
||||
if (request->download_start_time == GST_CLOCK_TIME_NONE) {
|
||||
GST_LOG ("Got first data for URI %s", request->uri);
|
||||
request->download_start_time = now;
|
||||
}
|
||||
request->download_newest_data_time = now;
|
||||
|
||||
GST_LOG ("Adding %u bytes to buffer (request URI %s)",
|
||||
(guint) (gst_buffer_get_size (gst_buffer)), request->uri);
|
||||
|
||||
download_request_add_buffer (request, gst_buffer);
|
||||
|
||||
|
|
|
@ -328,6 +328,22 @@ download_request_get_bytes_available (DownloadRequest * request)
|
|||
return ret;
|
||||
}
|
||||
|
||||
guint64
|
||||
download_request_get_cur_offset (DownloadRequest * request)
|
||||
{
|
||||
DownloadRequestPrivate *priv = DOWNLOAD_REQUEST_PRIVATE (request);
|
||||
guint64 ret = GST_BUFFER_OFFSET_NONE;
|
||||
|
||||
g_rec_mutex_lock (&priv->lock);
|
||||
|
||||
if (priv->buffer != NULL)
|
||||
ret = GST_BUFFER_OFFSET (priv->buffer);
|
||||
|
||||
g_rec_mutex_unlock (&priv->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
download_request_set_uri (DownloadRequest * request, const gchar * uri,
|
||||
gint64 range_start, gint64 range_end)
|
||||
|
|
|
@ -68,6 +68,7 @@ struct _DownloadRequest
|
|||
|
||||
guint64 download_request_time; /* Epoch time when the download started */
|
||||
guint64 download_start_time; /* Epoch time when the first data for the download arrived */
|
||||
guint64 download_newest_data_time; /* Epoch time when the most recent data for the download arrived */
|
||||
guint64 download_end_time; /* Epoch time when the download finished */
|
||||
};
|
||||
|
||||
|
@ -87,6 +88,7 @@ void download_request_add_buffer (DownloadRequest *request, GstBuffer *buffer);
|
|||
GstBuffer * download_request_take_buffer (DownloadRequest *request);
|
||||
GstBuffer * download_request_take_buffer_range (DownloadRequest *request, gint64 range_start, gint64 range_end);
|
||||
guint64 download_request_get_bytes_available (DownloadRequest *request);
|
||||
guint64 download_request_get_cur_offset (DownloadRequest *request);
|
||||
|
||||
DownloadRequest * download_request_new (void);
|
||||
DownloadRequest * download_request_new_uri (const gchar * uri);
|
||||
|
|
Loading…
Reference in a new issue