mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
hlsdemux: Update to non-deprecated GLib thread API
This commit is contained in:
parent
e8befb7ce3
commit
6abed8da20
4 changed files with 15 additions and 24 deletions
|
@ -41,12 +41,7 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
|
|
||||||
* with newer GLib versions (>= 2.31.0) */
|
|
||||||
#define GLIB_DISABLE_DEPRECATION_WARNINGS
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gst/glib-compat-private.h>
|
|
||||||
#include <gcrypt.h>
|
#include <gcrypt.h>
|
||||||
#include "gsthlsdemux.h"
|
#include "gsthlsdemux.h"
|
||||||
|
|
||||||
|
@ -879,8 +874,8 @@ gst_hls_demux_updates_loop (GstHLSDemux * demux)
|
||||||
|
|
||||||
/* block until the next scheduled update or the signal to quit this thread */
|
/* block until the next scheduled update or the signal to quit this thread */
|
||||||
GST_DEBUG_OBJECT (demux, "Waiting");
|
GST_DEBUG_OBJECT (demux, "Waiting");
|
||||||
if (g_cond_timed_wait (GST_TASK_GET_COND (demux->updates_task),
|
if (g_cond_wait_until (GST_TASK_GET_COND (demux->updates_task),
|
||||||
&demux->updates_timed_lock, &demux->next_update)) {
|
&demux->updates_timed_lock, demux->next_update)) {
|
||||||
GST_DEBUG_OBJECT (demux, "Unlocked");
|
GST_DEBUG_OBJECT (demux, "Unlocked");
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
|
@ -1009,7 +1004,7 @@ gst_hls_demux_cache_fragments (GstHLSDemux * demux)
|
||||||
gst_element_post_message (GST_ELEMENT (demux),
|
gst_element_post_message (GST_ELEMENT (demux),
|
||||||
gst_message_new_buffering (GST_OBJECT (demux),
|
gst_message_new_buffering (GST_OBJECT (demux),
|
||||||
100 * i / demux->fragments_cache));
|
100 * i / demux->fragments_cache));
|
||||||
g_get_current_time (&demux->next_update);
|
demux->next_update = g_get_monotonic_time ();
|
||||||
if (!gst_hls_demux_get_next_fragment (demux, TRUE)) {
|
if (!gst_hls_demux_get_next_fragment (demux, TRUE)) {
|
||||||
if (demux->end_of_playlist)
|
if (demux->end_of_playlist)
|
||||||
break;
|
break;
|
||||||
|
@ -1025,7 +1020,7 @@ gst_hls_demux_cache_fragments (GstHLSDemux * demux)
|
||||||
gst_element_post_message (GST_ELEMENT (demux),
|
gst_element_post_message (GST_ELEMENT (demux),
|
||||||
gst_message_new_buffering (GST_OBJECT (demux), 100));
|
gst_message_new_buffering (GST_OBJECT (demux), 100));
|
||||||
|
|
||||||
g_get_current_time (&demux->next_update);
|
demux->next_update = g_get_monotonic_time ();
|
||||||
|
|
||||||
demux->need_cache = FALSE;
|
demux->need_cache = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1197,11 +1192,10 @@ gst_hls_demux_schedule (GstHLSDemux * demux)
|
||||||
|
|
||||||
/* schedule the next update using the target duration field of the
|
/* schedule the next update using the target duration field of the
|
||||||
* playlist */
|
* playlist */
|
||||||
g_time_val_add (&demux->next_update,
|
demux->next_update += gst_m3u8_client_get_target_duration (demux->client)
|
||||||
gst_m3u8_client_get_target_duration (demux->client)
|
/ GST_SECOND * G_USEC_PER_SEC * update_factor;
|
||||||
/ GST_SECOND * G_USEC_PER_SEC * update_factor);
|
GST_DEBUG_OBJECT (demux, "Next update scheduled at %" G_GINT64_FORMAT,
|
||||||
GST_DEBUG_OBJECT (demux, "Next update scheduled at %s",
|
demux->next_update);
|
||||||
g_time_val_to_iso8601 (&demux->next_update));
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1209,7 +1203,6 @@ gst_hls_demux_schedule (GstHLSDemux * demux)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_hls_demux_switch_playlist (GstHLSDemux * demux)
|
gst_hls_demux_switch_playlist (GstHLSDemux * demux)
|
||||||
{
|
{
|
||||||
GTimeVal now;
|
|
||||||
GstClockTime diff;
|
GstClockTime diff;
|
||||||
gsize size;
|
gsize size;
|
||||||
gint bitrate;
|
gint bitrate;
|
||||||
|
@ -1226,8 +1219,7 @@ gst_hls_demux_switch_playlist (GstHLSDemux * demux)
|
||||||
|
|
||||||
/* compare the time when the fragment was downloaded with the time when it was
|
/* compare the time when the fragment was downloaded with the time when it was
|
||||||
* scheduled */
|
* scheduled */
|
||||||
g_get_current_time (&now);
|
diff = g_get_monotonic_time () - demux->next_update;
|
||||||
diff = (GST_TIMEVAL_TO_TIME (now) - GST_TIMEVAL_TO_TIME (demux->next_update));
|
|
||||||
buffer = gst_fragment_get_buffer (fragment);
|
buffer = gst_fragment_get_buffer (fragment);
|
||||||
size = gst_buffer_get_size (buffer);
|
size = gst_buffer_get_size (buffer);
|
||||||
bitrate = (size * 8) / ((double) diff / GST_SECOND);
|
bitrate = (size * 8) / ((double) diff / GST_SECOND);
|
||||||
|
|
|
@ -84,7 +84,7 @@ struct _GstHLSDemux
|
||||||
GstTask *updates_task;
|
GstTask *updates_task;
|
||||||
GRecMutex updates_lock;
|
GRecMutex updates_lock;
|
||||||
GMutex updates_timed_lock;
|
GMutex updates_timed_lock;
|
||||||
GTimeVal next_update; /* Time of the next update */
|
gint64 next_update; /* Time of the next update */
|
||||||
gboolean cancelled;
|
gboolean cancelled;
|
||||||
|
|
||||||
/* Position in the stream */
|
/* Position in the stream */
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <gst/glib-compat-private.h>
|
|
||||||
#include "gstfragmented.h"
|
#include "gstfragmented.h"
|
||||||
#include "m3u8.h"
|
#include "m3u8.h"
|
||||||
|
|
||||||
|
@ -440,7 +439,7 @@ gst_m3u8_client_new (const gchar * uri)
|
||||||
client->current = NULL;
|
client->current = NULL;
|
||||||
client->sequence = -1;
|
client->sequence = -1;
|
||||||
client->update_failed_count = 0;
|
client->update_failed_count = 0;
|
||||||
client->lock = g_mutex_new ();
|
g_mutex_init (&client->lock);
|
||||||
gst_m3u8_set_uri (client->main, g_strdup (uri));
|
gst_m3u8_set_uri (client->main, g_strdup (uri));
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
|
@ -452,7 +451,7 @@ gst_m3u8_client_free (GstM3U8Client * self)
|
||||||
g_return_if_fail (self != NULL);
|
g_return_if_fail (self != NULL);
|
||||||
|
|
||||||
gst_m3u8_free (self->main);
|
gst_m3u8_free (self->main);
|
||||||
g_mutex_free (self->lock);
|
g_mutex_clear (&self->lock);
|
||||||
g_free (self);
|
g_free (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ typedef struct _GstM3U8Client GstM3U8Client;
|
||||||
#define GST_M3U8(m) ((GstM3U8*)m)
|
#define GST_M3U8(m) ((GstM3U8*)m)
|
||||||
#define GST_M3U8_MEDIA_FILE(f) ((GstM3U8MediaFile*)f)
|
#define GST_M3U8_MEDIA_FILE(f) ((GstM3U8MediaFile*)f)
|
||||||
|
|
||||||
#define GST_M3U8_CLIENT_LOCK(c) g_mutex_lock (c->lock);
|
#define GST_M3U8_CLIENT_LOCK(c) g_mutex_lock (&c->lock);
|
||||||
#define GST_M3U8_CLIENT_UNLOCK(c) g_mutex_unlock (c->lock);
|
#define GST_M3U8_CLIENT_UNLOCK(c) g_mutex_unlock (&c->lock);
|
||||||
|
|
||||||
struct _GstM3U8
|
struct _GstM3U8
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ struct _GstM3U8Client
|
||||||
GstM3U8 *current;
|
GstM3U8 *current;
|
||||||
guint update_failed_count;
|
guint update_failed_count;
|
||||||
gint sequence; /* the next sequence for this client */
|
gint sequence; /* the next sequence for this client */
|
||||||
GMutex *lock;
|
GMutex lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue