qtinternetradio/irqmediaplayer/src/irqmmfadapter.cpp
changeset 14 896e9dbc5f19
parent 5 0930554dc389
child 17 38bbf2dcd608
--- a/qtinternetradio/irqmediaplayer/src/irqmmfadapter.cpp	Tue Jul 06 14:07:20 2010 +0300
+++ b/qtinternetradio/irqmediaplayer/src/irqmmfadapter.cpp	Wed Aug 18 09:40:26 2010 +0300
@@ -19,6 +19,8 @@
 #include <coedef.h>
 #include <QStringList>
 #include <hxmetadatakeys.h>
+#include <StereoWideningBase.h>
+
 #include "irqmetadata.h"
 #include "irqenums.h"
 #include "irqmmfadapter.h"
@@ -30,6 +32,7 @@
 const TInt KVolumeMinPercentage  = 0;              // Minimum volume percentage
 const TInt KVolumeMaxPercentage  = 100;            // Maximum volume percentage
 const TInt KLoadingCompletePercentage = 100;       // Loading Complete percentage
+const int KDefaultStereoLevel = 100;            // Default stereo level
 
 // ---------------------------------------------------------------------------
 //  IRQMMFAdapter::IRQMMFAdapter
@@ -40,7 +43,7 @@
 IRQMMFAdapter::IRQMMFAdapter() :
     iVideoPlayer(NULL)
     ,iQMetaData(NULL)
-    ,iPrepareTimer(NULL)
+    ,iPrepareTimer(NULL), iStereoEffect(NULL)
 {
     iPlayState = EStopped;
 }
@@ -67,6 +70,9 @@
         delete iPrepareTimer;
         iPrepareTimer = NULL;
     }
+    
+    delete iStereoEffect;
+    iStereoEffect = NULL;
 }
 
 // ---------------------------------------------------------------------------
@@ -209,6 +215,33 @@
     return (void*)iVideoPlayer;
 }
 
+void IRQMMFAdapter::enableStereoEffect()
+{
+    if (IRQPlayerAdapterInterface::EPlaying != iPlayState)
+    {
+        return;
+    }
+
+    TRAP_IGNORE(enableStereoEffectL());
+}
+
+void IRQMMFAdapter::disableStereoEffect()
+{
+    if (iStereoEffect)
+    {
+        if (iStereoEffect->IsEnabled())
+        {
+            TRAPD(error, iStereoEffect->DisableL());
+            if (KErrNone != error)
+            {
+                emit errorOccured(EIRQPlayerErrorSetStereoFailed);
+            }
+            delete iStereoEffect;
+            iStereoEffect = NULL;
+        }
+    }
+}
+
 // ---------------------------------------------------------------------------
 //  IRQMMFAdapter::MvpuoOpenComplete
 //  Callback function, MVideoPlayerUtilityObserver method
@@ -530,3 +563,22 @@
         stop();
     }
 }
+
+void IRQMMFAdapter::enableStereoEffectL()
+{
+    LOG_METHOD;
+    TUint stereoLevel = KDefaultStereoLevel;
+
+    if (!iStereoEffect)
+    {
+        CVideoPlayerUtility* playerInstance = (CVideoPlayerUtility*)getPlayerInstance();
+        iStereoEffect = CStereoWidening::NewL(*playerInstance, EFalse, stereoLevel);
+    }
+
+    if (!iStereoEffect->IsEnabled())
+    {
+        iStereoEffect->EnableL();
+        iStereoEffect->SetStereoWideningLevelL(stereoLevel);
+        iStereoEffect->ApplyL();
+    }
+}