gst/rtpmanager/rtpsession.c: Add G_PARAM_STATIC_STRINGS.

Original commit message from CVS:
* gst/rtpmanager/rtpsession.c: (rtp_session_class_init),
(copy_source), (rtp_session_create_sources),
(rtp_session_get_property):
Add G_PARAM_STATIC_STRINGS.
Add property to return a GValueArray of all known RTPSources in the
session.
* gst/rtpmanager/rtpsource.c: (rtp_source_class_init),
(rtp_source_create_sdes), (rtp_source_set_property),
(rtp_source_get_property):
Remove properties to set the various SDES items, an application is never
supposed to change the RTPSource data.
Change the SDES getter properties to one SDES property that returns all
SDES items in a GstStructure.
This commit is contained in:
Wim Taymans 2008-11-22 15:24:47 +00:00
parent b31ce48a0d
commit a44013a44c
3 changed files with 158 additions and 120 deletions

View file

@ -1,3 +1,20 @@
2008-11-22 Wim Taymans <wim.taymans@collabora.co.uk>
* gst/rtpmanager/rtpsession.c: (rtp_session_class_init),
(copy_source), (rtp_session_create_sources),
(rtp_session_get_property):
Add G_PARAM_STATIC_STRINGS.
Add property to return a GValueArray of all known RTPSources in the
session.
* gst/rtpmanager/rtpsource.c: (rtp_source_class_init),
(rtp_source_create_sdes), (rtp_source_set_property),
(rtp_source_get_property):
Remove properties to set the various SDES items, an application is never
supposed to change the RTPSource data.
Change the SDES getter properties to one SDES property that returns all
SDES items in a GstStructure.
2008-11-22 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* tests/check/elements/speexresample.c: (GST_START_TEST):

View file

@ -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);
@ -370,6 +405,35 @@ rtp_session_finalize (GObject * object)
G_OBJECT_CLASS (rtp_session_parent_class)->finalize (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;

View file

@ -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,40 +95,24 @@ 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
@ -149,9 +120,6 @@ rtp_source_class_init (RTPSourceClass * klass)
* 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,
g_param_spec_boxed ("stats", "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));