gstbasertpdepayload.h 3.86 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* 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,GstBaseRTPDepayload))
#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(obj) \
  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_RTP_DEPAYLOAD))

41
42
43
#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)

44
/* in milliseconds */
45
#define RTP_QUEUE_DELAY 100;
46

47
48
49
50
51
#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))

52
53
54
55
56
57
58
59
60
typedef struct _GstBaseRTPDepayload      GstBaseRTPDepayload;
typedef struct _GstBaseRTPDepayloadClass GstBaseRTPDepayloadClass;

struct _GstBaseRTPDepayload
{
  GstElement parent;

  GstPad *sinkpad, *srcpad;

61
62
63
64
65
66
67
  /* lock to protect the queue */
  GStaticRecMutex queuelock;

  gboolean thread_running;
  /* the releaser thread */
  GThread *thread;

68
  /* this attribute must be set by the child */
69
70
  guint clock_rate;

71
  /* this value can be modified by the child if needed */
72
73
  guint queue_delay;

74
75
76
77
78
  /* 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 
   */
79
  GQueue *queue;
80
81

  /*< private >*/
82
83
84
85
  union {
    gboolean need_newsegment;
    gpointer _gst_reserved[GST_PADDING-1+1];
  };
86
87
88
89
90
91
};

struct _GstBaseRTPDepayloadClass
{
  GstElementClass parent_class;

92
  /* virtuals */
93
94
  gboolean (*set_caps) (GstBaseRTPDepayload *filter, GstCaps *caps);

95
96
97
  /* non-pure function, default implementation in base class
   * this does buffering, reordering and dropping 
   */
98
  GstFlowReturn (*add_to_queue) (GstBaseRTPDepayload *filter, GstBuffer *in);
99

100
101
102
  /* pure virtual function, child must use this to process incoming
   * rtp packets
   */
103
  GstBuffer * (*process) (GstBaseRTPDepayload *base, GstBuffer *in);
104

105
106
107
  /* non-pure function used to convert from RTP timestamp to GST timestamp
   * this function is used by the child class before gst_pad_pushing
   */
108
  void (*set_gst_timestamp) (GstBaseRTPDepayload *filter, guint32 timestamp, GstBuffer *buf);
109
110
111

  /*< private >*/
  gpointer _gst_reserved[GST_PADDING];
112
113
114
115
116
117
118
};

GType gst_base_rtp_depayload_get_type (void);

G_END_DECLS

#endif /* __GST_BASE_RTP_DEPAYLOAD_H__ */