Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • gstreamer gstreamer
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 672
    • Issues 672
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 354
    • Merge requests 354
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GStreamer
  • gstreamergstreamer
  • Issues
  • #668

Closed
Open
Created Mar 12, 2021 by Emad Alblueshi@EmadAlblueshi

Custom GSocket property for udpsrc element won't work on windows 10

Hi,

My use case is to utilize custom shared GSocket property for both udpsink and udpsrc elements to send/receive from/to udp server the example code works in Linux but in windows 10 I got below message in the console when I run the program

(test.exe:1628): GLib-GObject-CRITICAL **: 15:55:26.202: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
Unable to set the pipeline to the playing state.

The whole windows 10 issue is in this line

g_object_set ((GObject*) udp_m_audio_src, "socket", socket, NULL); 

The example code


#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <gst/gst.h>

int main (int argc, char *argv[])
{
  GError *error = NULL;
  GSocket *socket;
  GstElement *pipeline;
  GstElement *udp_m_audio_sink;
  GstElement *udp_m_audio_src;
  GstBus *bus;
  GstMessage *msg;
  GstStateChangeReturn ret;

  /* Initialize GStreamer */
  gst_init (&argc, &argv);

  /*  Initialize shared GSocket for sending and receiving */
  socket = g_socket_new (G_SOCKET_FAMILY_IPV4, G_SOCKET_TYPE_DATAGRAM, G_SOCKET_PROTOCOL_DEFAULT, &error);

  /* Build the pipeline */
  pipeline = gst_parse_launch_full ("autoaudiosrc ! queue ! audioconvert ! opusenc audio-type=voice bitrate=48000 ! rtpopuspay ! udpsink name=udp_m_audio_sink udpsrc name=udp_m_audio_src ! queue ! application/x-rtp, media=audio, payload=96, clock-rate=48000, encoding-name=OPUS ! rtpjitterbuffer ! rtpopusdepay ! opusdec ! audioconvert ! audioresample ! autoaudiosink", NULL, GST_PARSE_FLAG_FATAL_ERRORS, &error);

  udp_m_audio_sink = gst_bin_get_by_name ((GstBin*) pipeline, "udp_m_audio_sink");

  g_object_set ((GObject*) udp_m_audio_sink, "socket", socket, NULL);
  g_object_set ((GObject*) udp_m_audio_sink, "host", "127.0.0.1", NULL);
  g_object_set ((GObject*) udp_m_audio_sink, "port", 5001, NULL);
  g_object_set ((GObject*) udp_m_audio_sink, "async", FALSE, NULL);
  g_object_set ((GObject*) udp_m_audio_sink, "sync", FALSE, NULL);
  g_object_set ((GObject*) udp_m_audio_sink, "auto-multicast", FALSE, NULL);

  udp_m_audio_src = gst_bin_get_by_name ((GstBin*) pipeline, "udp_m_audio_src");

  // Below line works on linux but in windows you will get "g_object_unref: assertion 'G_IS_OBJECT (object)' failed"
  g_object_set ((GObject*) udp_m_audio_src, "socket", socket, NULL); 
  g_object_set ((GObject*) udp_m_audio_src, "auto-multicast", FALSE, NULL);

  /* Start playing */
  ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
  if (ret == GST_STATE_CHANGE_FAILURE) {
    g_printerr ("Unable to set the pipeline to the playing state.\n");
    gst_object_unref (pipeline);
    return -1;
  }

  /* Wait until error or EOS */
  bus = gst_element_get_bus (pipeline);
  msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

  /* Free resources */
  if (msg != NULL)
    gst_message_unref (msg);
  if (error != NULL)
    gst_object_unref (error);
  gst_object_unref (bus);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);
  gst_object_unref (socket);
  return 0;
}

I'm using Windows Pro 10 with MSYS2 and mingw-w64-gstreamer 1.18.3 and other plugins.

Any further details required I'm ready to provide. I really need this to work as soon as possible.

I really appreciate your time

Thanks!

Edited Mar 12, 2021 by Emad Alblueshi
Assignee
Assign to
Time tracking