File indexing completed on 2024-04-14 04:38:27

0001 /*  This file is part of the KDE project
0002     Copyright (C) 2006-2007 Matthias Kretz <kretz@kde.org>
0003 
0004     This library is free software; you can redistribute it and/or
0005     modify it under the terms of the GNU Lesser General Public
0006     License as published by the Free Software Foundation; either
0007     version 2.1 of the License, or (at your option) version 3, or any
0008     later version accepted by the membership of KDE e.V. (or its
0009     successor approved by the membership of KDE e.V.), Nokia Corporation
0010     (or its successors, if any) and the KDE Free Qt Foundation, which shall
0011     act as a proxy defined in Section 6 of version 3 of the license.
0012 
0013     This library is distributed in the hope that it will be useful,
0014     but WITHOUT ANY WARRANTY; without even the implied warranty of
0015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016     Lesser General Public License for more details.
0017 
0018     You should have received a copy of the GNU Lesser General Public
0019     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0020 
0021 */
0022 
0023 #include "phononnamespace.h"
0024 #include "phononnamespace_p.h"
0025 #include "phonondefs_p.h"
0026 
0027 #include "experimental/videoframe2.h"
0028 
0029 #include "factory_p.h"
0030 
0031 #include <QCoreApplication>
0032 #include <QList>
0033 
0034 namespace Phonon
0035 {
0036     /*!
0037         Returns the version number of Phonon at run-time as a string (for
0038         example, "4.0.0"). This may be a different version than the
0039         version the application was compiled against.
0040 
0041         \sa PHONON_VERSION_STR
0042     */
0043     const char *phononVersion()
0044     {
0045         return PHONON_VERSION_STR;
0046     }
0047 
0048     QString categoryToString(Category c)
0049     {
0050         switch(c)
0051         {
0052         case Phonon::NoCategory:
0053             break;
0054         case Phonon::NotificationCategory:
0055             return QCoreApplication::translate("Phonon::", "Notifications");
0056         case Phonon::MusicCategory:
0057             return QCoreApplication::translate("Phonon::", "Music");
0058         case Phonon::VideoCategory:
0059             return QCoreApplication::translate("Phonon::", "Video");
0060         case Phonon::CommunicationCategory:
0061             return QCoreApplication::translate("Phonon::", "Communication");
0062         case Phonon::GameCategory:
0063             return QCoreApplication::translate("Phonon::", "Games");
0064         case Phonon::AccessibilityCategory:
0065             return QCoreApplication::translate("Phonon::", "Accessibility");
0066         }
0067         return QString();
0068     }
0069 
0070     QString categoryToString(CaptureCategory c)
0071     {
0072         switch(c)
0073         {
0074         case Phonon::NoCaptureCategory:
0075             break;
0076         case Phonon::CommunicationCaptureCategory:
0077             return QCoreApplication::translate("Phonon::", "Communication");
0078         case Phonon::RecordingCaptureCategory:
0079             return QCoreApplication::translate("Phonon::", "Recording");
0080         case Phonon::ControlCaptureCategory:
0081             return QCoreApplication::translate("Phonon::", "Control");
0082         }
0083         return QString();
0084     }
0085 
0086     QDebug operator <<(QDebug dbg, const Phonon::DiscType &type)
0087     {
0088         switch (type) {
0089         case Phonon::NoDisc:
0090             dbg.space() << "Phonon::NoDisc";
0091             break;
0092         case Phonon::Cd:
0093             dbg.space() << "Phonon::Cd";
0094             break;
0095         case Phonon::Dvd:
0096             dbg.space() << "Phonon::Dvd";
0097             break;
0098         case Phonon::Vcd:
0099             dbg.space() << "Phonon::Vcd";
0100             break;
0101         case Phonon::BluRay:
0102             dbg.space() << "Phonon::BluRay";
0103             break;
0104         }
0105         return dbg.maybeSpace();
0106     }
0107 
0108     QDebug operator <<(QDebug dbg, const Phonon::MetaData &metaData)
0109     {
0110         switch (metaData) {
0111         case Phonon::ArtistMetaData:
0112             dbg.space() << "Phonon::ArtistMetaData";
0113             break;
0114         case Phonon::AlbumMetaData:
0115             dbg.space() << "Phonon::AlbumMetaData";
0116             break;
0117         case Phonon::TitleMetaData:
0118             dbg.space() << "Phonon::TitleMetaData";
0119             break;
0120         case Phonon::DateMetaData:
0121             dbg.space() << "Phonon::DateMetaData";
0122             break;
0123         case Phonon::GenreMetaData:
0124             dbg.space() << "Phonon::GenreMetaData";
0125             break;
0126         case Phonon::TracknumberMetaData:
0127             dbg.space() << "Phonon::TracknumberMetaData";
0128             break;
0129         case Phonon::DescriptionMetaData:
0130             dbg.space() << "Phonon::DescriptionMetaData";
0131             break;
0132         case Phonon::MusicBrainzDiscIdMetaData:
0133             dbg.space() << "Phonon::MusicBrainzDiscIdMetaData";
0134             break;
0135         }
0136         return dbg.maybeSpace();
0137     }
0138 
0139     QDebug operator <<(QDebug dbg, const Phonon::State &state)
0140     {
0141         switch (state) {
0142         case Phonon::LoadingState:
0143             dbg.space() << "Phonon::LoadingState";
0144             break;
0145         case Phonon::StoppedState:
0146             dbg.space() << "Phonon::StoppedState";
0147             break;
0148         case Phonon::PlayingState:
0149             dbg.space() << "Phonon::PlayingState";
0150             break;
0151         case Phonon::BufferingState:
0152             dbg.space() << "Phonon::BufferingState";
0153             break;
0154         case Phonon::PausedState:
0155             dbg.space() << "Phonon::PausedState";
0156             break;
0157         case Phonon::ErrorState:
0158             dbg.space() << "Phonon::ErrorState";
0159             break;
0160         }
0161         return dbg.maybeSpace();
0162     }
0163 
0164     QDebug operator <<(QDebug dbg, const Phonon::Category &category)
0165     {
0166         dbg.space() << categoryToString(category);
0167         return dbg.maybeSpace();
0168     }
0169 
0170     QDebug operator <<(QDebug dbg, const Phonon::CaptureCategory &category)
0171     {
0172         dbg.space() << categoryToString(category);
0173         return dbg.maybeSpace();
0174     }
0175 
0176     QDebug operator <<(QDebug dbg, const Phonon::Capture::DeviceType &type)
0177     {
0178         switch (type) {
0179         case Phonon::Capture::AudioType:
0180             dbg.space() << "Phonon::Capture::AudioType";
0181             break;
0182         case Phonon::Capture::VideoType:
0183             dbg.space() << "Phonon::Capture::VideoType";
0184             break;
0185         }
0186         return dbg.maybeSpace();
0187     }
0188 
0189     QDebug operator <<(QDebug dbg, const Phonon::ErrorType &errorType)
0190     {
0191         switch (errorType) {
0192         case Phonon::NoError:
0193             dbg.space() << "Phonon::NoError";
0194             break;
0195         case Phonon::NormalError:
0196             dbg.space() << "Phonon::NormalError";
0197             break;
0198         case Phonon::FatalError:
0199             dbg.space() << "Phonon::FatalError";
0200             break;
0201         }
0202         return dbg.maybeSpace();
0203     }
0204 }
0205 
0206 static int registerPhononMetaTypes()
0207 {
0208     qRegisterMetaType<Phonon::State>();
0209     qRegisterMetaType<Phonon::ErrorType>();
0210     qRegisterMetaType<Phonon::Category>();
0211     qRegisterMetaType<Phonon::CaptureCategory>();
0212 
0213     // need those for QSettings
0214     qRegisterMetaType<QList<int> >();
0215 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0216     qRegisterMetaTypeStreamOperators<QList<int> >("QList<int>");
0217 #endif
0218     qRegisterMetaType<Phonon::Experimental::VideoFrame2>();
0219 
0220     qRegisterMetaType<Phonon::DeviceAccess>();
0221 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0222     qRegisterMetaTypeStreamOperators<Phonon::DeviceAccess>("Phonon::DeviceAccess");
0223 #endif
0224     qRegisterMetaType<Phonon::DeviceAccessList>();
0225 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0226     qRegisterMetaTypeStreamOperators<Phonon::DeviceAccessList>("Phonon::DeviceAccessList");
0227 #endif
0228     return 0; // something
0229 }
0230 
0231 #ifdef Q_CONSTRUCTOR_FUNCTION
0232 Q_CONSTRUCTOR_FUNCTION(registerPhononMetaTypes)
0233 #else
0234 static const int _Phonon_registerMetaTypes = registerPhononMetaTypes();
0235 #endif
0236 
0237 // vim: sw=4 ts=4