notify: clean up process_incoming_notify()
[siplcs.git] / contrib / media-patches / farsight2_tcp_turn.patch
blobc0dfbd90903e7079b0fc7062d1873f419cf13d1c
1 From b8939d724427102f4450dd43b3467dc2b543afa8 Mon Sep 17 00:00:00 2001
2 From: Jakub Adam <jakub.adam@ktknet.cz>
3 Date: Mon, 9 May 2011 00:05:19 +0200
4 Subject: [PATCH] Patch needed for TURN relay TCP transport support
6 stream: Allow to set allowed stream transport protocols
8 nice stream transmitter: Add "demultiplex-func" property
9 ---
10 gst-libs/gst/farsight/fs-candidate.h | 10 ++-
11 gst/fsmsnconference/fs-msn-connection.c | 2 +-
12 transmitters/nice/fs-nice-stream-transmitter.c | 77 +++++++++++++++++++++++-
13 3 files changed, 84 insertions(+), 5 deletions(-)
15 diff --git a/gst-libs/gst/farsight/fs-candidate.h b/gst-libs/gst/farsight/fs-candidate.h
16 index d829a22..7913867 100644
17 --- a/gst-libs/gst/farsight/fs-candidate.h
18 +++ b/gst-libs/gst/farsight/fs-candidate.h
19 @@ -59,14 +59,18 @@ typedef enum
20 /**
21 * FsNetworkProtocol:
22 * @FS_NETWORK_PROTOCOL_UDP: A UDP based protocol
23 - * @FS_NETWORK_PROTOCOL_TCP: A TCP based protocol
24 + * @FS_NETWORK_PROTOCOL_TCP_ACTIVE: A TCP based protocol, will attempt to open
25 + * outbound connection
26 + * @FS_NETWORK_PROTOCOL_TCP_PASSIVE: A TCP based protocol, will listen for
27 + * incoming connections
29 * An enum for the base IP protocol
31 typedef enum
33 - FS_NETWORK_PROTOCOL_UDP,
34 - FS_NETWORK_PROTOCOL_TCP
35 + FS_NETWORK_PROTOCOL_UDP = 1,
36 + FS_NETWORK_PROTOCOL_TCP_ACTIVE = 2,
37 + FS_NETWORK_PROTOCOL_TCP_PASSIVE = 4
38 } FsNetworkProtocol;
40 /**
41 diff --git a/gst/fsmsnconference/fs-msn-connection.c b/gst/fsmsnconference/fs-msn-connection.c
42 index 65e786d..78994b2 100644
43 --- a/gst/fsmsnconference/fs-msn-connection.c
44 +++ b/gst/fsmsnconference/fs-msn-connection.c
45 @@ -533,7 +533,7 @@ fs_msn_open_listening_port_unlock (FsMsnConnection *self, guint16 port,
46 item = g_list_next (item))
48 candidate = fs_candidate_new (self->local_recipient_id, 1,
49 - FS_CANDIDATE_TYPE_HOST, FS_NETWORK_PROTOCOL_TCP, item->data, port);
50 + FS_CANDIDATE_TYPE_HOST, FS_NETWORK_PROTOCOL_TCP_PASSIVE, item->data, port);
51 candidate->username = g_strdup (session_id);
53 g_signal_emit (self, signals[SIGNAL_NEW_LOCAL_CANDIDATE], 0, candidate);
54 diff --git a/transmitters/nice/fs-nice-stream-transmitter.c b/transmitters/nice/fs-nice-stream-transmitter.c
55 index bd5dcbc..725b339 100644
56 --- a/transmitters/nice/fs-nice-stream-transmitter.c
57 +++ b/transmitters/nice/fs-nice-stream-transmitter.c
58 @@ -67,7 +67,9 @@ enum
59 PROP_COMPATIBILITY_MODE,
60 PROP_ASSOCIATE_ON_SOURCE,
61 PROP_RELAY_INFO,
62 - PROP_DEBUG
63 + PROP_DEBUG,
64 + PROP_TRANSPORT_PROTOCOLS,
65 + PROP_DEMULTIPLEX_FUNC
68 struct _FsNiceStreamTransmitterPrivate
69 @@ -84,6 +86,7 @@ struct _FsNiceStreamTransmitterPrivate
70 gboolean controlling_mode;
72 guint compatibility_mode;
73 + guint transport_protocols;
75 GMutex *mutex;
77 @@ -117,6 +120,8 @@ struct _FsNiceStreamTransmitterPrivate
78 gboolean gathered;
80 NiceGstStream *gststream;
82 + NiceAgentDemultiplexFunc demultiplex_func;
85 #define FS_NICE_STREAM_TRANSMITTER_GET_PRIVATE(o) \
86 @@ -348,6 +353,23 @@ fs_nice_stream_transmitter_class_init (FsNiceStreamTransmitterClass *klass)
87 FALSE,
88 G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
90 + g_object_class_install_property (gobject_class, PROP_TRANSPORT_PROTOCOLS,
91 + g_param_spec_uint (
92 + "transport-protocols",
93 + "Allowed transport protocols",
94 + "Protocols that can be used for stream transport specified as OR-ed "
95 + "values of FsNetworkProtocol",
96 + 0, G_MAXINT,
97 + FS_NETWORK_PROTOCOL_UDP,
98 + G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
100 + g_object_class_install_property (gobject_class, PROP_DEMULTIPLEX_FUNC,
101 + g_param_spec_pointer(
102 + "demultiplex-func",
103 + "Stream component demultiplexing function",
104 + "Callback function separating stream components on multiplexed"
105 + "connections",
106 + G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
109 static void
110 @@ -412,6 +434,38 @@ fs_nice_stream_transmitter_dispose (GObject *object)
113 static void
114 +fs_nice_stream_transmitter_set_transport_protocols (
115 + FsNiceStreamTransmitter *self,
116 + FsNetworkProtocol protocols)
118 + NiceCandidateTransport nice_protocols = 0;
119 + guint stream_id;
121 + FS_NICE_STREAM_TRANSMITTER_LOCK (self);
122 + stream_id = self->priv->stream_id;
123 + FS_NICE_STREAM_TRANSMITTER_UNLOCK (self);
125 + if (stream_id) {
126 + if (protocols & FS_NETWORK_PROTOCOL_TCP_ACTIVE)
127 + nice_protocols |= NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE;
128 + if (protocols & FS_NETWORK_PROTOCOL_TCP_PASSIVE)
129 + nice_protocols |= NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE;
130 + if (protocols & FS_NETWORK_PROTOCOL_UDP)
131 + nice_protocols |= NICE_CANDIDATE_TRANSPORT_UDP;
133 + nice_agent_set_stream_transport (self->priv->agent->agent, stream_id,
134 + nice_protocols);
138 +static void
139 +fs_nice_stream_transmitter_attach_demultiplexer (FsNiceStreamTransmitter *self)
141 + nice_agent_attach_demultiplexer (self->priv->agent->agent,
142 + self->priv->stream_id, self->priv->demultiplex_func, NULL);
145 +static void
146 fs_nice_stream_transmitter_stop (FsStreamTransmitter *streamtransmitter)
148 FsNiceStreamTransmitter *self =
149 @@ -568,6 +622,14 @@ fs_nice_stream_transmitter_set_property (GObject *object,
150 nice_debug_disable (TRUE);
152 break;
153 + case PROP_TRANSPORT_PROTOCOLS:
154 + self->priv->transport_protocols = g_value_get_uint (value);
155 + break;
156 + case PROP_DEMULTIPLEX_FUNC:
157 + self->priv->demultiplex_func = g_value_get_pointer(value);
158 + if (self->priv->agent)
159 + fs_nice_stream_transmitter_attach_demultiplexer(self);
160 + break;
161 default:
162 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
163 break;
164 @@ -601,6 +663,10 @@ fs_network_protocol_to_nice_candidate_protocol (FsNetworkProtocol proto)
166 case FS_NETWORK_PROTOCOL_UDP:
167 return NICE_CANDIDATE_TRANSPORT_UDP;
168 + case FS_NETWORK_PROTOCOL_TCP_ACTIVE:
169 + return NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE;
170 + case FS_NETWORK_PROTOCOL_TCP_PASSIVE:
171 + return NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE;
172 default:
173 GST_WARNING ("Invalid Fs network protocol type %u", proto);
174 return NICE_CANDIDATE_TRANSPORT_UDP;
175 @@ -982,6 +1048,10 @@ nice_candidate_transport_to_fs_network_protocol (NiceCandidateTransport trans)
177 case NICE_CANDIDATE_TRANSPORT_UDP:
178 return FS_NETWORK_PROTOCOL_UDP;
179 + case NICE_CANDIDATE_TRANSPORT_TCP_ACTIVE:
180 + return FS_NETWORK_PROTOCOL_TCP_ACTIVE;
181 + case NICE_CANDIDATE_TRANSPORT_TCP_PASSIVE:
182 + return FS_NETWORK_PROTOCOL_TCP_PASSIVE;
183 default:
184 GST_WARNING ("Invalid Nice network transport type %u", trans);
185 return FS_NETWORK_PROTOCOL_UDP;
186 @@ -1379,6 +1449,11 @@ fs_nice_stream_transmitter_build (FsNiceStreamTransmitter *self,
190 + fs_nice_stream_transmitter_set_transport_protocols(self,
191 + self->priv->transport_protocols);
192 + if (self->priv->demultiplex_func)
193 + fs_nice_stream_transmitter_attach_demultiplexer (self);
195 self->priv->state_changed_handler_id = g_signal_connect_object (agent->agent,
196 "component-state-changed", G_CALLBACK (agent_state_changed), self, 0);
197 self->priv->gathering_done_handler_id = g_signal_connect_object (agent->agent,
199 1.7.5.4