Hi Team ,
I have integrated GStreamer library 1.12.2 version in my ios application that supports audio and video streaming through raspberry pi device . Functionality that has been implemeted is as follows: 1. Video streaming has to run all time in my application once the application is launched and on main screen. 2. There are one button one for receiving audio along with video streaming that shoud run seamlessly For which i created two pipelines one for video and one for audio from raspberry pi device to my ios application. I have facing a crash as Attempted to dereference garbage pointer when toggling audio i.e play and pause audio or keeping my app still for couple of minutes it gets a crash . I am attaching some code which i used to create pipeline for video and audio. /* for video and audio du to app */ -(void) app_function { GstBus *bus; GSource *bus_source; GError *error = NULL;
GstBus *bus1; GSource *bus_source1;
GST_DEBUG ("Creating pipeline");
/* Create our own GLib Main Context and make it the default one */ context = g_main_context_new (); g_main_context_push_thread_default(context);
// du to app recieve working fine audiopipeline = gst_parse_launch("udpsrc port=5001 caps=\"audio/x-raw, rate = 8000, format=S16LE, channels=2\" !audioconvert ! audioresample ! autoaudiosink sync=false", &error); if (error) { gchar *message = g_strdup_printf("Unable to build audio pipeline: %s", error->message); g_clear_error (&error); [self setUIMessage:message]; g_free (message); return; } error = NULL; // Runing video pipeline pipeline = gst_parse_launch("udpsrc port=5000 ! application/x-rtp, payload=96 ! rtph264depay ! avdec_h264 ! autovideosink sync=false text-overlay=false", &error); if (error) { gchar *message = g_strdup_printf("Unable to build video pipeline: %s", error->message); g_clear_error (&error); [self setUIMessage:message]; g_free (message); return; }
/**************** for video *****************/ /* Set the pipeline to READY, so it can already accept a window handle */ gst_element_set_state(pipeline, GST_STATE_READY);
video_sink = gst_bin_get_by_interface(GST_BIN(pipeline), GST_TYPE_VIDEO_OVERLAY); if (!video_sink) { GST_ERROR ("Could not retrieve video sink"); return; } gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(video_sink), (guintptr) (id) ui_video_view);
/* Instruct the bus to emit signals for each received message, and connect to the interesting signals */ bus = gst_element_get_bus (pipeline); bus_source = gst_bus_create_watch (bus); g_source_set_callback (bus_source, (GSourceFunc) gst_bus_async_signal_func, NULL, NULL); g_source_attach (bus_source, context); g_source_unref (bus_source); g_signal_connect (G_OBJECT (bus), "message::error", (GCallback)error_cb, (__bridge void *)self); g_signal_connect (G_OBJECT (bus), "message::state-changed", (GCallback)state_changed_cb, (__bridge void *)self); gst_object_unref (bus);
// for audio /**************** for audio **************/ bus1 = gst_element_get_bus (audiopipeline); bus_source1 = gst_bus_create_watch (bus1); g_source_set_callback (bus_source1, (GSourceFunc) gst_bus_async_signal_func, NULL, NULL); g_source_attach (bus_source1, context); g_source_unref (bus_source1); g_signal_connect (G_OBJECT (bus1), "message::error", (GCallback)error_cb_audio, (__bridge void *)self); g_signal_connect (G_OBJECT (bus1), "message::state-changed", (GCallback)state_changed_cb_audio, (__bridge void *)self); gst_object_unref (bus1); /* Create a GLib Main Loop and set it to run */ GST_DEBUG ("Entering main loop..."); main_loop = g_main_loop_new (context, FALSE); [self check_initialization_complete]; g_main_loop_run (main_loop); GST_DEBUG ("Exited main loop"); g_main_loop_unref (main_loop); main_loop = NULL;
/* Free resources */ g_main_context_pop_thread_default(context); g_main_context_unref (context); gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (pipeline);
gst_element_set_state (audiopipeline, GST_STATE_NULL); gst_object_unref (audiopipeline);
return; } /* Retrieve errors from the bus and show them on the UI */ static void error_cb (GstBus *bus, GstMessage *msg, GStreamerBackend *self) { GError *err; gchar *debug_info; gchar *message_string; gst_message_parse_error (msg, &err, &debug_info); message_string = g_strdup_printf ("Error received from element %s: %s", GST_OBJECT_NAME (msg->src), err->message); g_clear_error (&err); g_free (debug_info); [self setUIMessage:message_string]; g_free (message_string); gst_element_set_state (self->pipeline, GST_STATE_NULL); } /* Notify UI about pipeline state changes */ static void state_changed_cb (GstBus *bus, GstMessage *msg, GStreamerBackend *self) { GstState old_state, new_state, pending_state; gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state); /* Only pay attention to messages coming from the pipeline, not its children */ if (GST_MESSAGE_SRC (msg) == GST_OBJECT (self->pipeline)) { gchar *message = g_strdup_printf("State changed to %s", gst_element_state_get_name(new_state)); [self setUIMessage:message]; g_free (message); } } /* Check if all conditions are met to report GStreamer as initialized. * These conditions will change depending on the application */ -(void) check_initialization_complete { if (!initialized && main_loop) { GST_DEBUG ("Initialization complete, notifying application."); if (ui_delegate && [ui_delegate respondsToSelector:@selector(gstreamerInitialized)]) { [ui_delegate gstreamerInitialized]; } initialized = TRUE; } } #pragma mark - For audio - /* Check if all conditions are met to report GStreamer as initialized. * These conditions will change depending on the application */ -(void) check_initialization_complete_audio { if (!audioinitialized && main_loop1) { GST_DEBUG ("Initialization complete, notifying application."); if (ui_delegate && [ui_delegate respondsToSelector:@selector(gstreamerInitialized)]) { [ui_delegate gstreamerInitialized]; } audioinitialized = TRUE; } } -(void) playaudio { if(gst_element_set_state(audiopipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { [self setUIMessage:"Failed to set audio pipeline to playing"]; } } -(void) pauseaudio {
if(gst_element_set_state(audiopipeline, GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE) { [self setUIMessage:"Failed to set audio pipeline to paused"]; } } /* Retrieve errors from the bus and show them on the UI */ static void error_cb_audio (GstBus *bus, GstMessage *msg, GStreamerBackend *self) { GError *err; gchar *debug_info; gchar *message_string;
gst_message_parse_error (msg, &err, &debug_info); message_string = g_strdup_printf ("Error received from element %s: %s", GST_OBJECT_NAME (msg->src), err->message); g_clear_error (&err); g_free (debug_info); [self setUIMessage:message_string]; g_free (message_string); gst_element_set_state (self->audiopipeline, GST_STATE_NULL); } /* Notify UI about pipeline state changes */ static void state_changed_cb_audio (GstBus *bus, GstMessage *msg, GStreamerBackend *self) { GstState old_state, new_state, pending_state; gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state); /* Only pay attention to messages coming from the pipeline, not its children */ if (GST_MESSAGE_SRC (msg) == GST_OBJECT (self->audiopipeline)) { gchar *message = g_strdup_printf("State changed to %s", gst_element_state_get_name(new_state)); [self setUIMessage:message]; g_free (message); } } Also , I am attaching crash files. Kindly help me to get me out of this issue. _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel crash-report-Homesmart-1 (1).txt (84K) Download Attachment crash-report-Homesmart-1.txt (89K) Download Attachment crash-report-Homesmart-1 (6) copy.txt (85K) Download Attachment crash-report-Homesmart-1 (7) copy.txt (90K) Download Attachment crash-report-Homesmart-1 (8) copy.txt (97K) Download Attachment crash-report-Homesmart-1 (9).txt (103K) Download Attachment |
Free forum by Nabble | Edit this page |