Exemplo n.º 1
0
GST_END_TEST
GST_START_TEST (copy)
{
  GstSDPMessage *message, *copy;
  glong length = -1;
  gchar *message_str, *copy_str;
  const gchar *repeat1[] = { "789", "012", NULL };
  const gchar *repeat2[] = { "987", "210", NULL };

  gst_sdp_message_new (&message);
  gst_sdp_message_parse_buffer ((guint8 *) sdp, length, message);

  gst_sdp_message_add_time (message, "123", "456", repeat1);
  gst_sdp_message_add_time (message, "321", "654", repeat2);

  gst_sdp_message_copy (message, &copy);

  message_str = gst_sdp_message_as_text (message);
  GST_DEBUG ("Original:\n%s", message_str);
  gst_sdp_message_free (message);
  copy_str = gst_sdp_message_as_text (copy);
  gst_sdp_message_free (copy);
  GST_DEBUG ("Copy:\n%s", copy_str);

  fail_if (g_strcmp0 (copy_str, message_str) != 0);
  g_free (copy_str);
  g_free (message_str);
}
Exemplo n.º 2
0
GstSDPMessage *
kms_sdp_session_process_offer (KmsSdpSession * self, GstSDPMessage * offer)
{
  SdpMessageContext *ctx;
  GstSDPMessage *answer = NULL, *copy;
  GError *err = NULL;

  GST_DEBUG_OBJECT (self, "Process offer");

  ctx = kms_sdp_message_context_new_from_sdp (offer, &err);
  if (err != NULL) {
    GST_ERROR_OBJECT (self, "Error processing offer (%s)", err->message);
    goto end;
  }

  kms_sdp_message_context_set_type (ctx, KMS_SDP_OFFER);
  self->remote_sdp_ctx = ctx;

  if (gst_sdp_message_copy (offer, &copy) != GST_SDP_OK) {
    GST_ERROR_OBJECT (self, "Error processing offer (Cannot copy SDP offer)");
    goto end;
  }

  kms_sdp_agent_set_remote_description (self->agent, copy, &err);
  if (err != NULL) {
    GST_ERROR_OBJECT (self, "Error processing offer (%s)", err->message);
    goto end;
  }

  ctx = kms_sdp_agent_create_answer (self->agent, &err);
  if (err != NULL) {
    GST_ERROR_OBJECT (self, "Error processing offer (%s)", err->message);
    goto end;
  }

  answer = kms_sdp_message_context_pack (ctx, &err);
  if (err != NULL) {
    GST_ERROR_OBJECT (self, "Error processing offer (%s)", err->message);
    kms_sdp_message_context_unref (ctx);
    goto end;
  }

  /* inmediate-TODO: review: a copy of answer? */
  kms_sdp_agent_set_local_description (self->agent, answer, &err);
  if (err != NULL) {
    GST_ERROR_OBJECT (self, "Error processing offer (%s)", err->message);
    goto end;
  }

  kms_sdp_message_context_set_type (ctx, KMS_SDP_ANSWER);
  self->local_sdp_ctx = ctx;
  self->neg_sdp_ctx = ctx;

end:
  g_clear_error (&err);

  return answer;
}
Exemplo n.º 3
0
gboolean
kms_sdp_session_process_answer (KmsSdpSession * self, GstSDPMessage * answer)
{
  GstSDPMessage *copy;
  SdpMessageContext *ctx;
  GError *err = NULL;

  GST_DEBUG_OBJECT (self, "Process answer");

  if (self->local_sdp_ctx == NULL) {
    // TODO: This should raise an error
    GST_ERROR_OBJECT (self, "Answer received without a local offer generated");
    return FALSE;
  }

  if (gst_sdp_message_copy (answer, &copy) != GST_SDP_OK) {
    GST_ERROR_OBJECT (self, "Error processing answer (Cannot copy SDP answer)");
    return FALSE;
  }

  kms_sdp_agent_set_remote_description (self->agent, copy, &err);
  if (err != NULL) {
    GST_ERROR_OBJECT (self, "Error processing answer (%s)", err->message);
    return FALSE;
  }

  ctx = kms_sdp_message_context_new_from_sdp (answer, &err);
  if (err != NULL) {
    GST_ERROR_OBJECT (self, "Error processing answer (%s)", err->message);
    g_error_free (err);
    return FALSE;
  }

  kms_sdp_message_context_set_type (ctx, KMS_SDP_ANSWER);
  self->remote_sdp_ctx = ctx;
  self->neg_sdp_ctx = ctx;

  return TRUE;
}