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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/*
* jingle-tp-util.c - Telepathy-flavoured Jingle utility functions
* Copyright © 2008–2012 Collabora Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include "jingle-tp-util.h"
WockyJingleMediaType
wocky_jingle_media_type_from_tp (TpMediaStreamType type)
{
switch (type)
{
case TP_MEDIA_STREAM_TYPE_AUDIO:
return WOCKY_JINGLE_MEDIA_TYPE_AUDIO;
case TP_MEDIA_STREAM_TYPE_VIDEO:
return WOCKY_JINGLE_MEDIA_TYPE_VIDEO;
default:
g_return_val_if_reached (WOCKY_JINGLE_MEDIA_TYPE_NONE);
}
}
TpMediaStreamType
wocky_jingle_media_type_to_tp (WockyJingleMediaType type)
{
switch (type)
{
case WOCKY_JINGLE_MEDIA_TYPE_AUDIO:
return TP_MEDIA_STREAM_TYPE_AUDIO;
case WOCKY_JINGLE_MEDIA_TYPE_VIDEO:
return TP_MEDIA_STREAM_TYPE_VIDEO;
default:
g_return_val_if_reached (TP_MEDIA_STREAM_TYPE_AUDIO);
}
}
static const gchar * const relay_type_map[] = {
/* WOCKY_JINGLE_RELAY_TYPE_UDP */ "udp",
/* WOCKY_JINGLE_RELAY_TYPE_TCP */ "tcp",
/* WOCKY_JINGLE_RELAY_TYPE_TLS */ "tls",
};
GPtrArray *
gabble_build_tp_relay_info (GPtrArray *relays)
{
guint i;
GPtrArray *tp_relays = g_ptr_array_sized_new (relays->len);
g_ptr_array_set_free_func (tp_relays, (GDestroyNotify) g_hash_table_unref);
for (i = 0; i < relays->len; i++)
{
WockyJingleRelay *relay = g_ptr_array_index (relays, i);
g_return_val_if_fail (relay->type < WOCKY_N_JINGLE_RELAY_TYPES, tp_relays);
g_ptr_array_add (tp_relays, tp_asv_new (
"type", G_TYPE_STRING, relay_type_map[relay->type],
"ip", G_TYPE_STRING, relay->ip,
"port", G_TYPE_UINT, relay->port,
"username", G_TYPE_STRING, relay->username,
"password", G_TYPE_STRING, relay->password,
"component", G_TYPE_UINT, relay->component,
NULL));
}
return tp_relays;
}
|