2 * @file miranda-media.c
6 * Copyright (C) 2010-2016 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "newpluginapi.h"
29 #include "m_protosvc.h"
30 #include "m_protoint.h"
32 #include "sipe-common.h"
33 #include "sipe-backend.h"
34 #include "sipe-core.h"
35 #include "miranda-private.h"
37 struct sipe_backend_media
{
41 struct sipe_backend_media
*
42 sipe_backend_media_new(struct sipe_core_public
*sipe_public
,
43 struct sipe_media_call
*call
,
44 const gchar
*participant
,
45 SipeMediaCallFlags flags
)
47 struct sipe_backend_media
*m
= g_new0(struct sipe_backend_media
,1);
53 sipe_backend_media_free(struct sipe_backend_media
*media
)
59 sipe_backend_media_set_cname(struct sipe_backend_media
*media
, gchar
*cname
)
64 struct sipe_backend_media_relays
*
65 sipe_backend_media_relays_convert(GSList
*media_relays
, gchar
*username
, gchar
*password
)
72 sipe_backend_media_relays_free(struct sipe_backend_media_relays
*media_relays
)
77 struct sipe_backend_media_stream
*
78 sipe_backend_media_add_stream(struct sipe_media_stream
*stream
,
80 SipeIceVersion ice_version
,
82 struct sipe_backend_media_relays
*media_relays
,
83 guint min_port
, guint max_port
)
90 sipe_backend_media_add_remote_candidates(struct sipe_media_call
*media
,
91 struct sipe_media_stream
*stream
,
97 gboolean
sipe_backend_media_is_initiator(struct sipe_media_call
*media
,
98 struct sipe_media_stream
*stream
)
104 gboolean
sipe_backend_media_accepted(struct sipe_backend_media
*media
)
111 sipe_backend_stream_initialized(struct sipe_media_call
*media
,
112 struct sipe_media_stream
*stream
)
119 sipe_backend_media_stream_get_active_local_candidates(struct sipe_media_stream
*stream
)
126 sipe_backend_media_stream_get_active_remote_candidates(struct sipe_media_stream
*stream
)
132 sipe_backend_media_set_encryption_keys(struct sipe_media_call
*media
,
133 struct sipe_media_stream
*stream
,
134 const guchar
*encryption_key
,
135 const guchar
*decryption_key
)
141 sipe_backend_media_set_require_encryption(struct sipe_media_call
*media
,
142 struct sipe_media_stream
*stream
,
143 const gboolean require_encryption
)
149 sipe_backend_stream_hold(struct sipe_media_call
*media
,
150 struct sipe_media_stream
*stream
,
157 sipe_backend_stream_unhold(struct sipe_media_call
*media
,
158 struct sipe_media_stream
*stream
,
165 sipe_backend_stream_is_held(struct sipe_media_stream
*stream
)
172 sipe_backend_media_stream_end(struct sipe_media_call
*media
,
173 struct sipe_media_stream
*stream
)
179 sipe_backend_media_stream_free(struct sipe_backend_media_stream
*stream
)
184 struct sipe_backend_codec
*
185 sipe_backend_codec_new(int id
, const char *name
, SipeMediaType type
,
186 guint clock_rate
, guint channels
)
193 sipe_backend_codec_free(struct sipe_backend_codec
*codec
)
199 sipe_backend_codec_get_id(struct sipe_backend_codec
*codec
)
206 sipe_backend_codec_get_name(struct sipe_backend_codec
*codec
)
213 sipe_backend_codec_get_clock_rate(struct sipe_backend_codec
*codec
)
220 sipe_backend_codec_add_optional_parameter(struct sipe_backend_codec
*codec
,
221 const gchar
*name
, const gchar
*value
)
227 sipe_backend_codec_get_optional_parameters(struct sipe_backend_codec
*codec
)
234 sipe_backend_set_remote_codecs(struct sipe_media_call
*media
,
235 struct sipe_media_stream
*stream
,
243 sipe_backend_get_local_codecs(struct sipe_media_call
*media
,
244 struct sipe_media_stream
*stream
)
250 struct sipe_backend_candidate
*
251 sipe_backend_candidate_new(const gchar
*foundation
,
252 SipeComponentType component
,
253 SipeCandidateType type
, SipeNetworkProtocol proto
,
254 const gchar
*ip
, guint port
,
255 const gchar
*username
,
256 const gchar
*password
)
263 sipe_backend_candidate_free(struct sipe_backend_candidate
*candidate
)
269 sipe_backend_candidate_get_username(struct sipe_backend_candidate
*candidate
)
276 sipe_backend_candidate_get_password(struct sipe_backend_candidate
*candidate
)
283 sipe_backend_candidate_get_foundation(struct sipe_backend_candidate
*candidate
)
290 sipe_backend_candidate_get_ip(struct sipe_backend_candidate
*candidate
)
297 sipe_backend_candidate_get_port(struct sipe_backend_candidate
*candidate
)
304 sipe_backend_candidate_get_base_ip(struct sipe_backend_candidate
*candidate
)
311 sipe_backend_candidate_get_base_port(struct sipe_backend_candidate
*candidate
)
318 sipe_backend_candidate_get_priority(struct sipe_backend_candidate
*candidate
)
325 sipe_backend_candidate_set_priority(struct sipe_backend_candidate
*candidate
, guint32 priority
)
331 sipe_backend_candidate_get_component_type(struct sipe_backend_candidate
*candidate
)
334 return SIPE_COMPONENT_NONE
;
338 sipe_backend_candidate_get_type(struct sipe_backend_candidate
*candidate
)
341 return SIPE_CANDIDATE_TYPE_ANY
;
345 sipe_backend_candidate_get_protocol(struct sipe_backend_candidate
*candidate
)
348 return SIPE_NETWORK_PROTOCOL_TCP_ACTIVE
;
352 sipe_backend_get_local_candidates(struct sipe_media_call
*media
,
353 struct sipe_media_stream
*stream
)
360 sipe_backend_media_accept(struct sipe_backend_media
*media
, gboolean local
)
366 sipe_backend_media_hangup(struct sipe_backend_media
*media
, gboolean local
)
372 sipe_backend_media_reject(struct sipe_backend_media
*media
, gboolean local
)
378 sipe_backend_media_get_encryption_policy(struct sipe_core_public
*sipe_public
)
380 return SIPE_ENCRYPTION_POLICY_REJECTED
;
384 sipe_backend_media_stream_read(struct sipe_media_stream
*stream
,
385 guint8
*buffer
, gsize len
)
391 sipe_backend_media_stream_write(struct sipe_media_stream
*stream
,
392 guint8
*buffer
, gsize len
)