Commit 3537c4d2 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

splitmuxsrc: Refactor part preparation code and remove "prepared" signal from reader helper object

We don't need a special signal anymore but can directly work with
async-done
parent 99bb6f44
......@@ -37,14 +37,6 @@ GST_DEBUG_CATEGORY_STATIC (splitmux_part_debug);
#define SPLITMUX_PART_TYPE_LOCK(p) g_mutex_lock(&(p)->type_lock)
#define SPLITMUX_PART_TYPE_UNLOCK(p) g_mutex_unlock(&(p)->type_lock)
enum
{
SIGNAL_PREPARED,
LAST_SIGNAL
};
static guint part_reader_signals[LAST_SIGNAL] = { 0 };
typedef struct _GstSplitMuxPartPad
{
GstPad parent;
......@@ -622,10 +614,6 @@ gst_splitmux_part_reader_class_init (GstSplitMuxPartReaderClass * klass)
gobject_klass->dispose = splitmux_part_reader_dispose;
gobject_klass->finalize = splitmux_part_reader_finalize;
part_reader_signals[SIGNAL_PREPARED] =
g_signal_new ("prepared", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GstSplitMuxPartReaderClass,
prepared), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gstelement_class->change_state = gst_splitmux_part_reader_change_state;
gstelement_class->send_event = gst_splitmux_part_reader_send_event;
......@@ -909,11 +897,9 @@ gst_splitmux_part_reader_finish_measuring_streams (GstSplitMuxPartReader *
if (reader->prep_state == PART_STATE_PREPARING_RESET_FOR_READY) {
/* Fire the prepared signal and go to READY state */
GST_DEBUG_OBJECT (reader,
"Stream measuring complete. File %s is now ready. Firing prepared signal",
reader->path);
"Stream measuring complete. File %s is now ready", reader->path);
reader->prep_state = PART_STATE_READY;
SPLITMUX_PART_UNLOCK (reader);
g_signal_emit (reader, part_reader_signals[SIGNAL_PREPARED], 0, NULL);
do_async_done (reader);
} else {
SPLITMUX_PART_UNLOCK (reader);
......
......@@ -108,8 +108,6 @@ static void splitmux_src_uri_handler_init (gpointer g_iface,
static GstPad *gst_splitmux_find_output_pad (GstSplitMuxPartReader * part,
GstPad * pad, GstSplitMuxSrc * splitmux);
static void gst_splitmux_part_prepared (GstSplitMuxPartReader * reader,
GstSplitMuxSrc * splitmux);
static gboolean gst_splitmux_end_of_part (GstSplitMuxSrc * splitmux,
SplitMuxSrcPad * pad);
static gboolean gst_splitmux_check_new_caps (SplitMuxSrcPad * splitpad,
......@@ -397,10 +395,6 @@ gst_splitmux_src_change_state (GstElement * element, GstStateChange transition)
return ret;
}
static gboolean gst_splitmux_src_prepare_next_part (GstSplitMuxSrc * splitmux);
static gboolean gst_splitmux_src_activate_part (GstSplitMuxSrc * splitmux,
guint part, GstSeekFlags extra_flags);
static void
gst_splitmux_src_activate_first_part (GstSplitMuxSrc * splitmux)
{
......@@ -419,6 +413,7 @@ gst_splitmux_part_bus_handler (GstBus * bus, GstMessage * msg,
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_ASYNC_DONE:{
guint idx = splitmux->num_prepared_parts;
gboolean need_no_more_pads;
if (idx >= splitmux->num_parts) {
/* Shouldn't really happen! */
......@@ -430,6 +425,17 @@ gst_splitmux_part_bus_handler (GstBus * bus, GstMessage * msg,
GST_DEBUG_OBJECT (splitmux, "Prepared file part %s (%u)",
splitmux->parts[idx]->path, idx);
/* signal no-more-pads as we have all pads at this point now */
SPLITMUX_SRC_LOCK (splitmux);
need_no_more_pads = !splitmux->pads_complete;
splitmux->pads_complete = TRUE;
SPLITMUX_SRC_UNLOCK (splitmux);
if (need_no_more_pads) {
GST_DEBUG_OBJECT (splitmux, "Signalling no-more-pads");
gst_element_no_more_pads (GST_ELEMENT_CAST (splitmux));
}
/* Extend our total duration to cover this part */
GST_OBJECT_LOCK (splitmux);
splitmux->total_duration +=
......@@ -443,8 +449,9 @@ gst_splitmux_part_bus_handler (GstBus * bus, GstMessage * msg,
GST_DEBUG_OBJECT (splitmux,
"Duration %" GST_TIME_FORMAT ", total duration now: %" GST_TIME_FORMAT
" and end offset %" GST_TIME_FORMAT,
gst_splitmux_part_reader_get_duration (splitmux->parts[idx]),
splitmux->total_duration, splitmux->end_offset);
GST_TIME_ARGS (gst_splitmux_part_reader_get_duration (splitmux->parts
[idx])), GST_TIME_ARGS (splitmux->total_duration),
GST_TIME_ARGS (splitmux->end_offset));
splitmux->num_prepared_parts++;
......@@ -527,9 +534,6 @@ gst_splitmux_part_create (GstSplitMuxSrc * splitmux, char *filename)
r = g_object_new (GST_TYPE_SPLITMUX_PART_READER, NULL);
g_signal_connect (r, "prepared", (GCallback) gst_splitmux_part_prepared,
splitmux);
gst_splitmux_part_reader_set_callbacks (r, splitmux,
(GstSplitMuxPartReaderPadCb) gst_splitmux_find_output_pad);
gst_splitmux_part_reader_set_location (r, filename);
......@@ -1081,24 +1085,6 @@ pad_not_found:
return NULL;
}
static void
gst_splitmux_part_prepared (GstSplitMuxPartReader * reader,
GstSplitMuxSrc * splitmux)
{
gboolean need_no_more_pads;
GST_LOG_OBJECT (splitmux, "Part %" GST_PTR_FORMAT " prepared", reader);
SPLITMUX_SRC_LOCK (splitmux);
need_no_more_pads = !splitmux->pads_complete;
splitmux->pads_complete = TRUE;
SPLITMUX_SRC_UNLOCK (splitmux);
if (need_no_more_pads) {
GST_DEBUG_OBJECT (splitmux, "Signalling no-more-pads");
gst_element_no_more_pads (GST_ELEMENT_CAST (splitmux));
}
}
static void
gst_splitmux_push_event (GstSplitMuxSrc * splitmux, GstEvent * e,
guint32 seqnum)
......
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