diff options
| -rw-r--r-- | gst/rtpmanager/rtpsession.c | 91 | ||||
| -rw-r--r-- | gst/rtpmanager/rtpsource.c | 170 | 
2 files changed, 141 insertions, 120 deletions
diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c index ccb15e38..4e8a732d 100644 --- a/gst/rtpmanager/rtpsession.c +++ b/gst/rtpmanager/rtpsession.c @@ -57,6 +57,7 @@ enum  #define DEFAULT_SDES_NOTE            NULL  #define DEFAULT_NUM_SOURCES          0  #define DEFAULT_NUM_ACTIVE_SOURCES   0 +#define DEFAULT_SOURCES              NULL  enum  { @@ -73,6 +74,7 @@ enum    PROP_SDES_NOTE,    PROP_NUM_SOURCES,    PROP_NUM_ACTIVE_SOURCES, +  PROP_SOURCES,    PROP_LAST  }; @@ -243,62 +245,95 @@ rtp_session_class_init (RTPSessionClass * klass)    g_object_class_install_property (gobject_class, PROP_INTERNAL_SOURCE,        g_param_spec_object ("internal-source", "Internal Source",            "The internal source element of the session", -          RTP_TYPE_SOURCE, G_PARAM_READABLE)); +          RTP_TYPE_SOURCE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));    g_object_class_install_property (gobject_class, PROP_BANDWIDTH,        g_param_spec_double ("bandwidth", "Bandwidth",            "The bandwidth of the session", -          0.0, G_MAXDOUBLE, DEFAULT_BANDWIDTH, G_PARAM_READWRITE)); +          0.0, G_MAXDOUBLE, DEFAULT_BANDWIDTH, +          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));    g_object_class_install_property (gobject_class, PROP_RTCP_FRACTION,        g_param_spec_double ("rtcp-fraction", "RTCP Fraction",            "The fraction of the bandwidth used for RTCP", -          0.0, G_MAXDOUBLE, DEFAULT_RTCP_FRACTION, G_PARAM_READWRITE)); +          0.0, G_MAXDOUBLE, DEFAULT_RTCP_FRACTION, +          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));    g_object_class_install_property (gobject_class, PROP_SDES_CNAME,        g_param_spec_string ("sdes-cname", "SDES CNAME",            "The CNAME to put in SDES messages of this session", -          DEFAULT_SDES_CNAME, G_PARAM_READWRITE)); +          DEFAULT_SDES_CNAME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));    g_object_class_install_property (gobject_class, PROP_SDES_NAME,        g_param_spec_string ("sdes-name", "SDES NAME",            "The NAME to put in SDES messages of this session", -          DEFAULT_SDES_NAME, G_PARAM_READWRITE)); +          DEFAULT_SDES_NAME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));    g_object_class_install_property (gobject_class, PROP_SDES_EMAIL,        g_param_spec_string ("sdes-email", "SDES EMAIL",            "The EMAIL to put in SDES messages of this session", -          DEFAULT_SDES_EMAIL, G_PARAM_READWRITE)); +          DEFAULT_SDES_EMAIL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));    g_object_class_install_property (gobject_class, PROP_SDES_PHONE,        g_param_spec_string ("sdes-phone", "SDES PHONE",            "The PHONE to put in SDES messages of this session", -          DEFAULT_SDES_PHONE, G_PARAM_READWRITE)); +          DEFAULT_SDES_PHONE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));    g_object_class_install_property (gobject_class, PROP_SDES_LOCATION,        g_param_spec_string ("sdes-location", "SDES LOCATION",            "The LOCATION to put in SDES messages of this session", -          DEFAULT_SDES_LOCATION, G_PARAM_READWRITE)); +          DEFAULT_SDES_LOCATION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));    g_object_class_install_property (gobject_class, PROP_SDES_TOOL,        g_param_spec_string ("sdes-tool", "SDES TOOL",            "The TOOL to put in SDES messages of this session", -          DEFAULT_SDES_TOOL, G_PARAM_READWRITE)); +          DEFAULT_SDES_TOOL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));    g_object_class_install_property (gobject_class, PROP_SDES_NOTE,        g_param_spec_string ("sdes-note", "SDES NOTE",            "The NOTE to put in SDES messages of this session", -          DEFAULT_SDES_NOTE, G_PARAM_READWRITE)); +          DEFAULT_SDES_NOTE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));    g_object_class_install_property (gobject_class, PROP_NUM_SOURCES,        g_param_spec_uint ("num-sources", "Num Sources",            "The number of sources in the session", 0, G_MAXUINT, -          DEFAULT_NUM_SOURCES, G_PARAM_READABLE)); +          DEFAULT_NUM_SOURCES, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));    g_object_class_install_property (gobject_class, PROP_NUM_ACTIVE_SOURCES,        g_param_spec_uint ("num-active-sources", "Num Active Sources",            "The number of active sources in the session", 0, G_MAXUINT, -          DEFAULT_NUM_ACTIVE_SOURCES, G_PARAM_READABLE)); +          DEFAULT_NUM_ACTIVE_SOURCES, +          G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); +  /** +   * RTPSource::sources +   * +   * Get a GValue Array of all sources in the session. +   * +   * <example> +   * <title>Getting the #RTPSources of a session +   * <programlisting> +   * { +   *   GValueArray *arr; +   *   GValue *val; +   *   guint i; +   * +   *   g_object_get (sess, "sources", &arr, NULL); +   * +   *   for (i = 0; i < arr->n_values; i++) { +   *     RTPSource *source; +   * +   *     val = g_value_array_get_nth (arr, i); +   *     source = g_value_get_object (val); +   *   } +   *   g_value_array_free (arr); +   * } +   * </programlisting> +   * </example> +   */ +  g_object_class_install_property (gobject_class, PROP_SOURCES, +      g_param_spec_boxed ("sources", "Sources", +          "An array of all known sources in the session", +          G_TYPE_VALUE_ARRAY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));    klass->get_source_by_ssrc =        GST_DEBUG_FUNCPTR (rtp_session_get_source_by_ssrc); @@ -371,6 +406,35 @@ rtp_session_finalize (GObject * object)  }  static void +copy_source (gpointer key, RTPSource * source, GValueArray * arr) +{ +  GValue value = { 0 }; + +  g_value_init (&value, RTP_TYPE_SOURCE); +  g_value_take_object (&value, source); +  g_value_array_append (arr, &value); +} + +static GValueArray * +rtp_session_create_sources (RTPSession * sess) +{ +  GValueArray *res; +  guint size; + +  RTP_SESSION_LOCK (sess); +  /* get number of elements in the table */ +  size = g_hash_table_size (sess->ssrcs[sess->mask_idx]); +  /* create the result value array */ +  res = g_value_array_new (size); + +  /* and copy all values into the array */ +  g_hash_table_foreach (sess->ssrcs[sess->mask_idx], (GHFunc) copy_source, res); +  RTP_SESSION_UNLOCK (sess); + +  return res; +} + +static void  rtp_session_set_property (GObject * object, guint prop_id,      const GValue * value, GParamSpec * pspec)  { @@ -471,6 +535,9 @@ rtp_session_get_property (GObject * object, guint prop_id,      case PROP_NUM_ACTIVE_SOURCES:        g_value_set_uint (value, rtp_session_get_num_active_sources (sess));        break; +    case PROP_SOURCES: +      g_value_take_boxed (value, rtp_session_create_sources (sess)); +      break;      default:        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);        break; diff --git a/gst/rtpmanager/rtpsource.c b/gst/rtpmanager/rtpsource.c index fc225271..5aff0054 100644 --- a/gst/rtpmanager/rtpsource.c +++ b/gst/rtpmanager/rtpsource.c @@ -38,13 +38,7 @@ enum  #define DEFAULT_IS_CSRC              FALSE  #define DEFAULT_IS_VALIDATED         FALSE  #define DEFAULT_IS_SENDER            FALSE -#define DEFAULT_SDES_CNAME           NULL -#define DEFAULT_SDES_NAME            NULL -#define DEFAULT_SDES_EMAIL           NULL -#define DEFAULT_SDES_PHONE           NULL -#define DEFAULT_SDES_LOCATION        NULL -#define DEFAULT_SDES_TOOL            NULL -#define DEFAULT_SDES_NOTE            NULL +#define DEFAULT_SDES                 NULL  enum  { @@ -53,13 +47,7 @@ enum    PROP_IS_CSRC,    PROP_IS_VALIDATED,    PROP_IS_SENDER, -  PROP_SDES_CNAME, -  PROP_SDES_NAME, -  PROP_SDES_EMAIL, -  PROP_SDES_PHONE, -  PROP_SDES_LOCATION, -  PROP_SDES_TOOL, -  PROP_SDES_NOTE, +  PROP_SDES,    PROP_STATS,    PROP_LAST  }; @@ -89,8 +77,7 @@ rtp_source_class_init (RTPSourceClass * klass)    g_object_class_install_property (gobject_class, PROP_SSRC,        g_param_spec_uint ("ssrc", "SSRC", -          "The SSRC of this source", 0, G_MAXUINT, -          DEFAULT_SSRC, +          "The SSRC of this source", 0, G_MAXUINT, DEFAULT_SSRC,            G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));    g_object_class_install_property (gobject_class, PROP_IS_CSRC, @@ -108,49 +95,30 @@ rtp_source_class_init (RTPSourceClass * klass)            "If this SSRC is a sender", DEFAULT_IS_SENDER,            G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); -  g_object_class_install_property (gobject_class, PROP_SDES_CNAME, -      g_param_spec_string ("sdes-cname", "SDES CNAME", -          "The CNAME to put in SDES messages of this source", -          DEFAULT_SDES_CNAME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - -  g_object_class_install_property (gobject_class, PROP_SDES_NAME, -      g_param_spec_string ("sdes-name", "SDES NAME", -          "The NAME to put in SDES messages of this source", -          DEFAULT_SDES_NAME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - -  g_object_class_install_property (gobject_class, PROP_SDES_EMAIL, -      g_param_spec_string ("sdes-email", "SDES EMAIL", -          "The EMAIL to put in SDES messages of this source", -          DEFAULT_SDES_EMAIL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - -  g_object_class_install_property (gobject_class, PROP_SDES_PHONE, -      g_param_spec_string ("sdes-phone", "SDES PHONE", -          "The PHONE to put in SDES messages of this source", -          DEFAULT_SDES_PHONE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - -  g_object_class_install_property (gobject_class, PROP_SDES_LOCATION, -      g_param_spec_string ("sdes-location", "SDES LOCATION", -          "The LOCATION to put in SDES messages of this source", -          DEFAULT_SDES_LOCATION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - -  g_object_class_install_property (gobject_class, PROP_SDES_TOOL, -      g_param_spec_string ("sdes-tool", "SDES TOOL", -          "The TOOL to put in SDES messages of this source", -          DEFAULT_SDES_TOOL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - -  g_object_class_install_property (gobject_class, PROP_SDES_NOTE, -      g_param_spec_string ("sdes-note", "SDES NOTE", -          "The NOTE to put in SDES messages of this source", -          DEFAULT_SDES_NOTE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); +  /** +   * RTPSource::sdes +   * +   * The current SDES items of the source. Returns a structure with the +   * following fields: +   * +   *  'cname'    G_TYPE_STRING  : The canonical name  +   *  'name'     G_TYPE_STRING  : The user name  +   *  'email'    G_TYPE_STRING  : The user's electronic mail address +   *  'phone'    G_TYPE_STRING  : The user's phone number +   *  'location' G_TYPE_STRING  : The geographic user location +   *  'tool'     G_TYPE_STRING  : The name of application or tool +   *  'note'     G_TYPE_STRING  : A notice about the source +   */ +  g_object_class_install_property (gobject_class, PROP_SDES, +      g_param_spec_boxed ("sdes", "SDES", +          "The SDES information for this source", +          GST_TYPE_STRUCTURE, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));    /**     * RTPSource::stats     *     * The statistics of the source. This property returns a GstStructure with     * name application/x-rtp-source-stats with the following fields: -   * -   *   -   *     *      */    g_object_class_install_property (gobject_class, PROP_STATS, @@ -298,6 +266,45 @@ rtp_source_create_stats (RTPSource * src)    return s;  } +static GstStructure * +rtp_source_create_sdes (RTPSource * src) +{ +  GstStructure *s; +  gchar *str; + +  s = gst_structure_new ("application/x-rtp-source-sdes", NULL); + +  if ((str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_CNAME))) { +    gst_structure_set (s, "cname", G_TYPE_STRING, str, NULL); +    g_free (str); +  } +  if ((str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_NAME))) { +    gst_structure_set (s, "name", G_TYPE_STRING, str, NULL); +    g_free (str); +  } +  if ((str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_EMAIL))) { +    gst_structure_set (s, "email", G_TYPE_STRING, str, NULL); +    g_free (str); +  } +  if ((str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_PHONE))) { +    gst_structure_set (s, "phone", G_TYPE_STRING, str, NULL); +    g_free (str); +  } +  if ((str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_LOC))) { +    gst_structure_set (s, "location", G_TYPE_STRING, str, NULL); +    g_free (str); +  } +  if ((str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_TOOL))) { +    gst_structure_set (s, "tool", G_TYPE_STRING, str, NULL); +    g_free (str); +  } +  if ((str = rtp_source_get_sdes_string (src, GST_RTCP_SDES_NOTE))) { +    gst_structure_set (s, "note", G_TYPE_STRING, str, NULL); +    g_free (str); +  } +  return s; +} +  static void  rtp_source_set_property (GObject * object, guint prop_id,      const GValue * value, GParamSpec * pspec) @@ -310,34 +317,6 @@ rtp_source_set_property (GObject * object, guint prop_id,      case PROP_SSRC:        src->ssrc = g_value_get_uint (value);        break; -    case PROP_SDES_CNAME: -      rtp_source_set_sdes_string (src, GST_RTCP_SDES_CNAME, -          g_value_get_string (value)); -      break; -    case PROP_SDES_NAME: -      rtp_source_set_sdes_string (src, GST_RTCP_SDES_NAME, -          g_value_get_string (value)); -      break; -    case PROP_SDES_EMAIL: -      rtp_source_set_sdes_string (src, GST_RTCP_SDES_EMAIL, -          g_value_get_string (value)); -      break; -    case PROP_SDES_PHONE: -      rtp_source_set_sdes_string (src, GST_RTCP_SDES_PHONE, -          g_value_get_string (value)); -      break; -    case PROP_SDES_LOCATION: -      rtp_source_set_sdes_string (src, GST_RTCP_SDES_LOC, -          g_value_get_string (value)); -      break; -    case PROP_SDES_TOOL: -      rtp_source_set_sdes_string (src, GST_RTCP_SDES_TOOL, -          g_value_get_string (value)); -      break; -    case PROP_SDES_NOTE: -      rtp_source_set_sdes_string (src, GST_RTCP_SDES_NOTE, -          g_value_get_string (value)); -      break;      default:        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);        break; @@ -365,33 +344,8 @@ rtp_source_get_property (GObject * object, guint prop_id,      case PROP_IS_SENDER:        g_value_set_boolean (value, rtp_source_is_sender (src));        break; -    case PROP_SDES_CNAME: -      g_value_take_string (value, rtp_source_get_sdes_string (src, -              GST_RTCP_SDES_CNAME)); -      break; -    case PROP_SDES_NAME: -      g_value_take_string (value, rtp_source_get_sdes_string (src, -              GST_RTCP_SDES_NAME)); -      break; -    case PROP_SDES_EMAIL: -      g_value_take_string (value, rtp_source_get_sdes_string (src, -              GST_RTCP_SDES_EMAIL)); -      break; -    case PROP_SDES_PHONE: -      g_value_take_string (value, rtp_source_get_sdes_string (src, -              GST_RTCP_SDES_PHONE)); -      break; -    case PROP_SDES_LOCATION: -      g_value_take_string (value, rtp_source_get_sdes_string (src, -              GST_RTCP_SDES_LOC)); -      break; -    case PROP_SDES_TOOL: -      g_value_take_string (value, rtp_source_get_sdes_string (src, -              GST_RTCP_SDES_TOOL)); -      break; -    case PROP_SDES_NOTE: -      g_value_take_string (value, rtp_source_get_sdes_string (src, -              GST_RTCP_SDES_NOTE)); +    case PROP_SDES: +      g_value_take_boxed (value, rtp_source_create_sdes (src));        break;      case PROP_STATS:        g_value_take_boxed (value, rtp_source_create_stats (src));  | 
