static GstEvent * create_event (GstEventType type) { GstEvent *event = NULL; switch (type) { case GST_EVENT_CUSTOM_DOWNSTREAM: event = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, gst_structure_new ("x-app/test", "test-field", G_TYPE_STRING, "test-value", NULL)); break; case GST_EVENT_CUSTOM_DOWNSTREAM_OOB: event = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM_OOB, gst_structure_new ("x-app/test", "test-field", G_TYPE_STRING, "test-value", NULL)); break; case GST_EVENT_EOS: event = gst_event_new_eos (); break; default: g_assert_not_reached (); break; } return event; }
/** * gst_event_new_tag: * @taglist: (transfer full): metadata list. The event will take ownership * of the taglist. * * Generates a metadata tag event from the given @taglist. * * Returns: (transfer full): a new #GstEvent */ GstEvent * gst_event_new_tag (GstTagList * taglist) { g_return_val_if_fail (taglist != NULL, NULL); return gst_event_new_custom (GST_EVENT_TAG, (GstStructure *) taglist); }
static void push_lost_event (GstHarness * h, guint32 seqnum, guint64 timestamp, guint64 duration, gboolean event_goes_through) { GstEvent *packet_loss_in = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, gst_structure_new ("GstRTPPacketLost", "seqnum", G_TYPE_UINT, seqnum, "timestamp", G_TYPE_UINT64, timestamp, "duration", G_TYPE_UINT64, duration, NULL)); GstEvent *it, *packet_loss_out = NULL; fail_unless_equals_int (TRUE, gst_harness_push_event (h, packet_loss_in)); while (NULL != (it = gst_harness_try_pull_event (h))) { if (GST_EVENT_TYPE (it) != GST_EVENT_CUSTOM_DOWNSTREAM || !gst_event_has_name (it, "GstRTPPacketLost")) { gst_event_unref (it); } else { packet_loss_out = it; break; } } if (event_goes_through) { fail_unless (packet_loss_in == packet_loss_out); gst_event_unref (packet_loss_out); } else { fail_unless (NULL == packet_loss_out); } }
gboolean fs_rtp_special_sources_stop_telephony_event (GList *current_extra_sources, FsDTMFMethod method) { GstStructure *structure = NULL; gchar *method_str; structure = gst_structure_new ("dtmf-event", "start", G_TYPE_BOOLEAN, FALSE, "type", G_TYPE_INT, 1, NULL); switch (method) { case FS_DTMF_METHOD_AUTO: method_str = "default"; break; case FS_DTMF_METHOD_RTP_RFC4733: method_str="RFC4733"; gst_structure_set (structure, "method", G_TYPE_INT, 1, NULL); break; case FS_DTMF_METHOD_IN_BAND: method_str="sound"; gst_structure_set (structure, "method", G_TYPE_INT, 2, NULL); break; default: method_str="unknown (defaulting to auto)"; } GST_DEBUG ("stopping telephony event using method=%s", method_str); return fs_rtp_special_sources_send_event (current_extra_sources, gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, structure)); }
static gpointer progress_buffer_range_monitor(ProgressBuffer *element) { g_mutex_lock(&element->lock); check_loop: while (element->srcresult == GST_FLOW_OK && !pending_eos(element) && (pending_range_start(element) || pending_range_stop(element) || !VALID_RANGE(element->range_start) && !VALID_RANGE(element->range_stop))) { g_cond_wait(&element->add_cond, &element->lock); } if (element->srcresult == GST_FLOW_OK && (VALID_RANGE(element->range_start) || VALID_RANGE(element->range_stop))) { element->range_stop = element->range_start = NO_RANGE_REQUEST; g_mutex_unlock(&element->lock); gst_pad_push_event(element->srcpad, gst_event_new_custom(FX_EVENT_RANGE_READY, NULL)); g_mutex_lock(&element->lock); goto check_loop; } else g_mutex_unlock(&element->lock); return NULL; }
/** * gst_event_new_navigation: * @structure: (transfer full): description of the event. The event will take * ownership of the structure. * * Create a new navigation event from the given description. * * Returns: (transfer full): a new #GstEvent */ GstEvent * gst_event_new_navigation (GstStructure * structure) { g_return_val_if_fail (structure != NULL, NULL); return gst_event_new_custom (GST_EVENT_NAVIGATION, structure); }
void lock_check_cb (GstPad * pad, int i) { GstStructure *s; GstEvent *event; if (i % 2) s = gst_structure_new ("stream-lock", "lock", G_TYPE_BOOLEAN, FALSE, NULL); else s = gst_structure_new ("stream-lock", "lock", G_TYPE_BOOLEAN, TRUE, NULL); event = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM_OOB, s); gst_pad_push_event (pad, event); if (i % 2) { fail_unless (buffers == NULL); } else { fail_unless (buffers && g_list_length (buffers) == 1); fail_unless (gst_rtp_buffer_get_ssrc (buffers->data) == 55); fail_unless (gst_rtp_buffer_get_timestamp (buffers->data) == 200 - 57 + 1000 + i); fail_unless (gst_rtp_buffer_get_seq (buffers->data) == 100 + 1 + (i / 2)); g_list_foreach (buffers, (GFunc) gst_buffer_unref, NULL); g_list_free (buffers); buffers = NULL; } }
static GstEvent * create_rtx_event (guint32 ssrc, guint8 payload_type, guint16 seqnum) { return gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, gst_structure_new ("GstRTPRetransmissionRequest", "seqnum", G_TYPE_UINT, seqnum, "ssrc", G_TYPE_UINT, ssrc, "payload-type", G_TYPE_UINT, payload_type, NULL)); }
static GstEvent * create_ntp_offset_event (GstClockTime ntp_offset, gboolean discont) { GstStructure *structure; structure = gst_structure_new ("GstNtpOffset", "ntp-offset", G_TYPE_UINT64, ntp_offset, "discont", G_TYPE_BOOLEAN, discont, NULL); return gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, structure); }
static GstEvent * gst_vader_event_new(GstVader *c, GstEventType type, GstClockTime timestamp) { GstEvent *e; e = gst_event_new_custom(type, NULL); GST_EVENT_TIMESTAMP(e) = timestamp; return e; }
static GstFlowReturn oob_source_create (GstPushSrc * src, GstBuffer ** p_buf) { *p_buf = gst_buffer_new (); gst_pad_push_event (GST_BASE_SRC_PAD (src), gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM_OOB, NULL)); return GST_FLOW_OK; }
GstEvent * kms_utils_remb_event_upstream_new (guint bitrate, guint ssrc) { GstEvent *event; event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, gst_structure_new (KMS_REMB_EVENT_NAME, "bitrate", G_TYPE_UINT, bitrate, "ssrc", G_TYPE_UINT, ssrc, NULL)); return event; }
/** * gst_event_new_reconfigure: * Create a new reconfigure event. The purpose of the reconfingure event is * to travel upstream and make elements renegotiate their caps or reconfigure * their buffer pools. This is useful when changing properties on elements * or changing the topology of the pipeline. * * Returns: (transfer full): a new #GstEvent */ GstEvent * gst_event_new_reconfigure (void) { GstEvent *event; GST_CAT_INFO (GST_CAT_EVENT, "creating reconfigure event"); event = gst_event_new_custom (GST_EVENT_RECONFIGURE, NULL); return event; }
static GstPadProbeReturn rtpsession_sinkpad_probe2 (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) { GstPadProbeReturn ret = GST_PAD_PROBE_OK; if (info->type == (GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_PUSH)) { GstBuffer *buffer = GST_BUFFER (info->data); GstRTPBuffer rtp = GST_RTP_BUFFER_INIT; guint payload_type = 0; static gint i = 0; /* retrieve current ssrc for retransmission stream only */ gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp); payload_type = gst_rtp_buffer_get_payload_type (&rtp); if (payload_type == 99) { if (i < 3) rtx_ssrc_before = gst_rtp_buffer_get_ssrc (&rtp); else rtx_ssrc_after = gst_rtp_buffer_get_ssrc (&rtp); } else { /* ask to retransmit every packet */ GstEvent *event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, gst_structure_new ("GstRTPRetransmissionRequest", "seqnum", G_TYPE_UINT, gst_rtp_buffer_get_seq (&rtp), "ssrc", G_TYPE_UINT, gst_rtp_buffer_get_ssrc (&rtp), NULL)); gst_pad_push_event (pad, event); if (i < 3) ssrc_before = gst_rtp_buffer_get_ssrc (&rtp); else ssrc_after = gst_rtp_buffer_get_ssrc (&rtp); } gst_rtp_buffer_unmap (&rtp); /* feint a collision on recv_rtcp_sink pad of gstrtpsession * (note that after being marked as collied the rtpsession ignores * all non bye packets) */ if (i == 2) { GstBuffer *rtcp_buffer = create_rtcp_app (rtx_ssrc_before, 0); /* push collied packet on recv_rtcp_sink */ gst_pad_push (srcpad, rtcp_buffer); } ++i; } return ret; }
static void kms_recorder_end_point_send_force_key_unit_event (GstElement * valve) { GstStructure *s; GstEvent *force_key_unit_event; GST_DEBUG ("Sending key "); s = gst_structure_new ("GstForceKeyUnit", "all-headers", G_TYPE_BOOLEAN, TRUE, NULL); force_key_unit_event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, s); gst_element_send_event (valve, force_key_unit_event); }
/* * This function sends a dummy event to force blocked probe to be called */ static void send_dummy_event (GstPad * pad, const gchar * name) { GstElement *parent = gst_pad_get_parent_element (pad); if (parent == NULL) { return; } if (GST_PAD_IS_SINK (pad)) { gst_pad_send_event (pad, gst_event_new_custom (GST_EVENT_TYPE_DOWNSTREAM | GST_EVENT_TYPE_SERIALIZED, gst_structure_new_empty (name))); } else { gst_pad_send_event (pad, gst_event_new_custom (GST_EVENT_TYPE_UPSTREAM | GST_EVENT_TYPE_SERIALIZED, gst_structure_new_empty (name))); } g_object_unref (parent); }
/** * gst_video_event_new_still_frame: * @in_still: boolean value for the still-frame state of the event. * * Creates a new Still Frame event. If @in_still is %TRUE, then the event * represents the start of a still frame sequence. If it is %FALSE, then * the event ends a still frame sequence. * * To parse an event created by gst_video_event_new_still_frame() use * gst_video_event_parse_still_frame(). * * Returns: The new GstEvent */ GstEvent * gst_video_event_new_still_frame (gboolean in_still) { GstEvent *still_event; GstStructure *s; s = gst_structure_new (GST_VIDEO_EVENT_STILL_STATE_NAME, "still-state", G_TYPE_BOOLEAN, in_still, NULL); still_event = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, s); return still_event; }
void QtCamRoi::setRegionOfInterest(const QRectF& roi) { if (!d_ptr->dev || !d_ptr->dev->viewfinder()) { return; } QSizeF vf = d_ptr->dev->viewfinder()->videoResolution(); if (vf.isEmpty()) { return; } int frameWidth = vf.width(); int frameHeight = vf.height(); int x = roi.x() * frameWidth; int y = roi.y() * frameHeight; int width = roi.width() * frameWidth; int height = roi.height() * frameHeight; // if we have an empty roi then we reset: int priority = roi.isEmpty() ? 0 : 1; GstStructure *region = gst_structure_new("region0", "region-x", G_TYPE_UINT, x, "region-y", G_TYPE_UINT, y, "region-w", G_TYPE_UINT, width, "region-h", G_TYPE_UINT, height, "region-priority", G_TYPE_UINT, priority, "region-id", G_TYPE_UINT, 0, NULL); GValue regionValue = G_VALUE_INIT; GValue regionList = G_VALUE_INIT; g_value_init(®ionValue, GST_TYPE_STRUCTURE); g_value_init(®ionList, GST_TYPE_LIST); gst_value_set_structure(®ionValue, region); gst_value_list_append_value(®ionList, ®ionValue); GstStructure *s = gst_structure_new("regions-of-interest", "frame-width", G_TYPE_UINT, frameWidth, "frame-height", G_TYPE_UINT, frameHeight, NULL); gst_structure_set_value(s, "regions", ®ionList); GstEvent *event = gst_event_new_custom(GST_EVENT_CUSTOM_UPSTREAM, s); gst_structure_free(region); g_value_unset(®ionValue); g_value_unset(®ionList); if (!d_ptr->sendEventToSource(event)) { qWarning() << "Failed to send ROI event"; } }
/** * gst_event_new_stream_start: * @stream_id: Identifier for this stream * * Create a new STREAM_START event. The stream start event can only * travel downstream synchronized with the buffer flow. It is expected * to be the first event that is sent for a new stream. * * Source elements, demuxers and other elements that create new streams * are supposed to send this event as the first event of a new stream. It * should not be send after a flushing seek or in similar situations * and is used to mark the beginning of a new logical stream. Elements * combining multiple streams must ensure that this event is only forwarded * downstream once and not for every single input stream. * * The @stream_id should be a unique string that consists of the upstream * stream-id, / as separator and a unique stream-id for this specific * stream. A new stream-id should only be created for a stream if the upstream * stream is split into (potentially) multiple new streams, e.g. in a demuxer, * but not for every single element in the pipeline. * gst_pad_create_stream_id() or gst_pad_create_stream_id_printf() can be * used to create a stream-id. * * Returns: (transfer full): the new STREAM_START event. */ GstEvent * gst_event_new_stream_start (const gchar * stream_id) { GstStructure *s; g_return_val_if_fail (stream_id != NULL, NULL); s = gst_structure_new_id (GST_QUARK (EVENT_STREAM_START), GST_QUARK (STREAM_ID), G_TYPE_STRING, stream_id, NULL); return gst_event_new_custom (GST_EVENT_STREAM_START, s); }
/** * gst_event_new_flush_stop: * @reset_time: if time should be reset * * Allocate a new flush stop event. The flush stop event can be sent * upstream and downstream and travels serialized with the dataflow. * It is typically sent after sending a FLUSH_START event to make the * pads accept data again. * * Elements can process this event synchronized with the dataflow since * the preceeding FLUSH_START event stopped the dataflow. * * This event is typically generated to complete a seek and to resume * dataflow. * * Returns: (transfer full): a new flush stop event. */ GstEvent * gst_event_new_flush_stop (gboolean reset_time) { GstEvent *event; GST_CAT_INFO (GST_CAT_EVENT, "creating flush stop %d", reset_time); event = gst_event_new_custom (GST_EVENT_FLUSH_STOP, gst_structure_new_id (GST_QUARK (EVENT_FLUSH_STOP), GST_QUARK (RESET_TIME), G_TYPE_BOOLEAN, reset_time, NULL)); return event; }
static void send_latency_probe (GstElement * parent, GstPad * pad, guint64 ts) { if (parent && (!GST_IS_BIN (parent)) && GST_OBJECT_FLAG_IS_SET (parent, GST_ELEMENT_FLAG_SOURCE)) { GstEvent *latency_probe = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, gst_structure_new_id (latency_probe_id, latency_probe_pad, GST_TYPE_PAD, pad, latency_probe_ts, G_TYPE_UINT64, ts, NULL)); gst_pad_push_event (pad, latency_probe); } }
/** * gst_event_new_toc_select: * @uid: UID in the TOC to start playback from. * * Generate a TOC select event with the given @uid. The purpose of the * TOC select event is to start playback based on the TOC's entry with the * given @uid. * * Returns: a new #GstEvent. */ GstEvent * gst_event_new_toc_select (const gchar * uid) { GstStructure *structure; g_return_val_if_fail (uid != NULL, NULL); GST_CAT_INFO (GST_CAT_EVENT, "creating toc select event for UID: %s", uid); structure = gst_structure_new_id (GST_QUARK (EVENT_TOC_SELECT), GST_QUARK (UID), G_TYPE_STRING, uid, NULL); return gst_event_new_custom (GST_EVENT_TOC_SELECT, structure); }
/** * gst_event_new_tag: * @taglist: (transfer full): metadata list. The event will take ownership * of the taglist. * * Generates a metadata tag event from the given @taglist. * * The scope of the taglist specifies if the taglist applies to the * complete medium or only to this specific stream. As the tag event * is a sticky event, elements should merge tags received from * upstream with a given scope with their own tags with the same * scope and create a new tag event from it. * * Returns: (transfer full): a new #GstEvent */ GstEvent * gst_event_new_tag (GstTagList * taglist) { GstStructure *s; GValue val = G_VALUE_INIT; const gchar *names[] = { "GstTagList-stream", "GstTagList-global" }; g_return_val_if_fail (taglist != NULL, NULL); s = gst_structure_new_empty (names[gst_tag_list_get_scope (taglist)]); g_value_init (&val, GST_TYPE_TAG_LIST); g_value_take_boxed (&val, taglist); gst_structure_id_take_value (s, GST_QUARK (TAGLIST), &val); return gst_event_new_custom (GST_EVENT_TAG, s); }
static void gst_dtmf_src_set_stream_lock (GstDTMFSrc * dtmfsrc, gboolean lock) { GstPad *srcpad = GST_BASE_SRC_PAD (dtmfsrc); GstEvent *event; GstStructure *structure; structure = gst_structure_new ("stream-lock", "lock", G_TYPE_BOOLEAN, lock, NULL); event = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM_OOB, structure); if (!gst_pad_push_event (srcpad, event)) { GST_WARNING_OBJECT (dtmfsrc, "stream-lock event not handled"); } }
/** * gst_event_new_latency: * @latency: the new latency value * * Create a new latency event. The event is sent upstream from the sinks and * notifies elements that they should add an additional @latency to the * running time before synchronising against the clock. * * The latency is mostly used in live sinks and is always expressed in * the time format. * * Returns: (transfer full): a new #GstEvent */ GstEvent * gst_event_new_latency (GstClockTime latency) { GstEvent *event; GstStructure *structure; GST_CAT_INFO (GST_CAT_EVENT, "creating latency event %" GST_TIME_FORMAT, GST_TIME_ARGS (latency)); structure = gst_structure_new_id (GST_QUARK (EVENT_LATENCY), GST_QUARK (LATENCY), G_TYPE_UINT64, latency, NULL); event = gst_event_new_custom (GST_EVENT_LATENCY, structure); return event; }
/** * gst_video_event_new_upstream_force_key_unit: * @running_time: the running_time at which a new key unit should be produced * @all_headers: %TRUE to produce headers when starting a new key unit * @count: integer that can be used to number key units * * Creates a new upstream force key unit event. An upstream force key unit event * can be sent to request upstream elements to produce a key unit. * * @running_time can be set to request a new key unit at a specific * running_time. If set to GST_CLOCK_TIME_NONE, upstream elements will produce a * new key unit as soon as possible. * * To parse an event created by gst_video_event_new_downstream_force_key_unit() use * gst_video_event_parse_downstream_force_key_unit(). * * Returns: The new GstEvent */ GstEvent * gst_video_event_new_upstream_force_key_unit (GstClockTime running_time, gboolean all_headers, guint count) { GstEvent *force_key_unit_event; GstStructure *s; s = gst_structure_new (GST_VIDEO_EVENT_FORCE_KEY_UNIT_NAME, "running-time", GST_TYPE_CLOCK_TIME, running_time, "all-headers", G_TYPE_BOOLEAN, all_headers, "count", G_TYPE_UINT, count, NULL); force_key_unit_event = gst_event_new_custom (GST_EVENT_CUSTOM_UPSTREAM, s); return force_key_unit_event; }
/** * gst_event_new_caps: * @caps: (transfer none): a #GstCaps * * Create a new CAPS event for @caps. The caps event can only travel downstream * synchronized with the buffer flow and contains the format of the buffers * that will follow after the event. * * Returns: (transfer full): the new CAPS event. */ GstEvent * gst_event_new_caps (GstCaps * caps) { GstEvent *event; g_return_val_if_fail (caps != NULL, NULL); g_return_val_if_fail (gst_caps_is_fixed (caps), NULL); GST_CAT_INFO (GST_CAT_EVENT, "creating caps event %" GST_PTR_FORMAT, caps); event = gst_event_new_custom (GST_EVENT_CAPS, gst_structure_new_id (GST_QUARK (EVENT_CAPS), GST_QUARK (CAPS), GST_TYPE_CAPS, caps, NULL)); return event; }
/** * gst_event_new_segment_done: * @format: The format of the position being done * @position: The position of the segment being done * * Create a new segment-done event. This event is sent by elements that * finish playback of a segment as a result of a segment seek. * * Returns: (transfer full): a new #GstEvent */ GstEvent * gst_event_new_segment_done (GstFormat format, gint64 position) { GstEvent *event; GstStructure *structure; GST_CAT_INFO (GST_CAT_EVENT, "creating segment-done event"); structure = gst_structure_new_id (GST_QUARK (EVENT_SEGMENT_DONE), GST_QUARK (FORMAT), GST_TYPE_FORMAT, format, GST_QUARK (POSITION), G_TYPE_INT64, position, NULL); event = gst_event_new_custom (GST_EVENT_SEGMENT_DONE, structure); return event; }
/* FIXME 0.11: take ownership of msg for consistency? */ GstEvent * gst_event_new_sink_message (const gchar * name, GstMessage * msg) { GstEvent *event; GstStructure *structure; g_return_val_if_fail (msg != NULL, NULL); GST_CAT_INFO (GST_CAT_EVENT, "creating sink-message event"); structure = gst_structure_new_id (g_quark_from_string (name), GST_QUARK (MESSAGE), GST_TYPE_MESSAGE, msg, NULL); event = gst_event_new_custom (GST_EVENT_SINK_MESSAGE, structure); return event; }
/* FIXME 0.11: take ownership of msg for consistency? */ GstEvent * gst_event_new_sink_message (GstMessage * msg) { GstEvent *event; GstStructure *structure; g_return_val_if_fail (msg != NULL, NULL); GST_CAT_INFO (GST_CAT_EVENT, "creating sink-message event"); structure = gst_structure_id_new (GST_QUARK (EVENT_SINK_MESSAGE), GST_QUARK (MESSAGE), GST_TYPE_MESSAGE, msg, NULL); event = gst_event_new_custom (GST_EVENT_SINK_MESSAGE, structure); return event; }