예제 #1
0
static GstFlowReturn
data_channel_buffer_received_cb (GObject * obj, GstBuffer * buffer,
    gpointer user_data)
{
  KmsWebRtcDataChannel *channel = KMS_WEBRTC_DATA_CHANNEL (obj);
  GstMapInfo info = GST_MAP_INFO_INIT;
  gchar *msg;

  GST_INFO_OBJECT (channel, "Buffer received");

  if (!gst_buffer_map (buffer, &info, GST_MAP_READ)) {
    fail ("Can not read buffer");
    return GST_FLOW_ERROR;
  }

  fail_if (strlen (TEST_MESSAGE) != info.size);
  msg = g_strndup ((const gchar *) info.data, info.size);

  gst_buffer_unmap (buffer, &info);

  GST_INFO ("Received message: \"%s\"", msg);

  fail_unless (g_strcmp0 (TEST_MESSAGE, msg) == 0);

  g_free (msg);

  g_idle_add (quit_main_loop_idle, user_data);

  return GST_FLOW_OK;
}
예제 #2
0
KmsWebRtcDataChannel *
kms_webrtc_data_channel_new (KmsWebRtcDataChannelBin * channel_bin)
{
  KmsWebRtcDataChannel *obj;

  obj = KMS_WEBRTC_DATA_CHANNEL (g_object_new (KMS_TYPE_WEBRTC_DATA_CHANNEL,
          NULL));

  obj->priv->channel_bin =
      KMS_WEBRTC_DATA_CHANNEL_BIN (g_object_ref (channel_bin));

  kms_webrtc_data_channel_bin_set_new_buffer_callback (channel_bin,
      kms_webrtc_data_channel_new_buffer, obj, NULL);

  return obj;
}
예제 #3
0
static void
kms_webrtc_data_channel_bin_finalize (GObject * object)
{
  KmsWebRtcDataChannel *self = KMS_WEBRTC_DATA_CHANNEL (object);

  GST_DEBUG_OBJECT (self, "finalize");

  if (self->priv->notify != NULL) {
    self->priv->notify (self->priv->user_data);
  }

  g_rec_mutex_clear (&self->priv->mutex);
  g_clear_object (&self->priv->channel_bin);

  /* chain up */
  G_OBJECT_CLASS (parent_class)->finalize (object);
}
예제 #4
0
static GstFlowReturn
kms_webrtc_data_channel_new_buffer (GObject * obj, GstBuffer * buffer,
    gpointer user_data)
{
  KmsWebRtcDataChannel *self = KMS_WEBRTC_DATA_CHANNEL (user_data);
  DataChannelNewBuffer cb;
  gpointer data;

  KMS_WEBRTC_DATA_CHANNEL_LOCK (self);

  cb = self->priv->cb;
  data = self->priv->user_data;

  KMS_WEBRTC_DATA_CHANNEL_UNLOCK (self);

  if (cb != NULL) {
    return cb (G_OBJECT (self), buffer, data);
  }

  return GST_FLOW_OK;
}