Volume key scenario has been applied for media element and webaudio.
authorkeonho07.kim <keonho07.kim@samsung.com>
Thu, 25 Apr 2013 16:41:18 +0000 (01:41 +0900)
committerkeonho07.kim <keonho07.kim@samsung.com>
Thu, 25 Apr 2013 17:05:57 +0000 (02:05 +0900)
[Title] Volume key senario has been applied for media element and webaudio.
[Problem] DCM-1102
[Cause] N/A
[Solution] N/A

Change-Id: Ib1c2a5da00aaccad87b3cdda492701b26517ae5f

15 files changed:
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/PlatformTizen.cmake
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp
Source/WebCore/platform/audio/gstreamer/tizen/AudioSessionManagerGStreamerTizen.cpp
Source/WebCore/platform/audio/gstreamer/tizen/AudioSessionManagerGStreamerTizen.h
Source/WebCore/platform/efl/tizen/TizenExtensibleAPI.cpp
Source/WebCore/platform/efl/tizen/TizenExtensibleAPI.h
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebKit2/UIProcess/API/C/WKContext.h
Source/WebKit2/UIProcess/API/efl/ewk_context.h
Source/cmake/OptionsTizen.cmake
packaging/webkit2-efl.spec

index fdcbd45..bb4fa28 100644 (file)
@@ -141,6 +141,10 @@ AudioContext::AudioContext(Document* document)
     // It's not that useful to have a callback function for this since the audio thread automatically starts rendering on the graph
     // when this has finished (see AudioDestinationNode).
     m_hrtfDatabaseLoader = HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(sampleRate());
+
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
+    document->incrementActiveMediaObjectCount();
+#endif
 }
 
 // Constructor for offline (non-realtime) rendering.
@@ -246,7 +250,7 @@ void AudioContext::uninitialize()
         return;
 
 #if ENABLE(TIZEN_WEB_AUDIO)
-        m_isInitialized = false;
+    m_isInitialized = false;
 #endif
 
         // This stops the audio thread and all audio rendering.
@@ -298,6 +302,11 @@ void AudioContext::stop()
     // Usually ScriptExecutionContext calls stop twice.
     if (m_isStopScheduled)
         return;
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
+    Document* document =  static_cast<Document*>(scriptExecutionContext());
+    if (!isOfflineContext())
+        document->decrementActiveMediaObjectCount();
+#endif
     m_isStopScheduled = true;
 
     // Don't call uninitialize() immediately here because the ScriptExecutionContext is in the middle
