static gboolean gst_index_gtype_resolver (GstIndex * index, GstObject * writer, gchar ** writer_string, gpointer data) { g_return_val_if_fail (writer != NULL, FALSE); if (GST_IS_PAD (writer)) { GstObject *element = gst_object_get_parent (GST_OBJECT (writer)); gchar *name; name = gst_object_get_name (writer); if (element) { *writer_string = g_strdup_printf ("%s.%s", G_OBJECT_TYPE_NAME (element), name); gst_object_unref (element); } else { *writer_string = name; name = NULL; } g_free (name); } else { *writer_string = g_strdup (G_OBJECT_TYPE_NAME (writer)); } return TRUE; }
/* Changing a GObject property of a GstObject will result in "deep_notify" * signals being emitted by the object itself, as well as in each parent * object. This is so that an application can connect a listener to the * top-level bin to catch property-change notifications for all contained * elements. * * This function is not MT safe in glib < 2.8 so we need to lock it with a * classwide mutex in that case. * * MT safe. */ static void gst_object_dispatch_properties_changed (GObject * object, guint n_pspecs, GParamSpec ** pspecs) { GstObject *gst_object, *parent, *old_parent; guint i; gchar *name, *debug_name; /* do the standard dispatching */ parent_class->dispatch_properties_changed (object, n_pspecs, pspecs); gst_object = GST_OBJECT_CAST (object); name = gst_object_get_name (gst_object); debug_name = GST_STR_NULL (name); /* now let the parent dispatch those, too */ parent = gst_object_get_parent (gst_object); while (parent) { for (i = 0; i < n_pspecs; i++) { GST_CAT_LOG_OBJECT (GST_CAT_PROPERTIES, parent, "deep notification from %s (%s)", debug_name, pspecs[i]->name); g_signal_emit (parent, gst_object_signals[DEEP_NOTIFY], g_quark_from_string (pspecs[i]->name), gst_object, pspecs[i]); } old_parent = parent; parent = gst_object_get_parent (old_parent); gst_object_unref (old_parent); } g_free (name); }
G_GNUC_UNUSED static void xml_loaded (GstXML * xml, GstObject * object, xmlNodePtr self, gpointer data) { xmlNodePtr children = self->xmlChildrenNode; while (children) { if (!strcmp ((const char *) children->name, "comment")) { xmlNodePtr nodes = children->xmlChildrenNode; while (nodes) { if (!strcmp ((const char *) nodes->name, "text")) { gchar *name = g_strdup ((gchar *) xmlNodeGetContent (nodes)); gchar *obj_name = gst_object_get_name (object); g_print ("object %s loaded with comment '%s'\n", obj_name, name); g_free (obj_name); g_free (name); } nodes = nodes->next; } } children = children->next; } }
static gboolean _create_input_chain (GstGLMixerBin * self, struct input_chain *chain, GstPad * mixer_pad) { GstGLMixerBinClass *klass = GST_GL_MIXER_BIN_GET_CLASS (self); GstPad *pad; gboolean res = TRUE; gchar *name; chain->self = self; chain->mixer_pad = mixer_pad; chain->upload = gst_element_factory_make ("glupload", NULL); chain->in_convert = gst_element_factory_make ("glcolorconvert", NULL); res &= gst_bin_add (GST_BIN (self), chain->in_convert); res &= gst_bin_add (GST_BIN (self), chain->upload); pad = gst_element_get_static_pad (chain->in_convert, "src"); if (gst_pad_link (pad, mixer_pad) != GST_PAD_LINK_OK) { gst_object_unref (pad); return FALSE; } gst_object_unref (pad); res &= gst_element_link_pads (chain->upload, "src", chain->in_convert, "sink"); pad = gst_element_get_static_pad (chain->upload, "sink"); if (!pad) { return FALSE; } else { GST_DEBUG_OBJECT (self, "setting target sink pad %" GST_PTR_FORMAT, pad); name = gst_object_get_name (GST_OBJECT (mixer_pad)); if (klass->create_input_pad) { chain->ghost_pad = klass->create_input_pad (self, chain->mixer_pad); gst_object_set_name (GST_OBJECT (chain->ghost_pad), name); gst_ghost_pad_set_target (chain->ghost_pad, pad); } else { chain->ghost_pad = GST_GHOST_PAD (gst_ghost_pad_new (GST_PAD_NAME (chain->mixer_pad), pad)); } g_free (name); GST_OBJECT_LOCK (self); if (self->priv->running) gst_pad_set_active (GST_PAD (chain->ghost_pad), TRUE); GST_OBJECT_UNLOCK (self); gst_element_add_pad (GST_ELEMENT_CAST (self), GST_PAD (chain->ghost_pad)); gst_object_unref (pad); } gst_element_sync_state_with_parent (chain->upload); gst_element_sync_state_with_parent (chain->in_convert); return TRUE; }
GstElement *create_audio_sink() { GstElement *bin, *decoder = NULL; GstIterator *iter; GstIteratorResult res; GError *error = NULL; GstPad *pad; gpointer element = NULL; bin = gst_parse_launch_full("decodebin ! queue ! audioconvert \ ! audioresample \ ! autoaudiosink", NULL, 0, &error); if (!bin) { g_error("GStreamer: failed to parse audio sink pipeline\n"); return NULL; } gst_object_set_name(GST_OBJECT(bin), "audio-sink"); iter = gst_bin_iterate_elements(GST_BIN(bin)); res = gst_iterator_next (iter, &element); while (res == GST_ITERATOR_OK) { gchar *name; name = gst_object_get_name(GST_OBJECT (element)); if (name) { if (!strncmp(name, "decodebin", strlen("decodebin"))) { decoder = GST_ELEMENT(element); } g_printf("GS: audio sink element: %s \n", name); g_free (name); } gst_object_unref (element); element = NULL; res = gst_iterator_next (iter, &element); } gst_iterator_free (iter); if (!decoder) { /* mem leak */ g_printf("decoder element not found\n"); return NULL; } /* add ghostpad */ pad = gst_element_get_static_pad(decoder, "sink"); gst_element_add_pad(bin, gst_ghost_pad_new("sink", pad)); gst_object_unref(GST_OBJECT(pad)); return bin; }
/** * Queries a GstObject for it's name */ QByteArray GstHelper::name(GstObject *obj) { Q_ASSERT(obj); QByteArray retVal; gchar *value = NULL; if ((value = gst_object_get_name (obj))) { retVal = QByteArray(value); g_free (value); } return retVal; }
static gint find_hlsdemux (GValue * value, gpointer user_data) { GstElement *e = GST_ELEMENT (g_value_get_object (value)); GstObject *fact = GST_OBJECT (gst_element_get_factory (e)); gchar *name = gst_object_get_name (fact); if (g_strcmp0 (name, "hlsdemux") == 0) { g_free (name); return 0; } g_free (name); return 1; }
static void owr_media_source_release_source_default(OwrMediaSource *media_source, GstElement *source) { GstPad *srcpad, *sinkpad; gchar *bin_name, *source_name; guint source_id = -1; GstElement *sink_bin, *source_pipeline; g_return_if_fail(media_source->priv->source_bin); g_return_if_fail(media_source->priv->source_tee); source_name = gst_object_get_name(GST_OBJECT(source)); if (!source_name || sscanf(source_name, "source-bin-%u", &source_id) != 1) { GST_WARNING_OBJECT(media_source, "Failed to get %s for clean up", source_name); g_free(source_name); return; } g_free(source_name); GST_DEBUG_OBJECT(media_source, "Unlinking source %u", source_id); /* Unlink parts from the source pipeline */ source_pipeline = gst_object_ref(media_source->priv->source_bin); g_assert(source_pipeline); bin_name = g_strdup_printf("source-sink-bin-%u", source_id); sink_bin = gst_bin_get_by_name(GST_BIN(source_pipeline), bin_name); if (!sink_bin) { GST_WARNING_OBJECT(media_source, "Failed to get %s from source pipeline", bin_name); g_free(bin_name); gst_object_unref(source_pipeline); return; } g_free(bin_name); gst_object_unref(source_pipeline); sinkpad = gst_element_get_static_pad(sink_bin, "sink"); /* The pad on the tee */ srcpad = gst_pad_get_peer(sinkpad); gst_object_unref(sinkpad); gst_pad_add_probe(srcpad, GST_PAD_PROBE_TYPE_IDLE, tee_idle_probe_cb, media_source, NULL); gst_object_unref(srcpad); gst_object_unref(sink_bin); }
static void gst_object_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { GstObject *gstobject; gstobject = GST_OBJECT (object); switch (prop_id) { case ARG_NAME: g_value_take_string (value, gst_object_get_name (gstobject)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
/* Changing a GObject property of a GstObject will result in "deep-notify" * signals being emitted by the object itself, as well as in each parent * object. This is so that an application can connect a listener to the * top-level bin to catch property-change notifications for all contained * elements. * * MT safe. */ static void gst_object_dispatch_properties_changed (GObject * object, guint n_pspecs, GParamSpec ** pspecs) { GstObject *gst_object, *parent, *old_parent; guint i; #ifndef GST_DISABLE_GST_DEBUG gchar *name = NULL; const gchar *debug_name; #endif /* do the standard dispatching */ ((GObjectClass *) gst_object_parent_class)->dispatch_properties_changed (object, n_pspecs, pspecs); gst_object = GST_OBJECT_CAST (object); #ifndef GST_DISABLE_GST_DEBUG if (G_UNLIKELY (_gst_debug_min >= GST_LEVEL_LOG)) { name = gst_object_get_name (gst_object); debug_name = GST_STR_NULL (name); } else debug_name = ""; #endif /* now let the parent dispatch those, too */ parent = gst_object_get_parent (gst_object); while (parent) { for (i = 0; i < n_pspecs; i++) { GST_CAT_LOG_OBJECT (GST_CAT_PROPERTIES, parent, "deep notification from %s (%s)", debug_name, pspecs[i]->name); g_signal_emit (parent, gst_object_signals[DEEP_NOTIFY], g_quark_from_string (pspecs[i]->name), gst_object, pspecs[i]); } old_parent = parent; parent = gst_object_get_parent (old_parent); gst_object_unref (old_parent); } #ifndef GST_DISABLE_GST_DEBUG g_free (name); #endif }
/* * RTP bus callback. */ static gboolean rtp_bus_callback (GstBus * bus, GstMessage * message, gpointer data) { GMainLoop *mainloop = (GMainLoop *) data; switch (GST_MESSAGE_TYPE (message)) { case GST_MESSAGE_ERROR: { GError *err; gchar *debug; gchar *element_name; element_name = (message->src) ? gst_object_get_name (message->src) : NULL; gst_message_parse_error (message, &err, &debug); g_print ("\nError from element %s: %s\n%s\n\n", GST_STR_NULL (element_name), err->message, (debug) ? debug : ""); g_error_free (err); g_free (debug); g_free (element_name); fail_if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR); g_main_loop_quit (mainloop); } break; case GST_MESSAGE_EOS: { g_main_loop_quit (mainloop); } break; break; default: { } break; } return TRUE; }
static GObject * gst_child_proxy_default_get_child_by_name (GstChildProxy * parent, const gchar * name) { guint count, i; GObject *object, *result; gchar *object_name; g_return_val_if_fail (GST_IS_CHILD_PROXY (parent), NULL); g_return_val_if_fail (name != NULL, NULL); result = NULL; count = gst_child_proxy_get_children_count (parent); for (i = 0; i < count; i++) { gboolean eq; if (!(object = gst_child_proxy_get_child_by_index (parent, i))) continue; if (!GST_IS_OBJECT (object)) { goto next; } object_name = gst_object_get_name (GST_OBJECT_CAST (object)); if (object_name == NULL) { g_warning ("child %u of parent %s has no name", i, GST_OBJECT_NAME (parent)); goto next; } eq = g_str_equal (object_name, name); g_free (object_name); if (eq) { result = object; break; } next: g_object_unref (object); } return result; }
/* Changing a GObject property of a GstObject will result in "deep_notify" * signals being emitted by the object itself, as well as in each parent * object. This is so that an application can connect a listener to the * top-level bin to catch property-change notifications for all contained * elements. * * This function is not MT safe in glib < 2.8 so we need to lock it with a * classwide mutex in that case. * * MT safe. */ static void gst_object_dispatch_properties_changed (GObject * object, guint n_pspecs, GParamSpec ** pspecs) { GstObject *gst_object, *parent, *old_parent; guint i; gchar *name, *debug_name; GstObjectClass *klass; /* we fail when this is not a GstObject */ g_return_if_fail (GST_IS_OBJECT (object)); klass = GST_OBJECT_GET_CLASS (object); /* do the standard dispatching */ G_OBJECT_CLASS (parent_class)->dispatch_properties_changed (object, n_pspecs, pspecs); gst_object = GST_OBJECT_CAST (object); name = gst_object_get_name (gst_object); debug_name = GST_STR_NULL (name); /* now let the parent dispatch those, too */ parent = gst_object_get_parent (gst_object); while (parent) { for (i = 0; i < n_pspecs; i++) { GST_LOG_OBJECT (parent, "deep notification from %s (%s)", debug_name, pspecs[i]->name); g_signal_emit (parent, gst_object_signals[DEEP_NOTIFY], g_quark_from_string (pspecs[i]->name), GST_OBJECT_CAST (object), pspecs[i]); } old_parent = parent; parent = gst_object_get_parent (old_parent); gst_object_unref (old_parent); } g_free (name); }
GstV4l2Allocator * gst_v4l2_allocator_new (GstObject * parent, GstV4l2Object * v4l2object) { GstV4l2Allocator *allocator; guint32 flags = 0; gchar *name, *parent_name; parent_name = gst_object_get_name (parent); name = g_strconcat (parent_name, ":allocator", NULL); g_free (parent_name); allocator = g_object_new (GST_TYPE_V4L2_ALLOCATOR, "name", name, NULL); gst_object_ref_sink (allocator); g_free (name); /* Save everything */ allocator->obj = v4l2object; /* Keep a ref on the elemnt so obj does not disapear */ gst_object_ref (allocator->obj->element); flags |= GST_V4L2_ALLOCATOR_PROBE (allocator, MMAP); flags |= GST_V4L2_ALLOCATOR_PROBE (allocator, USERPTR); flags |= GST_V4L2_ALLOCATOR_PROBE (allocator, DMABUF); if (flags == 0) { /* Drivers not ported from videobuf to videbuf2 don't allow freeing buffers * using REQBUFS(0). This is a workaround to still support these drivers, * which are known to have MMAP support. */ GST_WARNING_OBJECT (allocator, "Could not probe supported memory type, " "assuming MMAP is supported, this is expected for older drivers not " " yet ported to videobuf2 framework"); flags = GST_V4L2_ALLOCATOR_FLAG_MMAP_REQBUFS; } GST_OBJECT_FLAG_SET (allocator, flags); return allocator; }
static void _determine_reporting_level (GstValidateMonitor * monitor) { GstValidateRunner *runner; GstObject *object, *parent; gchar *object_name; GstValidateReportingDetails level = GST_VALIDATE_SHOW_UNKNOWN; object = gst_validate_monitor_get_target (monitor); runner = gst_validate_reporter_get_runner (GST_VALIDATE_REPORTER (monitor)); do { if (!GST_IS_OBJECT (object)) break; /* Let's allow for singling out pads */ if (GST_IS_PAD (object)) { level = _get_report_level_for_pad (runner, object); if (level != GST_VALIDATE_SHOW_UNKNOWN) break; } object_name = gst_object_get_name (object); level = gst_validate_runner_get_reporting_level_for_name (runner, object_name); parent = gst_object_get_parent (object); gst_object_unref (object); object = parent; g_free (object_name); } while (object && level == GST_VALIDATE_SHOW_UNKNOWN); if (object) gst_object_unref (object); if (runner) gst_object_unref (runner); monitor->level = level; }
static int cleanup_pipeline() { GError *error = NULL; GstIterator *iter; GstIteratorResult res; gpointer elts[2], element = NULL; int i, ct; ct = 0; memset(elts, 0, sizeof(elts)); iter = gst_bin_iterate_elements(GST_BIN(g_pipeline)); res = gst_iterator_next(iter, &element); while (res == GST_ITERATOR_OK) { gchar *name; assert(ct < (sizeof elts / sizeof(elts[0]))); elts[ct] = element; ct++; name = gst_object_get_name(GST_OBJECT(element)); if (name) { g_printf("GS: removing pipe element: %s \n", name); g_free (name); } gst_object_unref(element); element = NULL; res = gst_iterator_next(iter, &element); } gst_iterator_free (iter); for (i = 0; i < ct; i++) { gst_bin_remove(GST_BIN(g_pipeline), elts[i]); } }
static gboolean gst_index_gtype_resolver (GstIndex * index, GstObject * writer, gchar ** writer_string, gpointer data) { if (GST_IS_PAD (writer)) { GstElement *element = (GstElement *) gst_object_get_parent (GST_OBJECT (writer)); gchar *name; name = gst_object_get_name (writer); *writer_string = g_strdup_printf ("%s.%s", g_type_name (G_OBJECT_TYPE (element)), name); gst_object_unref (element); g_free (name); } else { *writer_string = g_strdup_printf ("%s", g_type_name (G_OBJECT_TYPE (writer))); } return TRUE; }
static gboolean message_comes_from_component(gchar *component_name, GstMessage *msg) { return g_str_has_prefix(gst_object_get_name(GST_MESSAGE_SRC(msg)),component_name); }
static void gve_bus_message_cb (GstBus * bus, GstMessage * message, gpointer data) { GstVideoEditor *gve = (GstVideoEditor *) data; GstMessageType msg_type; g_return_if_fail (gve != NULL); g_return_if_fail (GST_IS_VIDEO_EDITOR (gve)); msg_type = GST_MESSAGE_TYPE (message); switch (msg_type) { case GST_MESSAGE_ERROR: gve_error_msg (gve, message); if (gve->priv->main_pipeline) gst_element_set_state (gve->priv->main_pipeline, GST_STATE_NULL); break; case GST_MESSAGE_WARNING: GST_WARNING ("Warning message: %" GST_PTR_FORMAT, message); break; case GST_MESSAGE_STATE_CHANGED: { GstState old_state, new_state; gchar *src_name; gst_message_parse_state_changed (message, &old_state, &new_state, NULL); if (old_state == new_state) break; /* we only care about playbin (pipeline) state changes */ if (GST_MESSAGE_SRC (message) != GST_OBJECT (gve->priv->main_pipeline)) break; src_name = gst_object_get_name (message->src); GST_INFO ("%s changed state from %s to %s", src_name, gst_element_state_get_name (old_state), gst_element_state_get_name (new_state)); g_free (src_name); if (new_state == GST_STATE_PLAYING) gve_set_tick_timeout (gve, TIMEOUT); if (old_state == GST_STATE_PAUSED && new_state == GST_STATE_READY) { if (gve->priv->update_id > 0) { g_source_remove (gve->priv->update_id); gve->priv->update_id = 0; } } if (old_state == GST_STATE_NULL && new_state == GST_STATE_READY) GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN (gve->priv->main_pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "longomatch-editor-null-to-ready"); if (old_state == GST_STATE_READY && new_state == GST_STATE_PAUSED) GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN (gve->priv->main_pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "longomatch-editor-ready-to-paused"); break; } case GST_MESSAGE_EOS: if (gve->priv->update_id > 0) { g_source_remove (gve->priv->update_id); gve->priv->update_id = 0; } gst_element_set_state (gve->priv->main_pipeline, GST_STATE_NULL); g_signal_emit (gve, gve_signals[SIGNAL_PERCENT_COMPLETED], 0, (gfloat) 1); /* Close file sink properly */ g_object_set (G_OBJECT (gve->priv->file_sink), "location", "", NULL); break; default: GST_LOG ("Unhandled message: %" GST_PTR_FORMAT, message); break; } }
GstBusSyncReply Gst_bus_call(GstBus * bus, GstMessage *msg, gpointer user_data) { gchar * sourceName; // source GstObject * source; source = GST_MESSAGE_SRC(msg); if (!GST_IS_OBJECT(source)) return GST_BUS_DROP; sourceName = gst_object_get_name(source); switch (GST_MESSAGE_TYPE(msg)) { case GST_MESSAGE_EOS: { g_message("End-of-stream"); end_eof = 1; break; } case GST_MESSAGE_ERROR: { gchar * debug; GError *err; gst_message_parse_error(msg, &err, &debug); g_free (debug); lt_info_c( "%s:%s - GST_MESSAGE_ERROR: %s (%i) from %s\n", FILENAME, __FUNCTION__, err->message, err->code, sourceName ); if ( err->domain == GST_STREAM_ERROR ) { if ( err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND ) { if ( g_strrstr(sourceName, "videosink") ) lt_info_c( "%s:%s - GST_MESSAGE_ERROR: videosink\n", FILENAME, __FUNCTION__ ); //FIXME: how shall playback handle this event??? else if ( g_strrstr(sourceName, "audiosink") ) lt_info_c( "%s:%s - GST_MESSAGE_ERROR: audioSink\n", FILENAME, __FUNCTION__ ); //FIXME: how shall playback handle this event??? } } g_error_free(err); end_eof = 1; // NOTE: just to exit break; } case GST_MESSAGE_INFO: { gchar *debug; GError *inf; gst_message_parse_info (msg, &inf, &debug); g_free (debug); if ( inf->domain == GST_STREAM_ERROR && inf->code == GST_STREAM_ERROR_DECODE ) { if ( g_strrstr(sourceName, "videosink") ) lt_info_c( "%s:%s - GST_MESSAGE_INFO: videosink\n", FILENAME, __FUNCTION__ ); //FIXME: how shall playback handle this event??? } g_error_free(inf); break; } case GST_MESSAGE_TAG: { GstTagList *tags, *result; gst_message_parse_tag(msg, &tags); result = gst_tag_list_merge(m_stream_tags, tags, GST_TAG_MERGE_REPLACE); if (result) { if (m_stream_tags) gst_tag_list_free(m_stream_tags); m_stream_tags = result; } const GValue *gv_image = gst_tag_list_get_value_index(tags, GST_TAG_IMAGE, 0); if ( gv_image ) { GstBuffer *buf_image; buf_image = gst_value_get_buffer (gv_image); int fd = open("/tmp/.id3coverart", O_CREAT|O_WRONLY|O_TRUNC, 0644); if(fd >= 0) { int ret = write(fd, GST_BUFFER_DATA(buf_image), GST_BUFFER_SIZE(buf_image)); close(fd); lt_info_c( "%s:%s - GST_MESSAGE_INFO: cPlayback::state /tmp/.id3coverart %d bytes written\n", FILENAME, __FUNCTION__ , ret); } //FIXME: how shall playback handle this event??? } gst_tag_list_free(tags); lt_info_c( "%s:%s - GST_MESSAGE_INFO: update info tags\n", FILENAME, __FUNCTION__); //FIXME: how shall playback handle this event??? break; } case GST_MESSAGE_STATE_CHANGED: { if(GST_MESSAGE_SRC(msg) != GST_OBJECT(m_gst_playbin)) break; GstState old_state, new_state; gst_message_parse_state_changed(msg, &old_state, &new_state, NULL); if(old_state == new_state) break; lt_info_c( "%s:%s - GST_MESSAGE_STATE_CHANGED: state transition %s -> %s\n", FILENAME, __FUNCTION__, gst_element_state_get_name(old_state), gst_element_state_get_name(new_state)); GstStateChange transition = (GstStateChange)GST_STATE_TRANSITION(old_state, new_state); switch(transition) { case GST_STATE_CHANGE_NULL_TO_READY: { } break; case GST_STATE_CHANGE_READY_TO_PAUSED: { GstIterator *children; if (audioSink) { gst_object_unref(GST_OBJECT(audioSink)); audioSink = NULL; } if (videoSink) { gst_object_unref(GST_OBJECT(videoSink)); videoSink = NULL; } children = gst_bin_iterate_recurse(GST_BIN(m_gst_playbin)); audioSink = GST_ELEMENT_CAST(gst_iterator_find_custom(children, (GCompareFunc)match_sinktype, (gpointer)"GstDVBAudioSink")); videoSink = GST_ELEMENT_CAST(gst_iterator_find_custom(children, (GCompareFunc)match_sinktype, (gpointer)"GstDVBVideoSink")); gst_iterator_free(children); } break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: { } break; case GST_STATE_CHANGE_PLAYING_TO_PAUSED: { } break; case GST_STATE_CHANGE_PAUSED_TO_READY: { if (audioSink) { gst_object_unref(GST_OBJECT(audioSink)); audioSink = NULL; } if (videoSink) { gst_object_unref(GST_OBJECT(videoSink)); videoSink = NULL; } } break; case GST_STATE_CHANGE_READY_TO_NULL: { } break; } break; } #if 0 case GST_MESSAGE_ELEMENT: { if(gst_structure_has_name(gst_message_get_structure(msg), "prepare-xwindow-id")) { // set window id gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(GST_MESSAGE_SRC (msg)), glfb->getWindowID()); // reshape window gst_x_overlay_set_render_rectangle(GST_X_OVERLAY(GST_MESSAGE_SRC (msg)), 0, 0, glfb->getOSDWidth(), glfb->getOSDHeight()); // sync frames gst_x_overlay_expose(GST_X_OVERLAY(GST_MESSAGE_SRC (msg))); } } #endif break; default: break; } return GST_BUS_DROP; }
void eServiceMP3::gstBusCall(GstMessage *msg) { if (!msg) return; gchar *sourceName; GstObject *source; source = GST_MESSAGE_SRC(msg); if (!GST_IS_OBJECT(source)) return; sourceName = gst_object_get_name(source); #if 0 gchar *string; if (gst_message_get_structure(msg)) string = gst_structure_to_string(gst_message_get_structure(msg)); else string = g_strdup(GST_MESSAGE_TYPE_NAME(msg)); eDebug("eTsRemoteSource::gst_message from %s: %s", sourceName, string); g_free(string); #endif switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_EOS: m_event((iPlayableService*)this, evEOF); break; case GST_MESSAGE_STATE_CHANGED: { if(GST_MESSAGE_SRC(msg) != GST_OBJECT(m_gst_playbin)) break; GstState old_state, new_state; gst_message_parse_state_changed(msg, &old_state, &new_state, NULL); if(old_state == new_state) break; eDebug("eServiceMP3::state transition %s -> %s", gst_element_state_get_name(old_state), gst_element_state_get_name(new_state)); GstStateChange transition = (GstStateChange)GST_STATE_TRANSITION(old_state, new_state); switch(transition) { case GST_STATE_CHANGE_NULL_TO_READY: { } break; case GST_STATE_CHANGE_READY_TO_PAUSED: { GstElement *subsink = gst_bin_get_by_name(GST_BIN(m_gst_playbin), "subtitle_sink"); if (subsink) { #ifdef GSTREAMER_SUBTITLE_SYNC_MODE_BUG /* * HACK: disable sync mode for now, gstreamer suffers from a bug causing sparse streams to loose sync, after pause/resume / skip * see: https://bugzilla.gnome.org/show_bug.cgi?id=619434 * Sideeffect of using sync=false is that we receive subtitle buffers (far) ahead of their * display time. * Not too far ahead for subtitles contained in the media container. * But for external srt files, we could receive all subtitles at once. * And not just once, but after each pause/resume / skip. * So as soon as gstreamer has been fixed to keep sync in sparse streams, sync needs to be re-enabled. */ g_object_set (G_OBJECT (subsink), "sync", FALSE, NULL); #endif #if 0 /* we should not use ts-offset to sync with the decoder time, we have to do our own decoder timekeeping */ g_object_set (G_OBJECT (subsink), "ts-offset", -2L * GST_SECOND, NULL); /* late buffers probably will not occur very often */ g_object_set (G_OBJECT (subsink), "max-lateness", 0L, NULL); /* avoid prerolling (it might not be a good idea to preroll a sparse stream) */ g_object_set (G_OBJECT (subsink), "async", TRUE, NULL); #endif eDebug("eServiceMP3::subsink properties set!"); gst_object_unref(subsink); } setAC3Delay(ac3_delay); setPCMDelay(pcm_delay); } break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: { if ( m_sourceinfo.is_streaming && m_streamingsrc_timeout ) m_streamingsrc_timeout->stop(); } break; case GST_STATE_CHANGE_PLAYING_TO_PAUSED: { } break; case GST_STATE_CHANGE_PAUSED_TO_READY: { } break; case GST_STATE_CHANGE_READY_TO_NULL: { } break; } break; } case GST_MESSAGE_ERROR: { gchar *debug; GError *err; gst_message_parse_error (msg, &err, &debug); g_free (debug); eWarning("Gstreamer error: %s (%i) from %s", err->message, err->code, sourceName ); if ( err->domain == GST_STREAM_ERROR ) { if ( err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND ) { if ( g_strrstr(sourceName, "videosink") ) m_event((iPlayableService*)this, evUser+11); else if ( g_strrstr(sourceName, "audiosink") ) m_event((iPlayableService*)this, evUser+10); } } g_error_free(err); break; } case GST_MESSAGE_INFO: { gchar *debug; GError *inf; gst_message_parse_info (msg, &inf, &debug); g_free (debug); if ( inf->domain == GST_STREAM_ERROR && inf->code == GST_STREAM_ERROR_DECODE ) { if ( g_strrstr(sourceName, "videosink") ) m_event((iPlayableService*)this, evUser+14); } g_error_free(inf); break; } case GST_MESSAGE_TAG: { GstTagList *tags, *result; gst_message_parse_tag(msg, &tags); result = gst_tag_list_merge(m_stream_tags, tags, GST_TAG_MERGE_REPLACE); if (result) { if (m_stream_tags) gst_tag_list_free(m_stream_tags); m_stream_tags = result; } const GValue *gv_image = gst_tag_list_get_value_index(tags, GST_TAG_IMAGE, 0); if ( gv_image ) { GstBuffer *buf_image; buf_image = gst_value_get_buffer (gv_image); int fd = open("/tmp/.id3coverart", O_CREAT|O_WRONLY|O_TRUNC, 0644); int ret = write(fd, GST_BUFFER_DATA(buf_image), GST_BUFFER_SIZE(buf_image)); close(fd); eDebug("eServiceMP3::/tmp/.id3coverart %d bytes written ", ret); m_event((iPlayableService*)this, evUser+13); } gst_tag_list_free(tags); m_event((iPlayableService*)this, evUpdatedInfo); break; } case GST_MESSAGE_ASYNC_DONE: { if(GST_MESSAGE_SRC(msg) != GST_OBJECT(m_gst_playbin)) break; GstTagList *tags; gint i, active_idx, n_video = 0, n_audio = 0, n_text = 0; g_object_get (m_gst_playbin, "n-video", &n_video, NULL); g_object_get (m_gst_playbin, "n-audio", &n_audio, NULL); g_object_get (m_gst_playbin, "n-text", &n_text, NULL); eDebug("eServiceMP3::async-done - %d video, %d audio, %d subtitle", n_video, n_audio, n_text); if ( n_video + n_audio <= 0 ) stop(); active_idx = 0; m_audioStreams.clear(); m_subtitleStreams.clear(); for (i = 0; i < n_audio; i++) { audioStream audio; gchar *g_codec, *g_lang; GstPad* pad = 0; g_signal_emit_by_name (m_gst_playbin, "get-audio-pad", i, &pad); GstCaps* caps = gst_pad_get_negotiated_caps(pad); if (!caps) continue; GstStructure* str = gst_caps_get_structure(caps, 0); const gchar *g_type = gst_structure_get_name(str); eDebug("AUDIO STRUCT=%s", g_type); audio.type = gstCheckAudioPad(str); g_codec = g_strdup(g_type); g_lang = g_strdup_printf ("und"); g_signal_emit_by_name (m_gst_playbin, "get-audio-tags", i, &tags); if ( tags && gst_is_tag_list(tags) ) { gst_tag_list_get_string(tags, GST_TAG_AUDIO_CODEC, &g_codec); gst_tag_list_get_string(tags, GST_TAG_LANGUAGE_CODE, &g_lang); gst_tag_list_free(tags); } audio.language_code = std::string(g_lang); audio.codec = std::string(g_codec); eDebug("eServiceMP3::audio stream=%i codec=%s language=%s", i, g_codec, g_lang); m_audioStreams.push_back(audio); g_free (g_lang); g_free (g_codec); gst_caps_unref(caps); } for (i = 0; i < n_text; i++) { gchar *g_codec = NULL, *g_lang = NULL; g_signal_emit_by_name (m_gst_playbin, "get-text-tags", i, &tags); subtitleStream subs; g_lang = g_strdup_printf ("und"); if ( tags && gst_is_tag_list(tags) ) { gst_tag_list_get_string(tags, GST_TAG_LANGUAGE_CODE, &g_lang); gst_tag_list_get_string(tags, GST_TAG_SUBTITLE_CODEC, &g_codec); gst_tag_list_free(tags); } subs.language_code = std::string(g_lang); eDebug("eServiceMP3::subtitle stream=%i language=%s codec=%s", i, g_lang, g_codec); GstPad* pad = 0; g_signal_emit_by_name (m_gst_playbin, "get-text-pad", i, &pad); if ( pad ) g_signal_connect (G_OBJECT (pad), "notify::caps", G_CALLBACK (gstTextpadHasCAPS), this); subs.type = getSubtitleType(pad, g_codec); m_subtitleStreams.push_back(subs); g_free (g_lang); } m_event((iPlayableService*)this, evUpdatedInfo); if ( m_errorInfo.missing_codec != "" ) { if ( m_errorInfo.missing_codec.find("video/") == 0 || ( m_errorInfo.missing_codec.find("audio/") == 0 && getNumberOfTracks() == 0 ) ) m_event((iPlayableService*)this, evUser+12); } break; } case GST_MESSAGE_ELEMENT: { if (const GstStructure *msgstruct = gst_message_get_structure(msg)) { if ( gst_is_missing_plugin_message(msg) ) { GstCaps *caps; gst_structure_get (msgstruct, "detail", GST_TYPE_CAPS, &caps, NULL); std::string codec = (const char*) gst_caps_to_string(caps); gchar *description = gst_missing_plugin_message_get_description(msg); if ( description ) { eDebug("eServiceMP3::m_errorInfo.missing_codec = %s", codec.c_str()); m_errorInfo.error_message = "GStreamer plugin " + (std::string)description + " not available!\n"; m_errorInfo.missing_codec = codec.substr(0,(codec.find_first_of(','))); g_free(description); } gst_caps_unref(caps); } else { const gchar *eventname = gst_structure_get_name(msgstruct); if ( eventname ) { if (!strcmp(eventname, "eventSizeChanged") || !strcmp(eventname, "eventSizeAvail")) { gst_structure_get_int (msgstruct, "aspect_ratio", &m_aspect); gst_structure_get_int (msgstruct, "width", &m_width); gst_structure_get_int (msgstruct, "height", &m_height); if (strstr(eventname, "Changed")) m_event((iPlayableService*)this, evVideoSizeChanged); } else if (!strcmp(eventname, "eventFrameRateChanged") || !strcmp(eventname, "eventFrameRateAvail")) { gst_structure_get_int (msgstruct, "frame_rate", &m_framerate); if (strstr(eventname, "Changed")) m_event((iPlayableService*)this, evVideoFramerateChanged); } else if (!strcmp(eventname, "eventProgressiveChanged") || !strcmp(eventname, "eventProgressiveAvail")) { gst_structure_get_int (msgstruct, "progressive", &m_progressive); if (strstr(eventname, "Changed")) m_event((iPlayableService*)this, evVideoProgressiveChanged); } } } } break; } case GST_MESSAGE_BUFFERING: { GstBufferingMode mode; gst_message_parse_buffering(msg, &(m_bufferInfo.bufferPercent)); gst_message_parse_buffering_stats(msg, &mode, &(m_bufferInfo.avgInRate), &(m_bufferInfo.avgOutRate), &(m_bufferInfo.bufferingLeft)); m_event((iPlayableService*)this, evBuffering); break; } case GST_MESSAGE_STREAM_STATUS: { GstStreamStatusType type; GstElement *owner; gst_message_parse_stream_status (msg, &type, &owner); if ( type == GST_STREAM_STATUS_TYPE_CREATE && m_sourceinfo.is_streaming ) { if ( GST_IS_PAD(source) ) owner = gst_pad_get_parent_element(GST_PAD(source)); else if ( GST_IS_ELEMENT(source) ) owner = GST_ELEMENT(source); else owner = 0; if ( owner ) { GstElementFactory *factory = gst_element_get_factory(GST_ELEMENT(owner)); const gchar *name = gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(factory)); if (!strcmp(name, "souphttpsrc")) { m_streamingsrc_timeout->start(HTTP_TIMEOUT*1000, true); g_object_set (G_OBJECT (owner), "timeout", HTTP_TIMEOUT, NULL); eDebug("eServiceMP3::GST_STREAM_STATUS_TYPE_CREATE -> setting timeout on %s to %is", name, HTTP_TIMEOUT); } } if ( GST_IS_PAD(source) ) gst_object_unref(owner); } break; } default: break; } g_free (sourceName); }
* payloaded RTP packets. We simply ghost the pad here. */ static void new_session_pad (GstElement * session, GstPad * pad, GstSDPDemux * demux) { gchar *name; GstPadTemplate *template; gint id, ssrc, pt; GList *lstream; GstSDPStream *stream; gboolean all_added; GST_DEBUG_OBJECT (demux, "got new session pad %" GST_PTR_FORMAT, pad); GST_SDP_STREAM_LOCK (demux); /* find stream */ name = gst_object_get_name (GST_OBJECT_CAST (pad)); if (sscanf (name, "recv_rtp_src_%d_%d_%d", &id, &ssrc, &pt) != 3) goto unknown_stream; GST_DEBUG_OBJECT (demux, "stream: %u, SSRC %d, PT %d", id, ssrc, pt); stream = find_stream (demux, GINT_TO_POINTER (id), (gpointer) find_stream_by_id); if (stream == NULL) goto unknown_stream; /* no need for a timeout anymore now */ g_object_set (G_OBJECT (stream->udpsrc[0]), "timeout", (guint64) 0, NULL); /* create a new pad we will use to stream to */ template = gst_static_pad_template_get (&rtptemplate);
QString Object::name() const { return QGlib::Private::stringFromGCharPtr(gst_object_get_name(object<GstObject>())); }
EXPORT_C #endif gchar * gst_object_get_path_string (GstObject * object) { GSList *parentage; GSList *parents; void *parent; gchar *prevpath, *path; gchar *component; gchar *separator; /* ref object before adding to list */ gst_object_ref (object); parentage = g_slist_prepend (NULL, object); path = g_strdup (""); /* first walk the object hierarchy to build a list of the parents, * be carefull here with refcounting. */ do { if (GST_IS_OBJECT (object)) { parent = gst_object_get_parent (object); /* add parents to list, refcount remains increased while * we handle the object */ if (parent) parentage = g_slist_prepend (parentage, parent); } else { break; } object = parent; } while (object != NULL); /* then walk the parent list and print them out. we need to * decrease the refcounting on each element after we handled * it. */ for (parents = parentage; parents; parents = g_slist_next (parents)) { if (GST_IS_OBJECT (parents->data)) { GstObject *item = GST_OBJECT_CAST (parents->data); GstObjectClass *oclass = GST_OBJECT_GET_CLASS (item); component = gst_object_get_name (item); separator = oclass->path_string_separator; /* and unref now */ gst_object_unref (item); } else { component = g_strdup_printf ("%p", parents->data); separator = "/"; } prevpath = path; path = g_strjoin (separator, prevpath, component, NULL); g_free (prevpath); g_free (component); } g_slist_free (parentage); return path; }
/** * gst_v4l2_buffer_pool_new: * @obj: the v4l2 object owning the pool * * Construct a new buffer pool. * * Returns: the new pool, use gst_object_unref() to free resources */ GstBufferPool * gst_v4l2_buffer_pool_new (GstV4l2Object * obj, GstCaps * caps) { GstV4l2BufferPool *pool; GstStructure *config; gchar *name, *parent_name; gint fd; fd = v4l2_dup (obj->video_fd); if (fd < 0) goto dup_failed; /* setting a significant unique name */ parent_name = gst_object_get_name (GST_OBJECT (obj->element)); name = g_strconcat (parent_name, ":", "pool:", V4L2_TYPE_IS_OUTPUT (obj->type) ? "sink" : "src", NULL); g_free (parent_name); pool = (GstV4l2BufferPool *) g_object_new (GST_TYPE_V4L2_BUFFER_POOL, "name", name, NULL); g_free (name); gst_poll_fd_init (&pool->pollfd); pool->pollfd.fd = fd; gst_poll_add_fd (pool->poll, &pool->pollfd); if (V4L2_TYPE_IS_OUTPUT (obj->type)) gst_poll_fd_ctl_write (pool->poll, &pool->pollfd, TRUE); else gst_poll_fd_ctl_read (pool->poll, &pool->pollfd, TRUE); pool->video_fd = fd; pool->obj = obj; pool->can_poll_device = TRUE; pool->vallocator = gst_v4l2_allocator_new (GST_OBJECT (pool), obj->video_fd, &obj->format); if (pool->vallocator == NULL) goto allocator_failed; gst_object_ref (obj->element); config = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (pool)); gst_buffer_pool_config_set_params (config, caps, obj->info.size, 0, 0); /* This will simply set a default config, but will not configure the pool * because min and max are not valid */ gst_buffer_pool_set_config (GST_BUFFER_POOL_CAST (pool), config); return GST_BUFFER_POOL (pool); /* ERRORS */ dup_failed: { GST_ERROR ("failed to dup fd %d (%s)", errno, g_strerror (errno)); return NULL; } allocator_failed: { GST_ERROR_OBJECT (pool, "Failed to create V4L2 allocator"); return NULL; } }
static void print_plugin_features (GstPlugin * plugin) { GList *features, *origlist; gint num_features = 0; gint num_elements = 0; gint num_tracers = 0; gint num_typefinders = 0; gint num_devproviders = 0; gint num_other = 0; origlist = features = gst_registry_get_feature_list_by_plugin (gst_registry_get (), gst_plugin_get_name (plugin)); while (features) { GstPluginFeature *feature; feature = GST_PLUGIN_FEATURE (features->data); if (GST_IS_ELEMENT_FACTORY (feature)) { GstElementFactory *factory; factory = GST_ELEMENT_FACTORY (feature); n_print (" %s: %s\n", GST_OBJECT_NAME (factory), gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_LONGNAME)); num_elements++; } else if (GST_IS_TYPE_FIND_FACTORY (feature)) { GstTypeFindFactory *factory; const gchar *const *extensions; factory = GST_TYPE_FIND_FACTORY (feature); extensions = gst_type_find_factory_get_extensions (factory); if (extensions) { guint i = 0; g_print (" %s: %s: ", gst_plugin_get_name (plugin), gst_plugin_feature_get_name (feature)); while (extensions[i]) { g_print ("%s%s", i > 0 ? ", " : "", extensions[i]); i++; } g_print ("\n"); } else g_print (" %s: %s: no extensions\n", gst_plugin_get_name (plugin), gst_plugin_feature_get_name (feature)); num_typefinders++; } else if (GST_IS_DEVICE_PROVIDER_FACTORY (feature)) { GstDeviceProviderFactory *factory; factory = GST_DEVICE_PROVIDER_FACTORY (feature); n_print (" %s: %s\n", GST_OBJECT_NAME (factory), gst_device_provider_factory_get_metadata (factory, GST_ELEMENT_METADATA_LONGNAME)); num_devproviders++; } else if (GST_IS_TRACER_FACTORY (feature)) { n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)), g_type_name (G_OBJECT_TYPE (feature))); num_tracers++; } else if (feature) { n_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)), g_type_name (G_OBJECT_TYPE (feature))); num_other++; } num_features++; features = g_list_next (features); } gst_plugin_feature_list_free (origlist); n_print ("\n"); n_print (" %d features:\n", num_features); if (num_elements > 0) n_print (" +-- %d elements\n", num_elements); if (num_typefinders > 0) n_print (" +-- %d typefinders\n", num_typefinders); if (num_devproviders > 0) n_print (" +-- %d device providers\n", num_devproviders); if (num_tracers > 0) n_print (" +-- %d tracers\n", num_tracers); if (num_other > 0) n_print (" +-- %d other objects\n", num_other); n_print ("\n"); }
void eServiceMP3Record::gstBusCall(GstMessage *msg) { if (!msg) return; ePtr<iRecordableService> ptr = this; gchar *sourceName; GstObject *source; source = GST_MESSAGE_SRC(msg); if (!GST_IS_OBJECT(source)) return; sourceName = gst_object_get_name(source); switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_EOS: eDebug("[eMP3ServiceRecord] gstBusCall eos event"); // Stream end -> stop recording m_event((iRecordableService*)this, evGstRecordEnded); break; case GST_MESSAGE_STATE_CHANGED: { if(GST_MESSAGE_SRC(msg) != GST_OBJECT(m_recording_pipeline)) break; GstState old_state, new_state; gst_message_parse_state_changed(msg, &old_state, &new_state, NULL); if(old_state == new_state) break; GstStateChange transition = (GstStateChange)GST_STATE_TRANSITION(old_state, new_state); eDebug("[eMP3ServiceRecord] gstBusCall state transition %s -> %s", gst_element_state_get_name(old_state), gst_element_state_get_name(new_state)); switch(transition) { case GST_STATE_CHANGE_PAUSED_TO_PLAYING: { if (m_streamingsrc_timeout) m_streamingsrc_timeout->stop(); break; } default: break; } break; } case GST_MESSAGE_ERROR: { gchar *debug; GError *err; gst_message_parse_error(msg, &err, &debug); g_free(debug); if (err->code != GST_STREAM_ERROR_CODEC_NOT_FOUND) eWarning("[eServiceMP3Record] gstBusCall Gstreamer error: %s (%i) from %s", err->message, err->code, sourceName); g_error_free(err); break; } case GST_MESSAGE_ELEMENT: { const GstStructure *msgstruct = gst_message_get_structure(msg); if (msgstruct) { if (gst_is_missing_plugin_message(msg)) { GstCaps *caps = NULL; gst_structure_get (msgstruct, "detail", GST_TYPE_CAPS, &caps, NULL); if (caps) { std::string codec = (const char*) gst_caps_to_string(caps); eDebug("[eServiceMP3Record] gstBusCall cannot record because of incompatible codecs %s", codec.c_str()); gst_caps_unref(caps); } } else { const gchar *eventname = gst_structure_get_name(msgstruct); if (eventname) { if (!strcmp(eventname, "redirect")) { const char *uri = gst_structure_get_string(msgstruct, "new-location"); eDebug("[eServiceMP3Record] gstBusCall redirect to %s", uri); gst_element_set_state (m_recording_pipeline, GST_STATE_NULL); g_object_set(G_OBJECT (m_source), "uri", uri, NULL); gst_element_set_state (m_recording_pipeline, GST_STATE_PLAYING); } } } } break; } case GST_MESSAGE_STREAM_STATUS: { GstStreamStatusType type; GstElement *owner; gst_message_parse_stream_status (msg, &type, &owner); if (type == GST_STREAM_STATUS_TYPE_CREATE) { if (GST_IS_PAD(source)) owner = gst_pad_get_parent_element(GST_PAD(source)); else if (GST_IS_ELEMENT(source)) owner = GST_ELEMENT(source); else owner = 0; if (owner) { GstState state; gst_element_get_state(m_recording_pipeline, &state, NULL, 0LL); GstElementFactory *factory = gst_element_get_factory(GST_ELEMENT(owner)); const gchar *name = gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(factory)); if (!strcmp(name, "souphttpsrc") && (state == GST_STATE_READY) && !m_streamingsrc_timeout->isActive()) { m_streamingsrc_timeout->start(HTTP_TIMEOUT*1000, true); g_object_set (G_OBJECT (owner), "timeout", HTTP_TIMEOUT, NULL); eDebug("[eServiceMP3Record] gstBusCall setting timeout on %s to %is", name, HTTP_TIMEOUT); } } if (GST_IS_PAD(source)) gst_object_unref(owner); } break; } default: break; } g_free(sourceName); }
static gboolean bus_message (GstBus * bus, GstMessage * message, App * app) { gchar *sourceName; GstObject *source; gchar *string; GstState current_state; if (!message) return FALSE; source = GST_MESSAGE_SRC (message); if (!GST_IS_OBJECT (source)) return FALSE; sourceName = gst_object_get_name (source); if (gst_message_get_structure (message)) string = gst_structure_to_string (gst_message_get_structure (message)); else string = g_strdup (GST_MESSAGE_TYPE_NAME (message)); GST_DEBUG("gst_message from %s: %s", sourceName, string); g_free (string); switch (GST_MESSAGE_TYPE (message)) { case GST_MESSAGE_ERROR: { GError *gerror; gchar *debug; gst_message_parse_error (message, &gerror, &debug); gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug); g_error_free (gerror); g_free (debug); g_main_loop_quit (app->loop); break; } case GST_MESSAGE_WARNING: { GError *gerror; gchar *debug; gst_message_parse_warning (message, &gerror, &debug); gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug); g_error_free (gerror); g_free (debug); // g_main_loop_quit (app->loop); break; } case GST_MESSAGE_EOS: g_message ("received EOS"); g_main_loop_quit (app->loop); break; case GST_MESSAGE_ASYNC_DONE: break; case GST_MESSAGE_ELEMENT: { const GstStructure *msgstruct = gst_message_get_structure (message); if (msgstruct) { const gchar *eventname = gst_structure_get_name (msgstruct); if (!strcmp (eventname, "seekable")) app->is_seekable = TRUE; } break; } case GST_MESSAGE_STATE_CHANGED: { GstState old_state, new_state; GstStateChange transition; if (GST_MESSAGE_SRC (message) != GST_OBJECT (app->tsdemux)) break; gst_message_parse_state_changed (message, &old_state, &new_state, NULL); transition = (GstStateChange) GST_STATE_TRANSITION (old_state, new_state); switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: break; case GST_STATE_CHANGE_READY_TO_PAUSED: break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: { } break; case GST_STATE_CHANGE_PLAYING_TO_PAUSED: break; case GST_STATE_CHANGE_PAUSED_TO_READY: break; case GST_STATE_CHANGE_READY_TO_NULL: break; } break; } case GST_MESSAGE_SEGMENT_DONE: { GST_DEBUG ("GST_MESSAGE_SEGMENT_DONE!!!"); do_seek (app); } default: break; } gst_element_get_state (app->pipeline, ¤t_state, NULL, 0); if (app->current_segment == 0 && app->segment_count /*&& app->is_seekable*/ && current_state == GST_STATE_PLAYING) do_seek (app); GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(app->pipeline),GST_DEBUG_GRAPH_SHOW_ALL,"bdremux_pipelinegraph_message"); return TRUE; }
// ---------------------------------------------------------------------------- // Retrieve and process a bus message bool GStreamerImportFileHandle::ProcessBusMessage(bool & success) { bool cont = true; // Default to no errors success = true; // Get the next message GstMessage *msg = gst_bus_timed_pop(mBus, 100 * GST_MSECOND); if (!msg) { // Timed out...not an error return cont; } #if defined(__WXDEBUG__) gchar *objname = NULL; if (msg->src != NULL) { objname = gst_object_get_name(msg->src); } wxLogMessage(wxT("GStreamer: Got %s%s%s"), wxString::FromUTF8(GST_MESSAGE_TYPE_NAME(msg)).c_str(), objname ? wxT(" from ") : wxT(""), objname ? wxString::FromUTF8(objname).c_str() : wxT("")); if (objname != NULL) { g_free(objname); } #endif // Handle based on message type switch (GST_MESSAGE_TYPE(msg)) { // Handle error message from gstreamer case GST_MESSAGE_ERROR: { GError *err = NULL; gchar *debug = NULL; gst_message_parse_error(msg, &err, &debug); if (err) { wxString m; m.Printf(wxT("%s%s%s"), wxString::FromUTF8(err->message).c_str(), debug ? wxT("\n") : wxT(""), debug ? wxString::FromUTF8(debug).c_str() : wxT("")); #if defined(_DEBUG) wxMessageBox(m, wxT("GStreamer Error:")); #else wxLogMessage(wxT("GStreamer Error: %s"), m.c_str()); #endif g_error_free(err); } if (debug) { g_free(debug); } success = false; cont = false; } break; // Handle warning message from gstreamer case GST_MESSAGE_WARNING: { GError *err = NULL; gchar *debug = NULL; gst_message_parse_warning(msg, &err, &debug); if (err) { wxLogMessage(wxT("GStreamer Warning: %s%s%s"), wxString::FromUTF8(err->message).c_str(), debug ? wxT("\n") : wxT(""), debug ? wxString::FromUTF8(debug).c_str() : wxT("")); g_error_free(err); } if (debug) { g_free(debug); } } break; // Handle warning message from gstreamer case GST_MESSAGE_INFO: { GError *err = NULL; gchar *debug = NULL; gst_message_parse_info(msg, &err, &debug); if (err) { wxLogMessage(wxT("GStreamer Info: %s%s%s"), wxString::FromUTF8(err->message).c_str(), debug ? wxT("\n") : wxT(""), debug ? wxString::FromUTF8(debug).c_str() : wxT("")); g_error_free(err); } if (debug) { g_free(debug); } } break; // Handle metadata tags case GST_MESSAGE_TAG: { GstTagList *tags = NULL; // Retrieve tag list from message...just ignore failure gst_message_parse_tag(msg, &tags); if (tags) { // Go process the list OnTag(GST_APP_SINK(GST_MESSAGE_SRC(msg)), tags); // Done with list gst_tag_list_unref(tags); } } break; // Pre-roll is done...will happen for each group // (like with chained OGG files) case GST_MESSAGE_ASYNC_DONE: { // If this is the first async-done message, then tell // caller to end loop, but leave it active so that // gstreamer threads can still queue up. // // We'll receive multiple async-done messages for chained // ogg files, so ignore the message the 2nd and subsequent // occurrences. if (!mAsyncDone) { cont = false; mAsyncDone = true; } } break; // End of the stream (and all sub-streams) case GST_MESSAGE_EOS: { // Terminate loop cont = false; } break; } // Release the message gst_message_unref(msg); return cont; }
static void rygel_wmv_transcoder_bin_decodebin_pad_added (RygelWMVTranscoderBin* self, GstElement* decodebin, GstPad* new_pad) { #line 316 "rygel-wmv-transcoder-bin.c" GstElement* encoder; GstPad* enc_pad; GstPad* audio_enc_pad; GstPad* video_enc_pad; #line 79 "rygel-wmv-transcoder-bin.vala" g_return_if_fail (self != NULL); #line 79 "rygel-wmv-transcoder-bin.vala" g_return_if_fail (decodebin != NULL); #line 79 "rygel-wmv-transcoder-bin.vala" g_return_if_fail (new_pad != NULL); #line 327 "rygel-wmv-transcoder-bin.c" encoder = NULL; enc_pad = NULL; #line 83 "rygel-wmv-transcoder-bin.vala" audio_enc_pad = _gst_object_ref0 (gst_element_get_pad (self->priv->audio_enc, RYGEL_WMV_TRANSCODER_BIN_AUDIO_ENC_SINK)); #line 84 "rygel-wmv-transcoder-bin.vala" video_enc_pad = _gst_object_ref0 (gst_element_get_pad (self->priv->video_enc, RYGEL_WMV_TRANSCODER_BIN_VIDEO_ENC_SINK)); #line 87 "rygel-wmv-transcoder-bin.vala" if (gst_pad_can_link (new_pad, audio_enc_pad)) { #line 336 "rygel-wmv-transcoder-bin.c" GstElement* _tmp0_; GstPad* _tmp1_; #line 88 "rygel-wmv-transcoder-bin.vala" encoder = (_tmp0_ = _gst_object_ref0 (self->priv->audio_enc), _gst_object_unref0 (encoder), _tmp0_); #line 89 "rygel-wmv-transcoder-bin.vala" enc_pad = (_tmp1_ = _gst_object_ref0 (audio_enc_pad), _gst_object_unref0 (enc_pad), _tmp1_); #line 343 "rygel-wmv-transcoder-bin.c" } else { #line 90 "rygel-wmv-transcoder-bin.vala" if (gst_pad_can_link (new_pad, video_enc_pad)) { #line 347 "rygel-wmv-transcoder-bin.c" GstElement* _tmp2_; GstPad* _tmp3_; #line 91 "rygel-wmv-transcoder-bin.vala" encoder = (_tmp2_ = _gst_object_ref0 (self->priv->video_enc), _gst_object_unref0 (encoder), _tmp2_); #line 92 "rygel-wmv-transcoder-bin.vala" enc_pad = (_tmp3_ = _gst_object_ref0 (video_enc_pad), _gst_object_unref0 (enc_pad), _tmp3_); #line 354 "rygel-wmv-transcoder-bin.c" } else { _gst_object_unref0 (encoder); _gst_object_unref0 (enc_pad); _gst_object_unref0 (audio_enc_pad); _gst_object_unref0 (video_enc_pad); #line 94 "rygel-wmv-transcoder-bin.vala" return; #line 362 "rygel-wmv-transcoder-bin.c" } } #line 97 "rygel-wmv-transcoder-bin.vala" gst_element_link (encoder, self->priv->muxer); #line 99 "rygel-wmv-transcoder-bin.vala" if (gst_pad_link (new_pad, enc_pad) != GST_PAD_LINK_OK) { #line 369 "rygel-wmv-transcoder-bin.c" GError* _error_; #line 100 "rygel-wmv-transcoder-bin.vala" _error_ = g_error_new (RYGEL_GST_ERROR, RYGEL_GST_ERROR_LINK, _ ("Failed to link pad %s to %s"), gst_object_get_name ((GstObject*) new_pad), gst_object_get_name ((GstObject*) enc_pad)); #line 103 "rygel-wmv-transcoder-bin.vala" rygel_gst_utils_post_error ((GstElement*) self, _error_); #line 375 "rygel-wmv-transcoder-bin.c" _g_error_free0 (_error_); } _gst_object_unref0 (encoder); _gst_object_unref0 (enc_pad); _gst_object_unref0 (audio_enc_pad); _gst_object_unref0 (video_enc_pad); }