ekiga r5908 - in trunk: . lib/engine/protocol/skel



Author: dsandras
Date: Sun Jan 13 18:52:17 2008
New Revision: 5908
URL: http://svn.gnome.org/viewvc/ekiga?rev=5908&view=rev

Log:
Added comparison operators for the CodecDescription objects.
Added several operations to the CodecList class (append, comparison
operators, conversion to a GSList of strings, ...). 


Modified:
   trunk/ChangeLog
   trunk/lib/engine/protocol/skel/codec-description.cpp
   trunk/lib/engine/protocol/skel/codec-description.h

Modified: trunk/lib/engine/protocol/skel/codec-description.cpp
==============================================================================
--- trunk/lib/engine/protocol/skel/codec-description.cpp	(original)
+++ trunk/lib/engine/protocol/skel/codec-description.cpp	Sun Jan 13 18:52:17 2008
@@ -125,6 +125,21 @@
 }
 
 
+bool CodecDescription::operator== (const CodecDescription & c) const
+{
+  CodecDescription d = c;
+  CodecDescription e = (*this);
+
+  return (e.str () == d.str ());
+}
+
+
+bool CodecDescription::operator!= (const CodecDescription & c) const
+{
+  return (!((*this) == c));
+}
+
+
 CodecList::CodecList (GSList *codecs_config)
 {
   GSList *codecs_config_it = NULL;
@@ -140,3 +155,100 @@
     codecs_config_it = g_slist_next (codecs_config_it);
   }
 }
+
+
+void CodecList::append (CodecList & list)
+{
+  (*this).insert ((*this).begin (), list.begin (), list.end ());
+}
+
+
+CodecList CodecList::get_audio_list ()
+{
+  CodecList list;
+
+  for (CodecList::iterator it = (*this).begin ();
+       it != (*this).end ();
+       it++) {
+
+    if ((*it).audio)
+      list.push_back (*it);
+  }
+
+  return list;
+}
+
+
+CodecList CodecList::get_video_list ()
+{
+  CodecList list;
+
+  for (CodecList::iterator it = (*this).begin ();
+       it != (*this).end ();
+       it++) {
+
+    if (!(*it).audio)
+      list.push_back (*it);
+  }
+
+  return list;
+}
+
+
+GSList *CodecList::gslist ()
+{
+  GSList *list = NULL;
+
+  for (CodecList::iterator it = (*this).begin ();
+       it != (*this).end ();
+       it++) {
+
+    list = g_slist_append (list, g_strdup ((*it).str ().c_str ()));
+  }
+
+  return list;
+}
+
+
+bool CodecList::operator== (const CodecList & c) const
+{
+  CodecList::const_iterator it2 = c.begin ();
+
+  if ((*this).size () != c.size ())
+    return false;
+
+  for (CodecList::const_iterator it = (*this).begin ();
+       it != (*this).end ();
+       it++) {
+
+    if ((*it) != (*it2)) 
+      return false;
+    
+    it2++;
+  }
+
+  return true;
+}
+
+
+bool CodecList::operator!= (const CodecList & c) const
+{
+  return (!(*this == c));
+}
+
+
+std::ostream& operator<< (std::ostream & os, const CodecList & c)
+{
+  std::stringstream str;
+  for (CodecList::const_iterator it = c.begin ();
+       it != c.end ();
+       it++) {
+
+    if (it != c.begin ())
+      str << " ; ";
+
+    str << (*it).name;
+  }
+
+  return os << str.str ();
+}

Modified: trunk/lib/engine/protocol/skel/codec-description.h
==============================================================================
--- trunk/lib/engine/protocol/skel/codec-description.h	(original)
+++ trunk/lib/engine/protocol/skel/codec-description.h	Sun Jan 13 18:52:17 2008
@@ -100,6 +100,17 @@
       /** protocols is a list of protocols supported by the codec
       */
       std::list<std::string> protocols;
+
+
+      /** Return true if both CodecDescription are identical, false otherwise
+       * @return true if both CodecDescription are identical, false otherwise
+       */
+      bool operator== (const CodecDescription & c) const;
+
+      /** Return true if both CodecDescription are different, false otherwise
+       * @return true if both CodecDescription are different, false otherwise
+       */
+      bool operator!= (const CodecDescription & c) const;
     };
 
 
@@ -115,6 +126,46 @@
        * are CodecDescription objects formatted as a string.
        */
       CodecList (GSList *);
+
+
+      /** Append the given CodecList at the end of the current CodecList.
+       * @param list is the CodecList to append to the current one
+       */
+      void append (CodecList & list);
+
+
+      /** Return the list of audio codecs descriptions in the current CodecList 
+       * @return the list of audio CodecDescription
+       */
+      CodecList get_audio_list ();
+
+
+      /** Return the list of video codecs descriptions in the current CodecList 
+       * @return the list of video CodecDescription
+       */
+      CodecList get_video_list ();
+
+
+      /** Return the list of codecs descriptions under their str form
+       * @return the list of CodecDescription
+       */
+      GSList *gslist ();
+
+
+      /** Return true if both CodecList are identical, false otherwise
+       * @return true if both CodecList are identical, false otherwise
+       */
+      bool operator== (const CodecList & c) const;
+
+
+      /** Return true if both CodecList are different, false otherwise
+       * @return true if both CodecList are different, false otherwise
+       */
+      bool operator!= (const CodecList & c) const;
     };
 }
+
+/** Output the CodecList
+ */
+std::ostream& operator<< (std::ostream & os, const Ekiga::CodecList & c);
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]