index c353d57..60e8a96 100755 (executable)
@@ -20,6 +20,7 @@ LIST(APPEND WebCore_INCLUDE_DIRECTORIES
     ${LevelDB_INCLUDE_DIRS}
     ${LevelDB-MemEnv_INCLUDE_DIRS}
     ${Libavcodec_INCLUDE_DIR}
+    ${MMSOUND_INCLUDE_DIRS}
     ${MM-Player_INCLUDE_DIRS}
     ${OPENSSL_INCLUDE_DIRS}
     ${Pmapi_INCLUDE_DIRS}
@@ -39,6 +40,7 @@ LIST(APPEND WebCore_LIBRARIES
     ${LevelDB_LIBRARIES}
     ${LevelDB-MemEnv_LIBRARIES}
     ${Libavcodec_LIBS}
+    ${MMSOUND_LIBRARIES}
     ${MM-Player_LIBRARIES}
     ${OPENSSL_LIBRARIES}
     ${Pmapi_LIBRARIES}
index 0becdd2..3d0ba78 100755 (executable)
 #include "TizenExtensibleAPI.h"
 #endif
 
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
+#include "AudioSessionManagerGStreamerTizen.h"
+#endif
+
 using namespace std;
 using namespace WTF;
 using namespace Unicode;
@@ -502,6 +506,9 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
 #ifndef NDEBUG
     , m_didDispatchViewportPropertiesChanged(false)
 #endif
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
+    , m_activeMediaObjectCount(0)
+#endif
 {
     m_document = this;
 
@@ -1648,6 +1655,14 @@ bool Document::webkitHidden() const
 
 void Document::dispatchVisibilityStateChangeEvent()
 {
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
+    if (m_activeMediaObjectCount) {
+        if (!webkitHidden())
+            AudioSessionManagerGStreamerTizen::setVolumeSessionToMediaType();
+        else
+            AudioSessionManagerGStreamerTizen::clearVolumeSessionFromMediaType();
+    }
+#endif
     dispatchEvent(Event::create(eventNames().webkitvisibilitychangeEvent, false, false));
 }
 #endif
@@ -6176,4 +6191,19 @@ PassRefPtr<UndoManager> Document::undoManager()
 }
 #endif
 
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
+void Document::incrementActiveMediaObjectCount()
+{
+    if (!m_activeMediaObjectCount)
+        AudioSessionManagerGStreamerTizen::setVolumeSessionToMediaType();
+    atomicIncrement(&m_activeMediaObjectCount);
+}
+
+void Document::decrementActiveMediaObjectCount()
+{
+    atomicDecrement(&m_activeMediaObjectCount);
+    if (!m_activeMediaObjectCount)
+        AudioSessionManagerGStreamerTizen::clearVolumeSessionFromMediaType();
+}
+#endif
 } // namespace WebCore
index 3aeb586..3d7954f 100644 (file)
@@ -418,6 +418,10 @@ public:
     String webkitVisibilityState() const;
     bool webkitHidden() const;
     void dispatchVisibilityStateChangeEvent();
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
+    void incrementActiveMediaObjectCount();
+    void decrementActiveMediaObjectCount();
+#endif
 #endif
 
 #if ENABLE(CSP_NEXT)
@@ -1561,6 +1565,9 @@ private:
 #ifndef NDEBUG
     bool m_didDispatchViewportPropertiesChanged;
 #endif
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
+    int m_activeMediaObjectCount;
+#endif
 };
 
 // Put these methods here, because they require the Document definition, but we really want to inline them.
index a18a7a3..91a4425 100755 (executable)
@@ -290,6 +290,10 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tagName, Document* docum
 
     setHasCustomCallbacks();
     addElementToDocumentMap(this, document);
+
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
+    document->incrementActiveMediaObjectCount();
+#endif
 }
 
 HTMLMediaElement::~HTMLMediaElement()
@@ -317,6 +321,10 @@ HTMLMediaElement::~HTMLMediaElement()
     m_completelyLoaded = true;
     if (m_player)
         m_player->clearMediaPlayerClient();
+
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
+    document()->decrementActiveMediaObjectCount();
+#endif
 }
 
 void HTMLMediaElement::didMoveToNewDocument(Document* oldDocument)
@@ -370,7 +378,7 @@ void HTMLMediaElement::parseAttribute(const Attribute& attribute)
     else if (attribute.name() == loopAttr)
         updateDisableSleep();
 #endif
-#if ENABLE(TIZEN_MEDIA_STREAM)
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
     else if (attribute.name() == mutedAttr)
             m_muted = true;
 #endif
