static gboolean gst_jack_audio_src_allocate_channels (GstJackAudioSrc * src, gint channels) { jack_client_t *client; client = gst_jack_audio_client_get_client (src->client); /* remove ports we don't need */ while (src->port_count > channels) jack_port_unregister (client, src->ports[--src->port_count]); /* alloc enough input ports */ src->ports = g_realloc (src->ports, sizeof (jack_port_t *) * channels); src->buffers = g_realloc (src->buffers, sizeof (sample_t *) * channels); /* create an input port for each channel */ while (src->port_count < channels) { gchar *name; /* port names start from 1 and are local to the element */ name = g_strdup_printf ("in_%s_%d", GST_ELEMENT_NAME (src), src->port_count + 1); src->ports[src->port_count] = jack_port_register (client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0); if (src->ports[src->port_count] == NULL) return FALSE; src->port_count++; g_free (name); } return TRUE; }
MbEvent * handle_state_change_message (GstMessage *message) { MbEvent *mb_event = NULL; GstState old_state, new_state; GstElement *source = (GstElement *) message->src; gst_message_parse_state_changed (message, &old_state, &new_state, NULL); if (new_state == GST_STATE_PLAYING) { if (source == _mb_global_data.pipeline) { g_mutex_lock (&(_mb_global_data.mutex)); if (_mb_global_data.initialized == FALSE) { if (_mb_global_data.clock_provider == NULL) _mb_global_data.clock_provider = gst_element_get_clock(_mb_global_data.pipeline); _mb_global_data.initialized = TRUE; mb_event = create_app_event (MB_APP_INIT_DONE); } g_mutex_unlock (&(_mb_global_data.mutex)); } else { if (strcmp (G_OBJECT_TYPE_NAME(G_OBJECT (source)), "GstBin") == 0) mb_event = create_state_change_event (MB_BEGIN, GST_ELEMENT_NAME (source)); } } return mb_event; }
static void register_http_end_points (gint n) { const gchar *url; gint i; for (i = 0; i < n; i++) { GstElement *httpep = gst_element_factory_make ("httpendpoint", NULL); BOOST_CHECK ( httpep != NULL ); GST_DEBUG ("Registering %s", GST_ELEMENT_NAME (httpep) ); url = kms_http_ep_server_register_end_point (httpepserver, httpep, COOKIE_LIFETIME, DISCONNECTION_TIMEOUT); BOOST_CHECK (url != NULL); if (url == NULL) continue; /* Leave the last reference to http end point server */ g_object_unref (G_OBJECT (httpep) ); GST_DEBUG ("Registered url: %s", url); urls = g_slist_prepend (urls, (gpointer *) g_strdup (url) ); } urls_registered = g_slist_length (urls); }
static gboolean debug_graph (gpointer bin) { GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (bin), GST_DEBUG_GRAPH_SHOW_ALL, GST_ELEMENT_NAME (bin)); return FALSE; }
static GstBusSyncReply bus_sync_signal_handler (GstBus * bus, GstMessage * msg, gpointer data) { KmsRecorderEndpoint *self = KMS_RECORDER_ENDPOINT (data); if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) { ErrorData *data; GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (self), GST_DEBUG_GRAPH_SHOW_ALL, GST_ELEMENT_NAME (self)); kms_base_media_muxer_dot_file (self->priv->mux); GST_ERROR_OBJECT (self, "Message %" GST_PTR_FORMAT, msg); data = create_error_data (self, msg); GST_ERROR_OBJECT (self, "Error: %" GST_PTR_FORMAT, msg); gst_task_pool_push (self->priv->pool, kms_recorder_endpoint_post_error, data, NULL); } else if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS) { gst_task_pool_push (self->priv->pool, kms_recorder_endpoint_on_eos_message, self, NULL); } return GST_BUS_PASS; }
static void http_eos_cb (GstElement * appsink, gpointer user_data) { GST_INFO ("EOS received on %s element. Stopping main loop", GST_ELEMENT_NAME (httpep)); g_main_loop_quit (loop); }
static void player_state_changed_cb (GstElement * recorder, KmsUriEndpointState newState, gpointer loop) { GST_INFO ("Element %s changed its state to %s.", GST_ELEMENT_NAME (recorder), state2string (newState)); }
static GstFlowReturn post_recv_sample (GstElement * appsink, gpointer user_data) { GstSample *sample = NULL; GstFlowReturn ret; GstBuffer *buffer; g_signal_emit_by_name (appsink, "pull-sample", &sample); if (sample == NULL) return GST_FLOW_ERROR; buffer = gst_sample_get_buffer (sample); if (buffer == NULL) { ret = GST_FLOW_OK; goto end; } g_signal_emit_by_name (httpep, "push-buffer", buffer, &ret); if (ret != GST_FLOW_OK) { /* something wrong */ GST_ERROR ("Could not send buffer to httpep %s. Ret code %d", GST_ELEMENT_NAME (httpep), ret); } g_object_get (G_OBJECT (httpep), "http-method", &method, NULL); ck_assert_int_eq (method, KMS_HTTP_ENDPOINT_METHOD_POST); end: if (sample != NULL) gst_sample_unref (sample); return ret; }
void __mm_player_streaming_set_buffer(mm_player_streaming_t* streamer, GstElement * buffer, gboolean use_buffering, guint buffer_size, gdouble low_percent, gdouble high_percent, gdouble buffering_time, gboolean use_file, gchar * file_path, guint64 content_size) { debug_fenter(); return_if_fail(streamer); if (buffer) { streamer->buffer = buffer; debug_log("buffer element is %s.", GST_ELEMENT_NAME(buffer)); g_object_set ( G_OBJECT (streamer->buffer), "use-buffering", use_buffering, NULL ); } streaming_set_buffer_size(streamer, buffer_size); streaming_set_buffer_percent(streamer, low_percent, high_percent); streaming_set_buffer_type (streamer, use_file, file_path, content_size); streaming_set_buffering_time(streamer, buffering_time); debug_fleave(); return; }
static void on_demuxElementAdded (GstBin * demux, GstElement * element, gpointer user_data) { GstAdaptiveDemuxTestEnginePrivate *priv = (GstAdaptiveDemuxTestEnginePrivate *) user_data; GstAdaptiveDemuxTestOutputStream *stream = NULL; GstPad *internal_pad; gchar *srcbin_name; gint i; srcbin_name = GST_ELEMENT_NAME (element); GST_TEST_LOCK (priv); for (i = 0; i < priv->engine.output_streams->len; i++) { stream = g_ptr_array_index (priv->engine.output_streams, i); if (strstr (srcbin_name, GST_PAD_NAME (stream->pad)) != NULL) break; } fail_unless (stream != NULL); /* keep the reference to the internal_pad. * We will need it to identify the stream in the on_demuxReceivesEvent callback */ if (stream->internal_pad) { gst_pad_remove_probe (stream->internal_pad, stream->internal_pad_probe); gst_object_unref (stream->internal_pad); } internal_pad = gst_element_get_static_pad (element, "src"); stream->internal_pad_probe = gst_pad_add_probe (internal_pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, (GstPadProbeCallback) on_demuxReceivesEvent, priv, NULL); stream->internal_pad = internal_pad; GST_TEST_UNLOCK (priv); }
void GstPlayer::handleAddedPad(GstElement * upstream, GstPad * upstreamNewPad, GstElement * downstream) { GstPad *downstreamPad = gst_element_get_static_pad ( downstream, "sink"); GstPadLinkReturn result; GstCaps * newPadCaps = NULL; GstStructure * newPadStruct = NULL; const gchar * newPadType = NULL; QLOG_TRACE() << "Got pad " << GST_PAD_NAME (upstreamNewPad) << " from " << GST_ELEMENT_NAME (upstream); if (gst_pad_is_linked (downstreamPad)) { QLOG_TRACE() << " Pad already connected to downstream."; }else{ newPadCaps = gst_pad_get_caps (upstreamNewPad); newPadStruct = gst_caps_get_structure (newPadCaps, 0); newPadType = gst_structure_get_name (newPadStruct); if (!g_str_has_prefix (newPadType, "audio/x-raw")) { QLOG_TRACE() << "Pad is not of type is not raw audio but of type "<< newPadType <<". Can't connect."; }else{ result = gst_pad_link (upstreamNewPad, downstreamPad); if (GST_PAD_LINK_FAILED (result)) { QLOG_TRACE() << "Failed to link."; } else { QLOG_TRACE() << "Link successful."; } } } if (newPadCaps != NULL) gst_caps_unref (newPadCaps); gst_object_unref (downstreamPad); }
static gboolean bus_handler (GstBus * bus, GstMessage * message, gpointer data) { GMainLoop *loop = (GMainLoop *) data; switch (message->type) { case GST_MESSAGE_EOS:{ GST_LOG ("EOS event received"); g_main_loop_quit (loop); break; } case GST_MESSAGE_ERROR:{ GError *gerror; gchar *debug; gst_message_parse_error (message, &gerror, &debug); g_error ("Error from %s: %s (%s)\n", GST_ELEMENT_NAME (GST_MESSAGE_SRC (message)), gerror->message, GST_STR_NULL (debug)); g_error_free (gerror); g_free (debug); g_main_loop_quit (loop); break; } case GST_MESSAGE_WARNING:{ g_main_loop_quit (loop); break; } default: break; } return TRUE; }
static void kms_sdp_session_post_constructor (KmsSdpSession * self, KmsBaseSdpEndpoint * ep, guint id) { self->id = id; self->id_str = g_strdup_printf ("%s-sess%d", GST_ELEMENT_NAME (ep), id); self->ep = ep; }
static void appsink_eos_cb (GstElement * appsink, gpointer user_data) { GstFlowReturn ret; GST_INFO ("EOS received on %s. Preparing %s to finish the test", GST_ELEMENT_NAME (appsink), GST_ELEMENT_NAME (test_pipeline)); g_signal_emit_by_name (httpep, "end-of-stream", &ret); if (ret != GST_FLOW_OK) { // something wrong GST_ERROR ("Could not send EOS to %s. Ret code %d", GST_ELEMENT_NAME (httpep), ret); fail ("Can not send buffer to", GST_ELEMENT_NAME (httpep)); } }
void kms_muxing_pipeline_dot_file (KmsMuxingPipeline * obj) { g_return_if_fail (obj != NULL); GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (obj->priv->pipeline), GST_DEBUG_GRAPH_SHOW_ALL, GST_ELEMENT_NAME (obj->priv->pipeline)); }
static void recorder_state_changed_cb (GstElement * recorder, KmsUriEndpointState newState, gpointer loop) { GST_INFO ("Element %s changed its state to %s.", GST_ELEMENT_NAME (recorder), state2string (newState)); if (newState == KMS_URI_ENDPOINT_STATE_STOP) g_main_loop_quit (loop); }
static void post_decodebin_pad_removed_handler (GstElement * decodebin, GstPad * pad, KmsHttpEndpoint * self) { GstElement *appsink, *appsrc; GstPad *sinkpad; if (GST_PAD_IS_SINK (pad)) return; GST_DEBUG ("pad %" GST_PTR_FORMAT " removed", pad); appsink = g_object_steal_qdata (G_OBJECT (pad), appsink_data_quark ()); if (appsink == NULL) { GST_ERROR ("No appsink was found associated with %" GST_PTR_FORMAT, pad); return; } sinkpad = gst_element_get_static_pad (appsink, "sink"); appsrc = g_object_get_qdata (G_OBJECT (sinkpad), appsrc_data_quark ()); g_object_unref (sinkpad); if (!gst_element_set_locked_state (appsink, TRUE)) GST_ERROR ("Could not block element %s", GST_ELEMENT_NAME (appsink)); GST_DEBUG ("Removing appsink %s from %s", GST_ELEMENT_NAME (appsink), GST_ELEMENT_NAME (self->pipeline)); gst_element_set_state (appsink, GST_STATE_NULL); gst_bin_remove (GST_BIN (self->pipeline), appsink); if (appsrc == NULL) { GST_ERROR ("No appsink was found associated with %" GST_PTR_FORMAT, pad); return; } if (GST_OBJECT_PARENT (appsrc) != NULL) { g_object_ref (appsrc); gst_bin_remove (GST_BIN (GST_OBJECT_PARENT (appsrc)), appsrc); gst_element_set_state (appsrc, GST_STATE_NULL); g_object_unref (appsrc); } }
static GstStateChangeReturn nle_object_change_state (GstElement * element, GstStateChange transition) { GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: { GstObject *parent = gst_object_get_parent (GST_OBJECT (element)); /* Going to READY and if we are not in a composition, we need to make * sure that the object positioning state is properly commited */ if (parent) { if (g_strcmp0 (GST_ELEMENT_NAME (GST_ELEMENT (parent)), "current-bin") && !NLE_OBJECT_IS_COMPOSITION (NLE_OBJECT (element))) { GST_INFO ("Adding nleobject to something that is not a composition," " commiting ourself"); nle_object_commit (NLE_OBJECT (element), FALSE); } gst_object_unref (parent); } } break; case GST_STATE_CHANGE_READY_TO_PAUSED: if (nle_object_prepare (NLE_OBJECT (element)) == GST_STATE_CHANGE_FAILURE) { ret = GST_STATE_CHANGE_FAILURE; goto beach; } break; default: break; } GST_DEBUG_OBJECT (element, "Calling parent change_state"); ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); GST_DEBUG_OBJECT (element, "Return from parent change_state was %d", ret); if (ret == GST_STATE_CHANGE_FAILURE) goto beach; switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_READY: /* cleanup nleobject */ if (nle_object_cleanup (NLE_OBJECT (element)) == GST_STATE_CHANGE_FAILURE) ret = GST_STATE_CHANGE_FAILURE; break; default: break; } beach: return ret; }
void GstShow::newPad(GstElement *src, GstPad *new_pad, gpointer data) { GstPad *sink_pad; GstElement *color = (GstElement *) data; GstPadLinkReturn ret; GstCaps *new_pad_caps = NULL; GstStructure *new_pad_struct = NULL; const gchar *new_pad_type = NULL; g_print ("Received new pad '%s' from '%s':\n", GST_PAD_NAME (new_pad), GST_ELEMENT_NAME (src)); new_pad_caps = gst_pad_get_current_caps (new_pad); new_pad_struct = gst_caps_get_structure (new_pad_caps, 0); new_pad_type = gst_structure_get_name (new_pad_struct); g_print (" It has type '%s'.\n", new_pad_type); sink_pad = gst_element_get_static_pad (color, "sink"); if (!sink_pad){ L_(lerror) << "Gstreamer: no pad named sink"; return; } /* If our converter is already linked, we have nothing to do here */ if (gst_pad_is_linked (sink_pad)) { g_print (" We are already linked. Ignoring.\n"); /* Unreference the new pad's caps, if we got them */ if (new_pad_caps != NULL) gst_caps_unref (new_pad_caps); /* Unreference the sink pad */ gst_object_unref (sink_pad); return; } /* Attempt the link */ ret = gst_pad_link (new_pad, sink_pad); if (GST_PAD_LINK_FAILED (ret)) { g_print (" Type is '%s' but link failed.\n", new_pad_type); /* Unreference the new pad's caps, if we got them */ if (new_pad_caps != NULL) gst_caps_unref (new_pad_caps); /* Unreference the sink pad */ gst_object_unref (sink_pad); return; } else { g_print (" Link succeeded (type '%s').\n", new_pad_type); } }
static void bus_msg_cb (GstBus *bus, GstMessage *msg, gpointer pipeline) { switch (msg->type) { case GST_MESSAGE_ERROR: { GST_ERROR ("%s bus error: %" GST_PTR_FORMAT, GST_ELEMENT_NAME (pipeline), msg); BOOST_FAIL ("Error received on the bus"); break; } case GST_MESSAGE_WARNING: { GST_WARNING ("%s bus: %" GST_PTR_FORMAT, GST_ELEMENT_NAME (pipeline), msg); break; } default: break; } }
const gchar * gst_validate_monitor_get_element_name (GstValidateMonitor * monitor) { GstElement *element; element = gst_validate_monitor_get_element (monitor); if (element) return GST_ELEMENT_NAME (element); return NULL; }
static void vc_pad_added_handler (GstElement *src, GstPad *new_pad, vc_data *data) { GstPad *sink_pad = gst_element_get_static_pad (data->gst_data.depayloader, "sink"); GstPadLinkReturn ret; GstCaps *new_pad_caps = NULL; GstStructure *new_pad_struct = NULL; const gchar *new_pad_type = NULL; g_print ("Received new pad '%s' from '%s':\n", GST_PAD_NAME (new_pad), GST_ELEMENT_NAME (src)); /* Check the new pad's name */ if (!g_str_has_prefix (GST_PAD_NAME (new_pad), "recv_rtp_src_")) { g_print (" It is not the right pad. Need recv_rtp_src_. Ignoring.\n"); goto exit; } /* If our converter is already linked, we have nothing to do here */ if (gst_pad_is_linked (sink_pad)) { g_print (" Sink pad from %s already linked. Ignoring.\n", GST_ELEMENT_NAME (src)); goto exit; } /* Check the new pad's type */ new_pad_caps = gst_pad_get_caps (new_pad); new_pad_struct = gst_caps_get_structure (new_pad_caps, 0); new_pad_type = gst_structure_get_name (new_pad_struct); /* Attempt the link */ ret = gst_pad_link (new_pad, sink_pad); if (GST_PAD_LINK_FAILED (ret)) { g_print (" Type is '%s' but link failed.\n", new_pad_type); } else { g_print (" Link succeeded (type '%s').\n", new_pad_type); } exit: /* Unreference the new pad's caps, if we got them */ if (new_pad_caps != NULL) gst_caps_unref (new_pad_caps); /* Unreference the sink pad */ gst_object_unref (sink_pad); }
static gboolean disconnect_elements (GstElement * agnosticbin, GstElement * audiomixer) { gboolean done = FALSE, disconnected = FALSE; GValue val = G_VALUE_INIT; GstIterator *it; it = gst_element_iterate_src_pads (agnosticbin); do { switch (gst_iterator_next (it, &val)) { case GST_ITERATOR_OK: { GstPad *srcpad, *sinkpad; GstElement *mixer; srcpad = g_value_get_object (&val); sinkpad = gst_pad_get_peer (srcpad); mixer = gst_pad_get_parent_element (sinkpad); if (mixer == audiomixer) { GST_DEBUG ("Unlink %" GST_PTR_FORMAT " and %" GST_PTR_FORMAT, agnosticbin, mixer); if (!gst_pad_unlink (srcpad, sinkpad)) { GST_ERROR ("Can not unlink %" GST_PTR_FORMAT " and %" GST_PTR_FORMAT, srcpad, sinkpad); } gst_element_release_request_pad (mixer, sinkpad); gst_element_release_request_pad (agnosticbin, srcpad); disconnected |= TRUE; } gst_object_unref (sinkpad); gst_object_unref (mixer); g_value_reset (&val); break; } case GST_ITERATOR_RESYNC: gst_iterator_resync (it); break; case GST_ITERATOR_ERROR: GST_ERROR ("Error iterating over %s's src pads", GST_ELEMENT_NAME (agnosticbin)); case GST_ITERATOR_DONE: g_value_unset (&val); done = TRUE; break; } } while (!done); gst_iterator_free (it); return disconnected; }
/* This function will be called by the pad-added signal */ static void pad_added_handler(GstElement *src, GstPad *new_pad, CustomData *data) { GstPad *sink_pad = NULL; GstPadLinkReturn ret; GstCaps *new_pad_caps = NULL; GstStructure *new_pad_struct = NULL; const gchar *new_pad_type = NULL; g_print("Received new pad '%s' from '%s':\n", GST_PAD_NAME(new_pad), GST_ELEMENT_NAME(src)); /* Check the new pad's type */ new_pad_caps = gst_pad_get_caps(new_pad); new_pad_struct = gst_caps_get_structure(new_pad_caps, 0); new_pad_type = gst_structure_get_name(new_pad_struct); if (g_str_has_prefix(new_pad_type, "video/x-raw")) { sink_pad = gst_element_get_static_pad(data->vsink, "sink"); if (gst_pad_is_linked(sink_pad)) { g_print(" We are already linked. Ignoring.\n"); goto exit; } } if (g_str_has_prefix(new_pad_type, "audio/x-raw")) { sink_pad = gst_element_get_static_pad(data->convert, "sink"); if (gst_pad_is_linked(sink_pad)) { g_print(" We are already linked. Ignoring.\n"); goto exit; } } /* Attempt the link */ ret = gst_pad_link(new_pad, sink_pad); if (GST_PAD_LINK_FAILED(ret)) { g_print(" Type is '%s' but link failed.\n", new_pad_type); } else { g_print(" Link succeeded (type '%s').\n", new_pad_type); } exit: /* Unreference the new pad's caps, if we got them */ if (new_pad_caps != NULL) gst_caps_unref(new_pad_caps); /* Unreference the sink pad */ if (sink_pad != NULL) gst_object_unref(sink_pad); }
static void uridecodebin_element_added_cb (GstElement * uridecodebin, GstElement * child, GstDiscoverer * dc) { GST_DEBUG ("New element added to uridecodebin : %s", GST_ELEMENT_NAME (child)); if (G_OBJECT_TYPE (child) == dc->priv->decodebin2_type) { g_object_set (child, "post-stream-topology", TRUE, NULL); } }
/* Create and link output pad: selector:src%d ! output_pad */ static GstPad * setup_output_pad (GstElement * element, GstStaticPadTemplate * tmpl) { GstPad *srcpad = NULL, *output_pad = NULL; gulong probe_id = 0; if (tmpl == NULL) tmpl = &sinktemplate; /* create output_pad */ output_pad = gst_pad_new_from_static_template (tmpl, "sink"); fail_if (output_pad == NULL, "Could not create a output_pad"); /* add probe */ probe_id = gst_pad_add_probe (output_pad, GST_PAD_PROBE_TYPE_DATA_BOTH, (GstPadProbeCallback) probe_cb, NULL, NULL); g_object_set_data (G_OBJECT (output_pad), "probe_id", GINT_TO_POINTER (probe_id)); /* request src pad */ srcpad = gst_element_get_request_pad (element, "src_%u"); fail_if (srcpad == NULL, "Could not get source pad from %s", GST_ELEMENT_NAME (element)); /* link pads and activate */ fail_unless (gst_pad_link (srcpad, output_pad) == GST_PAD_LINK_OK, "Could not link %s source and output pad", GST_ELEMENT_NAME (element)); gst_pad_set_active (output_pad, TRUE); GST_DEBUG_OBJECT (output_pad, "set up %" GST_PTR_FORMAT " ! %" GST_PTR_FORMAT, srcpad, output_pad); gst_object_unref (srcpad); ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1); return output_pad; }
static int find_input_selector (GValue * value, void *userdata) { GstElement *element = g_value_get_object (value); g_assert (GST_IS_ELEMENT (element)); if (g_str_has_prefix (GST_ELEMENT_NAME (element), "inputselector")) { guint npads; g_object_get (element, "n-pads", &npads, NULL); if (npads > 1) return 0; } return !0; }
/* Must be called with mutex locked. */ static void gst_uri_downloader_stop (GstUriDownloader * downloader) { GstPad *pad; GstElement *urisrc; if (!downloader->priv->urisrc) return; GST_DEBUG_OBJECT (downloader, "Stopping source element %s", GST_ELEMENT_NAME (downloader->priv->urisrc)); /* remove the bus' sync handler */ gst_bus_set_sync_handler (downloader->priv->bus, NULL, NULL, NULL); /* unlink the source element from the internal pad */ pad = gst_pad_get_peer (downloader->priv->pad); if (pad) { gst_pad_unlink (pad, downloader->priv->pad); gst_object_unref (pad); } urisrc = downloader->priv->urisrc; downloader->priv->urisrc = NULL; /* unlock so it doesn't block on chain function while changing state */ g_mutex_unlock (&downloader->priv->lock); GST_DEBUG_OBJECT (downloader, "Stopping source element %s", GST_ELEMENT_NAME (urisrc)); /* set the element state to NULL */ gst_element_set_state (urisrc, GST_STATE_NULL); gst_element_get_state (urisrc, NULL, NULL, GST_CLOCK_TIME_NONE); gst_element_set_bus (urisrc, NULL); gst_object_unref (urisrc); /* caller expects the mutex to be locked */ g_mutex_lock (&downloader->priv->lock); gst_bus_set_flushing (downloader->priv->bus, TRUE); }
static GstBusSyncReply bus_sync_signal_handler (GstBus * bus, GstMessage * msg, gpointer data) { KmsRecorderEndpoint *self = KMS_RECORDER_ENDPOINT (data); if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) { ErrorData *data; GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (self), GST_DEBUG_GRAPH_SHOW_ALL, GST_ELEMENT_NAME (self)); kms_base_media_muxer_dot_file (self->priv->mux); GST_ERROR_OBJECT (self, "Message %" GST_PTR_FORMAT, msg); data = create_error_data (self, msg); GST_ERROR_OBJECT (self, "Error: %" GST_PTR_FORMAT, msg); gst_task_pool_push (self->priv->pool, kms_recorder_endpoint_post_error, data, NULL); } else if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS) { gst_task_pool_push (self->priv->pool, kms_recorder_endpoint_on_eos_message, self, NULL); } else if ((GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STATE_CHANGED) && (GST_OBJECT_CAST (KMS_BASE_MEDIA_MUXER_GET_PIPELINE (self-> priv->mux)) == GST_MESSAGE_SRC (msg))) { GstState new_state, pending; gst_message_parse_state_changed (msg, NULL, &new_state, &pending); if (pending == GST_STATE_VOID_PENDING || (pending == GST_STATE_NULL && new_state == GST_STATE_READY)) { GST_DEBUG_OBJECT (self, "Pipeline changed state to %d", new_state); switch (new_state) { case GST_STATE_PLAYING: kms_recorder_endpoint_state_changed (self, KMS_URI_ENDPOINT_STATE_START); break; case GST_STATE_READY: kms_recorder_endpoint_state_changed (self, KMS_URI_ENDPOINT_STATE_STOP); break; default: GST_DEBUG_OBJECT (self, "Not raising event"); break; } } } return GST_BUS_PASS; }
static GstElement * get_encoder (const GstCaps * caps, GError ** err) { GList *encoders = NULL; GList *filtered = NULL; GstElementFactory *factory = NULL; GstElement *encoder = NULL; encoders = gst_element_factory_list_get_elements (GST_ELEMENT_FACTORY_TYPE_ENCODER | GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE, GST_RANK_NONE); if (encoders == NULL) { *err = g_error_new (GST_CORE_ERROR, GST_CORE_ERROR_MISSING_PLUGIN, "Cannot find any image encoder"); goto fail; } GST_INFO ("got factory list %p", encoders); gst_plugin_feature_list_debug (encoders); filtered = gst_element_factory_list_filter (encoders, caps, GST_PAD_SRC, FALSE); GST_INFO ("got filtered list %p", filtered); if (filtered == NULL) { gchar *tmp = gst_caps_to_string (caps); *err = g_error_new (GST_CORE_ERROR, GST_CORE_ERROR_MISSING_PLUGIN, "Cannot find any image encoder for caps %s", tmp); g_free (tmp); goto fail; } gst_plugin_feature_list_debug (filtered); factory = (GstElementFactory *) filtered->data; GST_INFO ("got factory %p", factory); encoder = gst_element_factory_create (factory, NULL); GST_INFO ("created encoder element %p, %s", encoder, GST_ELEMENT_NAME (encoder)); fail: if (encoders) gst_plugin_feature_list_free (encoders); if (filtered) gst_plugin_feature_list_free (filtered); return encoder; }