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
static void
kms_sdp_session_finalize (GObject * object)
{
  KmsSdpSession *self = KMS_SDP_SESSION (object);

  GST_DEBUG_OBJECT (self, "finalize");

  if (self->local_sdp_ctx != NULL) {
    kms_sdp_message_context_unref (self->local_sdp_ctx);
  }

  if (self->remote_sdp_ctx != NULL) {
    kms_sdp_message_context_unref (self->remote_sdp_ctx);
  }

  g_clear_object (&self->ptmanager);
  g_clear_object (&self->agent);
  g_free (self->id_str);

  g_rec_mutex_clear (&self->mutex);

  /* chain up */
  G_OBJECT_CLASS (kms_sdp_session_parent_class)->finalize (object);
}
Exemplo n.º 3
0
static SdpMessageContext *
kms_sdp_agent_create_answer_impl (KmsSdpAgent * agent,
    const GstSDPMessage * offer, GError ** error)
{
  struct SdpAnswerData data;
  SdpMessageContext *ctx;
  gboolean bundle;
  SdpIPv ipv;

  SDP_AGENT_LOCK (agent);
  ipv = (agent->priv->use_ipv6) ? IPV6 : IPV4;
  bundle = g_slist_length (agent->priv->groups) > 0;
  SDP_AGENT_UNLOCK (agent);

  ctx = kms_sdp_message_context_new (ipv, agent->priv->addr, error);
  if (ctx == NULL) {
    return NULL;
  }

  kms_sdp_message_context_set_type (ctx, KMS_SDP_ANSWER);

  if (bundle
      && !kms_sdp_message_context_parse_groups_from_offer (ctx, offer, error)) {
    goto error;
  }

  if (!kms_sdp_message_context_set_common_session_attributes (ctx, offer,
          error)) {
    goto error;
  }

  data.agent = agent;
  data.ctx = ctx;
  data.err = error;

  if (!sdp_utils_for_each_media (offer, (GstSDPMediaFunc) create_media_answer,
          &data)) {
    goto error;
  }

  return ctx;

error:
  kms_sdp_message_context_unref (ctx);

  return NULL;
}
Exemplo n.º 4
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;
}