@@ -1001,7 +1009,7 @@ void HTMLMediaElement::loadResource(const KURL& initialURL, ContentType& content
         m_player->setPreload(m_preload);
     m_player->setPreservesPitch(m_webkitPreservesPitch);
 
-#if !ENABLE(TIZEN_MEDIA_STREAM)
+#if !ENABLE(TIZEN_GSTREAMER_AUDIO)
     if (fastHasAttribute(mutedAttr))
         m_muted = true;
     updateVolume();
@@ -1010,7 +1018,7 @@ void HTMLMediaElement::loadResource(const KURL& initialURL, ContentType& content
     if (!m_player->load(url, contentType, keySystem))
         mediaLoadingFailed(MediaPlayer::FormatError);
 
-#if ENABLE(TIZEN_MEDIA_STREAM)
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
     updateVolume();
 #endif
 
index 9df5401..a45dd23 100755 (executable)
@@ -204,6 +204,11 @@ void AudioDestinationGStreamer::finishBuildingPipelineAfterWavParserPadReady(Gst
         m_audioSinkAvailable = false;
         return;
     }
+#if ENABLE(TIZEN_WEB_AUDIO)
+    GValue value;
+    g_value_set_boolean(&value, true);
+    gst_child_proxy_set_property(GST_OBJECT(audioSink.get()), "close-handle-on-prepare", &value);
+#endif
 
     GstElement* audioConvert = gst_element_factory_make("audioconvert", 0);
     gst_bin_add_many(GST_BIN(m_pipeline), audioConvert, audioSink.get(), NULL);
index 19522c6..dd758a9 100644 (file)
 #if ENABLE(TIZEN_GSTREAMER_AUDIO)
 
 #include <unistd.h>
+#include <mm_sound.h>
+#if ENABLE(TIZEN_EXTENSIBLE_API)
+#include "TizenExtensibleAPI.h"
+#endif
+
+namespace WebCore {
 
+void AudioSessionManagerGStreamerTizen::setVolumeSessionToMediaType()
+{
+    volume_type_t volumeType;
+#if ENABLE(TIZEN_EXTENSIBLE_API)
+    if (TizenExtensibleAPI::extensibleAPI().mediaStreamRecord()) {
+        mm_sound_volume_get_current_playing_type(&volumeType);
+        if (volumeType != VOLUME_TYPE_MEDIA)
+            mm_sound_volume_primary_type_set(VOLUME_TYPE_MEDIA);
+    }
+#endif
+}
+
+void AudioSessionManagerGStreamerTizen::clearVolumeSessionFromMediaType()
+{
+#if ENABLE(TIZEN_EXTENSIBLE_API)
+    if (TizenExtensibleAPI::extensibleAPI().mediaStreamRecord())
+        mm_sound_volume_primary_type_clear();
+#endif
+}
+\r
 AudioSessionManagerGStreamerTizen::AudioSessionManagerGStreamerTizen()
     : m_eventType(ASM_EVENT_NONE)
     , m_handle(-1)
@@ -117,4 +143,5 @@ ASM_sound_events_t AudioSessionManagerGStreamerTizen::interpretSessionToEvent(MM
         return ASM_EVENT_NONE;
     }
 }
+}
 #endif
index 073dbc8..15d174d 100644 (file)
@@ -39,7 +39,7 @@
 #include <mm_session_private.h>
 #include <wtf/Forward.h>
 
-using namespace WebCore;
+namespace WebCore {
 
 class AudioSessionManagerGStreamerTizen : public RefCounted<AudioSessionManagerGStreamerTizen> {
 public:
@@ -48,6 +48,9 @@ public:
         return adoptRef(new AudioSessionManagerGStreamerTizen());
     }
 
+    static void setVolumeSessionToMediaType();
+    static void clearVolumeSessionFromMediaType();
+
     ~AudioSessionManagerGStreamerTizen();
 
     bool registerAudioSessionManager(MMSessionType, ASM_sound_cb_t, void*);
@@ -67,5 +70,6 @@ private:
     MMSessionType m_sessionType;
     ASM_sound_states_t m_stateType;
 };
+}
 #endif
 #endif
index a5f8f87..ead542f 100644 (file)
@@ -51,6 +51,7 @@ TizenExtensibleAPI::TizenExtensibleAPI()
     , m_encryptDatabase(false)
     , m_fullScreen(false)
     , m_mediaStreamRecord(false)
+    , m_mediaVolumeControl(false)
     , m_rotateCameraView(true)
 {
 }
@@ -73,6 +74,9 @@ void TizenExtensibleAPI::setTizenExtensibleAPI(ExtensibleAPI extensibleAPI, bool
         case MediaStreamRecord:
             m_mediaStreamRecord = enable;
             break;
+        case MediaVolumeControl:
+            m_mediaVolumeControl = enable;
+            break;
         case RotateCameraView:
             m_rotateCameraView = enable;
             break;
index 0b7f492..c7b9baa 100644 (file)
@@ -36,6 +36,7 @@ enum _ExtensibleAPI {
     EncryptionDatabase,
     FullScreen,
     MediaStreamRecord,
+    MediaVolumeControl,
     RotateCameraView
 };
 typedef enum _ExtensibleAPI ExtensibleAPI;
@@ -50,6 +51,7 @@ public:
     bool encryptDatabase() const { return m_encryptDatabase; }
     bool fullScreen() const { return m_fullScreen; }
     bool mediaStreamRecord() const { return m_mediaStreamRecord; }
+    bool mediaVolumeControl() const { return m_mediaVolumeControl; }
     bool rotateCameraView() const { return m_rotateCameraView; }
 
     void setTizenExtensibleAPI(ExtensibleAPI, bool enable);
@@ -62,6 +64,7 @@ private:
     bool m_encryptDatabase;
     bool m_fullScreen;
     bool m_mediaStreamRecord;
+    bool m_mediaVolumeControl;
     bool m_rotateCameraView;
 };
 
