[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [phonon/five] phonon: Implement VideoSourceControl, AudioSourceControl
From:       Casian Andrei <skeletk13 () gmail ! com>
Date:       2013-11-30 19:36:08
Message-ID: E1VmqKm-0007Rn-6f () scm ! kde ! org
[Download RAW message or body]

Git commit 5becc77e92b210b18c217124bb73c39dcbb1b409 by Casian Andrei.
Committed on 30/11/2013 at 19:29.
Pushed by casianandrei into branch 'five'.

Implement VideoSourceControl, AudioSourceControl

- first attempt
- builds
- not implemented in backends yet

M  +3    -1    phonon/backendinterface.h
M  +14   -0    phonon/factory.cpp
M  +2    -0    phonon/factory_p.h
M  +350  -0    phonon/sourcecontrol.cpp
M  +87   -0    phonon/sourcecontrol.h
M  +39   -3    phonon/sourcecontrol_p.h
M  +63   -1    phonon/sourcecontrolinterface.h

http://commits.kde.org/phonon/5becc77e92b210b18c217124bb73c39dcbb1b409

diff --git a/phonon/backendinterface.h b/phonon/backendinterface.h
index 51f543a..94b911c 100644
--- a/phonon/backendinterface.h
+++ b/phonon/backendinterface.h
@@ -48,7 +48,9 @@ public:
         VideoDataOutputClass,
         EffectClass,
         VideoWidgetClass,
-        VideoSurfaceOutputClass
+        VideoSurfaceOutputClass,
+        VideoSourceControlClass,
+        AudioSourceControlClass
     };
 
 #warning generic BS
diff --git a/phonon/factory.cpp b/phonon/factory.cpp
index 4029c58..56b04fe 100644
--- a/phonon/factory.cpp
+++ b/phonon/factory.cpp
@@ -199,6 +199,20 @@ QObject *Factory::createVideoSurfaceOutput(QObject *parent)
     return interface()->createObject(BackendInterface::VideoSurfaceOutputClass, parent);
 }
 
+QObject *Factory::createVideoSourceControl(QObject *parent)
+{
+    if (!backend())
+        return 0;
+    return interface()->createObject(BackendInterface::VideoSourceControlClass, parent);
+}
+
+QObject *Factory::createAudioSourceControl(QObject *parent)
+{
+    if (!backend())
+        return 0;
+    return interface()->createObject(BackendInterface::AudioSourceControlClass, parent);
+}
+
 QObject *Factory::backend()
 {
     if (globalFactory.isDestroyed())
diff --git a/phonon/factory_p.h b/phonon/factory_p.h
index 5a70586..1194c7a 100644
--- a/phonon/factory_p.h
+++ b/phonon/factory_p.h
@@ -39,6 +39,8 @@ QObject *createAudioOutput(QObject *parent = 0);
 QObject *createVideoWidget(QObject *parent = 0);
 QObject *createAudioDataOutput(QObject *parent = 0);
 QObject *createVideoSurfaceOutput(QObject *parent = 0);
+QObject *createVideoSourceControl(QObject *parent = 0);
+QObject *createAudioSourceControl(QObject *parent = 0);
 
 QObject *backend();
 BackendInterface *interface();
diff --git a/phonon/sourcecontrol.cpp b/phonon/sourcecontrol.cpp
index b2a0b8c..e49a62e 100644
--- a/phonon/sourcecontrol.cpp
+++ b/phonon/sourcecontrol.cpp
@@ -73,4 +73,354 @@ SourceControlPrivate::~SourceControlPrivate()
 
 }
 
