static void gst_hls_sink2_write_playlist (GstHlsSink2 * sink) { char *playlist_content; GError *error = NULL; playlist_content = gst_m3u8_playlist_render (sink->playlist); if (!g_file_set_contents (sink->playlist_location, playlist_content, -1, &error)) { GST_ERROR ("Failed to write playlist: %s", error->message); GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (("Failed to write playlist '%s'."), error->message), (NULL)); g_error_free (error); error = NULL; } g_free (playlist_content); }
static void gst_hls_sink_handle_message (GstBin * bin, GstMessage * message) { GstHlsSink *sink = GST_HLS_SINK_CAST (bin); switch (message->type) { case GST_MESSAGE_ELEMENT: { GFile *file; const char *filename, *title; char *playlist_content; GstClockTime running_time, duration; gboolean discont = FALSE; GError *error = NULL; gchar *entry_location; const GstStructure *structure; structure = gst_message_get_structure (message); if (strcmp (gst_structure_get_name (structure), "GstMultiFileSink")) break; filename = gst_structure_get_string (structure, "filename"); gst_structure_get_clock_time (structure, "running-time", &running_time); duration = running_time - sink->last_running_time; sink->last_running_time = running_time; file = g_file_new_for_path (filename); title = "ciao"; GST_INFO_OBJECT (sink, "COUNT %d", sink->index); if (sink->playlist_root == NULL) entry_location = g_path_get_basename (filename); else { gchar *name = g_path_get_basename (filename); entry_location = g_build_filename (sink->playlist_root, name, NULL); g_free (name); } gst_m3u8_playlist_add_entry (sink->playlist, entry_location, file, title, duration, sink->index, discont); g_free (entry_location); playlist_content = gst_m3u8_playlist_render (sink->playlist); g_file_set_contents (sink->playlist_location, playlist_content, -1, &error); g_free (playlist_content); /* multifilesink is starting a new file. It means that upstream sent a key * unit and we can schedule the next key unit now. */ sink->waiting_fku = FALSE; schedule_next_key_unit (sink); /* multifilesink is an internal implementation detail. If applications * need a notification, we should probably do our own message */ GST_DEBUG_OBJECT (bin, "dropping message %" GST_PTR_FORMAT, message); gst_message_unref (message); message = NULL; break; } default: break; } if (message) GST_BIN_CLASS (parent_class)->handle_message (bin, message); }