static void send_5app_1el_1err_2app_messages (guint interval_usecs) { GstMessage *m; GstStructure *s; gint i; for (i = 0; i < 5; i++) { s = gst_structure_new ("test_message", "msg_id", G_TYPE_INT, i, NULL); m = gst_message_new_application (NULL, s); GST_LOG ("posting application message"); gst_bus_post (test_bus, m); g_usleep (interval_usecs); } for (i = 0; i < 1; i++) { s = gst_structure_new ("test_message", "msg_id", G_TYPE_INT, i, NULL); m = gst_message_new_element (NULL, s); GST_LOG ("posting element message"); gst_bus_post (test_bus, m); g_usleep (interval_usecs); } for (i = 0; i < 1; i++) { m = gst_message_new_error (NULL, NULL, "debug string"); GST_LOG ("posting error message"); gst_bus_post (test_bus, m); g_usleep (interval_usecs); } for (i = 0; i < 2; i++) { s = gst_structure_new ("test_message", "msg_id", G_TYPE_INT, i, NULL); m = gst_message_new_application (NULL, s); GST_LOG ("posting application message"); gst_bus_post (test_bus, m); g_usleep (interval_usecs); } }
static VALUE application_initialize(VALUE self, VALUE src, VALUE structure) { G_INITIALIZE(self, gst_message_new_application(RVAL2GST_OBJ(src), RVAL2GST_STRUCT(structure))); return Qnil; }
/* This function is called when new metadata is discovered in the stream */ static void tags_cb (GstElement *playbin, gint stream, CustomData *data) { /* We are possibly in a GStreamer working thread, so we notify the main * thread of this event through a message in the bus */ gst_element_post_message (playbin, gst_message_new_application (GST_OBJECT (playbin), gst_structure_new_empty ("tags-changed"))); }
static gboolean buffer_probe_callback( GstElement *image_sink, GstBuffer *buffer, GstPad *pad) { GstMessage *message; gchar *message_name; unsigned char *data_photo = (unsigned char *) GST_BUFFER_DATA(buffer); if(!create_jpeg(data_photo)) { message_name = "photo-failed"; hildon_banner_show_information(GTK_WIDGET(cappdata->window), NULL, "Unable To Take Photo"); } else { message_name = "photo-taken"; } g_signal_handler_disconnect(G_OBJECT(image_sink), cappdata->buffer_cb_id); message = gst_message_new_application(GST_OBJECT(cappdata->pipeline), gst_structure_new(message_name, NULL)); gst_element_post_message(cappdata->pipeline, message); return TRUE; }
/** * send_underrun_message * * Sends UNDERRUN message to the bus. */ static void send_underrun_message(ProgressBuffer* element) { GstStructure *s = gst_structure_new_empty(PB_MESSAGE_UNDERRUN); GstMessage *msg = gst_message_new_application(GST_OBJECT(element), s); gst_element_post_message(GST_ELEMENT(element), msg); }
static void send_10_app_messages (void) { GstMessage *m; GstStructure *s; gint i; for (i = 0; i < 10; i++) { s = gst_structure_new ("test_message", "msg_id", G_TYPE_INT, i, NULL); m = gst_message_new_application (NULL, s); gst_bus_post (test_bus, m); } }
GstPadProbeReturn eos_event_cb (GstPad *pad, GstPadProbeInfo *info, gpointer data) { if (GST_EVENT_TYPE (GST_PAD_PROBE_INFO_DATA (info)) == GST_EVENT_EOS) { GstElement *bin = NULL; GstMessage *message = NULL; GstStructure *msg_struct = NULL; MbMedia *media; gchar *uri = NULL; int pads = 0; media = (MbMedia *) data; bin = gst_bin_get_by_name (GST_BIN(_mb_global_data.pipeline), media->name); g_assert(bin); g_mutex_lock (&(media->mutex)); pads = --media->valid_pads; g_mutex_unlock (&(media->mutex)); g_object_get (media->decoder, "uri", &uri, NULL); g_debug ("EOS received (%s): %s.\n", media->name, uri); g_debug ("%s still has %d valid pad(s).\n", media->name, pads); if (pads == 0) { MbEvent *event = create_state_change_event (MB_END, media->name); notify_handler (event); free (event); g_hash_table_remove (_mb_global_data.media_table, media->name); msg_struct = gst_structure_new ("end-media", "event_type", G_TYPE_INT, APP_EVT_MEDIA_END, "data", G_TYPE_POINTER, media, /* FILL ME IF NECESSARY */ NULL); message = gst_message_new_application (GST_OBJECT(bin), msg_struct); g_debug ("Posting event\n"); gst_bus_post (_mb_global_data.bus, message); } g_free (uri); } return GST_PAD_PROBE_OK; }
static gpointer pound_bus_with_messages (gpointer data) { gint thread_id = GPOINTER_TO_INT (data); gint i; for (i = 0; i < NUM_MESSAGES; i++) { GstMessage *m; GstStructure *s; s = gst_structure_new ("test_message", "thread_id", G_TYPE_INT, thread_id, "msg_id", G_TYPE_INT, i, NULL); m = gst_message_new_application (NULL, s); gst_bus_post (test_bus, m); } return NULL; }
static gboolean send_messages (gpointer data) { GstMessage *m; GstStructure *s; gint i; for (i = 0; i < 10; i++) { s = gst_structure_new ("test_message", "msg_id", G_TYPE_INT, i, NULL); m = gst_message_new_application (NULL, s); gst_bus_post (test_bus, m); s = gst_structure_new ("test_message", "msg_id", G_TYPE_INT, i, NULL); m = gst_message_new_custom (GST_MESSAGE_EOS, NULL, s); gst_bus_post (test_bus, m); } return FALSE; }
static GstFlowReturn gst_nekobus_show_frame (GstBaseSink * sink, GstBuffer * buf) { GstNekoBus *element; element = GST_NEKOBUS (sink); GstStructure *msg = gst_structure_new("nekobus::data", "element", G_TYPE_STRING, gst_element_get_name( GST_ELEMENT(element) ), "buffer", GST_TYPE_BUFFER, buf, NULL ); gst_bus_post( gst_element_get_bus(GST_ELEMENT(sink)), gst_message_new_application( GST_OBJECT(sink), msg ) ); /* we're leaving the buffer unref'ing to the bus receiver :/ -- what if noone receives the msg? FIXME */ return GST_FLOW_OK; }
/* is called every 50 milliseconds (20 times a second), the interrupt handler * will set a flag for us. We react to this by posting a message. */ static gboolean check_intr (GstElement * pipeline) { if (!caught_intr) { return TRUE; } else { caught_intr = FALSE; g_print ("handling interrupt.\n"); /* post an application specific message */ gst_element_post_message (GST_ELEMENT (pipeline), gst_message_new_application (GST_OBJECT (pipeline), gst_structure_new ("GstLaunchInterrupt", "message", G_TYPE_STRING, "Pipeline interrupted", NULL))); /* remove timeout handler */ return FALSE; } }
static void dec_counter (GstPlayRegion *PlayRegion) { if (PlayRegion->prerolled) return; if (g_atomic_int_dec_and_test (&PlayRegion->counter)) { /* all probes blocked and no-more-pads signaled, post * message on the bus. */ PlayRegion->prerolled = TRUE; g_print ("fire application message\n"); gst_bus_post (PlayRegion->bus, gst_message_new_application ( GST_OBJECT_CAST (PlayRegion->pipeline), gst_structure_new_empty ("ExPrerolled"))); } }
/** * send_position_message * Sends application message on the BUS with the following parameters: * - structure name is the constant defined as PB_MESSAGE_BUFFERING * - "start" as gint64 is the start position of the current buffer * - "position" as gint64 is current position up to which data has been read from the source * - "stop" as gint64 is the duration of the current segment, usually equals to the whole duration * * gboolean "mandatory" flag desribes whether the message must be sent anyways. * If it's TRUE message is aways sent, otherwise if it's FALSE the function tries to * avoid sending messages every time - it sends messages every percent of the whole size. */ static gboolean send_position_message(ProgressBuffer *element, gboolean mandatory) { gdouble percent = (double)element->sink_segment.position/element->sink_segment.stop * 100; mandatory |= (percent - element->last_update) > element->threshold; // Prevent sending update messages to often if (mandatory) { GstStructure *s = gst_structure_new(PB_MESSAGE_BUFFERING, "start", G_TYPE_INT64, element->sink_segment.start, "position", G_TYPE_INT64, element->sink_segment.position, "stop", G_TYPE_INT64, element->sink_segment.stop, "eos", G_TYPE_BOOLEAN, element->eos_status.eos, NULL); GstMessage *msg = gst_message_new_application(GST_OBJECT(element), s); gst_element_post_message(GST_ELEMENT(element), msg); element->last_update = percent; } return mandatory; }
ApplicationMessagePtr ApplicationMessage::create(const ObjectPtr & source, const Structure & structure) { GstStructure *s = structure.isValid() ? gst_structure_copy(structure) : NULL; return ApplicationMessagePtr::wrap(gst_message_new_application(source, s), false); }
gpointer upload_file (gpointer data) { int err; void* output; // Application key and secret. To get them, create an app here: // https://www.dropbox.com/developers/apps char *c_key = "lmg4kv8jw45nlsr"; //< consumer key char *c_secret = "xmq9x391l0y8nwy"; //< consumer secret char filename[200]; CustomData *cdata=(CustomData*)data; strcpy(filename,cdata->sink_filename); // User key and secret. Leave them NULL or set them with your AccessToken. // char *t_key = NULL; //< access token key // char *t_secret = NULL; //< access token secret char *t_key = "5j55oq1lf8h1zi2w"; //< access token key char *t_secret = "nvv5ps3hy4v4wy3"; //< access token secret // Global initialisation drbInit(); // Create a Dropbox client drbClient* cli = drbCreateClient(c_key, c_secret, t_key, t_secret); // Request a AccessToken if undefined (NULL) if(!t_key || !t_secret) { drbOAuthToken* reqTok = drbObtainRequestToken(cli); if (reqTok) { char* url = drbBuildAuthorizeUrl(reqTok); printf("Please visit %s\nThen press Enter...\n", url); free(url); fgetc(stdin); drbOAuthToken* accTok = drbObtainAccessToken(cli); if (accTok) { // This key and secret can replace the NULL value in t_key and // t_secret for the next time. printf("key: %s\nsecret: %s\n", accTok->key, accTok->secret); } else{ fprintf(stderr, "Failed to obtain an AccessToken...\n"); return NULL; } } else { fprintf(stderr, "Failed to obtain a RequestToken...\n"); return NULL; } } // Set default arguments to not repeat them on each API call drbSetDefault(cli, DRBOPT_ROOT, DRBVAL_ROOT_AUTO, DRBOPT_END); // upload current file FILE *file = fopen(filename, "r"); char fn[200]; memset(fn,0,sizeof(fn)); strcpy(fn,"/"); strcat(fn,filename); output = NULL; err = drbPutFile(cli, &output, DRBOPT_PATH, fn, DRBOPT_IO_DATA, file, DRBOPT_IO_FUNC, fread, DRBOPT_END); printf("File upload: %s\n", err ? "Failed" : "Successful"); fclose(file); output = NULL; //share public link to file drbShare(cli, &output, DRBOPT_PATH, fn, DRBOPT_END); drbLink* url = (drbLink*)output; // strcpy(link,url->url); We should return here!!!! drbDestroyClient(cli); // Global Cleanup drbCleanup(); gst_bus_post(cdata->bus,gst_message_new_application( GST_OBJECT_CAST(cdata->pipeline), gst_structure_new_empty("UploadDone"))); return url->url; }
/** * send_hls_not_full_message * * Sends HLS NOT FULL message to the bus. */ static void send_hls_not_full_message(HLSProgressBuffer* element) { GstStructure *s = gst_structure_empty_new(HLS_PB_MESSAGE_NOT_FULL); GstMessage *msg = gst_message_new_application(GST_OBJECT(element), s); gst_element_post_message(GST_ELEMENT(element), msg); }