+
+/*
+ * Video Source Control
+ */
+
+VideoSourceControl::VideoSourceControl(Source &source, QObject *parent)
+    : SourceControl(*new VideoSourceControlPrivate(source), parent)
+{
+
+}
+
+VideoSourceControl::~VideoSourceControl()
+{
+
+}
+
+bool VideoSourceControl::supportsMenus() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return false;
+    return d->m_interface->supportsMenus();
+}
+
+QSet<VideoSourceControl::Menu> VideoSourceControl::availableMenus() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return QSet<Menu>();
+    return d->m_interface->availableMenus();
+}
+
+VideoSourceControl::Menu VideoSourceControl::currentMenu() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return RootMenu;
+    return d->m_interface->currentMenu();
+}
+
+void VideoSourceControl::setCurrentMenu(Menu menu)
+{
+    P_D(VideoSourceControl);
+    if (!d->m_interface)
+        return;
+    d->m_interface->setCurrentMenu(menu);
+}
+
+bool VideoSourceControl::supportsChapters() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return false;
+    return d->m_interface->supportsChapters();
+}
+
+int VideoSourceControl::chapterCount() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return -1;
+    return d->m_interface->chapterCount();
+}
+
+int VideoSourceControl::currentChapter() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return -1;
+    return d->m_interface->currentChapter();
+}
+
+void VideoSourceControl::setCurrentChapter(int chapterNumber)
+{
+    P_D(VideoSourceControl);
+    if (!d->m_interface)
+        return;
+    d->m_interface->setCurrentChapter(chapterNumber);
+}
+
+bool VideoSourceControl::supportsAngles() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return false;
+    return d->m_interface->supportsAngles();
+}
+
+int VideoSourceControl::angleCount() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return -1;
+    return d->m_interface->angleCount();
+}
+
+int VideoSourceControl::currentAngle()
+{
+    P_D(VideoSourceControl);
+    if (!d->m_interface)
+        return -1;
+    return d->m_interface->currentAngle();
+}
+
+void VideoSourceControl::setCurrentAngle(int angleNumber)
+{
+    P_D(VideoSourceControl);
+    if (!d->m_interface)
+        return;
+    d->m_interface->setCurrentAngle(angleNumber);
+}
+
+bool VideoSourceControl::supportsTitles() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return false;
+    return d->m_interface->supportsTitles();
+}
+
+bool VideoSourceControl::isAutoplayingTitles() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return false;
+    return d->m_interface->isAutoplayingTitles();
+}
+
+void VideoSourceControl::setAutoplayTitles(bool enable)
+{
+    P_D(VideoSourceControl);
+    if (!d->m_interface)
+        return;
+    d->m_interface->setAutoplayTitles(enable);
+}
+
+int VideoSourceControl::titleCount() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return -1;
+    return d->m_interface->titleCount();
+}
+
+int VideoSourceControl::currentTitle() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return -1;
+    return d->m_interface->currentTitle();
+}
+
+void VideoSourceControl::setCurrentTitle(int titleNumber)
+{
+    P_D(VideoSourceControl);
+    if (!d->m_interface)
+        return;
+    d->m_interface->setCurrentTitle(titleNumber);
+}
+
+bool VideoSourceControl::supportsAudioChannels() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return false;
+    return d->m_interface->supportsAudioChannels();
+}
+
+int VideoSourceControl::audioChannelCount() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return -1;
+    return d->m_interface->audioChannelCount();
+}
+
+int VideoSourceControl::audioChannel() const
+{
+    P_D(const VideoSourceControl);
+    if (!d->m_interface)
+        return -1;
+    return d->m_interface->audioChannel();
+}
+
+void VideoSourceControl::setAudioChannel(int channelNumber)
+{
+    P_D(VideoSourceControl);
+    if (!d->m_interface)
+        return;
+    return d->m_interface->setAudioChannel(channelNumber);
+}
+
+// private
+
+VideoSourceControlPrivate::VideoSourceControlPrivate(Source &source)
+    : SourceControlPrivate(source)
+    , m_currentMenu(VideoSourceControl::RootMenu)
+    , m_currentChapter(0)
+    , m_currentAngle(0)
+    , m_currentTitle(0)
+    , m_autoplayTitlesEnabled(false)
+    , m_audioChannel(0)
+{
+
+}
+
+VideoSourceControlPrivate::~VideoSourceControlPrivate()
+{
+
+}
+
+void VideoSourceControlPrivate::createBackendObject()
+{
+    if (m_backendObject)
+        return;
+
+    P_Q(VideoSourceControl);
+    m_backendObject = Factory::createVideoSourceControl(q);
+    m_interface = qobject_cast<VideoSourceControlInterface *>(m_backendObject);
+    m_scInterface = static_cast<SourceControlInterface *>(m_interface);
+    if (m_backendObject && m_interface)
+        setupBackendObject();
+}
+
+void VideoSourceControlPrivate::setupBackendObject()
+{
+    P_Q(VideoSourceControl);
+    Q_ASSERT(m_backendObject);
+
+    QObject::connect(m_backendObject, SIGNAL(availableMenusChanged()),
+                     q, SLOT(availableMenusChanged()),
+                     Qt::QueuedConnection);
+    QObject::connect(m_backendObject, SIGNAL(currentMenuChanged(VideoSourceControl::Menu)),
+                     q, SLOT(currentMenuChanged(VideoSourceControl::Menu)),
+                     Qt::QueuedConnection);
+
+    QObject::connect(m_backendObject, SIGNAL(chapterCountChanged(int)),
+                     q, SLOT(chapterCountChanged(int)),
+                     Qt::QueuedConnection);
+    QObject::connect(m_backendObject, SIGNAL(currentChapterChanged(int)),
+                     q, SLOT(currentChapterChanged(int)),
+                     Qt::QueuedConnection);
+
+    QObject::connect(m_backendObject, SIGNAL(angleCountChanged(int)),
+                     q, SLOT(angleCountChanged(int)),
+                     Qt::QueuedConnection);
+    QObject::connect(m_backendObject, SIGNAL(currentAngleChanged(int)),
+                     q, SLOT(currentAngleChanged(int)),
+                     Qt::QueuedConnection);
+
+    QObject::connect(m_backendObject, SIGNAL(titleCountChanged(int)),
+                     q, SLOT(titleCountChanged(int)),
+                     Qt::QueuedConnection);
+    QObject::connect(m_backendObject, SIGNAL(currentTitleChanged(int)),
+                     q, SLOT(currentTitleChanged(int)),
+                     Qt::QueuedConnection);
+
+    QObject::connect(m_backendObject, SIGNAL(audioChannelCountChanged(int)),
+                     q, SLOT(audioChannelCountChanged(int)),
+                     Qt::QueuedConnection);
+}
+
+
+/*
+ * Audio Source Control
+ */
+
+AudioSourceControl::AudioSourceControl(Source &source, QObject *parent)
+    : SourceControl(*new AudioSourceControlPrivate(source), parent)
+{
+
+}
+
+AudioSourceControl::~AudioSourceControl()
+{
+
+}
+
+bool AudioSourceControl::supportsTracks() const
+{
+    P_D(const AudioSourceControl);
+    if (!d->m_interface)
+        return false;
+    return d->m_interface->supportsTracks();
+}
+
+int AudioSourceControl::trackCount() const
+{
+    P_D(const AudioSourceControl);
+    if (!d->m_interface)
+        return -1;
+    return d->m_interface->trackCount();
+}
+
+int AudioSourceControl::trackNumber() const
+{
+    P_D(const AudioSourceControl);
+    if (!d->m_interface)
+        return -1;
+    return d->m_interface->trackNumber();
+}
+
+void AudioSourceControl::setTrackNumber(int trackNumber)
+{
+    P_D(AudioSourceControl);
+    if (!d->m_interface)
+        return;
+    d->m_interface->setTrackNumber(trackNumber);
+}
+
+// private
+
+AudioSourceControlPrivate::AudioSourceControlPrivate(Source &source)
+    : SourceControlPrivate(source)
+    , m_currentTrack(0)
+{
+
+}
+
+AudioSourceControlPrivate::~AudioSourceControlPrivate()
+{
+
+}
+
+void AudioSourceControlPrivate::createBackendObject()
+{
+    if (m_backendObject)
+        return;
+
+    P_Q(AudioSourceControl);
+    m_backendObject = Factory::createAudioSourceControl(q);
+    m_interface = qobject_cast<AudioSourceControlInterface *>(m_backendObject);
+    m_scInterface = static_cast<SourceControlInterface *>(m_interface);
+    if (m_backendObject && m_interface)
+       setupBackendObject();
+}
+
+void AudioSourceControlPrivate::setupBackendObject()
+{
+    P_Q(AudioSourceControl);
+    Q_ASSERT(m_backendObject);
+
+    QObject::connect(m_backendObject, SIGNAL(trackCountChanged(int)),
+                     q, SLOT(trackCountChanged(int)),
+                     Qt::QueuedConnection);
+    QObject::connect(m_backendObject, SIGNAL(currentTrackChanged(int)),
+                     q, SLOT(currentTrackChanged(int)),
+                     Qt::QueuedConnection);
+}
+
 } // Phonon namespace
