gst-libs/gst/rtp/gstbasertpaudiopayload.c: Some cleanups, remove minptime property as it is now in the parent class.

Original commit message from CVS:
* gst-libs/gst/rtp/gstbasertpaudiopayload.c:
(gst_base_rtp_audio_payload_class_init),
(gst_base_rtp_audio_payload_init),
(gst_base_rtp_audio_payload_finalize),
(gst_base_rtp_audio_payload_handle_frame_based_buffer),
(gst_base_rtp_audio_payload_handle_sample_based_buffer),
(gst_base_rtp_payload_audio_handle_event):
Some cleanups, remove minptime property as it is now in the parent
class.
Override parent class event function.
* gst-libs/gst/rtp/gstbasertppayload.c:
(gst_basertppayload_class_init), (gst_basertppayload_init),
(gst_basertppayload_event), (gst_basertppayload_set_property),
(gst_basertppayload_get_property):
* gst-libs/gst/rtp/gstbasertppayload.h:
Add min-ptime property.
Add handle-event vmethod. Fixes #415001.
This commit is contained in:
Wim Taymans 2007-05-21 09:45:28 +00:00
parent 13b6bdeed0
commit 7ace85992a
4 changed files with 70 additions and 105 deletions

View file

@ -1,3 +1,24 @@
2007-05-21 Wim Taymans <wim@fluendo.com>
* gst-libs/gst/rtp/gstbasertpaudiopayload.c:
(gst_base_rtp_audio_payload_class_init),
(gst_base_rtp_audio_payload_init),
(gst_base_rtp_audio_payload_finalize),
(gst_base_rtp_audio_payload_handle_frame_based_buffer),
(gst_base_rtp_audio_payload_handle_sample_based_buffer),
(gst_base_rtp_payload_audio_handle_event):
Some cleanups, remove minptime property as it is now in the parent
class.
Override parent class event function.
* gst-libs/gst/rtp/gstbasertppayload.c:
(gst_basertppayload_class_init), (gst_basertppayload_init),
(gst_basertppayload_event), (gst_basertppayload_set_property),
(gst_basertppayload_get_property):
* gst-libs/gst/rtp/gstbasertppayload.h:
Add min-ptime property.
Add handle-event vmethod. Fixes #415001.
2007-05-18 Stefan Kost <ensonic@users.sf.net>
* gst-libs/gst/audio/gstbaseaudiosink.c

View file

