Added qmafw-gst-subtitles-renderer-0.0.55 for Meego Harmattan 1.2
[mafwsubrenderer] / qmafw-gst-subtitles-renderer / src / MafwGstRendererDolby.cpp
diff --git a/qmafw-gst-subtitles-renderer/src/MafwGstRendererDolby.cpp b/qmafw-gst-subtitles-renderer/src/MafwGstRendererDolby.cpp
new file mode 100644 (file)
index 0000000..91a6fa0
--- /dev/null
@@ -0,0 +1,312 @@
+/*
+ * This file is part of QMAFW
+ *
+ * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights
+ * reserved.
+ *
+ * Contact: Visa Smolander <visa.smolander@nokia.com>
+ *
+ * This software, including documentation, is protected by copyright controlled
+ * by Nokia Corporation. All rights are reserved. Copying, including
+ * reproducing, storing, adapting or translating, any or all of this material
+ * requires the prior written consent of Nokia Corporation. This material also
+ * contains confidential information which may not be disclosed to others
+ * without the prior written consent of Nokia.
+ *
+ */
+
+#include "MafwGstRendererDolby.h"
+
+#include <QDebug>
+
+const int DEFAULT_COLOR = 2;
+const int DEFAULT_ROOM_SIZE = 2;
+const int MAX_VALUE = 4;
+
+enum MafwDolbyStates
+{
+    MafwDolbyOff,
+    MafwDolbyOn,
+    MafwDolbyAuto
+};
+
+MafwGstRendererDolby::MafwGstRendererDolby( QObject* parent ):
+        QObject(parent),
+        m_dolbyConfMusic(0),
+        m_dolbyConfMusicRoom(0),
+        m_dolbyConfMusicColor(0),
+        m_dolbyConfVideo(0),
+        m_dolbyConfVideoRoom(0),
+        m_dolbyConfVideoColor(0)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+    m_currentMusicDolbyState = MafwDolbyOff;
+    m_currentMusicDolbyRoom = DEFAULT_ROOM_SIZE;
+    m_currentMusicDolbyColor = DEFAULT_COLOR;
+    m_currentVideoDolbyState = MafwDolbyOff;
+    m_currentVideoDolbyRoom = DEFAULT_ROOM_SIZE;
+    m_currentVideoDolbyColor = DEFAULT_COLOR;
+}
+
+void MafwGstRendererDolby::initialize()
+{
+    if (!m_dolbyConfMusic)
+    {
+        m_dolbyConfMusic = new GConfItem("/apps/Multimedia/music/dolbyConf", this);
+    }
+    if (!m_dolbyConfMusicRoom)
+    {
+        m_dolbyConfMusicRoom = new GConfItem("/apps/Multimedia/music/dolbyConfRoom", this);
+    }
+    if (!m_dolbyConfMusicColor)
+    {
+        m_dolbyConfMusicColor = new GConfItem("/apps/Multimedia/music/dolbyConfColor", this);
+    }
+    if (!m_dolbyConfVideo)
+    {
+        m_dolbyConfVideo = new GConfItem("/apps/Multimedia/video/dolbyConf", this);
+    }
+    if (!m_dolbyConfVideoRoom)
+    {
+        m_dolbyConfVideoRoom = new GConfItem("/apps/Multimedia/video/dolbyConfRoom", this);
+    }
+    if (!m_dolbyConfVideoColor)
+    {
+        m_dolbyConfVideoColor = new GConfItem("/apps/Multimedia/video/dolbyConfColor", this);
+    }
+    if (!m_dolbyConfMusic->value().toString().isEmpty())
+    {
+        valueMusicChanged();
+        connect(m_dolbyConfMusic, SIGNAL(valueChanged()), this, SLOT(valueMusicChanged()));
+        connect(m_dolbyConfMusicRoom, SIGNAL(valueChanged()), this, SLOT(valueMusicChanged()));
+        connect(m_dolbyConfMusicColor, SIGNAL(valueChanged()), this, SLOT(valueMusicChanged()));
+    }
+    if (!m_dolbyConfVideo->value().toString().isEmpty())
+    {
+        valueVideoChanged();
+        connect(m_dolbyConfVideo, SIGNAL(valueChanged()), this, SLOT(valueVideoChanged()));
+        connect(m_dolbyConfVideoRoom, SIGNAL(valueChanged()), this, SLOT(valueVideoChanged()));
+        connect(m_dolbyConfVideoColor, SIGNAL(valueChanged()), this, SLOT(valueVideoChanged()));
+    }
+}
+
+MafwGstRendererDolby::~MafwGstRendererDolby()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+}
+
+bool MafwGstRendererDolby::setMusicDolbyState (uint value)
+{
+    qDebug() << __PRETTY_FUNCTION__ << value;
+    if ( value <= MafwDolbyAuto)
+    {
+        m_currentMusicDolbyState = value;
+        m_dolbyConfMusic->set(m_currentMusicDolbyState);
+        return true;
+    }
+    else
+    {
+        m_currentMusicDolbyState = MafwDolbyOff;
+        m_dolbyConfMusic->set(m_currentMusicDolbyState);
+        return false;
+    }
+}
+
+bool MafwGstRendererDolby::setMusicDolbyRoom (int value)
+{
+    qDebug() << __PRETTY_FUNCTION__ << value;
+    if ( value < 0)
+    {
+        m_currentMusicDolbyRoom = 0;
+        m_dolbyConfMusicRoom->set(m_currentMusicDolbyRoom);
+    }
+    else if ( value > MAX_VALUE)
+    {
+        m_currentMusicDolbyRoom = MAX_VALUE;
+        m_dolbyConfMusicRoom->set(m_currentMusicDolbyRoom);
+    }
+    else
+    {
+        m_currentMusicDolbyRoom = value;
+        m_dolbyConfMusicRoom->set(m_currentMusicDolbyRoom);
+    }
+    return true;
+}
+
+bool MafwGstRendererDolby::setMusicDolbyColor (int value)
+{
+    qDebug() << __PRETTY_FUNCTION__ << value;
+    if ( value < 0)
+    {
+        m_currentMusicDolbyColor = 0;
+        m_dolbyConfMusicColor->set(m_currentMusicDolbyColor);
+    }
+    else if ( value > MAX_VALUE)
+    {
+        m_currentMusicDolbyColor = MAX_VALUE;
+        m_dolbyConfMusicColor->set(m_currentMusicDolbyColor);
+    }
+    else
+    {
+        m_currentMusicDolbyColor = value;
+        m_dolbyConfMusicColor->set(m_currentMusicDolbyColor);
+    }
+    return true;
+}
+
+bool MafwGstRendererDolby::setVideoDolbyState (uint value)
+{
+    qDebug() << __PRETTY_FUNCTION__ << value;
+    if ( value <= MafwDolbyAuto)
+    {
+        m_currentVideoDolbyState = value;
+        m_dolbyConfVideo->set(int(m_currentVideoDolbyState));
+        return true;
+    }
+    else
+    {
+        m_currentVideoDolbyState = MafwDolbyOff;
+        m_dolbyConfVideo->set(int(m_currentVideoDolbyState));
+        return false;
+    }
+}
+
+bool MafwGstRendererDolby::setVideoDolbyRoom (int value)
+{
+    qDebug() << __PRETTY_FUNCTION__ << value;
+    if ( value < 0)
+    {
+        m_currentVideoDolbyRoom = 0;
+        m_dolbyConfVideoRoom->set(m_currentVideoDolbyRoom);
+    }
+    else if ( value > MAX_VALUE)
+    {
+        m_currentVideoDolbyRoom = MAX_VALUE;
+        m_dolbyConfVideoRoom->set(m_currentVideoDolbyRoom);
+    }
+    else
+    {
+        m_currentVideoDolbyRoom = value;
+        m_dolbyConfVideoRoom->set(m_currentVideoDolbyRoom);
+    }
+    return true;
+}
+
+bool MafwGstRendererDolby::setVideoDolbyColor (int value)
+{
+    qDebug() << __PRETTY_FUNCTION__ << value;
+    if ( value < 0)
+    {
+        m_currentVideoDolbyColor = 0;
+        m_dolbyConfVideoColor->set(m_currentVideoDolbyColor);
+    }
+    else if ( value > MAX_VALUE)
+    {
+        m_currentVideoDolbyColor = MAX_VALUE;
+        m_dolbyConfVideoColor->set(m_currentVideoDolbyColor);
+    }
+    else
+    {
+        m_currentVideoDolbyColor = value;
+        m_dolbyConfVideoColor->set(m_currentVideoDolbyColor);
+    }
+    return true;
+}
+
+void MafwGstRendererDolby::valueMusicChanged()
+{
+    m_currentMusicDolbyState = m_dolbyConfMusic->value().toUInt();
+    if (!(m_currentMusicDolbyState <= MafwDolbyAuto))
+    {
+        m_currentMusicDolbyState = MafwDolbyOff;
+        m_currentMusicDolbyRoom = m_dolbyConfMusicRoom->value().toInt();
+        if (m_currentMusicDolbyRoom < 0)
+        {
+            m_currentMusicDolbyRoom = 0;
+        }
+        if (m_currentMusicDolbyRoom > MAX_VALUE)
+        {
+            m_currentMusicDolbyRoom = MAX_VALUE;
+        }
+        m_currentMusicDolbyColor = m_dolbyConfMusicColor->value().toInt();
+        if (m_currentMusicDolbyColor < 0)
+        {
+            m_currentMusicDolbyColor = 0;
+        }
+        if (m_currentMusicDolbyColor > MAX_VALUE)
+        {
+            m_currentMusicDolbyColor = MAX_VALUE;
+        }
+    }
+    qDebug() << __PRETTY_FUNCTION__ << "state" << m_currentMusicDolbyState;
+    qDebug() << __PRETTY_FUNCTION__ << "room" << m_currentMusicDolbyRoom;
+    qDebug() << __PRETTY_FUNCTION__ << "color" << m_currentMusicDolbyColor;
+   Q_EMIT mafwDHMMusicPropertyChanged();
+}
+
+void MafwGstRendererDolby::valueVideoChanged()
+{
+    m_currentVideoDolbyState = m_dolbyConfVideo->value().toUInt();
+    if (!(m_currentVideoDolbyState <= MafwDolbyAuto))
+    {
+        m_currentVideoDolbyState = MafwDolbyOff;
+        m_currentVideoDolbyRoom = m_dolbyConfVideoRoom->value().toInt();
+        if (m_currentVideoDolbyRoom < 0)
+        {
+            m_currentVideoDolbyRoom = 0;
+        }
+        if (m_currentVideoDolbyRoom > MAX_VALUE)
+        {
+            m_currentVideoDolbyRoom = MAX_VALUE;
+        }
+        m_currentVideoDolbyColor = m_dolbyConfVideoColor->value().toInt();
+        if (m_currentVideoDolbyColor < 0)
+        {
+            m_currentVideoDolbyColor = 0;
+        }
+        if (m_currentVideoDolbyColor > MAX_VALUE)
+        {
+            m_currentVideoDolbyColor = MAX_VALUE;
+        }
+    }
+    qDebug() << __PRETTY_FUNCTION__ << "state" << m_currentVideoDolbyState;
+    qDebug() << __PRETTY_FUNCTION__ << "room" << m_currentVideoDolbyRoom;
+    qDebug() << __PRETTY_FUNCTION__ << "color" << m_currentVideoDolbyColor;
+   Q_EMIT mafwDHMVideoPropertyChanged();
+}
+
+uint MafwGstRendererDolby::getMusicDolbyState ()
+{
+    qDebug() << __PRETTY_FUNCTION__ << m_currentMusicDolbyState;
+    return m_currentMusicDolbyState;
+}
+
+int MafwGstRendererDolby::getMusicDolbyRoom ()
+{
+    qDebug() << __PRETTY_FUNCTION__ << m_currentMusicDolbyRoom;
+    return m_currentMusicDolbyRoom;
+}
+
+int MafwGstRendererDolby::getMusicDolbyColor ()
+{
+    qDebug() << __PRETTY_FUNCTION__ << m_currentMusicDolbyColor;
+    return m_currentMusicDolbyColor;
+}
+
+uint MafwGstRendererDolby::getVideoDolbyState ()
+{
+    qDebug() << __PRETTY_FUNCTION__ << m_currentVideoDolbyState;
+    return m_currentVideoDolbyState;
+}
+
+int MafwGstRendererDolby::getVideoDolbyRoom ()
+{
+    qDebug() << __PRETTY_FUNCTION__ << m_currentVideoDolbyRoom;
+    return m_currentVideoDolbyRoom;
+}
+
+int MafwGstRendererDolby::getVideoDolbyColor ()
+{
+    qDebug() << __PRETTY_FUNCTION__ << m_currentVideoDolbyColor;
+    return m_currentVideoDolbyColor;
+}