diff --git a/phonon/sourcecontrol.h b/phonon/sourcecontrol.h
index 11a6da8..313508e 100644
--- a/phonon/sourcecontrol.h
+++ b/phonon/sourcecontrol.h
@@ -33,6 +33,8 @@ namespace Phonon
 {
 
 class SourceControlPrivate;
+class VideoSourceControlPrivate;
+class AudioSourceControlPrivate;
 
 class PHONON_EXPORT SourceControl : public QObject, public Frontend
 {
@@ -49,6 +51,91 @@ private:
     P_DECLARE_PRIVATE(SourceControl)
 };
 
+class PHONON_EXPORT VideoSourceControl : public SourceControl
+{
+    Q_OBJECT
+
+public:
+    enum Menu {
+        RootMenu,
+        TitleMenu,
+        AudioMenu,
+        SubtitleMenu,
+        ChapterMenu,
+        AngleMenu
+    };
+
+public:
+    explicit VideoSourceControl(Source &source, QObject *parent = 0);
+    virtual ~VideoSourceControl();
+
+    bool supportsMenus() const;
+    QSet<Menu> availableMenus() const;
+    Menu currentMenu() const;
+    void setCurrentMenu(Menu menu);
+
+    bool supportsChapters() const;
+    int chapterCount() const;
+    int currentChapter() const;
+    void setCurrentChapter(int chapterNumber);
+
+    bool supportsAngles() const;
+    int angleCount() const;
+    int currentAngle();
+    void setCurrentAngle(int angleNumber);
+
+    bool supportsTitles() const;
+    bool isAutoplayingTitles() const;
+    void setAutoplayTitles(bool enable);
+    int titleCount() const;
+    int currentTitle() const;
+    void setCurrentTitle(int titleNumber);
+
+    bool supportsAudioChannels() const;
+    int audioChannelCount() const;
+    int audioChannel() const;
+    void setAudioChannel(int channelNumber);
+
+Q_SIGNALS:
+    void availableMenusChanged();
+    void currentMenuChanged(Menu menu);
+
+    void chapterCountChanged(int count);
+    void currentChapterChanged(int chapterNumber);
+
+    void angleCountChanged(int count);
+    void currentAngleChanged(int angleNumber);
+
+    void titleCountChanged(int count);
+    void currentTitleChanged(int titleNumber);
+
+    void audioChannelCountChanged(int count);
+
+private:
+    P_DECLARE_PRIVATE(VideoSourceControl)
+};
+
+class PHONON_EXPORT AudioSourceControl : public SourceControl
+{
+    Q_OBJECT
+
+public:
+    explicit AudioSourceControl(Source &source, QObject *parent = 0);
+    virtual ~AudioSourceControl();
+
+    bool supportsTracks() const;
+    int trackCount() const;
+    int trackNumber() const;
+    void setTrackNumber(int trackNumber);
+
+Q_SIGNALS:
+    void trackCountChanged(int count);
+    void currentTrackChanged(int trackNumber);
+
+private:
+    P_DECLARE_PRIVATE(AudioSourceControl)
+};
+
 } // Phonon namespace
 
 #endif // PHONON_SOURCE_CONTROL_H_
