Imported existing code

This commit is contained in:
Hazim Gazov
2010-04-02 02:48:44 -03:00
parent 48fbc5ae91
commit 7a86d01598
13996 changed files with 2468699 additions and 0 deletions

View File

@@ -0,0 +1,118 @@
/* GStreamer
* Copyright (C) <2005> Philippe Khalaf <burger@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.
*/
#ifndef __GST_BASE_RTP_DEPAYLOAD_H__
#define __GST_BASE_RTP_DEPAYLOAD_H__
#include <gst/gst.h>
#include <gst/rtp/gstrtpbuffer.h>
G_BEGIN_DECLS
/* #define's don't like whitespacey bits */
#define GST_TYPE_BASE_RTP_DEPAYLOAD (gst_base_rtp_depayload_get_type())
#define GST_BASE_RTP_DEPAYLOAD(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_RTP_DEPAYLOAD,GstBaseRTPDepayload))
#define GST_BASE_RTP_DEPAYLOAD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_RTP_DEPAYLOAD,GstBaseRTPDepayloadClass))
#define GST_BASE_RTP_DEPAYLOAD_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_BASE_RTP_DEPAYLOAD,GstBaseRTPDepayloadClass))
#define GST_IS_BASE_RTP_DEPAYLOAD(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_RTP_DEPAYLOAD))
#define GST_IS_BASE_RTP_DEPAYLOAD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_RTP_DEPAYLOAD))
#define GST_BASE_RTP_DEPAYLOAD_SINKPAD(depayload) (GST_BASE_RTP_DEPAYLOAD (depayload)->sinkpad)
#define GST_BASE_RTP_DEPAYLOAD_SRCPAD(depayload) (GST_BASE_RTP_DEPAYLOAD (depayload)->srcpad)
/* in milliseconds */
#define RTP_QUEUE_DELAY 100;
#define QUEUE_LOCK_INIT(base) (g_static_rec_mutex_init(&base->queuelock))
#define QUEUE_LOCK_FREE(base) (g_static_rec_mutex_free(&base->queuelock))
#define QUEUE_LOCK(base) (g_static_rec_mutex_lock(&base->queuelock))
#define QUEUE_UNLOCK(base) (g_static_rec_mutex_unlock(&base->queuelock))
typedef struct _GstBaseRTPDepayload GstBaseRTPDepayload;
typedef struct _GstBaseRTPDepayloadClass GstBaseRTPDepayloadClass;
struct _GstBaseRTPDepayload
{
GstElement parent;
GstPad *sinkpad, *srcpad;
/* lock to protect the queue */
GStaticRecMutex queuelock;
gboolean thread_running;
/* the releaser thread */
GThread *thread;
/* this attribute must be set by the child */
guint clock_rate;
/* this value can be modified by the child if needed */
guint queue_delay;
/* we will queue up to RTP_QUEUEDELAY ms of packets,
* reordering them if necessary
* dropping any packets that are more than
* RTP_QUEUEDELAY ms late
*/
GQueue *queue;
GstSegment segment;
gboolean need_newsegment;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
struct _GstBaseRTPDepayloadClass
{
GstElementClass parent_class;
/* virtuals */
gboolean (*set_caps) (GstBaseRTPDepayload *filter, GstCaps *caps);
/* non-pure function, default implementation in base class
* this does buffering, reordering and dropping
*/
GstFlowReturn (*add_to_queue) (GstBaseRTPDepayload *filter, GstBuffer *in);
/* pure virtual function, child must use this to process incoming
* rtp packets
*/
GstBuffer * (*process) (GstBaseRTPDepayload *base, GstBuffer *in);
/* non-pure function used to convert from RTP timestamp to GST timestamp
* this function is used by the child class before gst_pad_pushing
*/
void (*set_gst_timestamp) (GstBaseRTPDepayload *filter, guint32 timestamp, GstBuffer *buf);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
GType gst_base_rtp_depayload_get_type (void);
G_END_DECLS
#endif /* __GST_BASE_RTP_DEPAYLOAD_H__ */

View File

@@ -0,0 +1,118 @@
/* GStreamer
* Copyright (C) <2005> Wim Taymans <wim@fluendo.com>
*
* 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.
*/
#ifndef __GST_BASE_RTP_PAYLOAD_H__
#define __GST_BASE_RTP_PAYLOAD_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_BASE_RTP_PAYLOAD \
(gst_basertppayload_get_type())
#define GST_BASE_RTP_PAYLOAD(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_RTP_PAYLOAD,GstBaseRTPPayload))
#define GST_BASE_RTP_PAYLOAD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_RTP_PAYLOAD,GstBaseRTPPayloadClass))
#define GST_BASE_RTP_PAYLOAD_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_RTP_PAYLOAD, GstBaseRTPPayloadClass))
#define GST_IS_BASE_RTP_PAYLOAD(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_RTP_PAYLOAD))
#define GST_IS_BASE_RTP_PAYLOAD_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_RTP_PAYLOAD))
typedef struct _GstBaseRTPPayload GstBaseRTPPayload;
typedef struct _GstBaseRTPPayloadClass GstBaseRTPPayloadClass;
#define GST_BASE_RTP_PAYLOAD_SINKPAD(payload) (GST_BASE_RTP_PAYLOAD (payload)->sinkpad)
#define GST_BASE_RTP_PAYLOAD_SRCPAD(payload) (GST_BASE_RTP_PAYLOAD (payload)->srcpad)
#define GST_BASE_RTP_PAYLOAD_PT(payload) (GST_BASE_RTP_PAYLOAD (payload)->pt)
#define GST_BASE_RTP_PAYLOAD_MTU(payload) (GST_BASE_RTP_PAYLOAD (payload)->mtu)
struct _GstBaseRTPPayload
{
GstElement element;
/*< private >*/
GstPad *sinkpad;
GstPad *srcpad;
GRand *seq_rand;
GRand *ssrc_rand;
GRand *ts_rand;
guint32 ts_base;
guint16 seqnum_base;
gchar *media;
gchar *encoding_name;
gboolean dynamic;
guint32 clock_rate;
gint32 ts_offset;
guint32 timestamp;
gint16 seqnum_offset;
guint16 seqnum;
gint64 max_ptime;
guint pt;
guint ssrc;
guint current_ssrc;
guint mtu;
GstSegment segment;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
struct _GstBaseRTPPayloadClass
{
GstElementClass parent_class;
/* receive caps on the sink pad, configure the payloader. */
gboolean (*set_caps) (GstBaseRTPPayload *payload, GstCaps *caps);
/* handle a buffer, perform 0 or more gst_basertppayload_push() on
* the RTP buffers */
GstFlowReturn (*handle_buffer) (GstBaseRTPPayload *payload,
GstBuffer *buffer);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
GType gst_basertppayload_get_type (void);
void gst_basertppayload_set_options (GstBaseRTPPayload *payload,
gchar *media, gboolean dynamic,
gchar *encoding_name,
guint32 clock_rate);
gboolean gst_basertppayload_set_outcaps (GstBaseRTPPayload *payload,
gchar *fieldname, ...);
gboolean gst_basertppayload_is_filled (GstBaseRTPPayload *payload,
guint size, GstClockTime duration);
GstFlowReturn gst_basertppayload_push (GstBaseRTPPayload *payload,
GstBuffer *buffer);
G_END_DECLS
#endif /* __GST_BASE_RTP_PAYLOAD_H__ */

View File

@@ -0,0 +1,130 @@
/* GStreamer
* Copyright (C) <2005> Philippe Khalaf <burger@speedy.org>
* <2005> Wim Taymans <wim@fluendo.com>
*
* gstrtpbuffer.h: various helper functions to manipulate buffers
* with RTP payload.
*
* 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.
*/
#ifndef __GST_RTPBUFFER_H__
#define __GST_RTPBUFFER_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_RTP_VERSION 2
typedef enum
{
/* Audio: */
GST_RTP_PAYLOAD_PCMU = 0, /* ITU-T G.711. mu-law audio (RFC 3551) */
GST_RTP_PAYLOAD_GSM = 3,
GST_RTP_PAYLOAD_PCMA = 8, /* ITU-T G.711 A-law audio (RFC 3551) */
GST_RTP_PAYLOAD_L16_STEREO = 10,
GST_RTP_PAYLOAD_L16_MONO = 11,
GST_RTP_PAYLOAD_MPA = 14, /* Audio MPEG 1-3 */
GST_RTP_PAYLOAD_G723_63 = 16, /* Not standard */
GST_RTP_PAYLOAD_G723_53 = 17, /* Not standard */
GST_RTP_PAYLOAD_TS48 = 18, /* Not standard */
GST_RTP_PAYLOAD_TS41 = 19, /* Not standard */
GST_RTP_PAYLOAD_G728 = 20, /* Not standard */
GST_RTP_PAYLOAD_G729 = 21, /* Not standard */
/* Video: */
GST_RTP_PAYLOAD_MPV = 32, /* Video MPEG 1 & 2 */
GST_RTP_PAYLOAD_H263 = 34,
/* BOTH */
} GstRTPPayload;
/* Defining the above as strings, to make the declaration of pad_templates
* easier. So if please keep these synchronized with the above.
*/
#define GST_RTP_PAYLOAD_PCMU_STRING "0"
#define GST_RTP_PAYLOAD_GSM_STRING "3"
#define GST_RTP_PAYLOAD_PCMA_STRING "8"
#define GST_RTP_PAYLOAD_L16_STEREO_STRING "10"
#define GST_RTP_PAYLOAD_L16_MONO_STRING "11"
#define GST_RTP_PAYLOAD_MPA_STRING "14"
#define GST_RTP_PAYLOAD_G723_63_STRING "16"
#define GST_RTP_PAYLOAD_G723_53_STRING "17"
#define GST_RTP_PAYLOAD_TS48_STRING "18"
#define GST_RTP_PAYLOAD_TS41_STRING "19"
#define GST_RTP_PAYLOAD_G728_STRING "20"
#define GST_RTP_PAYLOAD_G729_STRING "21"
#define GST_RTP_PAYLOAD_MPV_STRING "32"
#define GST_RTP_PAYLOAD_H263_STRING "34"
/* creating buffers */
GstBuffer* gst_rtp_buffer_new (void);
void gst_rtp_buffer_allocate_data (GstBuffer *buffer, guint payload_len,
guint8 pad_len, guint8 csrc_count);
GstBuffer* gst_rtp_buffer_new_take_data (gpointer data, guint len);
GstBuffer* gst_rtp_buffer_new_copy_data (gpointer data, guint len);
GstBuffer* gst_rtp_buffer_new_allocate (guint payload_len, guint8 pad_len, guint8 csrc_count);
GstBuffer* gst_rtp_buffer_new_allocate_len (guint packet_len, guint8 pad_len, guint8 csrc_count);
guint gst_rtp_buffer_calc_header_len (guint8 csrc_count);
guint gst_rtp_buffer_calc_packet_len (guint payload_len, guint8 pad_len, guint8 csrc_count);
guint gst_rtp_buffer_calc_payload_len (guint packet_len, guint8 pad_len, guint8 csrc_count);
gboolean gst_rtp_buffer_validate_data (guint8 *data, guint len);
gboolean gst_rtp_buffer_validate (GstBuffer *buffer);
void gst_rtp_buffer_set_packet_len (GstBuffer *buffer, guint len);
guint gst_rtp_buffer_get_packet_len (GstBuffer *buffer);
guint8 gst_rtp_buffer_get_version (GstBuffer *buffer);
void gst_rtp_buffer_set_version (GstBuffer *buffer, guint8 version);
gboolean gst_rtp_buffer_get_padding (GstBuffer *buffer);
void gst_rtp_buffer_set_padding (GstBuffer *buffer, gboolean padding);
void gst_rtp_buffer_pad_to (GstBuffer *buffer, guint len);
gboolean gst_rtp_buffer_get_extension (GstBuffer *buffer);
void gst_rtp_buffer_set_extension (GstBuffer *buffer, gboolean extension);
guint32 gst_rtp_buffer_get_ssrc (GstBuffer *buffer);
void gst_rtp_buffer_set_ssrc (GstBuffer *buffer, guint32 ssrc);
guint8 gst_rtp_buffer_get_csrc_count (GstBuffer *buffer);
guint32 gst_rtp_buffer_get_csrc (GstBuffer *buffer, guint8 idx);
void gst_rtp_buffer_set_csrc (GstBuffer *buffer, guint8 idx, guint32 csrc);
gboolean gst_rtp_buffer_get_marker (GstBuffer *buffer);
void gst_rtp_buffer_set_marker (GstBuffer *buffer, gboolean marker);
guint8 gst_rtp_buffer_get_payload_type (GstBuffer *buffer);
void gst_rtp_buffer_set_payload_type (GstBuffer *buffer, guint8 payload_type);
guint16 gst_rtp_buffer_get_seq (GstBuffer *buffer);
void gst_rtp_buffer_set_seq (GstBuffer *buffer, guint16 seq);
guint32 gst_rtp_buffer_get_timestamp (GstBuffer *buffer);
void gst_rtp_buffer_set_timestamp (GstBuffer *buffer, guint32 timestamp);
GstBuffer* gst_rtp_buffer_get_payload_buffer (GstBuffer *buffer);
guint gst_rtp_buffer_get_payload_len (GstBuffer *buffer);
gpointer gst_rtp_buffer_get_payload (GstBuffer *buffer);
G_END_DECLS
#endif /* __GST_RTPBUFFER_H__ */