~oah-dev/oah/gst-plugins-bad

« back to all changes in this revision

Viewing changes to gst/rtpmanager/rtpsource.h

  • Committer: Haakon Sporsheim
  • Date: 2009-03-12 13:52:03 UTC
  • Revision ID: haakon.sporsheim@tandberg.com-20090312135203-i5k294hgkushb0mt
Initial import of git repository: git://anongit.freedesktop.org/gstreamer/gst-plugins-bad (tag: RELEASE-0_10_10)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GStreamer
 
2
 * Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Library General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Library General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Library General Public
 
15
 * License along with this library; if not, write to the
 
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
 * Boston, MA 02111-1307, USA.
 
18
 */
 
19
 
 
20
#ifndef __RTP_SOURCE_H__
 
21
#define __RTP_SOURCE_H__
 
22
 
 
23
#include <gst/gst.h>
 
24
#include <gst/rtp/gstrtcpbuffer.h>
 
25
#include <gst/netbuffer/gstnetbuffer.h>
 
26
 
 
27
#include "rtpstats.h"
 
28
 
 
29
/* the default number of consecutive RTP packets we need to receive before the
 
30
 * source is considered valid */
 
31
#define RTP_NO_PROBATION        0
 
32
#define RTP_DEFAULT_PROBATION   2
 
33
 
 
34
#define RTP_SEQ_MOD          (1 << 16)
 
35
 
 
36
typedef struct _RTPSource RTPSource;
 
37
typedef struct _RTPSourceClass RTPSourceClass;
 
38
 
 
39
#define RTP_TYPE_SOURCE             (rtp_source_get_type())
 
40
#define RTP_SOURCE(src)             (G_TYPE_CHECK_INSTANCE_CAST((src),RTP_TYPE_SOURCE,RTPSource))
 
41
#define RTP_SOURCE_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),RTP_TYPE_SOURCE,RTPSourceClass))
 
42
#define RTP_IS_SOURCE(src)          (G_TYPE_CHECK_INSTANCE_TYPE((src),RTP_TYPE_SOURCE))
 
43
#define RTP_IS_SOURCE_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),RTP_TYPE_SOURCE))
 
44
#define RTP_SOURCE_CAST(src)        ((RTPSource *)(src))
 
45
 
 
46
/**
 
47
 * RTP_SOURCE_IS_ACTIVE:
 
48
 * @src: an #RTPSource
 
49
 *
 
50
 * Check if @src is active. A source is active when it has been validated
 
51
 * and has not yet received a BYE packet.
 
52
 */
 
53
#define RTP_SOURCE_IS_ACTIVE(src)  (src->validated && !src->received_bye)
 
54
 
 
55
/**
 
56
 * RTP_SOURCE_IS_SENDER:
 
57
 * @src: an #RTPSource
 
58
 *
 
59
 * Check if @src is a sender.
 
60
 */
 
61
#define RTP_SOURCE_IS_SENDER(src)  (src->is_sender)
 
62
 
 
63
/**
 
64
 * RTPSourcePushRTP:
 
65
 * @src: an #RTPSource
 
66
 * @buffer: the RTP buffer ready for processing
 
67
 * @user_data: user data specified when registering
 
68
 *
 
69
 * This callback will be called when @src has @buffer ready for further
 
70
 * processing.
 
71
 *
 
72
 * Returns: a #GstFlowReturn.
 
73
 */
 
74
typedef GstFlowReturn (*RTPSourcePushRTP) (RTPSource *src, GstBuffer *buffer, 
 
75
        gpointer user_data);
 
76
 
 
77
/**
 
78
 * RTPSourceClockRate:
 
79
 * @src: an #RTPSource
 
80
 * @payload: a payload type
 
81
 * @user_data: user data specified when registering
 
82
 *
 
83
 * This callback will be called when @src needs the clock-rate of the
 
84
 * @payload.
 
85
 *
 
86
 * Returns: a clock-rate for @payload.
 
87
 */
 
88
typedef gint (*RTPSourceClockRate) (RTPSource *src, guint8 payload, gpointer user_data);
 
89
 
 
90
/**
 
91
 * RTPSourceCallbacks:
 
92
 * @push_rtp: a packet becomes available for handling
 
93
 * @clock_rate: a clock-rate is requested
 
94
 * @get_time: the current clock time is requested
 
95
 *
 
96
 * Callbacks performed by #RTPSource when actions need to be performed.
 
97
 */
 
98
typedef struct {
 
99
  RTPSourcePushRTP     push_rtp;
 
100
  RTPSourceClockRate   clock_rate;
 
101
} RTPSourceCallbacks;
 
102
 
 
103
/**
 
104
 * RTPSource:
 
105
 *
 
106
 * A source in the #RTPSession
 
107
 */
 
