<commit_before>/*  This file is part of the KDE project
    Copyright (C) 2006-2007 <NAME> <<EMAIL>>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License version 2 as published by the Free Software Foundation.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.

*/

#include "backend.h"

#include "audiodataoutput.h"
#include "audioeffect.h"
#include "audiooutput.h"
#include "audiopath.h"
#include "brightnesscontrol.h"
#include "mediaobject.h"
#include "videodataoutput.h"
#include "videoeffect.h"
#include "videopath.h"
#include "videowidget.h"
#include "visualization.h"
#include "volumefadereffect.h"

#include <QtCore/QSet>
#include <QtCore/QVariant>

#include <kgenericfactory.h>
#include <klocale.h>

typedef KGenericFactory<Phonon::Fake::Backend, Phonon::Fake::Backend> FakeBackendFactory;
K_EXPORT_COMPONENT_FACTORY(phonon_fake, FakeBackendFactory("fakebackend"))

namespace Phonon
{
namespace Fake
{

Backend::Backend(QObject *parent, const QStringList &)
    : QObject(parent)
{
    setProperty("identifier",     QLatin1String("phonon_fake"));
    setProperty("backendName",    i18n("Fake"));
    setProperty("backendComment", i18n("Testing Backend"));
    setProperty("backendVersion", QLatin1String("0.1"));
    setProperty("backendIcon",    QLatin1String(""));
    setProperty("backendWebsite", QLatin1String("http://multimedia.kde.org/"));
}

Backend::~Backend()
{
}

QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList<QVariant> &args)
{
    switch (c) {
    case MediaObjectClass:
        return new MediaObject(parent);
    case AudioPathClass:
        return new AudioPath(parent);
    case VolumeFaderEffectClass:
        return new VolumeFaderEffect(parent);
    case AudioOutputClass:
        {
            AudioOutput *ao = new AudioOutput(parent);
            m_audioOutputs.append(ao);
            return ao;
        }
    case AudioDataOutputClass:
        return new AudioDataOutput(parent);
    case VisualizationClass:
        return new Visualization(parent);
    case VideoPathClass:
        return new VideoPath(parent);
    case BrightnessControlClass:
        return new BrightnessControl(parent);
    case VideoDataOutputClass:
        return new VideoDataOutput(parent);
    case DeinterlaceFilterClass:
        return 0;//new DeinterlaceFilter(parent);
    case AudioEffectClass:
        return new AudioEffect(args[0].toInt(), parent);
    case VideoEffectClass:
        return new VideoEffect(args[0].toInt(), parent);
    case VideoWidgetClass:
        return new VideoWidget(qobject_cast<QWidget *>(parent));
    }
    return 0;
}

bool Backend::supportsVideo() const
{
    return true;
}

bool Backend::supportsOSD() const
{
    return false;
}

bool Backend::supportsFourcc(quint32 fourcc) const
{
    switch(fourcc)
    {
    case 0x00000000:
        return true;
    default:
        return false;
    }
}

bool Backend::supportsSubtitles() const
{
    return false;
}

QStringList Backend::availableMimeTypes() const
{
    if (m_supportedMimeTypes.isEmpty())
        const_cast<Backend *>(this)->m_supportedMimeTypes
            << QLatin1String("audio/x-vorbis+ogg")
            //<< QLatin1String("audio/mpeg")
            << QLatin1String("audio/x-wav")
            << QLatin1String("video/x-ogm+ogg");
    return m_supportedMimeTypes;
}

QSet<int> Backend::objectDescriptionIndexes(ObjectDescriptionType type) const
{
    QSet<int> set;
    switch(type)
    {
    case Phonon::AudioOutputDeviceType:
        set << 10000 << 10001;
        break;
    case Phonon::AudioCaptureDeviceType:
        set << 20000 << 20001;
        break;
    case Phonon::VideoOutputDeviceType:
        set << 40000 << 40001 << 40002 << 40003;
        break;
    case Phonon::VideoCaptureDeviceType:
        set << 30000 << 30001;
        break;
    case Phonon::VisualizationType:
    case Phonon::AudioCodecType:
    case Phonon::VideoCodecType:
    case Phonon::ContainerFormatType:
        break;
    case Phonon::AudioEffectType:
        set << 0x7F000001;
        break;
    case Phonon::VideoEffectType:
        set << 0x7E000001;
        break;
    }
    return set;
}

QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(ObjectDescriptionType type, int index) const
{
    QHash<QByteArray, QVariant> ret;
    switch (type) {
    case Phonon::AudioOutputDeviceType:
        switch (index) {
        case 10000:
            ret.insert("name", QLatin1String("internal Soundcard"));
            break;
        case 10001:
            ret.insert("name", QLatin1String("USB Headset"));<commit_msg>list all kinds of devices to test the icons<commit_after>/*  This file is part of the KDE project
    Copyright (C) 2006-2007 <NAME> <<EMAIL>>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License version 2 as published by the Free Software Foundation.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.

*/

#include "backend.h"

#include "audiodataoutput.h"
#include "audioeffect.h"
#include "audiooutput.h"
#include "audiopath.h"
#include "brightnesscontrol.h"
#include "mediaobject.h"
#include "videodataoutput.h"
#include "videoeffect.h"
#include "videopath.h"
#include "videowidget.h"
#include "visualization.h"
#include "volumefadereffect.h"

#include <QtCore/QSet>
#include <QtCore/QVariant>

#include <kgenericfactory.h>
#include <klocale.h>

typedef KGenericFactory<Phonon::Fake::Backend, Phonon::Fake::Backend> FakeBackendFactory;
K_EXPORT_COMPONENT_FACTORY(phonon_fake, FakeBackendFactory("fakebackend"))

namespace Phonon
{
namespace Fake
{

Backend::Backend(QObject *parent, const QStringList &)
    : QObject(parent)
{
    setProperty("identifier",     QLatin1String("phonon_fake"));
    setProperty("backendName",    i18n("Fake"));
    setProperty("backendComment", i18n("Testing Backend"));
    setProperty("backendVersion", QLatin1String("0.1"));
    setProperty("backendIcon",    QLatin1String(""));
    setProperty("backendWebsite", QLatin1String("http://multimedia.kde.org/"));
}

Backend::~Backend()
{
}

QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList<QVariant> &args)
{
    switch (c) {
    case MediaObjectClass:
        return new MediaObject(parent);
    case AudioPathClass:
        return new AudioPath(parent);
    case VolumeFaderEffectClass:
        return new VolumeFaderEffect(parent);
    case AudioOutputClass:
        {
            AudioOutput *ao = new AudioOutput(parent);
            m_audioOutputs.append(ao);
            return ao;
        }
    case AudioDataOutputClass:
        return new AudioDataOutput(parent);
    case VisualizationClass:
        return new Visualization(parent);
    case VideoPathClass:
        return new VideoPath(parent);
    case BrightnessControlClass:
        return new BrightnessControl(parent);
    case VideoDataOutputClass:
        return new VideoDataOutput(parent);
    case DeinterlaceFilterClass:
        return 0;//new DeinterlaceFilter(parent);
    case AudioEffectClass:
        return new AudioEffect(args[0].toInt(), parent);
    case VideoEffectClass:
        return new VideoEffect(args[0].toInt(), parent);
    case VideoWidgetClass:
        return new VideoWidget(qobject_cast<QWidget *>(parent));
    }
    return 0;
}

bool Backend::supportsVideo() const
{
    return true;
}

bool Backend::supportsOSD() const
{
    return false;
}

bool Backend::supportsFourcc(quint32 fourcc) const
{
    switch(fourcc)
    {
    case 0x00000000:
        return true;
    default:
        return false;
    }
}

bool Backend::supportsSubtitles() const
{
    return false;
}

QStringList Backend::availableMimeTypes() const
{
    if (m_supportedMimeTypes.isEmpty())
        const_cast<Backend *>(this)->m_supportedMimeTypes
            << QLatin1String("audio/x-vorbis+ogg")
            //<< QLatin1String("audio/mpeg")
            << QLatin1String("audio/x-wav")
            << QLatin1String("video/x-ogm+ogg");
    return m_supportedMimeTypes;
}

QSet<int> Backend::objectDescriptionIndexes(ObjectDescriptionType type) const
{
    QSet<int> set;
    switch(type)
    {
    case Phonon::AudioOutputDeviceType:
        set << 10000 << 10001
            << 10002 << 10003
            << 10004 << 10005
            << 10006 << 10007
            << 10008 << 10009;
        break;
    case Phonon::AudioCaptureDeviceType:
        set << 20000 << 20001;
        break;
    case Phonon::VideoOutputDeviceType:
        set << 40000 << 40001 << 40002 << 40003;
        break;
    case Phonon::VideoCaptureDeviceType:
        set << 30000 << 30001;
        break;
    case Phonon::VisualizationType:
    case Phonon::AudioCodecType:
    case Phonon::VideoCodecType:
    case Phonon::ContainerFormatType:
        break;
    case Phonon::AudioEffectType:
        set << 0x7F000001;
        break;
    case Phonon::VideoEffectType:
        set << 0x7E000001;
        break;
    }
    return set;
}

QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(ObjectDescriptionType type, int index) const
{
    QHash<QByteArray, QVariant> ret;
    switch (type) {
    case Phonon::AudioOutputDeviceType:
        switch (index) {
        case 10000:
            ret.insert("name", QLatin1String("internal Soundcard"));
            ret.insert("icon", QLatin1String("audio-card"));
            break;
        case 10001:
            ret.insert("name", QLatin1String("USB Soundcard"));
            ret.insert("icon", QLatin1String("audio-card-usb"));
            break;
        case 10002:
            ret.insert("name", QLatin1String("Firewire Soundcard"));
            ret.insert("icon", QLatin1String("audio-card-firewire"));
            break;
        case 10003:
            ret.insert("name", QLatin1String("Headset"));
            ret.insert("icon", QLatin1String("audio-headset"));
            break;
        case 10004:
            ret.insert("name", QLatin1String("USB Headset"));
            ret.insert("icon", QLatin1String("audio-headset-usb"));
            break;
        case 10005:
            ret.insert("name", QLatin1String("Bluetooth Headset"));
            ret.insert("icon", QLatin1String("audio-headset-bluetooth"));
            break;
        case 10006:
            ret.insert("name", QLatin1String("Jack Audio Connection Kit"));
            ret.insert("icon", QLatin1String("jackd"));
            break;
        case 10007:
            ret.insert("name", QLatin1String("aRts"));
            ret.insert("icon", QLatin1String("arts"));
            break;
        case 10008:
            ret.insert("name", QLatin1String("ESD"));
            ret.insert("icon", QLatin1String("esd"));
            break;
        case 10009:
            ret.insert("name", QLatin1String("Pulseaudio"));
            ret.insert("icon", QLatin1String("pulseaudio"));
{'fraction_non_alphanumeric': 0.10995868117041908, 'fraction_numerical': 0.029682097984653006, 'mean_word_length': 3.133844545137679, 'pattern_counts': {'":': 0, '<': 113, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5912245', 'n_tokens_mistral': 3790, 'n_tokens_neox': 3509, 'n_words': 863}