annotate libpurple/media/codec.c @ 29629:ffb8cd9fb528

Allow binding 'Paste as Plain Text'. This should be useful when people paste non-plaintext text as plaintext text often enough that right-click -> 'Paste as Plain Text' isn't good enough.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 22 Mar 2010 20:15:55 +0000
parents e18c1d347e37
children 1feb2baeac2d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29144
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 =
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
86 g_list_delete_link(priv->optional_params,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
87 priv->optional_params)) {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
88 g_free(priv->optional_params->data);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
89 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
90 }
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 static void
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
93 purple_media_codec_set_property (GObject *object, guint prop_id,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
94 const GValue *value, GParamSpec *pspec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
95 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
96 PurpleMediaCodecPrivate *priv;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
97 g_return_if_fail(PURPLE_IS_MEDIA_CODEC(object));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
98
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
99 priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(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 switch (prop_id) {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
102 case PROP_ID:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
103 priv->id = g_value_get_uint(value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
104 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
105 case PROP_ENCODING_NAME:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
106 g_free(priv->encoding_name);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
107 priv->encoding_name = g_value_dup_string(value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
108 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
109 case PROP_MEDIA_TYPE:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
110 priv->media_type = g_value_get_flags(value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
111 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
112 case PROP_CLOCK_RATE:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
113 priv->clock_rate = g_value_get_uint(value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
114 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
115 case PROP_CHANNELS:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
116 priv->channels = g_value_get_uint(value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
117 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
118 case PROP_OPTIONAL_PARAMS:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
119 priv->optional_params = g_value_get_pointer(value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
120 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
121 default:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
122 G_OBJECT_WARN_INVALID_PROPERTY_ID(
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
123 object, prop_id, pspec);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
124 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
125 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
126 }
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 static void
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
129 purple_media_codec_get_property (GObject *object, guint prop_id,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
130 GValue *value, GParamSpec *pspec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
131 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
132 PurpleMediaCodecPrivate *priv;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
133 g_return_if_fail(PURPLE_IS_MEDIA_CODEC(object));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
134
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
135 priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(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 switch (prop_id) {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
138 case PROP_ID:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
139 g_value_set_uint(value, priv->id);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
140 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
141 case PROP_ENCODING_NAME:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
142 g_value_set_string(value, priv->encoding_name);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
143 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
144 case PROP_MEDIA_TYPE:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
145 g_value_set_flags(value, priv->media_type);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
146 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
147 case PROP_CLOCK_RATE:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
148 g_value_set_uint(value, priv->clock_rate);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
149 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
150 case PROP_CHANNELS:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
151 g_value_set_uint(value, priv->channels);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
152 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
153 case PROP_OPTIONAL_PARAMS:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
154 g_value_set_pointer(value, priv->optional_params);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
155 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
156 default:
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
157 G_OBJECT_WARN_INVALID_PROPERTY_ID(
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
158 object, prop_id, pspec);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
159 break;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
160 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
161 }
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 static void
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
164 purple_media_codec_class_init(PurpleMediaCodecClass *klass)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
165 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
166 GObjectClass *gobject_class = (GObjectClass*)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 gobject_class->finalize = purple_media_codec_finalize;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
169 gobject_class->set_property = purple_media_codec_set_property;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
170 gobject_class->get_property = purple_media_codec_get_property;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
171
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
172 g_object_class_install_property(gobject_class, PROP_ID,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
173 g_param_spec_uint("id",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
174 "ID",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
175 "The numeric identifier of the codec.",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
176 0, G_MAXUINT, 0,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
177 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
178
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
179 g_object_class_install_property(gobject_class, PROP_ENCODING_NAME,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
180 g_param_spec_string("encoding-name",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
181 "Encoding Name",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
182 "The name of the codec.",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
183 NULL,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
184 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
185
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
186 g_object_class_install_property(gobject_class, PROP_MEDIA_TYPE,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
187 g_param_spec_flags("media-type",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
188 "Media Type",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
189 "Whether this is an audio of video codec.",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
190 PURPLE_TYPE_MEDIA_SESSION_TYPE,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
191 PURPLE_MEDIA_NONE,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
192 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
193
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
194 g_object_class_install_property(gobject_class, PROP_CLOCK_RATE,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
195 g_param_spec_uint("clock-rate",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
196 "Create Callback",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
197 "The function called to create this element.",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
198 0, G_MAXUINT, 0,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
199 G_PARAM_READWRITE));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
200
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
201 g_object_class_install_property(gobject_class, PROP_CHANNELS,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
202 g_param_spec_uint("channels",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
203 "Channels",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
204 "The number of channels in this codec.",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
205 0, G_MAXUINT, 0,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
206 G_PARAM_READWRITE));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
207 g_object_class_install_property(gobject_class, PROP_OPTIONAL_PARAMS,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
208 g_param_spec_pointer("optional-params",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
209 "Optional Params",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
210 "A list of optional parameters for the codec.",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
211 G_PARAM_READWRITE));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
212
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
213 g_type_class_add_private(klass, sizeof(PurpleMediaCodecPrivate));
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
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
216 PurpleMediaCodec *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
217 purple_media_codec_new(int id, const char *encoding_name,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
218 PurpleMediaSessionType media_type, guint clock_rate)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
219 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
220 PurpleMediaCodec *codec =
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
221 g_object_new(PURPLE_TYPE_MEDIA_CODEC,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
222 "id", id,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
223 "encoding_name", encoding_name,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
224 "media_type", media_type,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
225 "clock-rate", clock_rate, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
226 return codec;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
227 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
228
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
229 guint
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
230 purple_media_codec_get_id(PurpleMediaCodec *codec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
231 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
232 guint id;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
233 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
234 g_object_get(codec, "id", &id, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
235 return id;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
236 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
237
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
238 gchar *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
239 purple_media_codec_get_encoding_name(PurpleMediaCodec *codec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
240 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
241 gchar *name;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
242 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
243 g_object_get(codec, "encoding-name", &name, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
244 return name;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
245 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
246
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
247 guint
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
248 purple_media_codec_get_clock_rate(PurpleMediaCodec *codec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
249 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
250 guint clock_rate;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
251 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
252 g_object_get(codec, "clock-rate", &clock_rate, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
253 return clock_rate;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
254 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
255
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
256 guint
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
257 purple_media_codec_get_channels(PurpleMediaCodec *codec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
258 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
259 guint channels;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
260 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
261 g_object_get(codec, "channels", &channels, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
262 return channels;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
263 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
264
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
265 GList *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
266 purple_media_codec_get_optional_parameters(PurpleMediaCodec *codec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
267 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
268 GList *optional_params;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
269 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
270 g_object_get(codec, "optional-params", &optional_params, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
271 return optional_params;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
272 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
273
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
274 void
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
275 purple_media_codec_add_optional_parameter(PurpleMediaCodec *codec,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
276 const gchar *name, const gchar *value)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
277 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
278 PurpleMediaCodecPrivate *priv;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
279 PurpleKeyValuePair *new_param;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
280
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
281 g_return_if_fail(codec != NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
282 g_return_if_fail(name != NULL && value != NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
283
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
284 priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
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 new_param = g_new0(PurpleKeyValuePair, 1);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
287 new_param->key = g_strdup(name);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
288 new_param->value = g_strdup(value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
289 priv->optional_params = g_list_append(
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
290 priv->optional_params, new_param);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
291 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
292
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
293 void
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
294 purple_media_codec_remove_optional_parameter(PurpleMediaCodec *codec,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
295 PurpleKeyValuePair *param)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
296 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
297 PurpleMediaCodecPrivate *priv;
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 g_return_if_fail(codec != NULL && param != NULL);
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 priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
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 g_free(param->key);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
304 g_free(param->value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
305 g_free(param);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
306
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
307 priv->optional_params =
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
308 g_list_remove(priv->optional_params, param);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
309 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
310
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
311 PurpleKeyValuePair *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
312 purple_media_codec_get_optional_parameter(PurpleMediaCodec *codec,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
313 const gchar *name, const gchar *value)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
314 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
315 PurpleMediaCodecPrivate *priv;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
316 GList *iter;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
317
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
318 g_return_val_if_fail(codec != NULL, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
319 g_return_val_if_fail(name != NULL, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
320
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
321 priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
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 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
324 PurpleKeyValuePair *param = iter->data;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
325 if (!g_ascii_strcasecmp(param->key, name) &&
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
326 (value == NULL ||
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
327 !g_ascii_strcasecmp(param->value, value)))
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
328 return param;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
329 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
330
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
331 return NULL;
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
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
334 PurpleMediaCodec *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
335 purple_media_codec_copy(PurpleMediaCodec *codec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
336 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
337 PurpleMediaCodecPrivate *priv;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
338 PurpleMediaCodec *new_codec;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
339 GList *iter;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
340
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
341 if (codec == NULL)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
342 return NULL;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
343
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
344 priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
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 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
347 priv->media_type, priv->clock_rate);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
348 g_object_set(codec, "channels", priv->channels, NULL);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
349
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
350 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
351 PurpleKeyValuePair *param =
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
352 (PurpleKeyValuePair*)iter->data;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
353 purple_media_codec_add_optional_parameter(new_codec,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
354 param->key, param->value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
355 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
356
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
357 return new_codec;
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
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
360 GList *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
361 purple_media_codec_list_copy(GList *codecs)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
362 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
363 GList *new_list = NULL;
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 for (; codecs; codecs = g_list_next(codecs)) {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
366 new_list = g_list_prepend(new_list,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
367 purple_media_codec_copy(codecs->data));
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
368 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
369
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
370 new_list = g_list_reverse(new_list);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
371 return new_list;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
372 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
373
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
374 void
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
375 purple_media_codec_list_free(GList *codecs)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
376 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
377 for (; codecs; codecs =
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
378 g_list_delete_link(codecs, codecs)) {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
379 g_object_unref(codecs->data);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
380 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
381 }
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 gchar *
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
384 purple_media_codec_to_string(const PurpleMediaCodec *codec)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
385 {
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
386 PurpleMediaCodecPrivate *priv;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
387 GString *string = NULL;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
388 GList *item;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
389 gchar *charstring;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
390 const gchar *media_type_str = NULL;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
391
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
392 if (codec == NULL)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
393 return g_strdup("(NULL)");
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
394
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
395 priv = PURPLE_MEDIA_CODEC_GET_PRIVATE(codec);
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 string = g_string_new("");
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 if (priv->media_type & PURPLE_MEDIA_AUDIO)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
400 media_type_str = "audio";
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
401 else if (priv->media_type & PURPLE_MEDIA_VIDEO)
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
402 media_type_str = "video";
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
403
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
404 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
405 media_type_str, priv->encoding_name,
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
406 priv->clock_rate, priv->channels);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
407
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
408 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
409 PurpleKeyValuePair *param = item->data;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
410 g_string_append_printf (string, " %s=%s",
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
411 param->key, (gchar *)param->value);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
412 }
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
413
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
414 charstring = string->str;
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
415 g_string_free (string, FALSE);
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
416
e18c1d347e37 Break PurpleMediaCodec out into its own file.
maiku@pidgin.im
parents:
diff changeset
417 return charstring;
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