108
struct _RTPSource {
 
109
  GObject       object;
 
110
 
 
111
  /*< private >*/
 
112
  guint32       ssrc;
 
113
 
 
114
  gint          probation;
 
115
  gboolean      validated;
 
116
  gboolean      internal;
 
117
  gboolean      is_csrc;
 
118
  gboolean      is_sender;
 
119
 
 
120
  guint8       *sdes[9];
 
121
  guint         sdes_len[9];
 
122
 
 
123
  gboolean      received_bye;
 
124
  gchar        *bye_reason;
 
125
 
 
126
  gboolean      have_rtp_from;
 
127
  GstNetAddress rtp_from;
 
128
  gboolean      have_rtcp_from;
 
129
  GstNetAddress rtcp_from;
 
130
 
 
131
  gint          payload;
 
132
  GstCaps      *caps;
 
133
  gint          clock_rate;
 
134
  gint32        seqnum_base;
 
135
 
 
136
  GstClockTime  bye_time;
 
137
  GstClockTime  last_activity;
 
138
  GstClockTime  last_rtp_activity;
 
139
 
 
140
  GstClockTime  last_rtptime;
 
141
  GstClockTime  last_ntpnstime;
 
142
 
 
143
  /* for bitrate estimation */
 
144
  guint64       bitrate;
 
145
  GstClockTime  prev_ntpnstime;
 
146
  guint64       bytes_sent;
 
147
 
 
148
  GQueue       *packets;
 
149
 
 
150
  RTPSourceCallbacks callbacks;
 
151
  gpointer           user_data;
 
152
 
 
153
  RTPSourceStats stats;
 
154
};
 
155
 
 
156
struct _RTPSourceClass {
 
157
  GObjectClass   parent_class;
 
158
};
 
159
 
 
160
GType rtp_source_get_type (void);
 
161
 
 
162
/* managing lifetime of sources */
 
163
RTPSource*      rtp_source_new                 (guint32 ssrc);
 
164
void            rtp_source_set_callbacks       (RTPSource *src, RTPSourceCallbacks *cb, gpointer data);
 
165
 
 
166
/* properties */
 
167
guint32         rtp_source_get_ssrc            (RTPSource *src);
 
168
 
 
169
void            rtp_source_set_as_csrc         (RTPSource *src);
 
170
gboolean        rtp_source_is_as_csrc          (RTPSource *src);
 
171
 
 
172
gboolean        rtp_source_is_active           (RTPSource *src);
 
173
gboolean        rtp_source_is_validated        (RTPSource *src);
 
174
gboolean        rtp_source_is_sender           (RTPSource *src);
 
175
 
 
176
gboolean        rtp_source_received_bye        (RTPSource *src);
 
177
gchar *         rtp_source_get_bye_reason      (RTPSource *src);
 
178
 
 
179
void            rtp_source_update_caps         (RTPSource *src, GstCaps *caps);
 
180
 
 
181
/* SDES info */
 
182
gboolean        rtp_source_set_sdes            (RTPSource *src, GstRTCPSDESType type, 
 
183
                                                const guint8 *data, guint len);
 
184
gboolean        rtp_source_set_sdes_string     (RTPSource *src, GstRTCPSDESType type,
 
185
                                                const gchar *data);
 
186
gboolean        rtp_source_get_sdes            (RTPSource *src, GstRTCPSDESType type,
 
187
                                                guint8 **data, guint *len);
 
188
gchar*          rtp_source_get_sdes_string     (RTPSource *src, GstRTCPSDESType type);
 
189
 
 
190
/* handling network address */
 
191
void            rtp_source_set_rtp_from        (RTPSource *src, GstNetAddress *address);
 
192
void            rtp_source_set_rtcp_from       (RTPSource *src, GstNetAddress *address);
 
193
 
 
194
/* handling RTP */
 
195
GstFlowReturn   rtp_source_process_rtp         (RTPSource *src, GstBuffer *buffer, RTPArrivalStats *arrival);
 
196
 
 
197
GstFlowReturn   rtp_source_send_rtp            (RTPSource *src, GstBuffer *buffer, guint64 ntpnstime);
 
198
 
 
199
/* RTCP messages */
 
200
void            rtp_source_process_bye         (RTPSource *src, const gchar *reason);
 
201
void            rtp_source_process_sr          (RTPSource *src, GstClockTime time, guint64 ntptime,
 
202
                                                guint32 rtptime, guint32 packet_count, guint32 octet_count);
 
203
void            rtp_source_process_rb          (RTPSource *src, GstClockTime time, guint8 fractionlost,
 
204
                                                gint32 packetslost, guint32 exthighestseq, guint32 jitter,
 
205
                                                guint32 lsr, guint32 dlsr);
 
206
 
 
207
gboolean        rtp_source_get_new_sr          (RTPSource *src, guint64 ntpnstime, guint64 *ntptime,
 
208
                                                guint32 *rtptime, guint32 *packet_count,
 
209
                                                guint32 *octet_count);
 
210
gboolean        rtp_source_get_new_rb          (RTPSource *src, GstClockTime time, guint8 *fractionlost,
 
211
                                                gint32 *packetslost, guint32 *exthighestseq, guint32 *jitter,
 
212
                                                guint32 *lsr, guint32 *dlsr);
 
213
 
 
214
gboolean        rtp_source_get_last_sr         (RTPSource *src, GstClockTime *time, guint64 *ntptime,
 
215
                                                guint32 *rtptime, guint32 *packet_count,
 
216
                                                guint32 *octet_count);
 
217
gboolean        rtp_source_get_last_rb         (RTPSource *src, guint8 *fractionlost, gint32 *packetslost,
 
218
                                                guint32 *exthighestseq, guint32 *jitter,
 
219
                                                guint32 *lsr, guint32 *dlsr, guint32 *round_trip);
 
220
 
 
221
void            rtp_source_reset               (RTPSource * src);
 
222
 
 
223
#endif /* __RTP_SOURCE_H__ */