Exemplo n.º 1
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.º 2
0
GstSDPMessage *
kms_sdp_session_process_offer (KmsSdpSession * self, GstSDPMessage * offer)
{
  SdpMessageContext *ctx;
  GstSDPMessage *answer = NULL;
  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;

  ctx = kms_sdp_agent_create_answer (self->agent, offer, &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;
  }

  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;
}