/** * fs_session_parse_telephony_event_started: * @session: a #FsSession to match against the message * @message: a #GstMessage to parse * @method: (out): Returns the #FsDTMFMethod in the message if not %NULL. * @event: (out): Returns the #FsDTMFEvent in the message if not %NULL. * @volume: (out): Returns the volume in the message if not %NULL. * * Parses a "farstream-telephony-event-started" message and checks if it matches * the @session parameters. * * Returns: %TRUE if the message matches the session and is valid. */ gboolean fs_session_parse_telephony_event_started (FsSession *session, GstMessage *message, FsDTMFMethod *method, FsDTMFEvent *event, guint8 *volume) { const GstStructure *s; const GValue *value; g_return_val_if_fail (session != NULL, FALSE); if (!check_message (message, session, "farstream-telephony-event-started")) return FALSE; s = gst_message_get_structure (message); if (!gst_structure_has_field_typed (s, "method", FS_TYPE_DTMF_METHOD)) return FALSE; if (method) gst_structure_get_enum (s, "method", FS_TYPE_DTMF_METHOD, (gint*) method); if (!gst_structure_has_field_typed (s, "event", FS_TYPE_DTMF_EVENT)) return FALSE; if (event) gst_structure_get_enum (s, "event", FS_TYPE_DTMF_EVENT, (gint*) event); value = gst_structure_get_value (s, "volume"); if (!value || !G_VALUE_HOLDS (value, G_TYPE_UCHAR)) return FALSE; if (volume) *volume = g_value_get_uchar (value); return TRUE; }
static GstSample * totem_gst_tag_list_get_cover_real (GstTagList *tag_list) { GstSample *cover_sample = NULL; guint i; for (i = 0; ; i++) { GstSample *sample; GstCaps *caps; const GstStructure *caps_struct; int type; if (!gst_tag_list_get_sample_index (tag_list, GST_TAG_IMAGE, i, &sample)) break; caps = gst_sample_get_caps (sample); caps_struct = gst_caps_get_structure (caps, 0); gst_structure_get_enum (caps_struct, "image-type", GST_TYPE_TAG_IMAGE_TYPE, &type); if (type == GST_TAG_IMAGE_TYPE_UNDEFINED) { if (cover_sample == NULL) { /* take a ref here since we will continue and unref below */ cover_sample = gst_sample_ref (sample); } } else if (type == GST_TAG_IMAGE_TYPE_FRONT_COVER) { cover_sample = sample; break; } gst_sample_unref (sample); } return cover_sample; }
static GdkPixbuf * gst_thumbnailer_cover_from_tags (GstTagList *tags, GCancellable *cancellable) { GstSample *cover = NULL; guint i; GstSample *sample; GstCaps *caps; const GstStructure *caps_struct; gint type; GstBuffer *buffer; GdkPixbuf *pixbuf = NULL; for (i = 0; ; i++) { if (g_cancellable_is_cancelled (cancellable)) break; /* look for image in the tags */ if (!gst_tag_list_get_sample_index (tags, GST_TAG_IMAGE, i, &sample)) break; caps = gst_sample_get_caps (sample); caps_struct = gst_caps_get_structure (caps, 0); gst_structure_get_enum (caps_struct, "image-type", GST_TYPE_TAG_IMAGE_TYPE, &type); if (type == GST_TAG_IMAGE_TYPE_FRONT_COVER) { /* found the cover */ cover = sample; break; } gst_sample_unref (sample); } if (cover == NULL && !g_cancellable_is_cancelled (cancellable)) { /* look for preview image */ gst_tag_list_get_sample_index (tags, GST_TAG_PREVIEW_IMAGE, 0, &cover); } if (cover != NULL) { /* create image */ buffer = gst_sample_get_buffer (cover); pixbuf = gst_thumbnailer_buffer_to_pixbuf (buffer); gst_sample_unref (cover); } return pixbuf; }
/** * fs_session_parse_telephony_event_stopped: * @session: a #FsSession to match against the message * @message: a #GstMessage to parse * @method: (out): Returns the #FsDTMFMethod in the message if not %NULL. * * Parses a "farstream-telephony-event-stopped" message and checks if it matches * the @session parameters. * * Returns: %TRUE if the message matches the session and is valid. */ gboolean fs_session_parse_telephony_event_stopped (FsSession *session, GstMessage *message, FsDTMFMethod *method) { const GstStructure *s; g_return_val_if_fail (session != NULL, FALSE); if (!check_message (message, session, "farstream-telephony-event-stopped")) return FALSE; s = gst_message_get_structure (message); if (!gst_structure_has_field_typed (s, "method", FS_TYPE_DTMF_METHOD)) return FALSE; if (method) gst_structure_get_enum (s, "method", FS_TYPE_DTMF_METHOD, (gint*) method); return TRUE; }
static const GValue * totem_gst_tag_list_get_cover_real (GstTagList *tag_list) { const GValue *cover_value = NULL; guint i; for (i = 0; ; i++) { const GValue *value; GstBuffer *buffer; GstStructure *caps_struct; int type; value = gst_tag_list_get_value_index (tag_list, GST_TAG_IMAGE, i); if (value == NULL) break; buffer = gst_value_get_buffer (value); caps_struct = gst_caps_get_structure (buffer->caps, 0); gst_structure_get_enum (caps_struct, "image-type", GST_TYPE_TAG_IMAGE_TYPE, &type); if (type == GST_TAG_IMAGE_TYPE_UNDEFINED) { if (cover_value == NULL) cover_value = value; } else if (type == GST_TAG_IMAGE_TYPE_FRONT_COVER) { cover_value = value; break; } } return cover_value; }
static gboolean async_bus_cb (GstBus *bus, GstMessage *message, gpointer user_data) { switch (GST_MESSAGE_TYPE(message)) { case GST_MESSAGE_ERROR: { GError *error = NULL; gchar *debug_str = NULL; gst_message_parse_error (message, &error, &debug_str); g_print ("Got gst message: %s %s", error->message, debug_str); } break; case GST_MESSAGE_WARNING: { GError *error = NULL; gchar *debug_str = NULL; gst_message_parse_warning (message, &error, &debug_str); g_warning ("Got gst message: %s %s", error->message, debug_str); } break; case GST_MESSAGE_ELEMENT: { const GstStructure *s = gst_message_get_structure (message); if (gst_structure_has_name (s, "farstream-error")) { gint error; const gchar *error_msg = gst_structure_get_string (s, "error-msg"); g_assert (gst_structure_get_enum (s, "error-no", FS_TYPE_ERROR, &error)); if (FS_ERROR_IS_FATAL (error)) g_error ("Farstream fatal error: %d %s", error, error_msg); else g_warning ("Farstream non-fatal error: %d %s", error, error_msg); } else if (gst_structure_has_name (s, "farstream-new-local-candidate")) { const GValue *val = gst_structure_get_value (s, "candidate"); FsCandidate *cand = NULL; g_assert (val); cand = g_value_get_boxed (val); g_print ("New candidate: socket %s\n", cand->ip); g_print ("You can press ENTER on the other side\n"); } else if (gst_structure_has_name (s, "farstream-local-candidates-prepared")) { g_print ("Local candidates prepared\n"); } else if (gst_structure_has_name (s, "farstream-recv-codecs-changed")) { const GValue *val = gst_structure_get_value (s, "codecs"); GList *codecs = NULL; g_assert (val); codecs = g_value_get_boxed (val); g_print ("Recv codecs changed:\n"); for (; codecs; codecs = g_list_next (codecs)) { FsCodec *codec = codecs->data; gchar *tmp = fs_codec_to_string (codec); g_print ("%s\n", tmp); g_free (tmp); } } else if (gst_structure_has_name (s, "farstream-send-codec-changed")) { const GValue *val = gst_structure_get_value (s, "codec"); FsCodec *codec = NULL; gchar *tmp; g_assert (val); codec = g_value_get_boxed (val); tmp = fs_codec_to_string (codec); g_print ("Send codec changed: %s\n", tmp); g_free (tmp); } } break; default: break; } return TRUE; }
static gboolean handle_queued_objects (APP_STATE_T * state) { GstMiniObject *object = NULL; g_mutex_lock (state->queue_lock); if (state->flushing) { g_cond_broadcast (state->cond); goto beach; } else if (g_async_queue_length (state->queue) == 0) { goto beach; } if ((object = g_async_queue_try_pop (state->queue))) { if (GST_IS_BUFFER (object)) { GstBuffer *buffer = GST_BUFFER_CAST (object); update_image (state, buffer); render_scene (state); gst_buffer_unref (buffer); if (!SYNC_BUFFERS) { object = NULL; } } else if (GST_IS_QUERY (object)) { GstQuery *query = GST_QUERY_CAST (object); GstStructure *s = (GstStructure *) gst_query_get_structure (query); if (gst_structure_has_name (s, "eglglessink-allocate-eglimage")) { GstBuffer *buffer; GstVideoFormat format; gint width, height; GValue v = { 0, }; if (!gst_structure_get_enum (s, "format", GST_TYPE_VIDEO_FORMAT, (gint *) & format) || !gst_structure_get_int (s, "width", &width) || !gst_structure_get_int (s, "height", &height)) { g_assert_not_reached (); } buffer = gst_egl_allocate_eglimage (state, GST_EGL_IMAGE_BUFFER_POOL (state->pool)->allocator, format, width, height); g_value_init (&v, G_TYPE_POINTER); g_value_set_pointer (&v, buffer); gst_structure_set_value (s, "buffer", &v); g_value_unset (&v); } else { g_assert_not_reached (); } } else if (GST_IS_EVENT (object)) { GstEvent *event = GST_EVENT_CAST (object); g_print ("\nevent %p %s\n", event, gst_event_type_get_name (GST_EVENT_TYPE (event))); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: flush_internal (state); break; default: break; } gst_event_unref (event); object = NULL; } } if (object) { state->popped_obj = object; g_cond_broadcast (state->cond); } beach: g_mutex_unlock (state->queue_lock); return FALSE; }
/** * rb_gst_process_embedded_image: * @taglist: a #GstTagList containing an image * @tag: the tag name * * Converts embedded image data extracted from a tag list into * a #GdkPixbuf. The returned #GdkPixbuf is owned by the caller. * * Returns: a #GdkPixbuf, or NULL. */ GdkPixbuf * rb_gst_process_embedded_image (const GstTagList *taglist, const char *tag) { GstBuffer *buf; GdkPixbufLoader *loader; GdkPixbuf *pixbuf; GError *error = NULL; const GValue *val = NULL; guint i; for (i = 0; ; i++) { const GValue *value; const char *media_type; GstStructure *caps_struct; int imgtype; value = gst_tag_list_get_value_index (taglist, tag, i); if (value == NULL) { break; } buf = gst_value_get_buffer (value); if (buf == NULL) { rb_debug ("apparently couldn't get image buffer"); continue; } caps_struct = gst_caps_get_structure (buf->caps, 0); media_type = gst_structure_get_name (caps_struct); /* other things to ignore? */ if (g_strcmp0 (media_type, "text/uri-list") == 0) { rb_debug ("ignoring text/uri-list image tag"); continue; } gst_structure_get_enum (caps_struct, "image-type", GST_TYPE_TAG_IMAGE_TYPE, &imgtype); rb_debug ("image type %d", imgtype); if (imgtype == GST_TAG_IMAGE_TYPE_UNDEFINED) { if (val == NULL) { rb_debug ("got undefined image type"); val = value; } } else if (imgtype == GST_TAG_IMAGE_TYPE_FRONT_COVER) { rb_debug ("got front cover image"); val = value; } } if (val == NULL) { rb_debug ("couldn't find an image to process"); return NULL; } rb_debug ("found image at value %u for tag %s", i, tag); loader = gdk_pixbuf_loader_new (); buf = gst_value_get_buffer (val); rb_debug ("sending %d bytes to pixbuf loader", buf->size); if (gdk_pixbuf_loader_write (loader, buf->data, buf->size, &error) == FALSE) { rb_debug ("pixbuf loader doesn't like the data: %s", error->message); g_error_free (error); g_object_unref (loader); return NULL; } pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); if (pixbuf != NULL) { g_object_ref (pixbuf); } gdk_pixbuf_loader_close (loader, NULL); g_object_unref (loader); if (pixbuf == NULL) { rb_debug ("pixbuf loader didn't give us a pixbuf"); return NULL; } rb_debug ("returning embedded image: %d x %d / %d", gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), gdk_pixbuf_get_bits_per_sample (pixbuf)); return pixbuf; }