static void check_get_dtmf_event_message (GstBus * bus, gint number, gint volume) { GstMessage *message; gboolean have_message = FALSE; while (!have_message && (message = gst_bus_pop_filtered (bus, GST_MESSAGE_ELEMENT)) != NULL) { if (gst_message_has_name (message, "dtmf-event")) { const GstStructure *s = gst_message_get_structure (message); gint stype, snumber, smethod, svolume; fail_unless (gst_structure_get (s, "type", G_TYPE_INT, &stype, "number", G_TYPE_INT, &snumber, "method", G_TYPE_INT, &smethod, "volume", G_TYPE_INT, &svolume, NULL)); fail_unless (stype == 1); fail_unless (smethod == 1); fail_unless (snumber == number); fail_unless (svolume == volume); have_message = TRUE; } gst_message_unref (message); } fail_unless (have_message); }
static void check_no_dtmf_event_message (GstBus * bus) { GstMessage *message; gboolean have_message = FALSE; while (!have_message && (message = gst_bus_pop_filtered (bus, GST_MESSAGE_ELEMENT)) != NULL) { if (gst_message_has_name (message, "dtmf-event") || gst_message_has_name (message, "dtmf-event-processed") || gst_message_has_name (message, "dtmf-event-dropped")) { have_message = TRUE; } gst_message_unref (message); } fail_unless (!have_message); }
/** * gst_is_video_overlay_prepare_window_handle_message: * @msg: a #GstMessage * * Convenience function to check if the given message is a * "prepare-window-handle" message from a #GstVideoOverlay. * * Returns: whether @msg is a "prepare-window-handle" message */ gboolean gst_is_video_overlay_prepare_window_handle_message (GstMessage * msg) { g_return_val_if_fail (msg != NULL, FALSE); if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ELEMENT) return FALSE; return gst_message_has_name (msg, "prepare-window-handle"); }
static GstBusSyncReply bus_sync_callback (GstBus * bus, GstMessage * message, gpointer data) { GtkWidget *ui_drawing; if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) return GST_BUS_PASS; if (!gst_message_has_name (message, "prepare-window-handle")) return GST_BUS_PASS; /* FIXME: make sure to get XID in main thread */ ui_drawing = GTK_WIDGET (gtk_builder_get_object (builder, "viewfinderArea")); gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (message->src), GDK_WINDOW_XID (gtk_widget_get_window (ui_drawing))); gst_message_unref (message); return GST_BUS_DROP; }
static void check_message_structure (GstStructure * expected_s) { GstMessage *message; gboolean have_message = FALSE; while (!have_message && (message = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ELEMENT)) != NULL) { if (gst_message_has_name (message, gst_structure_get_name (expected_s))) { const GstStructure *s = gst_message_get_structure (message); fail_unless (gst_structure_is_equal (s, expected_s)); have_message = TRUE; } gst_message_unref (message); } fail_unless (have_message); gst_structure_free (expected_s); }
static void run_pipeline (GstElement * pipeline) { GstMessage *msg; GstBus *bus; bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_element_set_state (pipeline, GST_STATE_PAUSED); gst_element_get_state (pipeline, NULL, NULL, -1); gst_element_set_state (pipeline, GST_STATE_PLAYING); while (1) { msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_EOS | GST_MESSAGE_ERROR | GST_MESSAGE_ELEMENT); fail_unless (msg != NULL); if (msg) { if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ELEMENT) { if (gst_message_has_name (msg, "GstMultiFileSink")) mfs_messages = g_list_append (mfs_messages, msg); else gst_message_unref (msg); continue; } fail_unless (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS); gst_message_unref (msg); } break; } gst_object_unref (bus); gst_element_set_state (pipeline, GST_STATE_NULL); }
static void bus_message_cb (GstBus * bus, GstMessage * msg, AppInfo * info) { switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_ASYNC_DONE:{ /* only interested in async-done messages from the top-level pipeline */ if (msg->src != GST_OBJECT_CAST (info->pipe)) break; if (!info->prerolled) { /* make slider visible if it's not visible already */ gtk_widget_show (info->slider); /* initial frame is often black, so seek to beginning plus a bit */ seek_to (info, 0.001); info->prerolled = TRUE; } /* update position */ if (!gst_element_query_position (info->pipe, GST_FORMAT_TIME, &info->cur_pos)) info->cur_pos = -1; break; } case GST_MESSAGE_ELEMENT:{ const GValue *val; GdkPixbuf *pixbuf = NULL; const GstStructure *structure; /* only interested in element messages from our gdkpixbufsink */ if (msg->src != GST_OBJECT_CAST (info->sink)) break; /* only interested in these two messages */ if (!gst_message_has_name (msg, "preroll-pixbuf") && !gst_message_has_name (msg, "pixbuf")) { break; } g_print ("pixbuf\n"); structure = gst_message_get_structure (msg); val = gst_structure_get_value (structure, "pixbuf"); g_return_if_fail (val != NULL); pixbuf = GDK_PIXBUF (g_value_dup_object (val)); gtk_image_set_from_pixbuf (GTK_IMAGE (info->img), pixbuf); g_object_unref (pixbuf); break; } case GST_MESSAGE_ERROR:{ GError *err = NULL; gchar *dbg = NULL; gst_message_parse_error (msg, &err, &dbg); g_error ("Error: %s\n%s\n", err->message, (dbg) ? dbg : ""); g_error_free (err); g_free (dbg); break; } default: break; } }
static gboolean gst_PlayRegion_handle_message (GstBus * bus, GstMessage * message, gpointer data) { GstPlayRegion *PlayRegion = (GstPlayRegion *) data; switch (GST_MESSAGE_TYPE (message)) { case GST_MESSAGE_APPLICATION: if (gst_message_has_name (message, "ExPrerolled")) { /* it's our message */ g_print ("we are all prerolled, do seek\n"); gst_element_seek (PlayRegion->pipeline, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET, 2 * GST_SECOND, GST_SEEK_TYPE_SET, 5 * GST_SECOND); gst_element_set_state (PlayRegion->pipeline, GST_STATE_PLAYING); } break; case GST_MESSAGE_EOS: gst_PlayRegion_handle_eos (PlayRegion); break; case GST_MESSAGE_ERROR: { GError *error = NULL; gchar *debug; gst_message_parse_error (message, &error, &debug); gst_PlayRegion_handle_error (PlayRegion, error, debug); } break; case GST_MESSAGE_WARNING: { GError *error = NULL; gchar *debug; gst_message_parse_warning (message, &error, &debug); gst_PlayRegion_handle_warning (PlayRegion, error, debug); } break; case GST_MESSAGE_INFO: { GError *error = NULL; gchar *debug; gst_message_parse_info (message, &error, &debug); gst_PlayRegion_handle_info (PlayRegion, error, debug); } break; case GST_MESSAGE_TAG: { GstTagList *tag_list; gst_message_parse_tag (message, &tag_list); if (verbose) g_print ("tag\n"); } break; case GST_MESSAGE_STATE_CHANGED: { GstState oldstate, newstate, pending; gst_message_parse_state_changed (message, &oldstate, &newstate, &pending); if (GST_ELEMENT (message->src) == PlayRegion->pipeline) { if (verbose) g_print ("state change from %s to %s\n", gst_element_state_get_name (oldstate), gst_element_state_get_name (newstate)); switch (GST_STATE_TRANSITION (oldstate, newstate)) { case GST_STATE_CHANGE_NULL_TO_READY: gst_PlayRegion_handle_null_to_ready (PlayRegion); break; case GST_STATE_CHANGE_READY_TO_PAUSED: gst_PlayRegion_handle_ready_to_paused (PlayRegion); break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: gst_PlayRegion_handle_paused_to_playing (PlayRegion); break; case GST_STATE_CHANGE_PLAYING_TO_PAUSED: gst_PlayRegion_handle_playing_to_paused (PlayRegion); break; case GST_STATE_CHANGE_PAUSED_TO_READY: gst_PlayRegion_handle_paused_to_ready (PlayRegion); break; case GST_STATE_CHANGE_READY_TO_NULL: gst_PlayRegion_handle_ready_to_null (PlayRegion); break; default: if (verbose) g_print ("unknown state change from %s to %s\n", gst_element_state_get_name (oldstate), gst_element_state_get_name (newstate)); } } } break; case GST_MESSAGE_BUFFERING: { int percent; gst_message_parse_buffering (message, &percent); //g_print("buffering %d\n", percent); if (!PlayRegion->paused_for_buffering && percent < 100) { g_print ("pausing for buffing\n"); PlayRegion->paused_for_buffering = TRUE; gst_element_set_state (PlayRegion->pipeline, GST_STATE_PAUSED); } else if (PlayRegion->paused_for_buffering && percent == 100) { g_print ("unpausing for buffing\n"); PlayRegion->paused_for_buffering = FALSE; gst_element_set_state (PlayRegion->pipeline, GST_STATE_PLAYING); } } break; case GST_MESSAGE_STATE_DIRTY: case GST_MESSAGE_CLOCK_PROVIDE: case GST_MESSAGE_CLOCK_LOST: case GST_MESSAGE_NEW_CLOCK: case GST_MESSAGE_STRUCTURE_CHANGE: case GST_MESSAGE_STREAM_STATUS: break; case GST_MESSAGE_STEP_DONE: case GST_MESSAGE_ELEMENT: case GST_MESSAGE_SEGMENT_START: case GST_MESSAGE_SEGMENT_DONE: case GST_MESSAGE_DURATION: case GST_MESSAGE_LATENCY: case GST_MESSAGE_ASYNC_START: case GST_MESSAGE_ASYNC_DONE: case GST_MESSAGE_REQUEST_STATE: case GST_MESSAGE_STEP_START: case GST_MESSAGE_QOS: default: if (verbose) { g_print ("message: %s\n", GST_MESSAGE_TYPE_NAME (message)); } break; } return TRUE; }