static void gst_play_sink_convert_bin_set_targets (GstPlaySinkConvertBin * self, gboolean passthrough) { GstPad *pad; GstElement *head, *tail; GST_DEBUG_OBJECT (self, "Setting pad targets with passthrough %d", passthrough); if (self->conversion_elements == NULL || passthrough) { GST_DEBUG_OBJECT (self, "no conversion elements, using identity (%p) as " "head/tail", self->identity); if (!passthrough) { GST_WARNING_OBJECT (self, "Doing passthrough as no converter elements were added"); } head = tail = self->identity; } else { head = GST_ELEMENT (g_list_first (self->conversion_elements)->data); tail = GST_ELEMENT (g_list_last (self->conversion_elements)->data); GST_DEBUG_OBJECT (self, "conversion elements in use, picking " "head:%s and tail:%s", GST_OBJECT_NAME (head), GST_OBJECT_NAME (tail)); } g_return_if_fail (head != NULL); g_return_if_fail (tail != NULL); pad = gst_element_get_static_pad (head, "sink"); GST_DEBUG_OBJECT (self, "Ghosting bin sink pad to %" GST_PTR_FORMAT, pad); gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (self->sinkpad), pad); gst_object_unref (pad); pad = gst_element_get_static_pad (tail, "src"); GST_DEBUG_OBJECT (self, "Ghosting bin src pad to %" GST_PTR_FORMAT, pad); gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (self->srcpad), pad); gst_object_unref (pad); }
/* * helper_find_suggest: * @data: helper data struct * @probability: probability of the match * @caps: caps of the type * * If given @probability is higher, replace previously store caps. */ static void helper_find_suggest (gpointer data, GstTypeFindProbability probability, GstCaps * caps) { GstTypeFindHelper *helper = (GstTypeFindHelper *) data; GST_LOG_OBJECT (helper->obj, "'%s' called suggest (%u, %" GST_PTR_FORMAT ")", GST_OBJECT_NAME (helper->factory), probability, caps); if (probability > helper->best_probability) { gst_caps_replace (&helper->caps, caps); helper->best_probability = probability; } }
/* on error print the error and quit the application */ static void error_cb (GstBus * bus, GstMessage * msg, APP_STATE_T * state) { GError *err; gchar *debug_info; gst_message_parse_error (msg, &err, &debug_info); g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message); g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none"); g_clear_error (&err); g_free (debug_info); flush_start (state); gst_element_set_state (state->pipeline, GST_STATE_READY); }
/* This function is called when an error message is posted on the bus */ static void error_cb (GstBus *bus, GstMessage *msg, CustomData *data) { GError *err; gchar *debug_info; /* Print error details on the screen */ gst_message_parse_error (msg, &err, &debug_info); g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message); update_timelabel (data, err->message); g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none"); g_clear_error (&err); g_free (debug_info); /* Set the pipeline to READY (which stops playback) */ audio_stop_player (data); }
/* * buf_helper_find_suggest: * @data: helper data struct * @probability: probability of the match * @caps: caps of the type * * If given @probability is higher, replace previously store caps. */ static void buf_helper_find_suggest (gpointer data, guint probability, GstCaps * caps) { GstTypeFindBufHelper *helper = (GstTypeFindBufHelper *) data; GST_LOG_OBJECT (helper->obj, "'%s' called suggest (%u, %" GST_PTR_FORMAT ")", GST_OBJECT_NAME (helper->factory), probability, caps); /* Note: not >= as we call typefinders in order of rank, highest first */ if (probability > helper->best_probability) { gst_caps_replace (&helper->caps, caps); helper->best_probability = probability; } }
/** * gst_object_replace: * @oldobj: pointer to a place of a #GstObject to replace * @newobj: a new #GstObject * * Unrefs the #GstObject pointed to by @oldobj, refs @newobj and * puts @newobj in *@oldobj. Be carefull when calling this * function, it does not take any locks. You might want to lock * the object owning @oldobj pointer before calling this * function. * * Make sure not to LOCK @oldobj because it might be unreffed * which could cause a deadlock when it is disposed. */ void gst_object_replace (GstObject ** oldobj, GstObject * newobj) { g_return_if_fail (oldobj != NULL); g_return_if_fail (*oldobj == NULL || GST_IS_OBJECT (*oldobj)); g_return_if_fail (newobj == NULL || GST_IS_OBJECT (newobj)); #ifdef DEBUG_REFCOUNT GST_CAT_LOG (GST_CAT_REFCOUNTING, "replace %s (%d) with %s (%d)", *oldobj ? GST_STR_NULL (GST_OBJECT_NAME (*oldobj)) : "(NONE)", *oldobj ? G_OBJECT (*oldobj)->ref_count : 0, newobj ? GST_STR_NULL (GST_OBJECT_NAME (newobj)) : "(NONE)", newobj ? G_OBJECT (newobj)->ref_count : 0); #endif if (G_LIKELY (*oldobj != newobj)) { if (newobj) gst_object_ref (newobj); if (*oldobj) gst_object_unref (*oldobj); *oldobj = newobj; } }
static void connect_sink (GstElement * element, GstPad * pad, gpointer user_data) { KmsConnectData *data = user_data; GST_DEBUG_OBJECT (pad, "New pad %" GST_PTR_FORMAT, element); if (g_strcmp0 (GST_OBJECT_NAME (pad), data->pad_name)) { return; } connect_pads_and_remove_on_unlinked (data->src, element, data->pad_name); GST_INFO_OBJECT (pad, "Linking %s", data->pad_name); }
/* must be called with monitor lock */ static gboolean is_provider_hidden (GstDeviceMonitor * monitor, GList * hidden, GstDeviceProvider * provider) { GstDeviceProviderFactory *factory; if (monitor->priv->show_all) return FALSE; factory = gst_device_provider_get_factory (provider); if (g_list_find_custom (hidden, GST_OBJECT_NAME (factory), (GCompareFunc) g_strcmp0)) return TRUE; return FALSE; }
static void rtp_ssrc_demux_new_ssrc_pad (GstElement * ssrcdemux, guint ssrc, GstPad * pad, KmsBaseRtpSession * self) { const gchar *rtp_pad_name = GST_OBJECT_NAME (pad); gchar *rtcp_pad_name; SdpMediaConfig *mconf; GstPad *src, *sink; GST_DEBUG_OBJECT (self, "pad: %" GST_PTR_FORMAT " ssrc: %" G_GUINT32_FORMAT, pad, ssrc); KMS_SDP_SESSION_LOCK (self); if (self->remote_audio_ssrc == ssrc || ssrcs_are_mapped (ssrcdemux, self->local_audio_ssrc, ssrc)) { mconf = self->audio_neg_mconf; } else if (self->remote_video_ssrc == ssrc || ssrcs_are_mapped (ssrcdemux, self->local_video_ssrc, ssrc)) { mconf = self->video_neg_mconf; } else { if (!kms_i_rtp_session_manager_custom_ssrc_management (self->manager, self, ssrcdemux, ssrc, pad)) { GST_ERROR_OBJECT (pad, "SSRC %" G_GUINT32_FORMAT " not matching.", ssrc); } goto end; } /* RTP */ sink = kms_i_rtp_session_manager_request_rtp_sink (self->manager, self, mconf); kms_base_rtp_session_link_pads (pad, sink); g_object_unref (sink); /* RTCP */ rtcp_pad_name = g_strconcat ("rtcp_", rtp_pad_name, NULL); src = gst_element_get_static_pad (ssrcdemux, rtcp_pad_name); g_free (rtcp_pad_name); sink = kms_i_rtp_session_manager_request_rtcp_sink (self->manager, self, mconf); kms_base_rtp_session_link_pads (src, sink); g_object_unref (src); g_object_unref (sink); end: KMS_SDP_SESSION_UNLOCK (self); }
static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data) { GMainLoop *loop = (GMainLoop *)data; GstState old_state, new_state; switch (GST_MESSAGE_TYPE(msg)) { case GST_MESSAGE_STATE_CHANGED: gst_message_parse_state_changed (msg, &old_state, &new_state, NULL); if(msg->src == GST_OBJECT(app.pipeline) && new_state == GST_STATE_READY && old_state == GST_STATE_NULL) { g_debug ("Element %s changed state from %s to %s.\n", GST_OBJECT_NAME (msg->src), gst_element_state_get_name (old_state), gst_element_state_get_name (new_state)); if(app.ready_callback) { app.ready_callback(); } } break; case GST_MESSAGE_EOS: g_warning("End of stream\n"); g_main_loop_quit(loop); break; case GST_MESSAGE_ERROR: { gchar *debug; GError *error; gst_message_parse_error(msg, &error, &debug); // g_free(debug); g_printerr("Error: %s\n", error->message); g_printerr("Debug: %s\n", debug); g_error_free(error); g_main_loop_quit(loop); break; } default: break; } return TRUE; }
void error_cb(GstBus *bus, GstMessage *msg, CustomData *data) { GError *err; gchar *debug_info; gchar *message_string; gst_message_parse_error(msg, &err, &debug_info); GPlayerDEBUG("ERROR from element %s: %s\n", GST_OBJECT_NAME(msg->src), err->message); GPlayerDEBUG("Debugging info: %s\n", (debug_info) ? debug_info : "none"); if (strcasestr(err->message, "not") != NULL && strcasestr(err->message, "found") != NULL) { gplayer_error(NOT_FOUND, data); data->target_state = GST_STATE_NULL; data->is_live = (gst_element_set_state(data->pipeline, data->target_state) == GST_STATE_CHANGE_NO_PREROLL); } else if ((strstr(err->message, "missing") != NULL && strstr(err->message, "plug-in") != NULL) || (strstr(err->message, "No URI handler implemented for") != NULL)) { gplayer_error(NOT_SUPPORTED, data); data->target_state = GST_STATE_NULL; data->is_live = (gst_element_set_state(data->pipeline, data->target_state) == GST_STATE_CHANGE_NO_PREROLL); } else if (strstr(err->message, "type") != NULL && strstr(err->message, "stream") != NULL) { gplayer_error(UNKNOWN_ERROR, data); data->target_state = GST_STATE_NULL; data->is_live = (gst_element_set_state(data->pipeline, data->target_state) == GST_STATE_CHANGE_NO_PREROLL); } else if (strstr(err->message, "Stream") != NULL && strstr(err->message, "enough") != NULL) { if (!data->flow_error) { gplayer_error(UNKNOWN_ERROR, data); data->target_state = GST_STATE_PAUSED; data->is_live = (gst_element_set_state(data->pipeline, data->target_state) == GST_STATE_CHANGE_NO_PREROLL); } } else if (strstr(err->message, "Internal") != NULL && strstr(err->message, "flow") != NULL) { data->flow_error = TRUE; } g_error_free(err); g_free(debug_info); }
static void gst_ss_demux_stream_init (GstSSDemux *demux, GstSSDemuxStream *stream, SS_STREAM_TYPE stream_type) { stream->cond = g_cond_new (); stream->lock = g_mutex_new (); stream->queue = g_queue_new (); stream->parent = demux; stream->pipe = NULL; stream->urisrc = NULL; stream->parser = NULL; stream->sink = NULL; stream->frag_cnt = 0; stream->type = stream_type ; stream->uri = NULL; stream->start_ts = -1; stream->sent_ns = FALSE; stream->switch_ts = GST_CLOCK_TIME_NONE; stream->avg_dur = GST_CLOCK_TIME_NONE; if (stream->type == SS_STREAM_VIDEO) { stream->pad = gst_pad_new_from_static_template (&ssdemux_videosrc_template, "video"); stream->name = g_strdup("video"); } else if (stream->type == SS_STREAM_AUDIO) { stream->pad = gst_pad_new_from_static_template (&ssdemux_audiosrc_template, "audio"); stream->name = g_strdup("audio"); } else if (stream->type == SS_STREAM_TEXT) { stream->pad = gst_pad_new_from_static_template (&ssdemux_subsrc_template, "subtitle"); stream->name = g_strdup("text"); } GST_PAD_ELEMENT_PRIVATE (stream->pad) = stream; gst_pad_use_fixed_caps (stream->pad); gst_pad_set_event_function (stream->pad, gst_ss_demux_handle_src_event); gst_pad_set_query_function (stream->pad, gst_ss_demux_handle_src_query); stream->caps = ssm_parse_get_stream_caps (demux->parser, stream->type); g_print ("prepare video caps = %s", gst_caps_to_string(stream->caps)); GST_DEBUG_OBJECT (demux, "setting caps %" GST_PTR_FORMAT, stream->caps); gst_pad_set_caps (stream->pad, stream->caps); GST_DEBUG_OBJECT (demux, "adding pad %s %p to demux %p", GST_OBJECT_NAME (stream->pad), stream->pad, demux); gst_pad_set_active (stream->pad, TRUE); gst_element_add_pad (GST_ELEMENT_CAST (demux), stream->pad); }
/** * gst_pipeline_use_clock: * @pipeline: a [GstPipeline]() * @clock: (transfer none) (allow-none): the clock to use * * Force _pipeline_ to use the given _clock_. The pipeline will * always use the given clock even if new clock providers are added * to this pipeline. * * If _clock_ is [NULL]() all clocking will be disabled which will make * the pipeline run as fast as possible. * * MT safe. */ void gst_pipeline_use_clock (GstPipeline * pipeline, GstClock * clock) { GstClock **clock_p; g_return_if_fail (GST_IS_PIPELINE (pipeline)); GST_OBJECT_LOCK (pipeline); GST_OBJECT_FLAG_SET (pipeline, GST_PIPELINE_FLAG_FIXED_CLOCK); clock_p = &pipeline->fixed_clock; gst_object_replace ((GstObject **) clock_p, (GstObject *) clock); GST_OBJECT_UNLOCK (pipeline); GST_CAT_DEBUG (GST_CAT_CLOCK, "pipeline using fixed clock %p (%s)", clock, (clock ? GST_OBJECT_NAME (clock) : "nil")); }
void gss_program_add_stream_table (GssProgram * program, GString * s) { GList *g; gboolean have_hls = FALSE; GSS_A ("<table class='table table-striped table-bordered " "table-condensed'>\n"); GSS_A ("<thead>\n"); GSS_A ("<tr>\n"); GSS_A ("<th>Type</th>\n"); GSS_A ("<th>Size</th>\n"); GSS_A ("<th>Bitrate</th>\n"); GSS_A ("</tr>\n"); GSS_A ("</thead>\n"); GSS_A ("<tbody>\n"); for (g = program->streams; g; g = g_list_next (g)) { GssStream *stream = g->data; GSS_A ("<tr>\n"); GSS_P ("<td>%s</td>\n", gss_stream_type_get_name (stream->type)); GSS_P ("<td>%dx%d</td>\n", stream->width, stream->height); GSS_P ("<td>%d kbps</td>\n", stream->bitrate / 1000); GSS_P ("<td><a href=\"%s\">stream</a></td>\n", stream->location); GSS_P ("<td><a href=\"%s\">playlist</a></td>\n", stream->playlist_location); GSS_A ("</tr>\n"); if (stream->type == GSS_STREAM_TYPE_M2TS_H264BASE_AAC || stream->type == GSS_STREAM_TYPE_M2TS_H264MAIN_AAC) { have_hls = TRUE; } } if (have_hls) { GSS_A ("<tr>\n"); GSS_P ("<td colspan='7'><a href='/%s.m3u8'>HLS</a></td>\n", GST_OBJECT_NAME (program)); GSS_A ("</tr>\n"); } GSS_A ("<tr>\n"); GSS_P ("<td colspan='7'><a class='btn btn-mini' href='/'>" "<i class='icon-plus'></i>Add</a></td>\n"); GSS_A ("</tr>\n"); GSS_A ("</tbody>\n"); GSS_A ("</table>\n"); }
gboolean gst_task_pool_need_schedule_thread (GstTaskPool * pool, gboolean needed) { gboolean ret; g_return_val_if_fail (GST_IS_TASK_POOL (pool), FALSE); g_return_val_if_fail (needed || pool->priv->need_schedule_thread > 0, FALSE); /* We don't allow this for the default pool */ if (pool == gst_task_pool_get_default ()) { gst_object_unref (pool); return FALSE; } g_mutex_lock (&pool->priv->schedule_lock); if (needed) { ret = TRUE; if (pool->priv->need_schedule_thread == 0) { pool->priv->schedule_context = g_main_context_new (); pool->priv->schedule_loop = g_main_loop_new (pool->priv->schedule_context, FALSE); pool->priv->schedule_thread = g_thread_new (GST_OBJECT_NAME (pool), gst_task_pool_schedule_func, pool); g_cond_wait (&pool->priv->schedule_cond, &pool->priv->schedule_lock); } pool->priv->need_schedule_thread++; } else { ret = FALSE; pool->priv->need_schedule_thread--; if (pool->priv->need_schedule_thread == 0) { g_main_loop_quit (pool->priv->schedule_loop); g_thread_join (pool->priv->schedule_thread); g_main_loop_unref (pool->priv->schedule_loop); pool->priv->schedule_loop = NULL; g_main_context_unref (pool->priv->schedule_context); pool->priv->schedule_context = NULL; pool->priv->schedule_thread = NULL; } } g_mutex_unlock (&pool->priv->schedule_lock); return ret; }
static gboolean link_unlinked_pads (GstElement *bin, GstPadDirection dir, const gchar *pad_name, guint *pad_count, GError **error) { GstPad *pad = NULL; guint i = 0; while ((pad = gst_bin_find_unlinked_pad (GST_BIN (bin), dir))) { GstPad *ghostpad; gchar *tmp; if (i) tmp = g_strdup_printf ("%s%d", pad_name, i); else tmp = g_strdup (pad_name); i++; ghostpad = gst_ghost_pad_new (tmp, pad); gst_object_unref (pad); g_free (tmp); if (!ghostpad) { g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION, "Could not create ghostpad for pad %s:%s", GST_DEBUG_PAD_NAME (pad)); return FALSE; } if (!gst_element_add_pad (bin, ghostpad)) { g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION, "Could not add pad %s to bin", GST_OBJECT_NAME (ghostpad)); return FALSE; } } if (pad_count) *pad_count = i; return TRUE; }
static void on_error_video (GstBus *bus, GstMessage *message, gpointer user_data) { GError *err; gchar *debug_info; gchar *message_string; gst_message_parse_error (message, &err, &debug_info); message_string = g_strdup_printf ("Error received from element %s: %s", GST_OBJECT_NAME (message->src), err->message); g_message ("debug_info = %s \n message_string = %s\n", debug_info, message_string); g_clear_error (&err); g_free (debug_info); g_free (message_string); }
void GstPlayer::handleStateChangeMessage(GstMessage *msg){ GstState old_state, new_state; gst_message_parse_state_changed (msg, &old_state, &new_state, NULL); QString objectNamePlayer = gstObjectName; if( objectNamePlayer == GST_OBJECT_NAME (msg->src)){ if(new_state == GST_STATE_PLAYING || old_state == GST_STATE_PLAYING){ QLOG_TRACE() << "[GST] "<< this << gst_element_state_get_name (old_state) << "->"<< gst_element_state_get_name (new_state); } switch(new_state){ case GST_STATE_VOID_PENDING: loaded=false; playing=false; break; case GST_STATE_READY: loaded=true; playing=false; break; case GST_STATE_NULL: loaded=false; playing=false; break; case GST_STATE_PAUSED: loaded=true; playing=false; if(playingRequested){ QLOG_TRACE() << "Queued request. Ask to play!"; playingRequested = false; this->requestPlay(); } break; case GST_STATE_PLAYING: loaded=true; playing=true; break; } //QLOG_TRACE() << "GstPlayer: emit state change"; this->stateChanged(); } }
/* should be called with the object LOCK */ static void gst_task_configure_name (GstTask * task) { #ifdef HAVE_SYS_PRCTL_H const gchar *name; gchar thread_name[17] = { 0, }; name = GST_OBJECT_NAME (task); /* set the thread name to something easily identifiable */ if (!snprintf (thread_name, 17, "%s", GST_STR_NULL (name))) { GST_DEBUG_OBJECT (task, "Could not create thread name for '%s'", name); } else { GST_DEBUG_OBJECT (task, "Setting thread name to '%s'", thread_name); if (prctl (PR_SET_NAME, (unsigned long int) thread_name, 0, 0, 0)) GST_DEBUG_OBJECT (task, "Failed to set thread name"); } #endif }
static GstElement * gst_auto_video_src_create_element_with_pretty_name (GstAutoVideoSrc * src, GstElementFactory * factory) { GstElement *element; gchar *name, *marker; marker = g_strdup (GST_PLUGIN_FEATURE (factory)->name); if (g_str_has_suffix (marker, "src")) marker[strlen (marker) - 4] = '\0'; if (g_str_has_prefix (marker, "gst")) g_memmove (marker, marker + 3, strlen (marker + 3) + 1); name = g_strdup_printf ("%s-actual-src-%s", GST_OBJECT_NAME (src), marker); g_free (marker); element = gst_element_factory_create (factory, name); g_free (name); return element; }
static void remove_on_unlinked_async (gpointer data, gpointer not_used) { GstElement *elem = GST_ELEMENT_CAST (data); GstObject *parent = gst_object_get_parent (GST_OBJECT (elem)); gst_element_set_locked_state (elem, TRUE); if (g_strcmp0 (GST_OBJECT_NAME (gst_element_get_factory (elem)), "queue") == 0) { g_object_set (G_OBJECT (elem), "flush-on-eos", TRUE, NULL); gst_element_send_event (elem, gst_event_new_eos ()); } gst_element_set_state (elem, GST_STATE_NULL); if (parent != NULL) { gst_bin_remove (GST_BIN (parent), elem); g_object_unref (parent); } g_object_unref (data); }
static void kms_enc_tree_bin_create_encoder_for_caps (KmsEncTreeBin * self, const GstCaps * caps, gint target_bitrate) { GList *encoder_list, *filtered_list, *l; GstElementFactory *encoder_factory = NULL; encoder_list = gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_ENCODER, GST_RANK_NONE); /* HACK: Augment the openh264 rank */ for (l = encoder_list; l != NULL; l = l->next) { encoder_factory = GST_ELEMENT_FACTORY (l->data); if (g_str_has_prefix (GST_OBJECT_NAME (encoder_factory), "openh264")) { encoder_list = g_list_remove (encoder_list, l->data); encoder_list = g_list_prepend (encoder_list, encoder_factory); break; } } encoder_factory = NULL; filtered_list = gst_element_factory_list_filter (encoder_list, caps, GST_PAD_SRC, FALSE); for (l = filtered_list; l != NULL && encoder_factory == NULL; l = l->next) { encoder_factory = GST_ELEMENT_FACTORY (l->data); if (gst_element_factory_get_num_pad_templates (encoder_factory) != 2) encoder_factory = NULL; } if (encoder_factory != NULL) { self->priv->enc = gst_element_factory_create (encoder_factory, NULL); kms_enc_tree_bin_set_encoder_type (self); configure_encoder (self->priv->enc, self->priv->enc_type, target_bitrate); } gst_plugin_feature_list_free (filtered_list); gst_plugin_feature_list_free (encoder_list); }
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; }
static void debug_dump_header (GstBin * bin, GstDebugGraphDetails details, GString * str) { gchar *state_name = NULL; gchar *param_name = NULL; if (details & GST_DEBUG_GRAPH_SHOW_STATES) { state_name = debug_dump_get_element_state (GST_ELEMENT (bin)); } if (details & GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS) { param_name = debug_dump_get_object_params (G_OBJECT (bin), details, NULL); } /* write header */ g_string_append_printf (str, "digraph pipeline {\n" " rankdir=LR;\n" " fontname=\"sans\";\n" " fontsize=\"10\";\n" " labelloc=t;\n" " nodesep=.1;\n" " ranksep=.2;\n" " label=\"<%s>\\n%s%s%s\";\n" " node [style=\"filled,rounded\", shape=box, fontsize=\"9\", fontname=\"sans\", margin=\"0.0,0.0\"];\n" " edge [labelfontsize=\"6\", fontsize=\"9\", fontname=\"monospace\"];\n" " \n" " legend [\n" " pos=\"0,0!\",\n" " margin=\"0.05,0.05\",\n" " style=\"filled\",\n" " label=\"Legend\\lElement-States: [~] void-pending, [0] null, [-] ready, [=] paused, [>] playing\\lPad-Activation: [-] none, [>] push, [<] pull\\lPad-Flags: [b]locked, [f]lushing, [b]locking; upper-case is set\\lPad-Task: [T] has started task, [t] has paused task\\l\",\n" " ];" "\n", G_OBJECT_TYPE_NAME (bin), GST_OBJECT_NAME (bin), (state_name ? state_name : ""), (param_name ? param_name : "") ); if (state_name) g_free (state_name); if (param_name) g_free (param_name); }
static gboolean handle_pipeline_message(GstBus *bus, GstMessage *msg, gpointer video_decoder) { SpiceGstDecoder *decoder = video_decoder; if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_ERROR) { GError *err = NULL; gchar *debug_info = NULL; gst_message_parse_error(msg, &err, &debug_info); spice_warning("GStreamer error from element %s: %s", GST_OBJECT_NAME(msg->src), err->message); if (debug_info) { SPICE_DEBUG("debug information: %s", debug_info); g_free(debug_info); } g_clear_error(&err); /* We won't be able to process any more frame anyway */ free_pipeline(decoder); } return TRUE; }
gboolean on_pipeline_msg(GstBus * bus, GstMessage * msg, gpointer loop) { gchar * debug; GError * error;; switch(GST_MESSAGE_TYPE(msg)) { // Mensaje de finalización del stream case GST_MESSAGE_EOS: fprintf(stderr, "End of stream\n"); kill(getpid(), SIGUSR1); break; // Mensaje que indica que se ha producido un error case GST_MESSAGE_ERROR: gst_message_parse_error(msg, & error, & debug); g_free(debug); g_printerr("Error: %s\n", error->message); g_error_free(error); kill(getpid(), SIGUSR1); break; case GST_MESSAGE_STATE_CHANGED: { GstState old_state, new_state; gst_message_parse_state_changed(msg, &old_state, &new_state, NULL); g_print("Element %s changed state from %s to %s.\n", GST_OBJECT_NAME(msg->src), gst_element_state_get_name(old_state), gst_element_state_get_name(new_state)); break; } default: break; } return TRUE; }
/* takes a snapshot of the running_time of the pipeline and store this as the * element start_time. This is the time we will set as the running_time of the * pipeline when we go to PLAYING next. */ static void pipeline_update_start_time (GstElement * element) { GstPipeline *pipeline = GST_PIPELINE_CAST (element); GstClock *clock; GST_OBJECT_LOCK (element); if ((clock = element->clock)) { GstClockTime now; gst_object_ref (clock); GST_OBJECT_UNLOCK (element); /* calculate the time when we stopped */ now = gst_clock_get_time (clock); gst_object_unref (clock); GST_OBJECT_LOCK (element); /* store the current running time */ if (GST_ELEMENT_START_TIME (pipeline) != GST_CLOCK_TIME_NONE) { if (now != GST_CLOCK_TIME_NONE) GST_ELEMENT_START_TIME (pipeline) = now - element->base_time; else GST_WARNING_OBJECT (element, "Clock %s returned invalid time, can't calculate " "running_time when going to the PAUSED state", GST_OBJECT_NAME (clock)); /* we went to PAUSED, when going to PLAYING select clock and new * base_time */ pipeline->priv->update_clock = TRUE; } GST_DEBUG_OBJECT (element, "start_time=%" GST_TIME_FORMAT ", now=%" GST_TIME_FORMAT ", base_time %" GST_TIME_FORMAT, GST_TIME_ARGS (GST_ELEMENT_START_TIME (pipeline)), GST_TIME_ARGS (now), GST_TIME_ARGS (element->base_time)); } GST_OBJECT_UNLOCK (element); }
/** * gst_bus_remove_signal_watch: * @bus: a #GstBus you previously added a signal watch to * * Removes a signal watch previously added with gst_bus_add_signal_watch(). * * MT safe. */ void gst_bus_remove_signal_watch (GstBus * bus) { GSource *source = NULL; g_return_if_fail (GST_IS_BUS (bus)); /* I know the callees don't take this lock, so go ahead and abuse it */ GST_OBJECT_LOCK (bus); if (bus->priv->num_signal_watchers == 0) goto error; bus->priv->num_signal_watchers--; if (bus->priv->num_signal_watchers > 0) goto done; GST_DEBUG_OBJECT (bus, "removing signal watch %u", g_source_get_id (bus->priv->signal_watch)); source = bus->priv->signal_watch; done: GST_OBJECT_UNLOCK (bus); if (source) g_source_destroy (source); return; /* ERRORS */ error: { g_critical ("Bus %s has no signal watches attached", GST_OBJECT_NAME (bus)); GST_OBJECT_UNLOCK (bus); return; } }
/** * gst_bus_remove_signal_watch: * @bus: a #GstBus you previously added a signal watch to * * Removes a signal watch previously added with gst_bus_add_signal_watch(). * * MT safe. */ void gst_bus_remove_signal_watch (GstBus * bus) { guint id = 0; g_return_if_fail (GST_IS_BUS (bus)); /* I know the callees don't take this lock, so go ahead and abuse it */ GST_OBJECT_LOCK (bus); if (bus->num_signal_watchers == 0) goto error; bus->num_signal_watchers--; if (bus->num_signal_watchers > 0) goto done; id = bus->signal_watch_id; bus->signal_watch_id = 0; GST_DEBUG_OBJECT (bus, "removing signal watch %u", id); done: GST_OBJECT_UNLOCK (bus); if (id) g_source_remove (id); return; /* ERRORS */ error: { g_critical ("Bus %s has no signal watches attached", GST_OBJECT_NAME (bus)); GST_OBJECT_UNLOCK (bus); return; } }
static void gst_tee_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstTee *tee = GST_TEE (object); GST_OBJECT_LOCK (tee); switch (prop_id) { case PROP_HAS_CHAIN: tee->has_chain = g_value_get_boolean (value); break; case PROP_SILENT: tee->silent = g_value_get_boolean (value); break; case PROP_PULL_MODE: tee->pull_mode = (GstTeePullMode) g_value_get_enum (value); break; case PROP_ALLOC_PAD: { GstPad *pad = g_value_get_object (value); GST_OBJECT_LOCK (pad); if (GST_OBJECT_PARENT (pad) == GST_OBJECT_CAST (object)) tee->allocpad = pad; else GST_WARNING_OBJECT (object, "Tried to set alloc pad %s which" " is not my pad", GST_OBJECT_NAME (pad)); GST_OBJECT_UNLOCK (pad); break; } case PROP_ALLOW_NOT_LINKED: tee->allow_not_linked = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } GST_OBJECT_UNLOCK (tee); }