index 660d8f9..c807a59 100755 (executable)
@@ -412,13 +412,13 @@ MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer()
         m_playBin = 0;
     }
 
+    m_player = 0;
+
 #if ENABLE(TIZEN_GSTREAMER_AUDIO)
     if (m_audioSessionManager)
         m_audioSessionManager->setSoundState(ASM_STATE_STOP);
 #endif
 
-    m_player = 0;
-
     if (m_muteTimerHandler)
         g_source_remove(m_muteTimerHandler);
 
@@ -2286,16 +2286,13 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin()
         g_object_set(m_playBin.get(), "video-sink", fakeSink, NULL);
     }
 #endif
-
-#if ENABLE(TIZEN_GSTREAMER_AUDIO)
-    if (m_audioSessionManager)
-        m_audioSessionManager->registerAudioSessionManager(MM_SESSION_TYPE_SHARE, mediaPlayerPrivateAudioSessionNotifyCallback, player());
-#endif
-
 #if ENABLE(TIZEN_GSTREAMER_AUDIO)
     GstElement* realSink = gst_element_factory_make("avsysaudiosink", 0);
     g_object_set(realSink, "close-handle-on-prepare", 1, NULL);
     g_object_set(m_playBin.get(), "audio-sink", realSink, NULL);
+
+    if (m_audioSessionManager)
+        m_audioSessionManager->registerAudioSessionManager(MM_SESSION_TYPE_SHARE, mediaPlayerPrivateAudioSessionNotifyCallback, player());
 #else
     createAudioSink();
 #endif
index 85dbb26..4212196 100644 (file)
@@ -46,6 +46,7 @@ enum {
     kWKTizenExtensibleAPIEncryptionDatabase,
     kWKTizenExtensibleAPIFullScreen,
     kWKTizenExtensibleAPIMediaStreamRecord,
+    kWKTizenExtensibleAPIMediaVolumeControl,
     kWKTizenExtensibleAPIRotateCameraView
 };
 typedef uint32_t WKTizenExtensibleAPI;
index 6be76ae..667dad8 100755 (executable)
@@ -57,6 +57,7 @@ enum Ewk_Extensible_API {
     EWK_EXTENSIBLE_API_ENCRYPTION_DATABASE,
     EWK_EXTENSIBLE_API_FULL_SCREEN,
     EWK_EXTENSIBLE_API_MEDIA_STREAM_RECORD,
+    EWK_EXTENSIBLE_API_MEDIA_VOLUME_CONTROL,
     EWK_EXTENSIBLE_API_ROTATE_CAMERA_VIEW
 };
 /// Creates a type name for @a _Ewk_Extensible_API.
index 82a7c0c..f926e25 100644 (file)
@@ -356,6 +356,7 @@ IF (ENABLE_VIDEO)
     FIND_PACKAGE(GStreamer REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
     FIND_PACKAGE(ASM REQUIRED)
     FIND_PACKAGE(SESSION REQUIRED)
+    FIND_PACKAGE(MMSOUND REQUIRED)
 
     SET(WTF_USE_GSTREAMER 1)
     ADD_DEFINITIONS(-DWTF_USE_GSTREAMER=1)
index edacc10..f70864e 100644 (file)
@@ -42,6 +42,7 @@ BuildRequires: pkgconfig(location)
 BuildRequires: pkgconfig(mmutil-imgp)
 BuildRequires: pkgconfig(mmutil-jpeg)
 BuildRequires: pkgconfig(mm-session)
+BuildRequires: pkgconfig(mm-sound)
 BuildRequires: pkgconfig(sqlite3)
 BuildRequires: pkgconfig(utilX)
 BuildRequires: pkgconfig(vconf)