Commit 29c4e5ce authored by Ignacy Ruksza's avatar Ignacy Ruksza
Browse files

Playlists emitting functionality added.

parent c0afe655
Pipeline #261071 waiting for manual action with stages
in 39 seconds
......@@ -24573,9 +24573,55 @@
"presence": "sometimes"
}
},
"properties": {},
"properties": {
"emit-master": {
"blurb": "Emit signal when master playlist is updated",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "false",
"mutable": "null",
"readable": true,
"type": "gboolean",
"writable": true
},
"emit-variant": {
"blurb": "Emit signal when variant playlist is updated",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "false",
"mutable": "null",
"readable": true,
"type": "gboolean",
"writable": true
}
},
"rank": "primary",
"signals": {}
"signals": {
"master-playlist-updated": {
"args": [
{
"name": "arg0",
"type": "gchararray"
}
],
"return-type": "void",
"when": "last"
},
"variant-playlist-updated": {
"args": [
{
"name": "arg0",
"type": "gchararray"
}
],
"return-type": "void",
"when": "last"
}
}
},
"hlssink": {
"author": "Alessandro Decina <alessandro.d@gmail.com>",
......@@ -45,6 +45,23 @@
#include <gst/base/gsttypefindhelper.h>
#include "gsthlsdemux.h"
enum
{
PROP_0,
PROP_EMIT_MASTER_PLAYLIST,
PROP_EMIT_VARIANT_PLAYLIST,
};
enum
{
SIGNAL_0,
MASTER_PLAYLIST_UPDATED_SIGNAL,
VARIANT_PLAYLIST_UPDATED_SIGNAL,
LAST_SIGNAL
};
static guint gst_hls_demux_signals[LAST_SIGNAL] = { 0 };
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
......@@ -63,6 +80,12 @@ GST_DEBUG_CATEGORY (gst_hls_demux_debug);
/* GObject */
static void gst_hls_demux_finalize (GObject * obj);
static void
gst_hls_demux_set_property (GObject * obj, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void
gst_hls_demux_get_property (GObject * obj, guint prop_id,
GValue * value, GParamSpec * pspec);
/* GstElement */
static GstStateChangeReturn
......@@ -120,6 +143,16 @@ static void gst_hls_demux_set_current_variant (GstHLSDemux * hlsdemux,
#define gst_hls_demux_parent_class parent_class
G_DEFINE_TYPE (GstHLSDemux, gst_hls_demux, GST_TYPE_ADAPTIVE_DEMUX);
static void
gst_hls_demux_dispose (GObject * obj)
{
GstHLSDemux *demux = GST_HLS_DEMUX (obj);
if (demux->master_raw)
g_free (demux->master_raw);
if (demux->variant_raw)
g_free (demux->variant_raw);
}
static void
gst_hls_demux_finalize (GObject * obj)
{
......@@ -146,7 +179,62 @@ gst_hls_demux_class_init (GstHLSDemuxClass * klass)
element_class = (GstElementClass *) klass;
adaptivedemux_class = (GstAdaptiveDemuxClass *) klass;
gobject_class->dispose = gst_hls_demux_dispose;
gobject_class->finalize = gst_hls_demux_finalize;
gobject_class->set_property = gst_hls_demux_set_property;
gobject_class->get_property = gst_hls_demux_get_property;
/**
* GstHLSDemux:emit-master:
*
* Enable signal #GstHLSDemux::master-playlist-updated for
* retreiving master plalist raw content.
*
* Since: 1.18
*/
g_object_class_install_property (gobject_class, PROP_EMIT_MASTER_PLAYLIST,
g_param_spec_boolean ("emit-master", "Emit master playlist",
"Emit signal when master playlist is updated", FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstHLSDemux:emit-variant:
*
* Enable signal #GstHLSDemux::variant-playlist-updated for
* retreiving variant plalist raw content.
*
* Since: 1.18
*/
g_object_class_install_property (gobject_class, PROP_EMIT_VARIANT_PLAYLIST,
g_param_spec_boolean ("emit-variant", "Emit variant playlist",
"Emit signal when variant playlist is updated", FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstHLSDemux::master-playlist-updated:
* @demux: the #GstHLSDemux
* @data: Master playlist content
*
* Provides raw content of the current master playlist.
*
* Since: 1.18
*/
gst_hls_demux_signals[MASTER_PLAYLIST_UPDATED_SIGNAL] =
g_signal_new ("master-playlist-updated", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING);
/**
* GstHLSDemux::variant-playlist-updated:
* @demux: the #GstHLSDemux
* @data: Variant playlist content
*
* Provides raw content of the current variant playlist.
*
* Since: 1.18
*/
gst_hls_demux_signals[VARIANT_PLAYLIST_UPDATED_SIGNAL] =
g_signal_new ("variant-playlist-updated", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING);
element_class->change_state = GST_DEBUG_FUNCPTR (gst_hls_demux_change_state);
......@@ -194,6 +282,12 @@ gst_hls_demux_init (GstHLSDemux * demux)
demux->keys = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
g_mutex_init (&demux->keys_lock);
demux->master_raw = NULL;
demux->variant_raw = NULL;
demux->master_playlist_emit = FALSE;
demux->variant_playlist_emit = FALSE;
}
static GstStateChangeReturn
......@@ -223,6 +317,44 @@ gst_hls_demux_change_state (GstElement * element, GstStateChange transition)
return ret;
}
static void
gst_hls_demux_set_property (GObject * obj, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstHLSDemux *demux = GST_HLS_DEMUX (obj);
switch (prop_id) {
case PROP_EMIT_MASTER_PLAYLIST:
demux->master_playlist_emit = g_value_get_boolean (value);
break;
case PROP_EMIT_VARIANT_PLAYLIST:
demux->variant_playlist_emit = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
}
}
static void
gst_hls_demux_get_property (GObject * obj, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstHLSDemux *demux = GST_HLS_DEMUX (obj);
switch (prop_id) {
case PROP_EMIT_MASTER_PLAYLIST:
g_value_set_boolean (value, demux->master_playlist_emit);
break;
case PROP_EMIT_VARIANT_PLAYLIST:
g_value_set_boolean (value, demux->variant_playlist_emit);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
}
}
static GstPad *
gst_hls_demux_create_pad (GstHLSDemux * hlsdemux)
{
......@@ -619,6 +751,10 @@ gst_hls_demux_process_manifest (GstAdaptiveDemux * demux, GstBuffer * buf)
return FALSE;
}
if (hlsdemux->master_raw)
g_free (hlsdemux->master_raw);
hlsdemux->master_raw = g_strdup (playlist);
GST_M3U8_CLIENT_LOCK (self);
hlsdemux->master = gst_hls_master_playlist_new_from_data (playlist,
gst_adaptive_demux_get_manifest_ref_uri (demux));
......@@ -657,7 +793,20 @@ gst_hls_demux_process_manifest (GstAdaptiveDemux * demux, GstBuffer * buf)
GST_M3U8_CLIENT_UNLOCK (self);
return FALSE;
}
if (hlsdemux->master_playlist_emit)
g_signal_emit (hlsdemux,
gst_hls_demux_signals[MASTER_PLAYLIST_UPDATED_SIGNAL], 0,
hlsdemux->master_raw);
} else {
hlsdemux->variant_raw = hlsdemux->master_raw;
hlsdemux->master_raw = NULL;
if (hlsdemux->variant_playlist_emit)
g_signal_emit (hlsdemux,
gst_hls_demux_signals[VARIANT_PLAYLIST_UPDATED_SIGNAL], 0,
hlsdemux->variant_raw);
}
GST_M3U8_CLIENT_UNLOCK (self);
return gst_hls_demux_setup_streams (demux);
......@@ -1482,6 +1631,10 @@ retry:
return FALSE;
}
if (demux->variant_raw)
g_free (demux->variant_raw);
demux->variant_raw = g_strdup (playlist);
if (!gst_m3u8_update (m3u8, playlist)) {
GST_WARNING_OBJECT (demux, "Couldn't update playlist");
g_set_error (err, GST_STREAM_ERROR, GST_STREAM_ERROR_FAILED,
......@@ -1489,6 +1642,11 @@ retry:
return FALSE;
}
if (demux->variant_playlist_emit)
g_signal_emit (demux,
gst_hls_demux_signals[VARIANT_PLAYLIST_UPDATED_SIGNAL], 0,
demux->variant_raw);
for (i = 0; i < GST_HLS_N_MEDIA_TYPES; ++i) {
GList *mlist = demux->current_variant->media[i];
......
......@@ -147,6 +147,14 @@ struct _GstHLSDemux
GstHLSMasterPlaylist *master;
GstHLSVariantStream *current_variant;
/* Playlists raw data representation */
gchar *master_raw;
gchar *variant_raw;
/* Playlist emitting properties */
gboolean master_playlist_emit;
gboolean variant_playlist_emit;
};
struct _GstHLSDemuxClass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment