#include "TizenExtensibleAPI.h"
#endif
-#if ENABLE(TIZEN_DEVICE_ROTATION)
-#include <vconf.h>
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+#include <power.h>
#endif
using namespace std;
static const char* mediaSourceURLProtocol = "x-media-source";
#endif
-#if ENABLE(TIZEN_DEVICE_ROTATION)
-#define RADIAN_VALUE (57.2957)
-
-enum {
- ROTATE_0,
- ROTATE_90,
- ROTATE_180,
- ROTATE_270,
- ROTATE_ERROR
-};
-#endif
-
using namespace HTMLNames;
using namespace std;
#if ENABLE(TIZEN_GSTREAMER_VIDEO)
, m_suspended(false)
#endif
-#if ENABLE(TIZEN_DEVICE_ROTATION)
- , m_rotation(ROTATE_0)
-#endif
{
LOG(Media, "HTMLMediaElement::HTMLMediaElement");
document->registerForMediaVolumeCallbacks(this);
setHasCustomCallbacks();
addElementToDocumentMap(this, document);
-#if ENABLE(TIZEN_DEVICE_ROTATION)
- registerRotationCallback();
+
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
+ document->incrementActiveMediaObjectCount();
#endif
}
m_mediaController->removeMediaElement(this);
removeElementFromDocumentMap(this, document());
-#if ENABLE(TIZEN_DEVICE_ROTATION)
- unregisterRotationCallback();
-#endif
-}
-
-#if ENABLE(TIZEN_DEVICE_ROTATION)
-bool HTMLMediaElement::isHorizontal()
-{
- return (m_rotation == ROTATE_90 || m_rotation == ROTATE_270) ? true : false;
-}
-
-bool HTMLMediaElement::isVertical()
-{
- return (m_rotation == ROTATE_0 || m_rotation == ROTATE_180) ? true : false;
-}
-
-void HTMLMediaElement::registerRotationCallback()
-{
- sensor_create(&m_handle);
- sensor_accelerometer_set_cb(m_handle, 100, onRotationChanged, this);
- sensor_start(m_handle, SENSOR_ACCELEROMETER);
-
- return;
-}
-void HTMLMediaElement::unregisterRotationCallback()
-{
- sensor_accelerometer_unset_cb(m_handle);
- sensor_stop(m_handle, SENSOR_ACCELEROMETER);
- sensor_destroy(m_handle);
-
- return;
-}
-
-int HTMLMediaElement::calcRotation(float x, float y, float z)
-{
- double atanV, normZ, rawZ;
- int accTheta, accPitch;
- int rotation;
-
- atanV = atan2(y, x);
- accTheta = static_cast<int>(atanV * (RADIAN_VALUE) + 270) % 360;
- rawZ = static_cast<double>(z / (0.004 * 9.81));
-
- if (rawZ > 250)
- normZ = 1.0;
- else if (rawZ < -250)
- normZ = -1.0;
- else
- normZ = (static_cast<double>(rawZ)) / 250;
-
- accPitch = static_cast<int>(acos(normZ) * (RADIAN_VALUE));
-
- if ((accPitch > 35) && (accPitch < 145)) {
- if ((accTheta >= 315 && accTheta <= 359) || (accTheta >= 0 && accTheta < 45))
- rotation = ROTATE_0;
- else if (accTheta >= 45 && accTheta < 135)
- rotation = ROTATE_90;
- else if (accTheta >= 135 && accTheta < 225)
- rotation = ROTATE_180;
- else if (accTheta >= 225 && accTheta < 315)
- rotation = ROTATE_270;
- else
- rotation = ROTATE_ERROR;
- } else
- rotation = ROTATE_ERROR;
-
- return rotation;
-}
-
-void HTMLMediaElement::onRotationChanged(uint64_t timeStamp, sensor_data_accuracy_e accuracy, float x, float y, float z, void* userData)
-{
- HTMLMediaElement* that = static_cast<HTMLMediaElement*>(userData);
-
- int autoRotation = 0;
- vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &autoRotation);
- if (!autoRotation)
- return;
-
- int rotation = that->calcRotation(x, y, z);
- if (rotation == ROTATE_ERROR || rotation == that->m_rotation)
- return;
+ m_completelyLoaded = true;
+ if (m_player)
+ m_player->clearMediaPlayerClient();
- that->m_rotation = rotation;
-}
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
+ document()->decrementActiveMediaObjectCount();
#endif
+}
void HTMLMediaElement::didMoveToNewDocument(Document* oldDocument)
{
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
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_MEDIA_STREAM)
+#if !ENABLE(TIZEN_GSTREAMER_AUDIO)
if (fastHasAttribute(mutedAttr))
m_muted = true;
updateVolume();
if (!m_player->load(url, contentType, keySystem))
mediaLoadingFailed(MediaPlayer::FormatError);
-#if ENABLE(TIZEN_MEDIA_STREAM)
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
updateVolume();
#endif
// 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()
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)
void HTMLMediaElement::refreshCachedTime() const
{
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+ if (m_player->currentTime() > 0.0f || m_cachedTime == MediaPlayer::invalidTime())
+#endif
m_cachedTime = m_player->currentTime();
m_cachedTimeWallClockUpdateTime = WTF::currentTime();
}
static const double minimumTimePlayingBeforeCacheSnapshot = 0.5;
m_minimumWallClockTimeToCacheMediaTime = WTF::currentTime() + minimumTimePlayingBeforeCacheSnapshot;
+#if !ENABLE(TIZEN_GSTREAMER_VIDEO)
m_cachedTime = MediaPlayer::invalidTime();
+#endif
}
// playback state
return;
}
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+ if (isVideo())
+ power_lock_state(POWER_STATE_NORMAL, 0);
+#endif
playInternal();
}
if (userGestureRequiredForRateChange() && !ScriptController::processingUserGesture())
return;
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+ if (isVideo())
+ power_unlock_state(POWER_STATE_NORMAL);
+#endif
pauseInternal();
}
stopPeriodicTimers();
cancelPendingEventsAndCallbacks();
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+ if (isVideo())
+ power_unlock_state(POWER_STATE_NORMAL);
+#endif
}
void HTMLMediaElement::suspend(ReasonForSuspension why)
#if ENABLE(FULLSCREEN_API)
if (document() && document()->settings() && document()->settings()->fullScreenEnabled()) {
document()->requestFullScreenForElement(this, 0, Document::ExemptIFrameAllowFullScreenRequirement);
+#if ENABLE(TIZEN_FULLSCREEN_API)
+ if (hasMediaControls())
+ mediaControls()->updateMediaControlScale();
+#endif
return;
}
#endif
}
}
+#if ENABLE(TIZEN_FULLSCREEN_API)
+void HTMLMediaElement::updateMediaControlsStyle(bool needsRecalc)
+{
+ if (hasMediaControls())
+ mediaControls()->updateMediaControlScale();
+
+ if (needsRecalc)
+ recalcStyle(Node::Force);
+}
+#endif
+
void HTMLMediaElement::didBecomeFullscreenElement()
{
if (hasMediaControls())
controls->setMediaController(m_mediaController ? m_mediaController.get() : static_cast<MediaControllerInterface*>(this));
controls->reset();
+#if ENABLE(TIZEN_FULLSCREEN_API)
+ if (isFullscreen())
+ controls->updateMediaControlScale();
+#endif
if (isFullscreen())
controls->enteredFullscreen();