@ -83,20 +83,11 @@ struct _GstBaseRTPAudioPayloadPrivate
guint64 min_ptime;
};
#define DEFAULT_MIN_PTIME 0
enum
{
PROP_0,
PROP_MIN_PTIME
};
#define GST_BASE_RTP_AUDIO_PAYLOAD_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GST_TYPE_BASE_RTP_AUDIO_PAYLOAD, \
GstBaseRTPAudioPayloadPrivate))
static void gst_base_rtp_audio_payload_dispose (GObject * object);
static void gst_base_rtp_audio_payload_finalize (GObject * object);
static GstFlowReturn gst_base_rtp_audio_payload_handle_buffer (GstBaseRTPPayload
@ -114,15 +105,7 @@ static GstStateChangeReturn
gst_base_rtp_payload_audio_change_state (GstElement * element,
GstStateChange transition);
static gboolean
gst_base_rtp_payload_audio_handle_event (GstPad * pad, GstEvent * event,
gpointer data);
static void
gst_base_rtp_payload_audio_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void
gst_base_rtp_payload_audio_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
gst_base_rtp_payload_audio_handle_event (GstPad * pad, GstEvent * event);
GST_BOILERPLATE (GstBaseRTPAudioPayload, gst_base_rtp_audio_payload,
GstBaseRTPPayload, GST_TYPE_BASE_RTP_PAYLOAD);
@ -144,33 +127,17 @@ gst_base_rtp_audio_payload_class_init (GstBaseRTPAudioPayloadClass * klass)
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
gobject_class->finalize =
GST_DEBUG_FUNCPTR (gst_base_rtp_audio_payload_finalize);
gobject_class->dispose =
GST_DEBUG_FUNCPTR (gst_base_rtp_audio_payload_dispose);
gobject_class->set_property = gst_base_rtp_payload_audio_set_property;
gobject_class->get_property = gst_base_rtp_payload_audio_get_property;
parent_class = g_type_class_peek_parent (klass);
gstbasertppayload_class->handle_buffer =
GST_DEBUG_FUNCPTR (gst_base_rtp_audio_payload_handle_buffer);
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_base_rtp_payload_audio_change_state);
/**
* GstBaseRTPAudioPayload:min-ptime:
*
* Minimum duration of the packet data in ns (can't go above MTU)
*
* Since: 0.10.13
**/
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MIN_PTIME,
g_param_spec_int64 ("min-ptime", "Min packet time",
"Minimum duration of the packet data in ns (can't go above MTU)",
0, G_MAXINT64, DEFAULT_MIN_PTIME, G_PARAM_READWRITE));
gstbasertppayload_class->handle_buffer =
GST_DEBUG_FUNCPTR (gst_base_rtp_audio_payload_handle_buffer);
gstbasertppayload_class->handle_event =
GST_DEBUG_FUNCPTR (gst_base_rtp_payload_audio_handle_event);
GST_DEBUG_CATEGORY_INIT (basertpaudiopayload_debug, "basertpaudiopayload", 0,
"base audio RTP payloader");
@ -180,9 +147,6 @@ static void
gst_base_rtp_audio_payload_init (GstBaseRTPAudioPayload * basertpaudiopayload,
GstBaseRTPAudioPayloadClass * klass)
{
GstBaseRTPPayload *basertppayload =
GST_BASE_RTP_PAYLOAD (basertpaudiopayload);
basertpaudiopayload->priv =
GST_BASE_RTP_AUDIO_PAYLOAD_GET_PRIVATE (basertpaudiopayload);
@ -198,28 +162,8 @@ gst_base_rtp_audio_payload_init (GstBaseRTPAudioPayload * basertpaudiopayload,
basertpaudiopayload->sample_size = 0;
basertpaudiopayload->priv->adapter = gst_adapter_new ();
gst_pad_add_event_probe (basertppayload->sinkpad,
G_CALLBACK (gst_base_rtp_payload_audio_handle_event), NULL);
}
static void
gst_base_rtp_audio_payload_dispose (GObject * object)
{
GstBaseRTPAudioPayload *basertpaudiopayload;
basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (object);
if (basertpaudiopayload->priv->adapter) {
g_object_unref (basertpaudiopayload->priv->adapter);
basertpaudiopayload->priv->adapter = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gst_base_rtp_audio_payload_finalize (GObject * object)
{
@ -227,6 +171,8 @@ gst_base_rtp_audio_payload_finalize (GObject * object)
basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (object);
g_object_unref (basertpaudiopayload->priv->adapter);
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
}
@ -390,7 +336,7 @@ gst_base_rtp_audio_payload_handle_frame_based_buffer (GstBaseRTPPayload *
/* min number of bytes based on a given ptime, has to be a multiple
of frame duration */
minptime_ms = basertpaudiopayload->priv->min_ptime / 1000000;
minptime_ms = basepayload->min_ptime / 1000000;
minptime_octets = frame_size * (int) (minptime_ms / frame_duration);
@ -518,8 +464,8 @@ gst_base_rtp_audio_payload_handle_sample_based_buffer (GstBaseRTPPayload *
/* min number of bytes based on a given ptime, has to be a multiple
of sample rate */
minptime_octets = basertpaudiopayload->priv->min_ptime *
basepayload->clock_rate / (sample_size * GST_SECOND);
minptime_octets = basepayload->min_ptime * basepayload->clock_rate /
(sample_size * GST_SECOND);
min_payload_len = MAX (minptime_octets, sample_size);
@ -671,45 +617,8 @@ gst_base_rtp_payload_audio_change_state (GstElement * element,
return ret;
}
static void
gst_base_rtp_payload_audio_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstBaseRTPAudioPayload *basertpaudiopayload;
basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (object);
switch (prop_id) {
case PROP_MIN_PTIME:
basertpaudiopayload->priv->min_ptime = g_value_get_int64 (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_base_rtp_payload_audio_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstBaseRTPAudioPayload *basertpaudiopayload;
basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (object);
switch (prop_id) {
case PROP_MIN_PTIME:
g_value_set_int64 (value, basertpaudiopayload->priv->min_ptime);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
gst_base_rtp_payload_audio_handle_event (GstPad * pad, GstEvent * event,
gpointer data)
gst_base_rtp_payload_audio_handle_event (GstPad * pad, GstEvent * event)
{
GstBaseRTPAudioPayload *basertpaudiopayload;
gboolean res = TRUE;

View file

@ -55,6 +55,7 @@ enum
#define DEFAULT_TIMESTAMP_OFFSET -1
#define DEFAULT_SEQNUM_OFFSET -1
#define DEFAULT_MAX_PTIME -1
#define DEFAULT_MIN_PTIME 0
enum
{
@ -65,6 +66,7 @@ enum
PROP_TIMESTAMP_OFFSET,
PROP_SEQNUM_OFFSET,
PROP_MAX_PTIME,
PROP_MIN_PTIME,
PROP_TIMESTAMP,
PROP_SEQNUM
};
@ -163,6 +165,17 @@ gst_basertppayload_class_init (GstBaseRTPPayloadClass * klass)
g_param_spec_int64 ("max-ptime", "Max packet time",
"Maximum duration of the packet data in ns (-1 = unlimited up to MTU)",
-1, G_MAXINT64, DEFAULT_MAX_PTIME, G_PARAM_READWRITE));
/**
* GstBaseRTPAudioPayload:min-ptime:
*
* Minimum duration of the packet data in ns (can't go above MTU)
*
* Since: 0.10.13
**/
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MIN_PTIME,
g_param_spec_int64 ("min-ptime", "Min packet time",
"Minimum duration of the packet data in ns (can't go above MTU)",
0, G_MAXINT64, DEFAULT_MIN_PTIME, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TIMESTAMP,
g_param_spec_uint ("timestamp", "Timestamp",
@ -214,6 +227,7 @@ gst_basertppayload_init (GstBaseRTPPayload * basertppayload, gpointer g_class)
basertppayload->ssrc = DEFAULT_SSRC;
basertppayload->ts_offset = DEFAULT_TIMESTAMP_OFFSET;
basertppayload->max_ptime = DEFAULT_MAX_PTIME;
basertppayload->min_ptime = DEFAULT_MIN_PTIME;
basertppayload->media = NULL;
basertppayload->encoding_name = NULL;
@ -266,9 +280,20 @@ static gboolean
gst_basertppayload_event (GstPad * pad, GstEvent * event)
{
GstBaseRTPPayload *basertppayload;
GstBaseRTPPayloadClass *basertppayload_class;
gboolean res;
basertppayload = GST_BASE_RTP_PAYLOAD (gst_pad_get_parent (pad));
basertppayload_class = GST_BASE_RTP_PAYLOAD_GET_CLASS (basertppayload);
if (basertppayload_class->handle_event) {
res = basertppayload_class->handle_event (pad, event);
if (res) {
gst_object_unref (basertppayload);
return res;
}
}
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
@ -477,6 +502,9 @@ gst_basertppayload_set_property (GObject * object, guint prop_id,
case PROP_MAX_PTIME:
basertppayload->max_ptime = g_value_get_int64 (value);
break;
case PROP_MIN_PTIME:
basertppayload->min_ptime = g_value_get_int64 (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -510,6 +538,9 @@ gst_basertppayload_get_property (GObject * object, guint prop_id,
case PROP_MAX_PTIME:
g_value_set_int64 (value, basertppayload->max_ptime);
break;
case PROP_MIN_PTIME:
g_value_set_int64 (value, basertppayload->min_ptime);
break;
case PROP_TIMESTAMP:
g_value_set_uint (value, basertppayload->timestamp);
break;

View file

@ -78,8 +78,11 @@ struct _GstBaseRTPPayload
GstSegment segment;
guint64 min_ptime;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
gpointer _gst_reserved[GST_PADDING - (sizeof(guint64)/sizeof(gpointer))];
};
struct _GstBaseRTPPayloadClass
@ -92,9 +95,10 @@ struct _GstBaseRTPPayloadClass
* the RTP buffers */
GstFlowReturn (*handle_buffer) (GstBaseRTPPayload *payload,
GstBuffer *buffer);
gboolean (*handle_event) (GstPad * pad, GstEvent * event);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
gpointer _gst_reserved[GST_PADDING-1];
};
GType gst_basertppayload_get_type (void);