[gst-devel] Re: [gst-cvs] burger gst-plugins-base: gst-plugins-base/ gst-plugins-base/gst-libs/gst/rtp/

Thomas Vander Stichele thomas at apestaart.org
Thu Apr 13 02:02:03 CEST 2006


Hi,


> Log message:
> 2006-04-12 Philippe Kalaf <philippe.kalaf at collabora.co.uk>
> 	* gst-libs/gst/rtp/gstrtpbuffer.h:
> 	Added GST_RTP_PAYLOAD_DYNAMIC_STRING for use by children
> 	* gst-libs/gst/rtp/gstbasertpaudiopayload.c:
> 	* gst-libs/gst/rtp/gstbasertpaudiopayload.h:
> 	New RTP audio base payloader class. Supports frame or sample based codecs

Woah, I don't know what to say.  No wait, I do.

- the releases are announced on the mailing list, and then again when
there is an actual freeze in effect.  It's also announced on IRC.  You
broke this freeze, again.  Let me know if there is something you think
we should do to make this more clear, but you really should make sure
you can commit.
- you are adding API, a complete new base class - without converting any
of the other already existing elements that should descend from this
base class.  You really should consider at least announcing your plans
to -devel
- your other patch in -good adds elements *without* any review at all.

This is a bit exceptional.  I hope you understand that I'm forced to
revert your patch to -base because it broke the freeze, and because of
that revert your patch to -good because it will quite obviously break.

Please discuss your plans for a less obstructive merge of your code on
the -devel list.  I'm sure your code is good, but the way it's being
merged isn't :) I hope you take no offense at my removing it.

Thanks,
Thomas

 they 