diff --git a/phonon/sourcecontrol_p.h b/phonon/sourcecontrol_p.h
index ba9985c..e1b065c 100644
--- a/phonon/sourcecontrol_p.h
+++ b/phonon/sourcecontrol_p.h
@@ -45,13 +45,49 @@ public:
 private:
     P_DECLARE_PUBLIC(SourceControl)
     Q_DISABLE_COPY(SourceControlPrivate);
+};
+
+class VideoSourceControlPrivate : public SourceControlPrivate
+{
+public:
+    explicit VideoSourceControlPrivate(Source &source);
+    virtual ~VideoSourceControlPrivate();
+
+    VideoSourceControlInterface *m_interface;
+
+    VideoSourceControl::Menu m_currentMenu;
+    int m_currentChapter;
+    int m_currentAngle;
+    int m_currentTitle;
+    bool m_autoplayTitlesEnabled;
+    int m_audioChannel;
 
 protected:
-    virtual void createBackendObject() = 0;
+    virtual void createBackendObject();
+    virtual void setupBackendObject();
 
 private:
-    P_DECLARE_PUBLIC(SourceControl)
-    Q_DISABLE_COPY(SourceControlPrivate)
+    P_DECLARE_PUBLIC(VideoSourceControl)
+    Q_DISABLE_COPY(VideoSourceControlPrivate);
+};
+
+class AudioSourceControlPrivate : public SourceControlPrivate
+{
+public:
+    explicit AudioSourceControlPrivate(Source &source);
+    virtual ~AudioSourceControlPrivate();
+
+    AudioSourceControlInterface *m_interface;
+
+    int m_currentTrack;
+
+protected:
+    virtual void createBackendObject();
+    virtual void setupBackendObject();
+
+private:
+    P_DECLARE_PUBLIC(AudioSourceControl)
+    Q_DISABLE_COPY(AudioSourceControlPrivate);
 };
 
 } // Phonon namespace
