Fix lock up issue in TizenWinset widget
[framework/web/webkit-efl.git] / Source / WebCore / html / HTMLMediaElement.cpp
index ffed24c..118c94d 100755 (executable)
 #include "TizenExtensibleAPI.h"
 #endif
 
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+#include <power.h>
+#endif
+
 using namespace std;
 
 namespace WebCore {
@@ -533,6 +537,10 @@ Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode*
     HTMLElement::insertedInto(insertionPoint);
     if (insertionPoint->inDocument() && !getAttribute(srcAttr).isEmpty() && m_networkState == NETWORK_EMPTY)
         scheduleLoad(MediaResource);
+
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+    resume();
+#endif
     configureMediaControls();
     return InsertionDone;
 }
@@ -543,7 +551,11 @@ void HTMLMediaElement::removedFrom(ContainerNode* insertionPoint)
         LOG(Media, "HTMLMediaElement::removedFromDocument");
         configureMediaControls();
         if (m_networkState > NETWORK_EMPTY)
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+            suspend(PageWillBeSuspended);
+#else
             pause();
+#endif
         if (m_isFullscreen)
             exitFullscreen();
     }
@@ -1007,6 +1019,12 @@ void HTMLMediaElement::loadResource(const KURL& initialURL, ContentType& content
 
     if (!autoplay())
         m_player->setPreload(m_preload);
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+    else {
+        if (isVideo())
+            power_lock_state(POWER_STATE_NORMAL, 0);
+    }
+#endif
     m_player->setPreservesPitch(m_webkitPreservesPitch);
 
 #if !ENABLE(TIZEN_GSTREAMER_AUDIO)
@@ -1526,6 +1544,10 @@ void HTMLMediaElement::mediaEngineError(PassRefPtr<MediaError> err)
 
     // 6 - Abort the overall resource selection algorithm.
     m_currentSourceNode = 0;
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+    if (isVideo())
+        power_unlock_state(POWER_STATE_NORMAL);
+#endif
 }
 
 void HTMLMediaElement::cancelPendingEventsAndCallbacks()
@@ -1609,6 +1631,10 @@ void HTMLMediaElement::mediaLoadingFailed(MediaPlayer::NetworkState error)
 
     if (document()->page() && document()->page()->settings()->diagnosticLoggingEnabled())
         document()->page()->chrome()->client()->logDiagnosticMessage(DiagnosticLoggingKeys::mediaLoadingFailedKey(), stringForNetworkState(error), DiagnosticLoggingKeys::failKey());
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+    if (isVideo())
+        power_unlock_state(POWER_STATE_NORMAL);
+#endif
 }
 
 void HTMLMediaElement::setNetworkState(MediaPlayer::NetworkState state)
@@ -2352,6 +2378,10 @@ void HTMLMediaElement::play()
             return;
     }
 
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+    if (isVideo())
+        power_lock_state(POWER_STATE_NORMAL, 0);
+#endif
     playInternal();
 }
 
@@ -2394,6 +2424,10 @@ void HTMLMediaElement::pause()
     if (userGestureRequiredForRateChange() && !ScriptController::processingUserGesture())
         return;
 
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+    if (isVideo())
+        power_unlock_state(POWER_STATE_NORMAL);
+#endif
     pauseInternal();
 }
 
@@ -3893,6 +3927,10 @@ void HTMLMediaElement::stop()
 
     stopPeriodicTimers();
     cancelPendingEventsAndCallbacks();
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+    if (isVideo())
+        power_unlock_state(POWER_STATE_NORMAL);
+#endif
 }
 
 void HTMLMediaElement::suspend(ReasonForSuspension why)
@@ -4751,7 +4789,7 @@ bool HTMLMediaElement::shouldSuspendMedia()
     if (!m_player)
         return false;
 
-    if (isVideo())
+    if (isVideo() || hasVideo())
         return true;
 
 #if ENABLE(TIZEN_EXTENSIBLE_API)