<commit_before>/*
 * sdp.c - Kurento Media Server
 *
 * Copyright (C) 2013 Kurento
 * Contact: <NAME> <<EMAIL>>
 * Contact: <NAME> <<EMAIL>>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "sdp_utils.h"
#include <gst/gst.h>
#include <glib.h>

#define GST_CAT_DEFAULT sdp_utils
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
#define GST_DEFAULT_NAME "sdp_utils"

#define SENDONLY_STR  "sendonly"
#define RECVONLY_STR  "recvonly"
#define SENDRECV_STR  "sendrecv"
#define INACTIVE_STR  "inactive"

static gchar *directions[] =
    { SENDONLY_STR, RECVONLY_STR, SENDRECV_STR, INACTIVE_STR, NULL };

#define RTPMAP "rtpmap"

const gchar *
sdp_utils_get_direction_str (GstSDPDirection direction)
{
  return directions[direction];
}

static GstSDPResult
sdp_message_create_from_src (const GstSDPMessage * src, GstSDPMessage ** msg)
{
  GstSDPResult result;
  const GstSDPConnection *conn;
  const GstSDPOrigin *orig;
  guint i;

  result = gst_sdp_message_new (msg);
  if (result != GST_SDP_OK) {
    GST_ERROR ("Error creating sdp message");
    return result;
  }

  conn = gst_sdp_message_get_connection (src);
  orig = gst_sdp_message_get_origin (src);

  gst_sdp_message_set_version (*msg, gst_sdp_message_get_version (src));
  gst_sdp_message_set_session_name (*msg,
      gst_sdp_message_get_session_name (src));
  gst_sdp_message_set_connection (*msg, conn->nettype, conn->addrtype,
      conn->address, conn->ttl, conn->addr_number);
  gst_sdp_message_set_origin (*msg, orig->username, orig->sess_id,
      orig->sess_version, orig->nettype, orig->addrtype, orig->addr);

  for (i = 0; i < gst_sdp_message_times_len (src); i++) {
    const GstSDPTime *time = gst_sdp_message_get_time (src, i);
    gchar **repeat;
    gint j;

    repeat = g_malloc (time->repeat->len) + 1;
    for (j = 0; j < time->repeat->len; j++) {
      repeat[j] = g_array_index (time->repeat, gchar *, j);
    }
    repeat[time->repeat->len] = NULL;

    gst_sdp_message_add_time (*msg, time->start, time->stop,
        (const gchar **) repeat);
    g_free (repeat);
  }

  return GST_SDP_OK;
}

static GstSDPResult
sdp_media_create_from_src (const GstSDPMedia * src, GstSDPMedia ** media)
{
  GstSDPResult result;

  result = gst_sdp_media_new (media);
  if (result != GST_SDP_OK) {
    GST_ERROR ("Error creating sdp media");
    return result;
  }

  gst_sdp_media_set_media (*media, gst_sdp_media_get_media (src));
  gst_sdp_media_set_port_info (*media, gst_sdp_media_get_port (src), 1);
  gst_sdp_media_set_proto (*media, gst_sdp_media_get_proto (src));

  return GST_SDP_OK;
}

static gboolean
sdp_utils_attribute_is_direction (const GstSDPAttribute * attr,
    GstSDPDirection * direction)
{
  gint i;

  for (i = 0; directions[i] != NULL; i++) {
    if (g_ascii_strcasecmp (attr->key, directions[i]) == 0) {<commit_msg>As specified by rfc3264 sdp time line should be "t=0 0"<commit_after>/*
 * sdp.c - Kurento Media Server
 *
 * Copyright (C) 2013 Kurento
 * Contact: <NAME> <<EMAIL>>
 * Contact: <NAME> <<EMAIL>>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "sdp_utils.h"
#include <gst/gst.h>
#include <glib.h>

#define GST_CAT_DEFAULT sdp_utils
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
#define GST_DEFAULT_NAME "sdp_utils"

#define SENDONLY_STR  "sendonly"
#define RECVONLY_STR  "recvonly"
#define SENDRECV_STR  "sendrecv"
#define INACTIVE_STR  "inactive"

static gchar *directions[] =
    { SENDONLY_STR, RECVONLY_STR, SENDRECV_STR, INACTIVE_STR, NULL };

#define RTPMAP "rtpmap"

const gchar *
sdp_utils_get_direction_str (GstSDPDirection direction)
{
  return directions[direction];
}

static GstSDPResult
sdp_message_create_from_src (const GstSDPMessage * src, GstSDPMessage ** msg)
{
  GstSDPResult result;
  const GstSDPConnection *conn;
  const GstSDPOrigin *orig;

  result = gst_sdp_message_new (msg);
  if (result != GST_SDP_OK) {
    GST_ERROR ("Error creating sdp message");
    return result;
  }

  conn = gst_sdp_message_get_connection (src);
  orig = gst_sdp_message_get_origin (src);

  gst_sdp_message_set_version (*msg, gst_sdp_message_get_version (src));
  gst_sdp_message_set_session_name (*msg,
      gst_sdp_message_get_session_name (src));
  gst_sdp_message_set_connection (*msg, conn->nettype, conn->addrtype,
      conn->address, conn->ttl, conn->addr_number);
  gst_sdp_message_set_origin (*msg, orig->username, orig->sess_id,
      orig->sess_version, orig->nettype, orig->addrtype, orig->addr);

  return GST_SDP_OK;
}

static GstSDPResult
sdp_media_create_from_src (const GstSDPMedia * src, GstSDPMedia ** media)
{
  GstSDPResult result;

  result = gst_sdp_media_new (media);
  if (result != GST_SDP_OK) {
    GST_ERROR ("Error creating sdp media");
    return result;
  }

  gst_sdp_media_set_media (*media, gst_sdp_media_get_media (src));
  gst_sdp_media_set_port_info (*media, gst_sdp_media_get_port (src), 1);
  gst_sdp_media_set_proto (*media, gst_sdp_media_get_proto (src));

  return GST_SDP_OK;
}

static gboolean
sdp_utils_attribute_is_direction (const GstSDPAttribute * attr,
    GstSDPDirection * direction)
{
  gint i;

  for (i = 0; directions[i] != NULL; i++) {
    if (g_ascii_strcasecmp (attr->key, directions[i]) == 0) {
{'fraction_non_alphanumeric': 0.1054481546572935, 'fraction_numerical': 0.003994248282473239, 'mean_word_length': 4.665158371040724, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5766634', 'n_tokens_mistral': 2334, 'n_tokens_neox': 2280, 'n_words': 587}