diff --git a/phonon/sourcecontrolinterface.h b/phonon/sourcecontrolinterface.h
index e51cade..b77e7eb 100644
--- a/phonon/sourcecontrolinterface.h
+++ b/phonon/sourcecontrolinterface.h
@@ -27,6 +27,8 @@
 
 #include "sourcecontrol.h"
 
+#include <QtCore/QSet>
+
 namespace Phonon
 {
 
@@ -40,8 +42,68 @@ public:
     virtual bool isActive() const = 0;
 };
 
+class VideoSourceControlInterface : public SourceControlInterface
+{
+public:
+    virtual bool supportsMenus() const = 0;
+    virtual QSet<VideoSourceControl::Menu> availableMenus() const = 0;
+    virtual VideoSourceControl::Menu currentMenu() const = 0;
+    virtual void setCurrentMenu(VideoSourceControl::Menu menu) = 0;
+
+    virtual bool supportsChapters() const = 0;
+    virtual int chapterCount() const = 0;
+    virtual int currentChapter() const = 0;
+    virtual void setCurrentChapter(int chapterNumber) = 0;
+
+    virtual bool supportsAngles() const = 0;
+    virtual int angleCount() const = 0;
+    virtual int currentAngle() = 0;
+    virtual void setCurrentAngle(int angleNumber) = 0;
+
+    virtual bool supportsTitles() const = 0;
+    virtual bool isAutoplayingTitles() const = 0;
+    virtual void setAutoplayTitles(bool enable) = 0;
+    virtual int titleCount() const = 0;
+    virtual int currentTitle() const = 0;
+    virtual void setCurrentTitle(int titleNumber) = 0;
+
+    virtual bool supportsAudioChannels() const = 0;
+    virtual int audioChannelCount() const = 0;
+    virtual int audioChannel() const = 0;
+    virtual void setAudioChannel(int channelNumber) = 0;
+
+Q_SIGNALS:
+    virtual void availableMenusChanged() = 0;
+    virtual void currentMenuChanged(VideoSourceControl::Menu menu) = 0;
+
+    virtual void chapterCountChanged(int count) = 0;
+    virtual void currentChapterChanged(int chapterNumber) = 0;
+
+    virtual void angleCountChanged(int count) = 0;
+    virtual void currentAngleChanged(int angleNumber) = 0;
+
+    virtual void titleCountChanged(int count) = 0;
+    virtual void currentTitleChanged(int titleNumber) = 0;
+
+    virtual void audioChannelCountChanged(int count) = 0;
+};
+
+class AudioSourceControlInterface : public SourceControlInterface
+{
+public:
+    virtual bool supportsTracks() const = 0;
+    virtual int trackCount() const = 0;
+    virtual int trackNumber() const = 0;
+    virtual void setTrackNumber(int trackNumber) = 0;
+
+Q_SIGNALS:
+    virtual void trackCountChanged(int count) = 0;
+    virtual void currentTrackChanged(int trackNumber) = 0;
+};
+
 } // namespace Phonon
 
-Q_DECLARE_INTERFACE(Phonon::SourceControlInterface, "0SourceControlInterface.phonon.kde.org")
+Q_DECLARE_INTERFACE(Phonon::VideoSourceControlInterface, "0VideoSourceControlInterface.phonon.kde.org")
+Q_DECLARE_INTERFACE(Phonon::AudioSourceControlInterface, "0AudioSourceControlInterface.phonon.kde.org")
 
 #endif // PHONON_SOURCE_CONTROL_INTERFACE_H_
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic