3
* Ekiga -- A VoIP and Video-Conferencing application
4
* Copyright (C) 2000-2009 Damien Sandras <dsandras@seconix.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or (at
9
* your option) any later version. This program is distributed in the hope
10
* that it will be useful, but WITHOUT ANY WARRANTY; without even the
11
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
* See the GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18
* Ekiga is licensed under the GPL license and as a special exception, you
19
* have permission to link or otherwise combine this program with the
20
* programs OPAL, OpenH323 and PWLIB, and distribute the combination, without
21
* applying the requirements of the GNU GPL to the OPAL, OpenH323 and PWLIB
22
* programs, as long as you do follow the requirements of the GNU GPL for all
23
* the rest of the software thus combined.
28
* codec-description.cpp - description
29
* ------------------------------------------
30
* begin : written in January 2008 by Damien Sandras
31
* copyright : (c) 2008 by Damien Sandras
32
* description : declaration of the interface of a codec description.
41
#include "codec-description.h"
44
using namespace Ekiga;
46
CodecDescription::CodecDescription ()
47
: rate (0), active (true), audio (false)
52
CodecDescription::CodecDescription (std::string _name,
55
std::string _protocols,
57
: name (_name), rate (_rate), active (_active), audio (_audio)
61
prots = g_strsplit (_protocols.c_str (), ", ", -1);
63
for (gchar** ptr = prots;
67
if ((*ptr)[0] != '\0') { // not the empty string
69
protocols.push_back (*ptr);
80
CodecDescription::CodecDescription (std::string codec)
86
vect = g_strsplit (codec.c_str (), "*", -1);
88
for (gchar** ptr = vect; *ptr != NULL; ptr++) {
99
vect = g_strsplit (tmp[3].c_str (), " ", -1);
100
for (gchar** ptr = vect; *ptr != NULL; ptr++) {
102
protocols.push_back (*ptr);
108
rate = atoi (tmp [1].c_str ());
109
audio = atoi (tmp [2].c_str ());
110
active = atoi (tmp [4].c_str ());
115
CodecDescription::str ()
117
std::stringstream val;
118
std::stringstream proto;
120
val << name << "*" << rate << "*" << audio << "*";
122
for (std::list<std::string>::iterator iter = protocols.begin ();
123
iter != protocols.end ();
126
if (iter != protocols.begin ())
131
val << proto.str () << "*" << (active ? "1" : "0");
138
CodecDescription::operator== (const CodecDescription & c) const
140
CodecDescription d = c;
141
CodecDescription e = (*this);
143
return (e.str () == d.str ());
148
CodecDescription::operator!= (const CodecDescription & c) const
150
return (!((*this) == c));
154
CodecList::CodecList (GSList *codecs_config)
156
GSList *codecs_config_it = NULL;
158
codecs_config_it = (GSList *) codecs_config;
159
while (codecs_config_it) {
162
Ekiga::CodecDescription d = Ekiga::CodecDescription ((char *) codecs_config_it->data);
163
if (!d.name.empty ())
164
codecs.push_back (d);
166
codecs_config_it = g_slist_next (codecs_config_it);
174
return codecs.begin ();
177
CodecList::const_iterator CodecList::begin () const
179
return codecs.begin ();
185
return codecs.end ();
188
CodecList::const_iterator
189
CodecList::end () const
191
return codecs.end ();
195
CodecList::append (CodecList& other)
197
codecs.insert (end (), other.begin (), other.end ());
201
CodecList::append (CodecDescription& descr)
203
codecs.push_back (descr);
207
CodecList::remove (iterator it)
213
CodecList::get_audio_list ()
217
for (iterator it = begin ();
222
result.codecs.push_back (*it);
230
CodecList::get_video_list ()
234
for (iterator it = begin ();
239
result.codecs.push_back (*it);
249
GSList* result = NULL;
251
for (iterator it = begin ();
255
result = g_slist_append (result, g_strdup ((*it).str ().c_str ()));
263
CodecList::operator== (const CodecList & c) const
265
CodecList::const_iterator it2 = c.begin ();
267
if (codecs.size () != c.codecs.size ())
270
for (const_iterator it = begin ();
285
CodecList::operator!= (const CodecList & c) const
287
return (!(*this == c));
292
operator<< (std::ostream & os, const CodecList & c)
294
std::stringstream str;
295
for (CodecList::const_iterator it = c.begin ();
299
if (it != c.begin ())
305
return os << str.str ();