annotate libpurple/media/codec.c @ 31410:b1022aa66b8a

Call msn_transaction_destroy from msn_cmdproc_send_trans. This way, it always owns in some way the transaction after being called.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 27 Nov 2010 07:08:24 +0000
parents 1feb2baeac2d
children a8cc50c2279f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
1 /**
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
2 * @file codec.c Codec for Media API
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
3 * @ingroup core
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
4 */
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
5
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
6 /* purple
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
7 *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
8 * Purple is the legal property of its developers, whose names are too numerous
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
10 * source distribution.
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
11 *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
15 * (at your option) any later version.
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
16 *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
20 * GNU General Public License for more details.
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
21 *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
25 */
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
26
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
27 #include "codec.h"
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
28
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
29 /** @copydoc _PurpleMediaCodecClass */
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
30 typedef struct _PurpleMediaCodecClass PurpleMediaCodecClass;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
31 /** @copydoc _PurpleMediaCodecPrivate */
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
32 typedef struct _PurpleMediaCodecPrivate PurpleMediaCodecPrivate;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
33
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
34 #define PURPLE_MEDIA_CODEC_GET_PRIVATE(obj) \
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
35 (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
36 PURPLE_TYPE_MEDIA_CODEC, PurpleMediaCodecPrivate))
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
37
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
38 struct _PurpleMediaCodecClass
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
39 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
40 GObjectClass parent_class;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
41 };
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
42
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
43 struct _PurpleMediaCodec
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
44 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
45 GObject parent;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
46 };
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
47
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
48 G_DEFINE_TYPE(PurpleMediaCodec, purple_media_codec, G_TYPE_OBJECT);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
49
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
50 struct _PurpleMediaCodecPrivate
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
51 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
52 gint id;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
53 char *encoding_name;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
54 PurpleMediaSessionType media_type;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
55 guint clock_rate;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
56 guint channels;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
57 GList *optional_params;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
58 };
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
59
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
60 enum {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
61 PROP_CODEC_0,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
62 PROP_ID,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
63 PROP_ENCODING_NAME,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
64 PROP_MEDIA_TYPE,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
65 PROP_CLOCK_RATE,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
66 PROP_CHANNELS,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
67 PROP_OPTIONAL_PARAMS,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
68 };
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
69
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
70 static void
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
71 purple_media_codec_init(PurpleMediaCodec *info)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
72 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
73 PurpleMediaCodecPrivate *priv =
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
74 PURPLE_MEDIA_CODEC_GET_PRIVATE(info);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
75 priv->encoding_name = NULL;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
76 priv->optional_params = NULL;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
77 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
78
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
79 static void
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
80 purple_media_codec_finalize(GObject *info)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
81 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
82 PurpleMediaCodecPrivate *priv =
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
83 PURPLE_MEDIA_CODEC_GET_PRIVATE(info);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
84 g_free(priv->encoding_name);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
85 for (; priv->optional_params; priv->optional_params =
30872
1feb2baeac2d Fix some media code leaks.
jakub.adam@ktknet.cz
parents: 29538
diff changeset
86 g_list_delete_link(priv->optional_params, priv->optional_params)) {
1feb2baeac2d Fix some media code leaks.
jakub.adam@ktknet.cz
parents: 29538
diff changeset
87 PurpleKeyValuePair *param = priv->optional_params->data;
1feb2baeac2d Fix some media code leaks.
jakub.adam@ktknet.cz
parents: 29538
diff changeset
88 g_free(param->key);
1feb2baeac2d Fix some media code leaks.
jakub.adam@ktknet.cz
parents: 29538
diff changeset
89 g_free(param->value);
1feb2baeac2d Fix some media code leaks.
jakub.adam@ktknet.cz
parents: 29538
diff changeset
90 g_free(param);
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
91 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
92 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
93
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
94 static void
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
95 purple_media_codec_set_property (GObject *object, guint prop_id,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
96 const GValue *value, GParamSpec *pspec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
97 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
98 PurpleMediaCodecPrivate *priv;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
99 g_return_if_fail(PURPLE_IS_MEDIA_CODEC(object));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
100
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
101 priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(object);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
102
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
103 switch (prop_id) {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
104 case PROP_ID:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
105 priv->id = g_value_get_uint(value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
106 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
107 case PROP_ENCODING_NAME:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
108 g_free(priv->encoding_name);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
109 priv->encoding_name = g_value_dup_string(value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
110 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
111 case PROP_MEDIA_TYPE:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
112 priv->media_type = g_value_get_flags(value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
113 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
114 case PROP_CLOCK_RATE:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
115 priv->clock_rate = g_value_get_uint(value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
116 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
117 case PROP_CHANNELS:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
118 priv->channels = g_value_get_uint(value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
119 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
120 case PROP_OPTIONAL_PARAMS:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
121 priv->optional_params = g_value_get_pointer(value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
122 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
123 default:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
124 G_OBJECT_WARN_INVALID_PROPERTY_ID(
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
125 object, prop_id, pspec);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
126 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
127 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
128 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
129
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
130 static void
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
131 purple_media_codec_get_property (GObject *object, guint prop_id,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
132 GValue *value, GParamSpec *pspec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
133 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
134 PurpleMediaCodecPrivate *priv;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
135 g_return_if_fail(PURPLE_IS_MEDIA_CODEC(object));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
136
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
137 priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(object);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
138
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
139 switch (prop_id) {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
140 case PROP_ID:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
141 g_value_set_uint(value, priv->id);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
142 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
143 case PROP_ENCODING_NAME:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
144 g_value_set_string(value, priv->encoding_name);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
145 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
146 case PROP_MEDIA_TYPE:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
147 g_value_set_flags(value, priv->media_type);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
148 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
149 case PROP_CLOCK_RATE:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
150 g_value_set_uint(value, priv->clock_rate);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
151 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
152 case PROP_CHANNELS:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
153 g_value_set_uint(value, priv->channels);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
154 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
155 case PROP_OPTIONAL_PARAMS:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
156 g_value_set_pointer(value, priv->optional_params);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
157 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
158 default:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
159 G_OBJECT_WARN_INVALID_PROPERTY_ID(
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
160 object, prop_id, pspec);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
161 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
162 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
163 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
164
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
165 static void
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
166 purple_media_codec_class_init(PurpleMediaCodecClass *klass)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
167 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
168 GObjectClass *gobject_class = (GObjectClass*)klass;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
169
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
170 gobject_class->finalize = purple_media_codec_finalize;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
171 gobject_class->set_property = purple_media_codec_set_property;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
172 gobject_class->get_property = purple_media_codec_get_property;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
173
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
174 g_object_class_install_property(gobject_class, PROP_ID,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
175 g_param_spec_uint("id",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
176 "ID",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
177 "The numeric identifier of the codec.",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
178 0, G_MAXUINT, 0,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
179 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
180
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
181 g_object_class_install_property(gobject_class, PROP_ENCODING_NAME,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
182 g_param_spec_string("encoding-name",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
183 "Encoding Name",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
184 "The name of the codec.",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
185 NULL,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
186 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
187
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
188 g_object_class_install_property(gobject_class, PROP_MEDIA_TYPE,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
189 g_param_spec_flags("media-type",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
190 "Media Type",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
191 "Whether this is an audio of video codec.",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
192 PURPLE_TYPE_MEDIA_SESSION_TYPE,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
193 PURPLE_MEDIA_NONE,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
194 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
195
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
196 g_object_class_install_property(gobject_class, PROP_CLOCK_RATE,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
197 g_param_spec_uint("clock-rate",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
198 "Create Callback",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
199 "The function called to create this element.",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
200 0, G_MAXUINT, 0,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
201 G_PARAM_READWRITE));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
202
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
203 g_object_class_install_property(gobject_class, PROP_CHANNELS,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
204 g_param_spec_uint("channels",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
205 "Channels",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
206 "The number of channels in this codec.",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
207 0, G_MAXUINT, 0,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
208 G_PARAM_READWRITE));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
209 g_object_class_install_property(gobject_class, PROP_OPTIONAL_PARAMS,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
210 g_param_spec_pointer("optional-params",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
211 "Optional Params",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
212 "A list of optional parameters for the codec.",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
213 G_PARAM_READWRITE));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
214
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
215 g_type_class_add_private(klass, sizeof(PurpleMediaCodecPrivate));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
216 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
217
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
218 PurpleMediaCodec *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
219 purple_media_codec_new(int id, const char *encoding_name,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
220 PurpleMediaSessionType media_type, guint clock_rate)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
221 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
222 PurpleMediaCodec *codec =
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
223 g_object_new(PURPLE_TYPE_MEDIA_CODEC,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
224 "id", id,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
225 "encoding_name", encoding_name,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
226 "media_type", media_type,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
227 "clock-rate", clock_rate, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
228 return codec;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
229 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
230
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
231 guint
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
232 purple_media_codec_get_id(PurpleMediaCodec *codec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
233 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
234 guint id;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
235 g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), 0);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
236 g_object_get(codec, "id", &id, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
237 return id;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
238 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
239
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
240 gchar *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
241 purple_media_codec_get_encoding_name(PurpleMediaCodec *codec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
242 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
243 gchar *name;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
244 g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
245 g_object_get(codec, "encoding-name", &name, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
246 return name;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
247 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
248
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
249 guint
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
250 purple_media_codec_get_clock_rate(PurpleMediaCodec *codec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
251 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
252 guint clock_rate;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
253 g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), 0);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
254 g_object_get(codec, "clock-rate", &clock_rate, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
255 return clock_rate;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
256 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
257
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
258 guint
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
259 purple_media_codec_get_channels(PurpleMediaCodec *codec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
260 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
261 guint channels;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
262 g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), 0);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
263 g_object_get(codec, "channels", &channels, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
264 return channels;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
265 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
266
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
267 GList *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
268 purple_media_codec_get_optional_parameters(PurpleMediaCodec *codec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
269 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
270 GList *optional_params;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
271 g_return_val_if_fail(PURPLE_IS_MEDIA_CODEC(codec), NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
272 g_object_get(codec, "optional-params", &optional_params, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
273 return optional_params;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
274 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
275
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
276 void
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
277 purple_media_codec_add_optional_parameter(PurpleMediaCodec *codec,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
278 const gchar *name, const gchar *value)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
279 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
280 PurpleMediaCodecPrivate *priv;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
281 PurpleKeyValuePair *new_param;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
282
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
283 g_return_if_fail(codec != NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
284 g_return_if_fail(name != NULL && value != NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
285
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
286 priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
287
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
288 new_param = g_new0(PurpleKeyValuePair, 1);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
289 new_param->key = g_strdup(name);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
290 new_param->value = g_strdup(value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
291 priv->optional_params = g_list_append(
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
292 priv->optional_params, new_param);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
293 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
294
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
295 void
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
296 purple_media_codec_remove_optional_parameter(PurpleMediaCodec *codec,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
297 PurpleKeyValuePair *param)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
298 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
299 PurpleMediaCodecPrivate *priv;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
300
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
301 g_return_if_fail(codec != NULL && param != NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
302
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
303 priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
304
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
305 g_free(param->key);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
306 g_free(param->value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
307
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
308 priv->optional_params =
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
309 g_list_remove(priv->optional_params, param);
30872
1feb2baeac2d Fix some media code leaks.
jakub.adam@ktknet.cz
parents: 29538
diff changeset
310 g_free(param);
29538
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
311 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
312
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
313 PurpleKeyValuePair *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
314 purple_media_codec_get_optional_parameter(PurpleMediaCodec *codec,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
315 const gchar *name, const gchar *value)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
316 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
317 PurpleMediaCodecPrivate *priv;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
318 GList *iter;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
319
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
320 g_return_val_if_fail(codec != NULL, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
321 g_return_val_if_fail(name != NULL, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
322
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
323 priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
324
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
325 for (iter = priv->optional_params; iter; iter = g_list_next(iter)) {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
326 PurpleKeyValuePair *param = iter->data;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
327 if (!g_ascii_strcasecmp(param->key, name) &&
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
328 (value == NULL ||
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
329 !g_ascii_strcasecmp(param->value, value)))
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
330 return param;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
331 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
332
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
333 return NULL;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
334 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
335
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
336 PurpleMediaCodec *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
337 purple_media_codec_copy(PurpleMediaCodec *codec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
338 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
339 PurpleMediaCodecPrivate *priv;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
340 PurpleMediaCodec *new_codec;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
341 GList *iter;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
342
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
343 if (codec == NULL)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
344 return NULL;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
345
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
346 priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
347
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
348 new_codec = purple_media_codec_new(priv->id, priv->encoding_name,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
349 priv->media_type, priv->clock_rate);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
350 g_object_set(codec, "channels", priv->channels, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
351
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
352 for (iter = priv->optional_params; iter; iter = g_list_next(iter)) {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
353 PurpleKeyValuePair *param =
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
354 (PurpleKeyValuePair*)iter->data;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
355 purple_media_codec_add_optional_parameter(new_codec,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
356 param->key, param->value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
357 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
358
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
359 return new_codec;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
360 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
361
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
362 GList *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
363 purple_media_codec_list_copy(GList *codecs)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
364 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
365 GList *new_list = NULL;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
366
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
367 for (; codecs; codecs = g_list_next(codecs)) {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
368 new_list = g_list_prepend(new_list,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
369 purple_media_codec_copy(codecs->data));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
370 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
371
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
372 new_list = g_list_reverse(new_list);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
373 return new_list;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
374 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
375
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
376 void
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
377 purple_media_codec_list_free(GList *codecs)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
378 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
379 for (; codecs; codecs =
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
380 g_list_delete_link(codecs, codecs)) {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
381 g_object_unref(codecs->data);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
382 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
383 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
384
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
385 gchar *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
386 purple_media_codec_to_string(const PurpleMediaCodec *codec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
387 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
388 PurpleMediaCodecPrivate *priv;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
389 GString *string = NULL;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
390 GList *item;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
391 gchar *charstring;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
392 const gchar *media_type_str = NULL;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
393
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
394 if (codec == NULL)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
395 return g_strdup("(NULL)");
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
396
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
397 priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
398
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
399 string = g_string_new("");
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
400
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
401 if (priv->media_type & PURPLE_MEDIA_AUDIO)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
402 media_type_str = "audio";
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
403 else if (priv->media_type & PURPLE_MEDIA_VIDEO)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
404 media_type_str = "video";
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
405
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
406 g_string_printf(string, "%d: %s %s clock:%d channels:%d", priv->id,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
407 media_type_str, priv->encoding_name,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
408 priv->clock_rate, priv->channels);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
409
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
410 for (item = priv->optional_params; item; item = g_list_next (item)) {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
411 PurpleKeyValuePair *param = item->data;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
412 g_string_append_printf (string, " %s=%s",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
413 param->key, (gchar *)param->value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
414 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
415
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
416 charstring = string->str;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
417 g_string_free (string, FALSE);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
418
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
419 return charstring;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
420 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
421