> Modified files:
>     .               : ChangeLog
>     gst-libs/gst/rtp: Makefile.am gstrtpbuffer.h
> Added files:
>     gst-libs/gst/rtp: gstbasertpaudiopayload.c
>                       gstbasertpaudiopayload.h
> 
> Links:
> http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/ChangeLog.diff?r1=1.2555&r2=1.2556
> http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/rtp/Makefile.am.diff?r1=1.5&r2=1.6
> http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/rtp/gstbasertpaudiopayload.c?rev=1.1&content-type=text/vnd.viewcvs-markup
> http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/rtp/gstbasertpaudiopayload.h?rev=1.1&content-type=text/vnd.viewcvs-markup
> http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/rtp/gstrtpbuffer.h.diff?r1=1.8&r2=1.9
> 
> ====Begin Diffs====
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/gstreamer/gst-plugins-base/ChangeLog,v
> retrieving revision 1.2555
> retrieving revision 1.2556
> diff -u -d -r1.2555 -r1.2556
> --- ChangeLog	12 Apr 2006 11:04:53 -0000	1.2555
> +++ ChangeLog	13 Apr 2006 03:55:12 -0000	1.2556
> @@ -1,3 +1,11 @@
> +2006-04-12 Philippe Kalaf <philippe.kalaf at collabora.co.uk>
> +
> +	* gst-libs/gst/rtp/gstrtpbuffer.h:
> +	Added GST_RTP_PAYLOAD_DYNAMIC_STRING for use by children
> +	* gst-libs/gst/rtp/gstbasertpaudiopayload.c:
> +	* gst-libs/gst/rtp/gstbasertpaudiopayload.h:
> +	New RTP audio base payloader class. Supports frame or sample based codecs
>  2006-04-12  Thomas Vander Stichele  <thomas at apestaart dot org>
>  
>  	* configure.ac:
> Index: Makefile.am
> RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/rtp/Makefile.am,v
> retrieving revision 1.5
> retrieving revision 1.6
> diff -u -d -r1.5 -r1.6
> --- Makefile.am	27 Nov 2005 16:27:20 -0000	1.5
> +++ Makefile.am	13 Apr 2006 03:55:12 -0000	1.6
> @@ -2,12 +2,14 @@
>  libgstrtpinclude_HEADERS = gstrtpbuffer.h \
>  			gstbasertppayload.h \
> +			gstbasertpaudiopayload.h \
>  			gstbasertpdepayload.h
>  lib_LTLIBRARIES = libgstrtp- at GST_MAJORMINOR@.la
>  libgstrtp_ at GST_MAJORMINOR@_la_SOURCES = gstrtpbuffer.c \
>    				gstbasertppayload.c \
> +  				gstbasertpaudiopayload.c \
>    				gstbasertpdepayload.c
>  libgstrtp_ at GST_MAJORMINOR@_la_CFLAGS = $(GST_CFLAGS)
> --- NEW FILE: gstbasertpaudiopayload.c ---
> /* GStreamer
>  * Copyright (C) <2006> Philippe Khalaf <burger at speedy.org> 
>  *
>  * 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.
>  */
> 
> #ifdef HAVE_CONFIG_H
> #include "config.h"
> #endif
> #include <stdlib.h>
> #include <string.h>
> #include <gst/rtp/gstrtpbuffer.h>
> #include <math.h>
> #include "gstbasertpaudiopayload.h"
> GST_DEBUG_CATEGORY (basertpaudiopayload_debug);
> #define GST_CAT_DEFAULT (basertpaudiopayload_debug)
> /* let us define a minimum of 10 ms for sample based codecs */
> #define GST_RTP_MIN_PTIME_MS 10
> static void gst_basertpaudiopayload_finalize (GObject * object);
> static GstFlowReturn
> gst_basertpaudiopayload_push (GstBaseRTPPayload * basepayload, guint8 * data,
>     guint payload_len, GstClockTime timestamp);
> static GstFlowReturn gst_basertpaudiopayload_handle_buffer (GstBaseRTPPayload *
>     payload, GstBuffer * buffer);
> gst_basertpaudiopayload_handle_frame_based_buffer (GstBaseRTPPayload *
>     basepayload, GstBuffer * buffer);
> gst_basertpaudiopayload_handle_sample_based_buffer (GstBaseRTPPayload *
> GST_BOILERPLATE (GstBaseRTPAudioPayload, gst_basertpaudiopayload,
>     GstBaseRTPPayload, GST_TYPE_BASE_RTP_PAYLOAD);
> static void
> gst_basertpaudiopayload_base_init (gpointer klass)
> {
> }
> gst_basertpaudiopayload_class_init (GstBaseRTPAudioPayloadClass * klass)
>   GObjectClass *gobject_class;
>   GstElementClass *gstelement_class;
>   GstBaseRTPPayloadClass *gstbasertppayload_class;
>   gobject_class = (GObjectClass *) klass;
>   gstelement_class = (GstElementClass *) klass;
>   gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
>   gobject_class->finalize = gst_basertpaudiopayload_finalize;
>   parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_PAYLOAD);
>   gstbasertppayload_class->handle_buffer =
>       gst_basertpaudiopayload_handle_buffer;
>   GST_DEBUG_CATEGORY_INIT (basertpaudiopayload_debug, "basertpaudiopayload", 0,
>       "base audio RTP payloader");
> gst_basertpaudiopayload_init (GstBaseRTPAudioPayload * basertpaudiopayload,
>     GstBaseRTPAudioPayloadClass * klass)
>   basertpaudiopayload->adapter = gst_adapter_new ();
>   basertpaudiopayload->adapter_base_ts = 0;
>   basertpaudiopayload->type = AUDIO_CODEC_TYPE_NONE;
>   /* 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;
> gst_basertpaudiopayload_finalize (GObject * object)
>   GstBaseRTPAudioPayload *basertpaudiopayload;
>   basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (object);
>   g_object_unref (basertpaudiopayload->adapter);
>   basertpaudiopayload->adapter = NULL;
>   GST_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
> void
> gst_basertpaudiopayload_set_frame_based (GstBaseRTPAudioPayload *
>     basertpaudiopayload)
>   g_return_if_fail (basertpaudiopayload != NULL);
>   if (basertpaudiopayload->type != AUDIO_CODEC_TYPE_NONE) {
>     GST_ERROR_OBJECT (basertpaudiopayload,
>         "Codec type already set! You should only set this once!");
>   }
>   basertpaudiopayload->type = AUDIO_CODEC_TYPE_FRAME_BASED;
> gst_basertpaudiopayload_set_sample_based (GstBaseRTPAudioPayload *
>   basertpaudiopayload->type = AUDIO_CODEC_TYPE_SAMPLE_BASED;
> /* These are options that need to be set for frame based audio codecs */
> gst_basertpaudiopayload_set_frame_options (GstBaseRTPAudioPayload
>     * basertpaudiopayload, gint frame_duration, gint frame_size)
>   basertpaudiopayload->frame_size = frame_size;
>   basertpaudiopayload->frame_duration = frame_duration;
> gst_basertpaudiopayload_set_sample_options (GstBaseRTPAudioPayload
>     * basertpaudiopayload, gint sample_size)
>   basertpaudiopayload->sample_size = sample_size;
> gst_basertpaudiopayload_handle_buffer (GstBaseRTPPayload * basepayload,
>     GstBuffer * buffer)
>   GstFlowReturn ret;
>   basertpaudiopayload = GST_BASE_RTP_AUDIO_PAYLOAD (basepayload);
>   ret = GST_FLOW_ERROR;
>   if (basertpaudiopayload->type == AUDIO_CODEC_TYPE_FRAME_BASED) {
>     ret = gst_basertpaudiopayload_handle_frame_based_buffer (basepayload,
>         buffer);
>   } else if (basertpaudiopayload->type == AUDIO_CODEC_TYPE_SAMPLE_BASED) {
>     ret = gst_basertpaudiopayload_handle_sample_based_buffer (basepayload,
>   } else {
>     GST_DEBUG_OBJECT (basertpaudiopayload, "Audio codec type not set");
>   return ret;
> /* this assumes all frames have a constant duration and a constant size */
>     basepayload, GstBuffer * buffer)
>   guint payload_len;
>   guint8 *data;
>   guint available;
>   gint frame_size, frame_duration;
>   guint maxptime_octets = G_MAXUINT;
>   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;
>   /* If buffer fits on an RTP packet, let's just push it through without using
>    * the adapter */
>   /* this will check again max_ptime and max_mtu */
>   if (!gst_basertppayload_is_filled (basepayload,
>           gst_rtp_buffer_calc_packet_len (GST_BUFFER_SIZE (buffer), 0, 0),
>           GST_BUFFER_DURATION (buffer))) {
>     ret = gst_basertpaudiopayload_push (basepayload, GST_BUFFER_DATA (buffer),
>         GST_BUFFER_SIZE (buffer), GST_BUFFER_TIMESTAMP (buffer));
>     return ret;
>   /* TODO : would be nice if we had some property that told the payloader to put
>    * just 1 frame per RTP packet, for the moment we can set the ptime to 0 or
>    * something smaller or equal to a 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) {
>       GST_WARNING_OBJECT (basertpaudiopayload,
>           "Given ptime %d is smaller than minimum %d ms, overwriting to minimum",
>           ptime_ms, frame_duration);
>       maxptime_octets = frame_size;
>     }
>   /* if the adapter is empty (should be), let's set the base timestamp */
>   if (gst_adapter_available (basertpaudiopayload->adapter) == 0) {
>     basertpaudiopayload->adapter_base_ts = GST_BUFFER_TIMESTAMP (buffer);
>         "Adapter should be empty but is not!");
>   gst_adapter_push (basertpaudiopayload->adapter, buffer);
>   available = gst_adapter_available (basertpaudiopayload->adapter);
>   /* as long as we have full frames */
>   /* this loop will always empty the adapter till the last frame */
>   /* TODO Make it possible to set a minimum size per packet, this way the
>    * algorithm doesn't empty the adapter if there is too little data left and
>    * will wait until the next buffers to arrive */
>   while (available >= frame_size) {
>     /* we need to see how many frames we can get based on maximum MTU, maximum
>      * ptime and the number of bytes available in the adapter */
>     payload_len = MIN (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),
>         /* currently available */
>         floor (available / frame_size) * frame_size);
>     data =
>         (guint8 *) gst_adapter_peek (basertpaudiopayload->adapter, payload_len);
>     ret =
>         gst_basertpaudiopayload_push (basepayload, data, payload_len,
>         basertpaudiopayload->adapter_base_ts);
>     gst_adapter_flush (basertpaudiopayload->adapter, payload_len);
>     gfloat ts_inc = (payload_len * frame_duration) / frame_size;
>     ts_inc = ts_inc * GST_MSECOND;
>     basertpaudiopayload->adapter_base_ts += ts_inc;
>     GST_DEBUG_OBJECT (basertpaudiopayload, "%f %f %d", ts_inc,
>         ts_inc * GST_MSECOND, (payload_len * frame_duration) / frame_size);
>     GST_DEBUG_OBJECT (basertpaudiopayload, "Pushing with ts %" GST_TIME_FORMAT,
>         GST_TIME_ARGS (basertpaudiopayload->adapter_base_ts));
>     available = gst_adapter_available (basertpaudiopayload->adapter);
>   /* adapter should be freed by now */
>   if (available != 0) {
>   guint minptime_octets = 0;
>   guint sample_size;
>   if (basertpaudiopayload->sample_size == 0) {
>   sample_size = basertpaudiopayload->sample_size;
>   /* max number of bytes based on given ptime */
>     maxptime_octets = basepayload->max_ptime * basepayload->clock_rate /
>         (sample_size * GST_SECOND);
>     minptime_octets = GST_RTP_MIN_PTIME_MS * basepayload->clock_rate /
>         (sample_size * 1000);
>     GST_DEBUG_OBJECT (basertpaudiopayload,
>         "Calculated max_octects %u and min_octets %u", maxptime_octets,
>         minptime_octets);
>     if (maxptime_octets < minptime_octets) {
>           "Given ptime %d is smaller than minimum %d, replacing by %d",
>           maxptime_octets, minptime_octets, minptime_octets);
>       maxptime_octets = minptime_octets;
>     GST_DEBUG_OBJECT (basertpaudiopayload, "Setting to %" GST_TIME_FORMAT,
>         GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
>   while (available >= minptime_octets) {
>             gst_rtp_buffer_calc_payload_len (GST_BASE_RTP_PAYLOAD_MTU
>                 (basertpaudiopayload), 0, 0),
>         available);
>     gfloat num = payload_len;
>     gfloat datarate = (sample_size * basepayload->clock_rate);
>     basertpaudiopayload->adapter_base_ts +=
>         /* payload_len (bytes) * nsecs/sec / datarate (bytes*sec) */
>         num / datarate * GST_SECOND;
>     GST_DEBUG_OBJECT (basertpaudiopayload, "Calculating ts inc %f %f %f", num,
>         datarate, num / datarate * GST_SECOND);
>     GST_DEBUG_OBJECT (basertpaudiopayload, "New ts is %" GST_TIME_FORMAT,
>     guint payload_len, GstClockTime timestamp)
>   GstBuffer *outbuf;
>   guint8 *payload;
>   /* 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);
> --- NEW FILE: gstbasertpaudiopayload.h ---
> #ifndef __GST_BASE_RTP_AUDIO_PAYLOAD_H__
> #define __GST_BASE_RTP_AUDIO_PAYLOAD_H__
> #include <gst/gst.h>
> #include <gst/rtp/gstbasertppayload.h>
> #include <gst/base/gstadapter.h>
> G_BEGIN_DECLS
> typedef struct _GstBaseRTPAudioPayload GstBaseRTPAudioPayload;
> typedef struct _GstBaseRTPAudioPayloadClass GstBaseRTPAudioPayloadClass;
> #define GST_TYPE_BASE_RTP_AUDIO_PAYLOAD \
>   (gst_basertpaudiopayload_get_type())
> #define GST_BASE_RTP_AUDIO_PAYLOAD(obj) \
>   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_RTP_AUDIO_PAYLOAD,GstBaseRTPAudioPayload))
> #define GST_BASE_RTP_AUDIO_PAYLOAD_CLASS(klass) \
>   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_RTP_AUDIO_PAYLOAD,GstBaseRTPAudioPayload))
> #define GST_IS_BASE_RTP_AUDIO_PAYLOAD(obj) \
>   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_RTP_AUDIO_PAYLOAD))
> #define GST_IS_BASE_RTP_AUDIO_PAYLOAD_CLASS(obj) \
>   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_RTP_AUDIO_PAYLOAD))
> typedef enum {
>   AUDIO_CODEC_TYPE_NONE,
>   AUDIO_CODEC_TYPE_FRAME_BASED,
>   AUDIO_CODEC_TYPE_SAMPLE_BASED
> } AudioCodecType;
> struct _GstBaseRTPAudioPayload
>   GstBaseRTPPayload payload;
>   GstClockTime adapter_base_ts;
>   GstAdapter *adapter;
>   gint frame_size;
>   gint frame_duration;
>   gint sample_size;
>   AudioCodecType type;
> };
> struct _GstBaseRTPAudioPayloadClass
>   GstBaseRTPPayloadClass parent_class;
> gboolean gst_basertpaudiopayload_plugin_init (GstPlugin * plugin);
> GType gst_basertpaudiopayload_get_type (void);
> gst_basertpaudiopayload_set_frame_based (GstBaseRTPAudioPayload *basertpaudiopayload);
> gst_basertpaudiopayload_set_sample_based (GstBaseRTPAudioPayload *basertpaudiopayload);
>     *basertpaudiopayload, gint frame_duration, gint frame_size);
>     *basertpaudiopayload, gint sample_size);
> G_END_DECLS
> #endif /* __GST_BASE_RTP_AUDIO_PAYLOAD_H__ */
> Index: gstrtpbuffer.h
> RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/rtp/gstrtpbuffer.h,v
> retrieving revision 1.8
> retrieving revision 1.9
> diff -u -d -r1.8 -r1.9
> --- gstrtpbuffer.h	6 Dec 2005 19:42:01 -0000	1.8
> +++ gstrtpbuffer.h	13 Apr 2006 03:55:12 -0000	1.9
> @@ -71,6 +71,8 @@
>  #define GST_RTP_PAYLOAD_MPV_STRING "32"
>  #define GST_RTP_PAYLOAD_H263_STRING "34"
> +#define GST_RTP_PAYLOAD_DYNAMIC_STRING "[96, 127]"
>  /* creating buffers */
>  GstBuffer*      gst_rtp_buffer_new              (void);
>  void            gst_rtp_buffer_allocate_data    (GstBuffer *buffer, guint payload_len, 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting language
> that extends applications into web and mobile media. Attend the live webcast
> and join the prime developer group breaking into this new coding territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> gstreamer-cvs-verbose mailing list
> gstreamer-cvs-verbose at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs-verbose





More information about the gstreamer-devel mailing list