2006-04-13 03:55:12 +00:00
|
|
|
/* GStreamer
|
2007-03-14 21:11:18 +00:00
|
|
|
* Copyright (C) <2006> Philippe Khalaf <philippe.kalaf@collabora.co.uk>
|
2006-04-13 03:55:12 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2006-09-29 23:50:53 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstbasertpaudiopayload
|
|
|
|
* @short_description: Base class for audio RTP payloader
|
|
|
|
*
|
|
|
|
* <refsect2>
|
|
|
|
* <para>
|
|
|
|
* Provides a base class for audio RTP payloaders for frame or sample based
|
|
|
|
* audio codecs (constant bitrate)
|
|
|
|
* </para>
|
|
|
|
* <para>
|
|
|
|
* This class derives from GstBaseRTPPayload. It can be used for payloading
|
|
|
|
* audio codecs. It will only work with constant bitrate codecs. It supports
|
|
|
|
* both frame based and sample based codecs. It takes care of packing up the
|
|
|
|
* audio data into RTP packets and filling up the headers accordingly. The
|
|
|
|
* payloading is done based on the maximum MTU (mtu) and the maximum time per
|
|
|
|
* packet (max-ptime). The general idea is to divide large data buffers into
|
|
|
|
* smaller RTP packets. The RTP packet size is the minimum of either the MTU,
|
2007-03-14 21:11:18 +00:00
|
|
|
* max-ptime (if set) or available data. The RTP packet size is always larger or
|
|
|
|
* equal to min-ptime (if set). If min-ptime is not set, any residual data is
|
|
|
|
* sent in a last RTP packet. In the case of frame based codecs, the resulting
|
|
|
|
* RTP packets always contain full frames.
|
2006-09-29 23:50:53 +00:00
|
|
|
* </para>
|
|
|
|
* <title>Usage</title>
|
|
|
|
* <para>
|
|
|
|
* To use this base class, your child element needs to call either
|
2007-05-04 13:10:07 +00:00
|
|
|
* gst_base_rtp_audio_payload_set_frame_based() or
|
|
|
|
* gst_base_rtp_audio_payload_set_sample_based(). This is usually done in the
|
2006-09-29 23:50:53 +00:00
|
|
|
* element's _init() function. Then, the child element must call either
|
2007-05-04 13:10:07 +00:00
|
|
|
* gst_base_rtp_audio_payload_set_frame_options() or
|
|
|
|
* gst_base_rtp_audio_payload_set_sample_options(). Since GstBaseRTPAudioPayload
|
2006-09-29 23:50:53 +00:00
|
|
|
* derives from GstBaseRTPPayload, the child element must set any variables or
|
|
|
|
* call/override any functions required by that base class. The child element
|
|
|
|
* does not need to override any other functions specific to
|
|
|
|
* GstBaseRTPAudioPayload.
|
|
|
|
* </para>
|
|
|
|
* </refsect2>
|
|
|
|
*/
|
|
|
|
|
2006-04-13 03:55:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <gst/rtp/gstrtpbuffer.h>
|
2007-03-14 21:11:18 +00:00
|
|
|
#include <gst/base/gstadapter.h>
|
2006-04-13 03:55:12 +00:00
|
|
|
|
|
|
|
#include "gstbasertpaudiopayload.h"
|
|
|
|
|
2006-06-23 09:53:09 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (basertpaudiopayload_debug);
|
2006-04-13 03:55:12 +00:00
|
|
|
#define GST_CAT_DEFAULT (basertpaudiopayload_debug)
|
|
|
|
|
2006-09-27 00:13:29 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
AUDIO_CODEC_TYPE_NONE,
|
|
|
|
AUDIO_CODEC_TYPE_FRAME_BASED,
|
|
|
|
AUDIO_CODEC_TYPE_SAMPLE_BASED
|
|
|
|
} AudioCodecType;
|
|
|
|
|
|
|
|
struct _GstBaseRTPAudioPayloadPrivate
|
|
|
|
{
|
|
|
|
AudioCodecType type;
|
2007-03-14 21:11:18 +00:00
|
|
|
GstAdapter *adapter;
|
|
|
|
guint64 min_ptime;
|
2006-09-27 00:13:29 +00:00
|
|
|
};
|
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
|
2006-09-27 00:13:29 +00:00
|
|
|
#define GST_BASE_RTP_AUDIO_PAYLOAD_GET_PRIVATE(o) \
|
2006-10-31 10:49:19 +00:00
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GST_TYPE_BASE_RTP_AUDIO_PAYLOAD, \
|
2006-09-27 00:13:29 +00:00
|
|
|
GstBaseRTPAudioPayloadPrivate))
|
|
|
|
|
|
|
|
static void gst_base_rtp_audio_payload_finalize (GObject * object);
|
2006-04-13 03:55:12 +00:00
|
|
|
|
2006-09-27 00:13:29 +00:00
|
|
|
static GstFlowReturn gst_base_rtp_audio_payload_handle_buffer (GstBaseRTPPayload
|
|
|
|
* payload, GstBuffer * buffer);
|
2006-04-13 03:55:12 +00:00
|
|
|
|
|
|
|
static GstFlowReturn
|
2006-09-27 00:13:29 +00:00
|
|
|
gst_base_rtp_audio_payload_handle_frame_based_buffer (GstBaseRTPPayload *
|
2006-04-13 03:55:12 +00:00
|
|
|
basepayload, GstBuffer * buffer);
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2006-09-27 00:13:29 +00:00
|
|
|
gst_base_rtp_audio_payload_handle_sample_based_buffer (GstBaseRTPPayload *
|
2006-04-13 03:55:12 +00:00
|
|
|
basepayload, GstBuffer * buffer);
|
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_base_rtp_payload_audio_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
|
|
|
static gboolean
|
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.
2007-05-21 09:45:28 +00:00
|
|
|
gst_base_rtp_payload_audio_handle_event (GstPad * pad, GstEvent * event);
|
2007-03-14 21:11:18 +00:00
|
|
|
|
2006-09-27 00:13:29 +00:00
|
|
|
GST_BOILERPLATE (GstBaseRTPAudioPayload, gst_base_rtp_audio_payload,
|
2006-04-13 03:55:12 +00:00
|
|
|
GstBaseRTPPayload, GST_TYPE_BASE_RTP_PAYLOAD);
|
|
|
|
|
|
|
|
static void
|
2006-09-27 00:13:29 +00:00
|
|
|
gst_base_rtp_audio_payload_base_init (gpointer klass)
|
2006-04-13 03:55:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-09-27 00:13:29 +00:00
|
|
|
gst_base_rtp_audio_payload_class_init (GstBaseRTPAudioPayloadClass * klass)
|
2006-04-13 03:55:12 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
GstBaseRTPPayloadClass *gstbasertppayload_class;
|
|
|
|
|
2006-09-27 00:13:29 +00:00
|
|
|
g_type_class_add_private (klass, sizeof (GstBaseRTPAudioPayloadPrivate));
|
|
|
|
|
2006-04-13 03:55:12 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
|
|
|
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
|
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.
2007-05-21 09:45:28 +00:00
|
|
|
|
2006-05-08 15:51:15 +00:00
|
|
|
gobject_class->finalize =
|
2006-09-27 00:13:29 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_base_rtp_audio_payload_finalize);
|
2006-04-13 03:55:12 +00:00
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
gstelement_class->change_state =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_base_rtp_payload_audio_change_state);
|
|
|
|
|
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.
2007-05-21 09:45:28 +00:00
|
|
|
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);
|
2007-03-14 21:11:18 +00:00
|
|
|
|
2006-04-13 03:55:12 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (basertpaudiopayload_debug, "basertpaudiopayload", 0,
|
|
|
|
"base audio RTP payloader");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-09-27 00:13:29 +00:00
|
|
|
gst_base_rtp_audio_payload_init (GstBaseRTPAudioPayload * basertpaudiopayload,
|
2006-04-13 03:55:12 +00:00
|
|
|
GstBaseRTPAudioPayloadClass * klass)
|
|
|
|
{
|
2006-10-31 10:49:19 +00:00
|
|
|
basertpaudiopayload->priv =
|
|
|
|
GST_BASE_RTP_AUDIO_PAYLOAD_GET_PRIVATE (basertpaudiopayload);
|
2006-09-27 00:13:29 +00:00
|
|
|
|
2006-05-18 23:00:02 +00:00
|
|
|
basertpaudiopayload->base_ts = 0;
|
2006-04-13 03:55:12 +00:00
|
|
|
|
2006-09-27 00:13:29 +00:00
|
|
|
basertpaudiopayload->priv->type = AUDIO_CODEC_TYPE_NONE;
|
2006-04-13 03:55:12 +00:00
|
|
|
|
|
|
|
/* these need to be set by child object if frame based */
|
|
|
|
basertpaudiopayload->frame_size = 0;
|
|
|
|
basertpaudiopayload->frame_duration = 0;
|
|
|
|
|
|
|
|
/* these need to be set by child object if sample based */
|
|
|
|
basertpaudiopayload->sample_size = 0;
|
2007-03-14 21:11:18 +00:00
|
|
|
|
|
|
|
basertpaudiopayload->priv->adapter = gst_adapter_new ();
|
|
|
|
}
|
|
|
|
|
2006-04-13 03:55:12 +00:00
|
|
|
static void
|
2006-09-27 00:13:29 +00:00
|
|
|
gst_base_rtp_audio_payload_finalize (GObject * object)
|
2006-04-13 03:55:12 +00:00
|
|
|
{
|
|
|
|
GstBaseRTPAudioPayload *basertpaudiopayload;
|
|
|
|
|
|
|
|
basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (object);
|
|
|
|
|
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.
2007-05-21 09:45:28 +00:00
|
|
|
g_object_unref (basertpaudiopayload->priv->adapter);
|
|
|
|
|
2006-04-13 03:55:12 +00:00
|
|
|
GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
|
|
|
|
}
|
|
|
|
|
2006-05-18 23:00:02 +00:00
|
|
|
/**
|
2006-09-27 00:13:29 +00:00
|
|
|
* gst_base_rtp_audio_payload_set_frame_based:
|
2006-05-18 23:00:02 +00:00
|
|
|
* @basertpaudiopayload: a pointer to the element.
|
|
|
|
*
|
|
|
|
* Tells #GstBaseRTPAudioPayload that the child element is for a frame based
|
|
|
|
* audio codec
|
|
|
|
*
|
|
|
|
*/
|
2006-04-13 03:55:12 +00:00
|
|
|
void
|
2006-09-27 00:13:29 +00:00
|
|
|
gst_base_rtp_audio_payload_set_frame_based (GstBaseRTPAudioPayload *
|
2006-04-13 03:55:12 +00:00
|
|
|
basertpaudiopayload)
|
|
|
|
{
|
|
|
|
g_return_if_fail (basertpaudiopayload != NULL);
|
|
|
|
|
2006-09-27 00:13:29 +00:00
|
|
|
g_return_if_fail (basertpaudiopayload->priv->type == AUDIO_CODEC_TYPE_NONE);
|
2006-05-19 17:57:56 +00:00
|
|
|
|
2006-09-27 00:13:29 +00:00
|
|
|
basertpaudiopayload->priv->type = AUDIO_CODEC_TYPE_FRAME_BASED;
|
2006-04-13 03:55:12 +00:00
|
|
|
}
|
|
|
|
|
2006-05-18 23:00:02 +00:00
|
|
|
/**
|
2006-09-27 00:13:29 +00:00
|
|
|
* gst_base_rtp_audio_payload_set_sample_based:
|
2006-05-18 23:00:02 +00:00
|
|
|
* @basertpaudiopayload: a pointer to the element.
|
|
|
|
*
|
|
|
|
* Tells #GstBaseRTPAudioPayload that the child element is for a sample based
|
|
|
|
* audio codec
|
|
|
|
*
|
|
|
|
*/
|
2006-04-13 03:55:12 +00:00
|
|
|
void
|
2006-09-27 00:13:29 +00:00
|
|
|
gst_base_rtp_audio_payload_set_sample_based (GstBaseRTPAudioPayload *
|
2006-04-13 03:55:12 +00:00
|
|
|
basertpaudiopayload)
|
|
|
|
{
|
|
|
|
g_return_if_fail (basertpaudiopayload != NULL);
|
|
|
|
|
2006-09-27 00:13:29 +00:00
|
|
|
g_return_if_fail (basertpaudiopayload->priv->type == AUDIO_CODEC_TYPE_NONE);
|
2006-05-19 17:57:56 +00:00
|
|
|
|
2006-09-27 00:13:29 +00:00
|
|
|
basertpaudiopayload->priv->type = AUDIO_CODEC_TYPE_SAMPLE_BASED;
|
2006-04-13 03:55:12 +00:00
|
|
|
}
|
|
|
|
|
2006-05-18 23:00:02 +00:00
|
|
|
/**
|
2006-09-27 00:13:29 +00:00
|
|
|
* gst_base_rtp_audio_payload_set_frame_options:
|
2006-05-18 23:00:02 +00:00
|
|
|
* @basertpaudiopayload: a pointer to the element.
|
2007-03-14 21:11:18 +00:00
|
|
|
* @frame_duration: The duraction of an audio frame in milliseconds.
|
2006-05-18 23:00:02 +00:00
|
|
|
* @frame_size: The size of an audio frame in bytes.
|
|
|
|
*
|
|
|
|
* Sets the options for frame based audio codecs.
|
|
|
|
*
|
|
|
|
*/
|
2006-04-13 03:55:12 +00:00
|
|
|
void
|
2006-09-27 00:13:29 +00:00
|
|
|
gst_base_rtp_audio_payload_set_frame_options (GstBaseRTPAudioPayload
|
2006-04-13 03:55:12 +00:00
|
|
|
* basertpaudiopayload, gint frame_duration, gint frame_size)
|
|
|
|
{
|
|
|
|
g_return_if_fail (basertpaudiopayload != NULL);
|
|
|
|
|
|
|
|
basertpaudiopayload->frame_size = frame_size;
|
|
|
|
basertpaudiopayload->frame_duration = frame_duration;
|
2007-03-14 21:11:18 +00:00
|
|
|
|
|
|
|
if (basertpaudiopayload->priv->adapter) {
|
|
|
|
gst_adapter_clear (basertpaudiopayload->priv->adapter);
|
|
|
|
}
|
2006-04-13 03:55:12 +00:00
|
|
|
}
|
|
|
|
|
2006-05-18 23:00:02 +00:00
|
|
|
/**
|
2006-09-27 00:13:29 +00:00
|
|
|
* gst_base_rtp_audio_payload_set_sample_options:
|
2006-05-18 23:00:02 +00:00
|
|
|
* @basertpaudiopayload: a pointer to the element.
|
|
|
|
* @sample_size: Size per sample in bytes.
|
|
|
|
*
|
|
|
|
* Sets the options for sample based audio codecs.
|
|
|
|
*
|
|
|
|
*/
|
2006-04-13 03:55:12 +00:00
|
|
|
void
|
2006-09-27 00:13:29 +00:00
|
|
|
gst_base_rtp_audio_payload_set_sample_options (GstBaseRTPAudioPayload
|
2006-04-13 03:55:12 +00:00
|
|
|
* basertpaudiopayload, gint sample_size)
|
|
|
|
{
|
|
|
|
g_return_if_fail (basertpaudiopayload != NULL);
|
|
|
|
|
|
|
|
basertpaudiopayload->sample_size = sample_size;
|
2007-03-14 21:11:18 +00:00
|
|
|
|
|
|
|
if (basertpaudiopayload->priv->adapter) {
|
|
|
|
gst_adapter_clear (basertpaudiopayload->priv->adapter);
|
|
|
|
}
|
2006-04-13 03:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2006-09-27 00:13:29 +00:00
|
|
|
gst_base_rtp_audio_payload_handle_buffer (GstBaseRTPPayload * basepayload,
|
2006-04-13 03:55:12 +00:00
|
|
|
GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
GstFlowReturn ret;
|
|
|
|
GstBaseRTPAudioPayload *basertpaudiopayload;
|
|
|
|
|
|
|
|
basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (basepayload);
|
|
|
|
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
|
2006-09-27 00:13:29 +00:00
|
|
|
if (basertpaudiopayload->priv->type == AUDIO_CODEC_TYPE_FRAME_BASED) {
|
|
|
|
ret = gst_base_rtp_audio_payload_handle_frame_based_buffer (basepayload,
|
2006-04-13 03:55:12 +00:00
|
|
|
buffer);
|
2006-09-27 00:13:29 +00:00
|
|
|
} else if (basertpaudiopayload->priv->type == AUDIO_CODEC_TYPE_SAMPLE_BASED) {
|
|
|
|
ret = gst_base_rtp_audio_payload_handle_sample_based_buffer (basepayload,
|
2006-04-13 03:55:12 +00:00
|
|
|
buffer);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (basertpaudiopayload, "Audio codec type not set");
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this assumes all frames have a constant duration and a constant size */
|
|
|
|
static GstFlowReturn
|
2006-09-27 00:13:29 +00:00
|
|
|
gst_base_rtp_audio_payload_handle_frame_based_buffer (GstBaseRTPPayload *
|
2006-04-13 03:55:12 +00:00
|
|
|
basepayload, GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
GstBaseRTPAudioPayload *basertpaudiopayload;
|
|
|
|
guint payload_len;
|
2007-03-14 21:11:18 +00:00
|
|
|
const guint8 *data = NULL;
|
2006-04-13 03:55:12 +00:00
|
|
|
GstFlowReturn ret;
|
|
|
|
guint available;
|
|
|
|
gint frame_size, frame_duration;
|
|
|
|
|
|
|
|
guint maxptime_octets = G_MAXUINT;
|
2007-03-14 21:11:18 +00:00
|
|
|
guint minptime_octets = 0;
|
|
|
|
guint min_payload_len;
|
|
|
|
guint max_payload_len;
|
|
|
|
gboolean use_adapter = FALSE;
|
2007-05-09 21:17:40 +00:00
|
|
|
guint minptime_ms;
|
2006-04-13 03:55:12 +00:00
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
ret = GST_FLOW_OK;
|
2006-04-13 03:55:12 +00:00
|
|
|
|
|
|
|
basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (basepayload);
|
|
|
|
|
|
|
|
if (basertpaudiopayload->frame_size == 0 ||
|
|
|
|
basertpaudiopayload->frame_duration == 0) {
|
|
|
|
GST_DEBUG_OBJECT (basertpaudiopayload, "Required options not set");
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
frame_size = basertpaudiopayload->frame_size;
|
|
|
|
frame_duration = basertpaudiopayload->frame_duration;
|
|
|
|
|
|
|
|
/* max number of bytes based on given ptime, has to be multiple of
|
|
|
|
* frame_duration */
|
|
|
|
if (basepayload->max_ptime != -1) {
|
|
|
|
guint ptime_ms = basepayload->max_ptime / 1000000;
|
|
|
|
|
|
|
|
maxptime_octets = frame_size * (int) (ptime_ms / frame_duration);
|
|
|
|
if (maxptime_octets == 0) {
|
2006-05-19 17:57:56 +00:00
|
|
|
GST_WARNING_OBJECT (basertpaudiopayload, "Given ptime %d is smaller than"
|
|
|
|
" minimum %d ms, overwriting to minimum", ptime_ms, frame_duration);
|
2006-04-13 03:55:12 +00:00
|
|
|
maxptime_octets = frame_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
max_payload_len = MIN (
|
|
|
|
/* MTU max */
|
|
|
|
(int) (gst_rtp_buffer_calc_payload_len (GST_BASE_RTP_PAYLOAD_MTU
|
|
|
|
(basertpaudiopayload), 0, 0) / frame_size) * frame_size,
|
|
|
|
/* ptime max */
|
|
|
|
maxptime_octets);
|
|
|
|
|
|
|
|
/* min number of bytes based on a given ptime, has to be a multiple
|
|
|
|
of frame duration */
|
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.
2007-05-21 09:45:28 +00:00
|
|
|
minptime_ms = basepayload->min_ptime / 1000000;
|
2007-03-14 21:11:18 +00:00
|
|
|
|
|
|
|
minptime_octets = frame_size * (int) (minptime_ms / frame_duration);
|
|
|
|
|
|
|
|
min_payload_len = MAX (minptime_octets, frame_size);
|
|
|
|
|
|
|
|
if (min_payload_len > max_payload_len) {
|
|
|
|
min_payload_len = max_payload_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (basertpaudiopayload,
|
|
|
|
"Calculated min_payload_len %u and max_payload_len %u",
|
|
|
|
min_payload_len, max_payload_len);
|
2006-04-13 03:55:12 +00:00
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
if (basertpaudiopayload->priv->adapter &&
|
|
|
|
gst_adapter_available (basertpaudiopayload->priv->adapter)) {
|
|
|
|
/* If there is always data in the adapter, we have to use it */
|
|
|
|
gst_adapter_push (basertpaudiopayload->priv->adapter, buffer);
|
|
|
|
available = gst_adapter_available (basertpaudiopayload->priv->adapter);
|
|
|
|
use_adapter = TRUE;
|
|
|
|
} else {
|
|
|
|
/* let's set the base timestamp */
|
|
|
|
basertpaudiopayload->base_ts = GST_BUFFER_TIMESTAMP (buffer);
|
|
|
|
|
|
|
|
/* If buffer fits on an RTP packet, let's just push it through */
|
|
|
|
/* this will check against max_ptime and max_mtu */
|
|
|
|
if (GST_BUFFER_SIZE (buffer) >= min_payload_len &&
|
|
|
|
GST_BUFFER_SIZE (buffer) <= max_payload_len) {
|
2007-04-21 14:40:45 +00:00
|
|
|
ret = gst_base_rtp_audio_payload_push (basertpaudiopayload,
|
2007-03-14 21:11:18 +00:00
|
|
|
GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer),
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer));
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
available = GST_BUFFER_SIZE (buffer);
|
|
|
|
data = (guint8 *) GST_BUFFER_DATA (buffer);
|
|
|
|
}
|
2006-04-13 03:55:12 +00:00
|
|
|
|
|
|
|
/* as long as we have full frames */
|
2007-03-14 21:11:18 +00:00
|
|
|
while (available >= min_payload_len) {
|
2006-12-09 15:12:38 +00:00
|
|
|
gfloat ts_inc;
|
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
/* We send as much as we can */
|
|
|
|
payload_len = MIN (max_payload_len, (available / frame_size) * frame_size);
|
|
|
|
|
|
|
|
if (use_adapter) {
|
|
|
|
data = gst_adapter_peek (basertpaudiopayload->priv->adapter, payload_len);
|
|
|
|
}
|
2006-04-13 03:55:12 +00:00
|
|
|
|
2007-04-21 14:40:45 +00:00
|
|
|
ret =
|
|
|
|
gst_base_rtp_audio_payload_push (basertpaudiopayload, data, payload_len,
|
2006-05-18 23:00:02 +00:00
|
|
|
basertpaudiopayload->base_ts);
|
2006-04-13 03:55:12 +00:00
|
|
|
|
2006-12-09 15:12:38 +00:00
|
|
|
ts_inc = (payload_len * frame_duration) / frame_size;
|
2006-04-13 03:55:12 +00:00
|
|
|
|
|
|
|
ts_inc = ts_inc * GST_MSECOND;
|
2007-02-10 19:27:48 +00:00
|
|
|
basertpaudiopayload->base_ts += gst_gdouble_to_guint64 (ts_inc);
|
2006-04-13 03:55:12 +00:00
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
if (use_adapter) {
|
|
|
|
gst_adapter_flush (basertpaudiopayload->priv->adapter, payload_len);
|
|
|
|
available = gst_adapter_available (basertpaudiopayload->priv->adapter);
|
|
|
|
} else {
|
|
|
|
available -= payload_len;
|
|
|
|
data += payload_len;
|
|
|
|
}
|
2006-04-13 03:55:12 +00:00
|
|
|
}
|
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
if (!use_adapter) {
|
|
|
|
if (available != 0 && basertpaudiopayload->priv->adapter) {
|
|
|
|
GstBuffer *buf;
|
2006-06-29 12:21:06 +00:00
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
buf = gst_buffer_create_sub (buffer,
|
|
|
|
GST_BUFFER_SIZE (buffer) - available, available);
|
|
|
|
gst_adapter_push (basertpaudiopayload->priv->adapter, buf);
|
|
|
|
} else {
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
}
|
2006-04-13 03:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2006-09-27 00:13:29 +00:00
|
|
|
gst_base_rtp_audio_payload_handle_sample_based_buffer (GstBaseRTPPayload *
|
2006-04-13 03:55:12 +00:00
|
|
|
basepayload, GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
GstBaseRTPAudioPayload *basertpaudiopayload;
|
|
|
|
guint payload_len;
|
2007-03-14 21:11:18 +00:00
|
|
|
const guint8 *data = NULL;
|
2006-04-13 03:55:12 +00:00
|
|
|
GstFlowReturn ret;
|
|
|
|
guint available;
|
|
|
|
|
|
|
|
guint maxptime_octets = G_MAXUINT;
|
2007-03-14 21:11:18 +00:00
|
|
|
guint minptime_octets = 0;
|
|
|
|
guint min_payload_len;
|
|
|
|
guint max_payload_len;
|
|
|
|
gboolean use_adapter = FALSE;
|
2006-04-13 03:55:12 +00:00
|
|
|
|
|
|
|
guint sample_size;
|
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
ret = GST_FLOW_OK;
|
2006-04-13 03:55:12 +00:00
|
|
|
|
|
|
|
basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (basepayload);
|
|
|
|
|
|
|
|
if (basertpaudiopayload->sample_size == 0) {
|
|
|
|
GST_DEBUG_OBJECT (basertpaudiopayload, "Required options not set");
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
sample_size = basertpaudiopayload->sample_size;
|
|
|
|
|
|
|
|
/* max number of bytes based on given ptime */
|
|
|
|
if (basepayload->max_ptime != -1) {
|
|
|
|
maxptime_octets = basepayload->max_ptime * basepayload->clock_rate /
|
|
|
|
(sample_size * GST_SECOND);
|
|
|
|
}
|
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
max_payload_len = MIN (
|
|
|
|
/* MTU max */
|
|
|
|
gst_rtp_buffer_calc_payload_len (GST_BASE_RTP_PAYLOAD_MTU
|
|
|
|
(basertpaudiopayload), 0, 0),
|
|
|
|
/* ptime max */
|
|
|
|
maxptime_octets);
|
2006-04-13 03:55:12 +00:00
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
/* min number of bytes based on a given ptime, has to be a multiple
|
|
|
|
of sample rate */
|
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.
2007-05-21 09:45:28 +00:00
|
|
|
minptime_octets = basepayload->min_ptime * basepayload->clock_rate /
|
|
|
|
(sample_size * GST_SECOND);
|
2006-04-13 03:55:12 +00:00
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
min_payload_len = MAX (minptime_octets, sample_size);
|
|
|
|
|
|
|
|
if (min_payload_len > max_payload_len) {
|
|
|
|
min_payload_len = max_payload_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (basertpaudiopayload,
|
|
|
|
"Calculated min_payload_len %u and max_payload_len %u",
|
|
|
|
min_payload_len, max_payload_len);
|
|
|
|
|
|
|
|
if (basertpaudiopayload->priv->adapter &&
|
|
|
|
gst_adapter_available (basertpaudiopayload->priv->adapter)) {
|
|
|
|
/* If there is always data in the adapter, we have to use it */
|
|
|
|
gst_adapter_push (basertpaudiopayload->priv->adapter, buffer);
|
|
|
|
available = gst_adapter_available (basertpaudiopayload->priv->adapter);
|
|
|
|
use_adapter = TRUE;
|
|
|
|
} else {
|
|
|
|
/* let's set the base timestamp */
|
|
|
|
basertpaudiopayload->base_ts = GST_BUFFER_TIMESTAMP (buffer);
|
|
|
|
|
|
|
|
/* If buffer fits on an RTP packet, let's just push it through */
|
|
|
|
/* this will check against max_ptime and max_mtu */
|
|
|
|
if (GST_BUFFER_SIZE (buffer) >= min_payload_len &&
|
|
|
|
GST_BUFFER_SIZE (buffer) <= max_payload_len) {
|
2007-04-21 14:40:45 +00:00
|
|
|
ret = gst_base_rtp_audio_payload_push (basertpaudiopayload,
|
2007-03-14 21:11:18 +00:00
|
|
|
GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer),
|
|
|
|
GST_BUFFER_TIMESTAMP (buffer));
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
available = GST_BUFFER_SIZE (buffer);
|
|
|
|
data = (guint8 *) GST_BUFFER_DATA (buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (available >= min_payload_len) {
|
2006-12-09 15:12:38 +00:00
|
|
|
gfloat num, datarate;
|
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
payload_len =
|
|
|
|
MIN (max_payload_len, (available / sample_size) * sample_size);
|
|
|
|
|
|
|
|
if (use_adapter) {
|
|
|
|
data = gst_adapter_peek (basertpaudiopayload->priv->adapter, payload_len);
|
|
|
|
}
|
2006-04-13 03:55:12 +00:00
|
|
|
|
2007-04-21 14:40:45 +00:00
|
|
|
ret =
|
|
|
|
gst_base_rtp_audio_payload_push (basertpaudiopayload, data, payload_len,
|
2006-05-18 23:00:02 +00:00
|
|
|
basertpaudiopayload->base_ts);
|
2006-04-13 03:55:12 +00:00
|
|
|
|
2006-12-09 15:12:38 +00:00
|
|
|
num = payload_len;
|
|
|
|
datarate = (sample_size * basepayload->clock_rate);
|
2006-04-13 03:55:12 +00:00
|
|
|
|
2006-05-18 23:00:02 +00:00
|
|
|
basertpaudiopayload->base_ts +=
|
2006-04-13 03:55:12 +00:00
|
|
|
/* payload_len (bytes) * nsecs/sec / datarate (bytes*sec) */
|
2007-02-10 19:27:48 +00:00
|
|
|
gst_gdouble_to_guint64 (num / datarate * GST_SECOND);
|
2006-04-13 03:55:12 +00:00
|
|
|
GST_DEBUG_OBJECT (basertpaudiopayload, "New ts is %" GST_TIME_FORMAT,
|
2006-05-18 23:00:02 +00:00
|
|
|
GST_TIME_ARGS (basertpaudiopayload->base_ts));
|
2006-04-13 03:55:12 +00:00
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
if (use_adapter) {
|
|
|
|
gst_adapter_flush (basertpaudiopayload->priv->adapter, payload_len);
|
|
|
|
available = gst_adapter_available (basertpaudiopayload->priv->adapter);
|
|
|
|
} else {
|
|
|
|
available -= payload_len;
|
|
|
|
data += payload_len;
|
|
|
|
}
|
2006-04-13 03:55:12 +00:00
|
|
|
}
|
|
|
|
|
2007-03-14 21:11:18 +00:00
|
|
|
if (!use_adapter) {
|
|
|
|
if (available != 0 && basertpaudiopayload->priv->adapter) {
|
|
|
|
GstBuffer *buf;
|
|
|
|
|
|
|
|
buf = gst_buffer_create_sub (buffer,
|
|
|
|
GST_BUFFER_SIZE (buffer) - available, available);
|
|
|
|
gst_adapter_push (basertpaudiopayload->priv->adapter, buf);
|
|
|
|
} else {
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
}
|
|
|
|
}
|
2006-06-29 12:21:06 +00:00
|
|
|
|
2006-04-13 03:55:12 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
Add RTCP docs.
Original commit message from CVS:
* docs/libs/gst-plugins-base-libs-docs.sgml:
* docs/libs/gst-plugins-base-libs-sections.txt:
* gst-libs/gst/rtp/gstbasertpaudiopayload.c:
(gst_base_rtp_audio_payload_get_adapter):
Add RTCP docs.
Fix some more docs.
* gst-libs/gst/rtp/Makefile.am:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_buffer_new_take_data), (gst_rtcp_buffer_new_copy_data),
(gst_rtcp_buffer_validate_data), (gst_rtcp_buffer_validate),
(gst_rtcp_buffer_get_packet_count), (read_packet_header),
(gst_rtcp_buffer_get_first_packet), (gst_rtcp_packet_move_to_next),
(gst_rtcp_buffer_add_packet), (gst_rtcp_packet_remove),
(gst_rtcp_packet_get_padding), (gst_rtcp_packet_get_type),
(gst_rtcp_packet_get_count), (gst_rtcp_packet_get_length),
(gst_rtcp_packet_sr_get_sender_info),
(gst_rtcp_packet_sr_set_sender_info),
(gst_rtcp_packet_rr_get_ssrc), (gst_rtcp_packet_rr_set_ssrc),
(gst_rtcp_packet_get_rb_count), (gst_rtcp_packet_get_rb),
(gst_rtcp_packet_add_rb), (gst_rtcp_packet_set_rb),
(gst_rtcp_packet_sdes_get_chunk_count),
(gst_rtcp_packet_sdes_first_chunk),
(gst_rtcp_packet_sdes_next_chunk), (gst_rtcp_packet_sdes_get_ssrc),
(gst_rtcp_packet_sdes_first_item),
(gst_rtcp_packet_sdes_next_item), (gst_rtcp_packet_sdes_get_item),
(gst_rtcp_packet_bye_get_ssrc_count),
(gst_rtcp_packet_bye_get_nth_ssrc), (gst_rtcp_packet_bye_add_ssrc),
(gst_rtcp_packet_bye_add_ssrcs), (get_reason_offset),
(gst_rtcp_packet_bye_get_reason_len),
(gst_rtcp_packet_bye_get_reason), (gst_rtcp_packet_bye_set_reason):
* gst-libs/gst/rtp/gstrtcpbuffer.h:
Add new helper object for parsing and creating RTCP messages.
2007-03-29 16:20:31 +00:00
|
|
|
/**
|
|
|
|
* gst_base_rtp_audio_payload_push:
|
2007-07-10 20:46:41 +00:00
|
|
|
* @baseaudiopayload: a #GstBaseRTPPayload
|
Add RTCP docs.
Original commit message from CVS:
* docs/libs/gst-plugins-base-libs-docs.sgml:
* docs/libs/gst-plugins-base-libs-sections.txt:
* gst-libs/gst/rtp/gstbasertpaudiopayload.c:
(gst_base_rtp_audio_payload_get_adapter):
Add RTCP docs.
Fix some more docs.
* gst-libs/gst/rtp/Makefile.am:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_buffer_new_take_data), (gst_rtcp_buffer_new_copy_data),
(gst_rtcp_buffer_validate_data), (gst_rtcp_buffer_validate),
(gst_rtcp_buffer_get_packet_count), (read_packet_header),
(gst_rtcp_buffer_get_first_packet), (gst_rtcp_packet_move_to_next),
(gst_rtcp_buffer_add_packet), (gst_rtcp_packet_remove),
(gst_rtcp_packet_get_padding), (gst_rtcp_packet_get_type),
(gst_rtcp_packet_get_count), (gst_rtcp_packet_get_length),
(gst_rtcp_packet_sr_get_sender_info),
(gst_rtcp_packet_sr_set_sender_info),
(gst_rtcp_packet_rr_get_ssrc), (gst_rtcp_packet_rr_set_ssrc),
(gst_rtcp_packet_get_rb_count), (gst_rtcp_packet_get_rb),
(gst_rtcp_packet_add_rb), (gst_rtcp_packet_set_rb),
(gst_rtcp_packet_sdes_get_chunk_count),
(gst_rtcp_packet_sdes_first_chunk),
(gst_rtcp_packet_sdes_next_chunk), (gst_rtcp_packet_sdes_get_ssrc),
(gst_rtcp_packet_sdes_first_item),
(gst_rtcp_packet_sdes_next_item), (gst_rtcp_packet_sdes_get_item),
(gst_rtcp_packet_bye_get_ssrc_count),
(gst_rtcp_packet_bye_get_nth_ssrc), (gst_rtcp_packet_bye_add_ssrc),
(gst_rtcp_packet_bye_add_ssrcs), (get_reason_offset),
(gst_rtcp_packet_bye_get_reason_len),
(gst_rtcp_packet_bye_get_reason), (gst_rtcp_packet_bye_set_reason):
* gst-libs/gst/rtp/gstrtcpbuffer.h:
Add new helper object for parsing and creating RTCP messages.
2007-03-29 16:20:31 +00:00
|
|
|
* @data: data to set as payload
|
|
|
|
* @payload_len: length of payload
|
|
|
|
* @timestamp: a #GstClockTime
|
|
|
|
*
|
|
|
|
* Create an RTP buffer and store @payload_len bytes of @data as the
|
|
|
|
* payload. Set the timestamp on the new buffer to @timestamp before pushing
|
|
|
|
* the buffer downstream.
|
|
|
|
*
|
|
|
|
* Returns: a #GstFlowReturn
|
2007-04-21 15:10:25 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.13
|
Add RTCP docs.
Original commit message from CVS:
* docs/libs/gst-plugins-base-libs-docs.sgml:
* docs/libs/gst-plugins-base-libs-sections.txt:
* gst-libs/gst/rtp/gstbasertpaudiopayload.c:
(gst_base_rtp_audio_payload_get_adapter):
Add RTCP docs.
Fix some more docs.
* gst-libs/gst/rtp/Makefile.am:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_buffer_new_take_data), (gst_rtcp_buffer_new_copy_data),
(gst_rtcp_buffer_validate_data), (gst_rtcp_buffer_validate),
(gst_rtcp_buffer_get_packet_count), (read_packet_header),
(gst_rtcp_buffer_get_first_packet), (gst_rtcp_packet_move_to_next),
(gst_rtcp_buffer_add_packet), (gst_rtcp_packet_remove),
(gst_rtcp_packet_get_padding), (gst_rtcp_packet_get_type),
(gst_rtcp_packet_get_count), (gst_rtcp_packet_get_length),
(gst_rtcp_packet_sr_get_sender_info),
(gst_rtcp_packet_sr_set_sender_info),
(gst_rtcp_packet_rr_get_ssrc), (gst_rtcp_packet_rr_set_ssrc),
(gst_rtcp_packet_get_rb_count), (gst_rtcp_packet_get_rb),
(gst_rtcp_packet_add_rb), (gst_rtcp_packet_set_rb),
(gst_rtcp_packet_sdes_get_chunk_count),
(gst_rtcp_packet_sdes_first_chunk),
(gst_rtcp_packet_sdes_next_chunk), (gst_rtcp_packet_sdes_get_ssrc),
(gst_rtcp_packet_sdes_first_item),
(gst_rtcp_packet_sdes_next_item), (gst_rtcp_packet_sdes_get_item),
(gst_rtcp_packet_bye_get_ssrc_count),
(gst_rtcp_packet_bye_get_nth_ssrc), (gst_rtcp_packet_bye_add_ssrc),
(gst_rtcp_packet_bye_add_ssrcs), (get_reason_offset),
(gst_rtcp_packet_bye_get_reason_len),
(gst_rtcp_packet_bye_get_reason), (gst_rtcp_packet_bye_set_reason):
* gst-libs/gst/rtp/gstrtcpbuffer.h:
Add new helper object for parsing and creating RTCP messages.
2007-03-29 16:20:31 +00:00
|
|
|
*/
|
2007-03-14 21:11:18 +00:00
|
|
|
GstFlowReturn
|
2007-04-21 14:40:45 +00:00
|
|
|
gst_base_rtp_audio_payload_push (GstBaseRTPAudioPayload * baseaudiopayload,
|
2007-03-14 21:11:18 +00:00
|
|
|
const guint8 * data, guint payload_len, GstClockTime timestamp)
|
2006-04-13 03:55:12 +00:00
|
|
|
{
|
2007-04-21 14:40:45 +00:00
|
|
|
GstBaseRTPPayload *basepayload;
|
2006-04-13 03:55:12 +00:00
|
|
|
GstBuffer *outbuf;
|
|
|
|
guint8 *payload;
|
|
|
|
GstFlowReturn ret;
|
|
|
|
|
2007-04-21 14:40:45 +00:00
|
|
|
basepayload = GST_BASE_RTP_PAYLOAD (baseaudiopayload);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (baseaudiopayload, "Pushing %d bytes ts %" GST_TIME_FORMAT,
|
2006-05-18 23:00:02 +00:00
|
|
|
payload_len, GST_TIME_ARGS (timestamp));
|
|
|
|
|
2006-04-13 03:55:12 +00:00
|
|
|
/* create buffer to hold the payload */
|
|
|
|
outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
|
|
|
|
|
|
|
|
/* copy payload */
|
|
|
|
gst_rtp_buffer_set_payload_type (outbuf, basepayload->pt);
|
|
|
|
payload = gst_rtp_buffer_get_payload (outbuf);
|
|
|
|
memcpy (payload, data, payload_len);
|
|
|
|
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
|
|
|
ret = gst_basertppayload_push (basepayload, outbuf);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2007-03-14 21:11:18 +00:00
|
|
|
|
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_base_rtp_payload_audio_change_state (GstElement * element,
|
|
|
|
GstStateChange transition)
|
|
|
|
{
|
|
|
|
GstBaseRTPAudioPayload *basertppayload;
|
|
|
|
GstStateChangeReturn ret;
|
|
|
|
|
|
|
|
basertppayload = GST_BASE_RTP_AUDIO_PAYLOAD (element);
|
|
|
|
|
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
|
|
if (basertppayload->priv->adapter) {
|
|
|
|
gst_adapter_clear (basertppayload->priv->adapter);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
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.
2007-05-21 09:45:28 +00:00
|
|
|
gst_base_rtp_payload_audio_handle_event (GstPad * pad, GstEvent * event)
|
2007-03-14 21:11:18 +00:00
|
|
|
{
|
|
|
|
GstBaseRTPAudioPayload *basertpaudiopayload;
|
2007-09-04 16:18:48 +00:00
|
|
|
gboolean res = FALSE;
|
2007-03-14 21:11:18 +00:00
|
|
|
|
|
|
|
basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (gst_pad_get_parent (pad));
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_EOS:
|
|
|
|
if (basertpaudiopayload->priv->adapter) {
|
|
|
|
gst_adapter_clear (basertpaudiopayload->priv->adapter);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_EVENT_FLUSH_STOP:
|
|
|
|
if (basertpaudiopayload->priv->adapter) {
|
|
|
|
gst_adapter_clear (basertpaudiopayload->priv->adapter);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_object_unref (basertpaudiopayload);
|
|
|
|
|
2007-09-04 16:18:48 +00:00
|
|
|
/* return FALSE to let parent handle the remainder of the event */
|
2007-03-14 21:11:18 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
Add RTCP docs.
Original commit message from CVS:
* docs/libs/gst-plugins-base-libs-docs.sgml:
* docs/libs/gst-plugins-base-libs-sections.txt:
* gst-libs/gst/rtp/gstbasertpaudiopayload.c:
(gst_base_rtp_audio_payload_get_adapter):
Add RTCP docs.
Fix some more docs.
* gst-libs/gst/rtp/Makefile.am:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_buffer_new_take_data), (gst_rtcp_buffer_new_copy_data),
(gst_rtcp_buffer_validate_data), (gst_rtcp_buffer_validate),
(gst_rtcp_buffer_get_packet_count), (read_packet_header),
(gst_rtcp_buffer_get_first_packet), (gst_rtcp_packet_move_to_next),
(gst_rtcp_buffer_add_packet), (gst_rtcp_packet_remove),
(gst_rtcp_packet_get_padding), (gst_rtcp_packet_get_type),
(gst_rtcp_packet_get_count), (gst_rtcp_packet_get_length),
(gst_rtcp_packet_sr_get_sender_info),
(gst_rtcp_packet_sr_set_sender_info),
(gst_rtcp_packet_rr_get_ssrc), (gst_rtcp_packet_rr_set_ssrc),
(gst_rtcp_packet_get_rb_count), (gst_rtcp_packet_get_rb),
(gst_rtcp_packet_add_rb), (gst_rtcp_packet_set_rb),
(gst_rtcp_packet_sdes_get_chunk_count),
(gst_rtcp_packet_sdes_first_chunk),
(gst_rtcp_packet_sdes_next_chunk), (gst_rtcp_packet_sdes_get_ssrc),
(gst_rtcp_packet_sdes_first_item),
(gst_rtcp_packet_sdes_next_item), (gst_rtcp_packet_sdes_get_item),
(gst_rtcp_packet_bye_get_ssrc_count),
(gst_rtcp_packet_bye_get_nth_ssrc), (gst_rtcp_packet_bye_add_ssrc),
(gst_rtcp_packet_bye_add_ssrcs), (get_reason_offset),
(gst_rtcp_packet_bye_get_reason_len),
(gst_rtcp_packet_bye_get_reason), (gst_rtcp_packet_bye_set_reason):
* gst-libs/gst/rtp/gstrtcpbuffer.h:
Add new helper object for parsing and creating RTCP messages.
2007-03-29 16:20:31 +00:00
|
|
|
/**
|
|
|
|
* gst_base_rtp_audio_payload_get_adapter:
|
|
|
|
* @basertpaudiopayload: a #GstBaseRTPAudioPayload
|
|
|
|
*
|
|
|
|
* Gets the internal adapter used by the depayloader.
|
|
|
|
*
|
|
|
|
* Returns: a #GstAdapter.
|
2007-04-21 15:10:25 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.13
|
Add RTCP docs.
Original commit message from CVS:
* docs/libs/gst-plugins-base-libs-docs.sgml:
* docs/libs/gst-plugins-base-libs-sections.txt:
* gst-libs/gst/rtp/gstbasertpaudiopayload.c:
(gst_base_rtp_audio_payload_get_adapter):
Add RTCP docs.
Fix some more docs.
* gst-libs/gst/rtp/Makefile.am:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_buffer_new_take_data), (gst_rtcp_buffer_new_copy_data),
(gst_rtcp_buffer_validate_data), (gst_rtcp_buffer_validate),
(gst_rtcp_buffer_get_packet_count), (read_packet_header),
(gst_rtcp_buffer_get_first_packet), (gst_rtcp_packet_move_to_next),
(gst_rtcp_buffer_add_packet), (gst_rtcp_packet_remove),
(gst_rtcp_packet_get_padding), (gst_rtcp_packet_get_type),
(gst_rtcp_packet_get_count), (gst_rtcp_packet_get_length),
(gst_rtcp_packet_sr_get_sender_info),
(gst_rtcp_packet_sr_set_sender_info),
(gst_rtcp_packet_rr_get_ssrc), (gst_rtcp_packet_rr_set_ssrc),
(gst_rtcp_packet_get_rb_count), (gst_rtcp_packet_get_rb),
(gst_rtcp_packet_add_rb), (gst_rtcp_packet_set_rb),
(gst_rtcp_packet_sdes_get_chunk_count),
(gst_rtcp_packet_sdes_first_chunk),
(gst_rtcp_packet_sdes_next_chunk), (gst_rtcp_packet_sdes_get_ssrc),
(gst_rtcp_packet_sdes_first_item),
(gst_rtcp_packet_sdes_next_item), (gst_rtcp_packet_sdes_get_item),
(gst_rtcp_packet_bye_get_ssrc_count),
(gst_rtcp_packet_bye_get_nth_ssrc), (gst_rtcp_packet_bye_add_ssrc),
(gst_rtcp_packet_bye_add_ssrcs), (get_reason_offset),
(gst_rtcp_packet_bye_get_reason_len),
(gst_rtcp_packet_bye_get_reason), (gst_rtcp_packet_bye_set_reason):
* gst-libs/gst/rtp/gstrtcpbuffer.h:
Add new helper object for parsing and creating RTCP messages.
2007-03-29 16:20:31 +00:00
|
|
|
*/
|
2007-03-14 21:11:18 +00:00
|
|
|
GstAdapter *
|
|
|
|
gst_base_rtp_audio_payload_get_adapter (GstBaseRTPAudioPayload
|
|
|
|
* basertpaudiopayload)
|
|
|
|
{
|
Add RTCP docs.
Original commit message from CVS:
* docs/libs/gst-plugins-base-libs-docs.sgml:
* docs/libs/gst-plugins-base-libs-sections.txt:
* gst-libs/gst/rtp/gstbasertpaudiopayload.c:
(gst_base_rtp_audio_payload_get_adapter):
Add RTCP docs.
Fix some more docs.
* gst-libs/gst/rtp/Makefile.am:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_buffer_new_take_data), (gst_rtcp_buffer_new_copy_data),
(gst_rtcp_buffer_validate_data), (gst_rtcp_buffer_validate),
(gst_rtcp_buffer_get_packet_count), (read_packet_header),
(gst_rtcp_buffer_get_first_packet), (gst_rtcp_packet_move_to_next),
(gst_rtcp_buffer_add_packet), (gst_rtcp_packet_remove),
(gst_rtcp_packet_get_padding), (gst_rtcp_packet_get_type),
(gst_rtcp_packet_get_count), (gst_rtcp_packet_get_length),
(gst_rtcp_packet_sr_get_sender_info),
(gst_rtcp_packet_sr_set_sender_info),
(gst_rtcp_packet_rr_get_ssrc), (gst_rtcp_packet_rr_set_ssrc),
(gst_rtcp_packet_get_rb_count), (gst_rtcp_packet_get_rb),
(gst_rtcp_packet_add_rb), (gst_rtcp_packet_set_rb),
(gst_rtcp_packet_sdes_get_chunk_count),
(gst_rtcp_packet_sdes_first_chunk),
(gst_rtcp_packet_sdes_next_chunk), (gst_rtcp_packet_sdes_get_ssrc),
(gst_rtcp_packet_sdes_first_item),
(gst_rtcp_packet_sdes_next_item), (gst_rtcp_packet_sdes_get_item),
(gst_rtcp_packet_bye_get_ssrc_count),
(gst_rtcp_packet_bye_get_nth_ssrc), (gst_rtcp_packet_bye_add_ssrc),
(gst_rtcp_packet_bye_add_ssrcs), (get_reason_offset),
(gst_rtcp_packet_bye_get_reason_len),
(gst_rtcp_packet_bye_get_reason), (gst_rtcp_packet_bye_set_reason):
* gst-libs/gst/rtp/gstrtcpbuffer.h:
Add new helper object for parsing and creating RTCP messages.
2007-03-29 16:20:31 +00:00
|
|
|
GstAdapter *adapter;
|
|
|
|
|
|
|
|
if ((adapter = basertpaudiopayload->priv->adapter))
|
|
|
|
g_object_ref (adapter);
|
2007-03-14 21:11:18 +00:00
|
|
|
|
Add RTCP docs.
Original commit message from CVS:
* docs/libs/gst-plugins-base-libs-docs.sgml:
* docs/libs/gst-plugins-base-libs-sections.txt:
* gst-libs/gst/rtp/gstbasertpaudiopayload.c:
(gst_base_rtp_audio_payload_get_adapter):
Add RTCP docs.
Fix some more docs.
* gst-libs/gst/rtp/Makefile.am:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_buffer_new_take_data), (gst_rtcp_buffer_new_copy_data),
(gst_rtcp_buffer_validate_data), (gst_rtcp_buffer_validate),
(gst_rtcp_buffer_get_packet_count), (read_packet_header),
(gst_rtcp_buffer_get_first_packet), (gst_rtcp_packet_move_to_next),
(gst_rtcp_buffer_add_packet), (gst_rtcp_packet_remove),
(gst_rtcp_packet_get_padding), (gst_rtcp_packet_get_type),
(gst_rtcp_packet_get_count), (gst_rtcp_packet_get_length),
(gst_rtcp_packet_sr_get_sender_info),
(gst_rtcp_packet_sr_set_sender_info),
(gst_rtcp_packet_rr_get_ssrc), (gst_rtcp_packet_rr_set_ssrc),
(gst_rtcp_packet_get_rb_count), (gst_rtcp_packet_get_rb),
(gst_rtcp_packet_add_rb), (gst_rtcp_packet_set_rb),
(gst_rtcp_packet_sdes_get_chunk_count),
(gst_rtcp_packet_sdes_first_chunk),
(gst_rtcp_packet_sdes_next_chunk), (gst_rtcp_packet_sdes_get_ssrc),
(gst_rtcp_packet_sdes_first_item),
(gst_rtcp_packet_sdes_next_item), (gst_rtcp_packet_sdes_get_item),
(gst_rtcp_packet_bye_get_ssrc_count),
(gst_rtcp_packet_bye_get_nth_ssrc), (gst_rtcp_packet_bye_add_ssrc),
(gst_rtcp_packet_bye_add_ssrcs), (get_reason_offset),
(gst_rtcp_packet_bye_get_reason_len),
(gst_rtcp_packet_bye_get_reason), (gst_rtcp_packet_bye_set_reason):
* gst-libs/gst/rtp/gstrtcpbuffer.h:
Add new helper object for parsing and creating RTCP messages.
2007-03-29 16:20:31 +00:00
|
|
|
return adapter;
|
2007-03-14 21:11:18 +00:00
|
|
|
}
|