| 1 | /* |
|---|
| 2 | * QuteCom, a voice over Internet phone |
|---|
| 3 | * Copyright (C) 2004-2010 Mbdsys |
|---|
| 4 | * |
|---|
| 5 | * This program is free software; you can redistribute it and/or modify |
|---|
| 6 | * it under the terms of the GNU General Public License as published by |
|---|
| 7 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 | * (at your option) any later version. |
|---|
| 9 | * |
|---|
| 10 | * This program is distributed in the hope that it will be useful, |
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | * GNU General Public License for more details. |
|---|
| 14 | * |
|---|
| 15 | * You should have received a copy of the GNU General Public License |
|---|
| 16 | * along with this program; if not, write to the Free Software |
|---|
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | */ |
|---|
| 19 | |
|---|
| 20 | #include <sipwrapper/EnumVideoQuality.h> |
|---|
| 21 | |
|---|
| 22 | #include <util/Logger.h> |
|---|
| 23 | |
|---|
| 24 | #include <map> |
|---|
| 25 | |
|---|
| 26 | typedef std::map<EnumVideoQuality::VideoQuality, std::string> VideoQualityMap; |
|---|
| 27 | static VideoQualityMap _videoQualityMap; |
|---|
| 28 | |
|---|
| 29 | static void init() { |
|---|
| 30 | _videoQualityMap[EnumVideoQuality::VideoQualityNormal] = "VideoQualityNormal"; |
|---|
| 31 | _videoQualityMap[EnumVideoQuality::VideoQualityGood] = "VideoQualityGood"; |
|---|
| 32 | _videoQualityMap[EnumVideoQuality::VideoQualityVeryGood] = "VideoQualityVeryGood"; |
|---|
| 33 | _videoQualityMap[EnumVideoQuality::VideoQualityExcellent] = "VideoQualityExcellent"; |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | std::string EnumVideoQuality::toString(VideoQuality videoQuality) { |
|---|
| 37 | init(); |
|---|
| 38 | std::string tmp = _videoQualityMap[videoQuality]; |
|---|
| 39 | if (tmp.empty()) { |
|---|
| 40 | LOG_FATAL("unknown VideoQuality=" + QString::number(videoQuality).toStdString()); |
|---|
| 41 | } |
|---|
| 42 | return tmp; |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | EnumVideoQuality::VideoQuality EnumVideoQuality::toVideoQuality(const std::string & videoQuality) { |
|---|
| 46 | init(); |
|---|
| 47 | for (VideoQualityMap::const_iterator it = _videoQualityMap.begin(); |
|---|
| 48 | it != _videoQualityMap.end(); ++it) { |
|---|
| 49 | |
|---|
| 50 | if ((*it).second == videoQuality) { |
|---|
| 51 | return (*it).first; |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | LOG_FATAL("unknown VideoQuality=" + videoQuality); |
|---|
| 56 | |
|---|
| 57 | //Avoid warning |
|---|
| 58 | return VideoQualityNormal; |
|---|
| 59 | } |
|---|