static const gchar *
kms_sdp_group_manager_get_group_val (KmsSdpGroupManager * obj,
    const gchar * semantics, const GstSDPMessage * msg)
{
  const gchar *val;
  guint i;

  for (i = 0;; i++) {
    gchar **values;
    gboolean found;

    val = gst_sdp_message_get_attribute_val_n (msg, GROUP_ATTR_VALUE, i);

    if (val == NULL) {
      /* No more group attributes */
      return NULL;
    }

    values = g_strsplit (val, " ", 2);
    found = g_strcmp0 (semantics, values[0]) == 0;
    g_strfreev (values);

    if (found) {
      return val;
    }
  }
}
static gboolean
kms_sdp_group_manager_is_handler_valid_for_groups_impl (KmsSdpGroupManager *
    obj, const GstSDPMedia * media, const GstSDPMessage * offer,
    KmsSdpHandler * handler)
{
  KmsSdpBaseGroup *group = NULL;
  gboolean ret = FALSE;
  const gchar *mid;

  mid = gst_sdp_media_get_attribute_val (media, "mid");
  group = kms_sdp_group_manager_get_group (obj, handler);

  if (mid == NULL) {
    /* handler will be compatible if has no group */
    ret = group == NULL;
    goto end;
  }

  if (group != NULL) {
    const gchar *val;
    gchar *semantics;

    g_object_get (group, "semantics", &semantics, NULL);

    val = kms_sdp_group_manager_get_group_val (obj, semantics, offer);
    g_free (semantics);

    if (val == NULL) {
      /* handler belongs to a group that this media does not */
      ret = FALSE;
    } else {
      ret = is_mid_in_group (val, mid);
    }
  } else {
    gint i;

    /* handler does not belong to any group, it will be incompatible if */
    /* media does */
    for (i = 0;; i++) {
      const gchar *val;

      val = gst_sdp_message_get_attribute_val_n (offer, GROUP_ATTR_VALUE, i);

      if (val == NULL) {
        /* No more group attributes */
        ret = TRUE;
        break;
      }

      if (is_mid_in_group (val, mid)) {
        break;
      }
    }
  }

end:
  g_clear_object (&group);

  return ret;
}
Exemple #3
0
gboolean
kms_sdp_message_context_parse_groups_from_offer (SdpMessageContext * ctx,
    const GstSDPMessage * offer, GError ** error)
{
  guint i, gid = 0;

  for (i = 0;; i++) {
    SdpMediaGroup *mgroup;
    gboolean is_bundle;
    const gchar *val;
    gchar **grp;
    guint j;

    val = gst_sdp_message_get_attribute_val_n (offer, "group", i);

    if (val == NULL) {
      return TRUE;
    }

    grp = g_strsplit (val, " ", 0);
    is_bundle = g_strcmp0 (grp[0] /* group type */ , "BUNDLE") == 0;

    if (!is_bundle) {
      GST_WARNING ("Group '%s' is not supported", grp[0]);
      g_strfreev (grp);
      continue;
    }

    mgroup = kms_sdp_message_context_create_group (ctx, gid++);
    for (j = 1; grp[j] != NULL; j++) {
      SdpMediaConfig *mconf;

      mconf = kms_sdp_context_new_media_config (g_slist_length (ctx->medias),
          g_strdup (grp[j]), NULL);

      ctx->medias = g_slist_append (ctx->medias, mconf);
      if (!kms_sdp_message_context_add_media_to_group (mgroup, mconf, error)) {
        g_strfreev (grp);
        return FALSE;
      }
    }

    g_strfreev (grp);
  }
}
static GstRTSPResult
gst_rtsp_wms_parse_sdp (GstRTSPExtension * ext, GstSDPMessage * sdp,
    GstStructure * props)
{
  const gchar *config, *maxps;
  gint i;
  GstRTSPWMS *ctx = (GstRTSPWMS *) ext;

  if (!ctx->active)
    return GST_RTSP_OK;

  for (i = 0; (config = gst_sdp_message_get_attribute_val_n (sdp, "pgmpu", i));
      i++) {
    if (g_str_has_prefix (config, HEADER_PREFIX)) {
      config += strlen (HEADER_PREFIX);
      gst_structure_set (props, "config", G_TYPE_STRING, config, NULL);
      break;
    }
  }
  if (config == NULL)
    goto no_config;

  gst_structure_set (props, "config", G_TYPE_STRING, config, NULL);

  maxps = gst_sdp_message_get_attribute_val (sdp, "maxps");
  if (maxps)
    gst_structure_set (props, "maxps", G_TYPE_STRING, maxps, NULL);

  gst_structure_set (props, "encoding-name", G_TYPE_STRING, "X-ASF-PF", NULL);
  gst_structure_set (props, "media", G_TYPE_STRING, "application", NULL);

  return GST_RTSP_OK;

  /* ERRORS */
no_config:
  {
    GST_DEBUG_OBJECT (ctx, "Could not find config SDP field, deactivating.");
    ctx->active = FALSE;
    return GST_RTSP_OK;
  }
}