#include "TizenExtensibleAPI.h"
#endif
-#if ENABLE(TIZEN_DEVICE_ROTATION)
-#include <vconf.h>
-#endif
-
using namespace std;
namespace WebCore {
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
-};
-
-int HTMLMediaElement::s_rotation = ROTATE_0;
-#endif
-
using namespace HTMLNames;
using namespace std;
setHasCustomCallbacks();
addElementToDocumentMap(this, document);
-#if ENABLE(TIZEN_DEVICE_ROTATION)
- registerRotationCallback();
-#endif
}
HTMLMediaElement::~HTMLMediaElement()
m_completelyLoaded = true;
if (m_player)
m_player->clearMediaPlayerClient();
-
-#if ENABLE(TIZEN_DEVICE_ROTATION)
- unregisterRotationCallback();
-#endif
-}
-
-#if ENABLE(TIZEN_DEVICE_ROTATION)
-bool HTMLMediaElement::isHorizontal()
-{
- return (s_rotation == ROTATE_90 || s_rotation == ROTATE_270) ? true : false;
-}
-
-bool HTMLMediaElement::isVertical()
-{
- return (s_rotation == ROTATE_0 || s_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 == s_rotation)
- return;
-
- s_rotation = rotation;
-}
-#endif
-
void HTMLMediaElement::didMoveToNewDocument(Document* oldDocument)
{
if (m_isWaitingUntilMediaCanStart) {
#if ENABLE(FULLSCREEN_API)
if (document() && document()->settings() && document()->settings()->fullScreenEnabled()) {
document()->requestFullScreenForElement(this, 0, Document::ExemptIFrameAllowFullScreenRequirement);
+#if ENABLE(TIZEN_FULLSCREEN_API)
+ updateMediaControlsStyle();
+#endif
return;
}
#endif
#include "TextTrackCue.h"
#endif
-#if ENABLE(TIZEN_DEVICE_ROTATION)
-#include <sensors.h>
-#endif
-
namespace WebCore {
#if ENABLE(WEB_AUDIO)
bool suspended() { return m_suspended; }
#endif
-#if ENABLE(TIZEN_DEVICE_ROTATION)
- static bool isHorizontal();
- static bool isVertical();
-#endif
-
#if ENABLE(TIZEN_FULLSCREEN_API)
void updateMediaControlsStyle();
#endif
bool shouldSuspendMedia();
#endif
-#if ENABLE(TIZEN_DEVICE_ROTATION)
- static void onRotationChanged(uint64_t timeStamp, sensor_data_accuracy_e accuracy, float x, float y, float z, void* userData);
-
- void registerRotationCallback();
- void unregisterRotationCallback();
-
- int calcRotation(float x, float y, float z);
-#endif
-
Timer<HTMLMediaElement> m_loadTimer;
Timer<HTMLMediaElement> m_progressEventTimer;
Timer<HTMLMediaElement> m_playbackProgressTimer;
#if ENABLE(TIZEN_GSTREAMER_VIDEO)
bool m_suspended;
#endif
-#if ENABLE(TIZEN_DEVICE_ROTATION)
- sensor_h m_handle;
- static int s_rotation;
-#endif
};
#if ENABLE(VIDEO_TRACK)
return;
double scaleFactor = 1 / document()->page()->chrome()->contentsScaleFactor();
-
-#if ENABLE(TIZEN_DEVICE_ROTATION)
- Settings* settings = document()->settings();
- if (settings && settings->deviceWidth() != compareResolution.width())
- scaleFactor *= (settings->deviceWidth() / static_cast<double>(HTMLMediaElement::isHorizontal() ? compareResolution.height() : compareResolution.width()));
-#endif
+ if (Settings* settings = document()->settings()) {
+ int compareWidth = (settings->deviceWidth() > settings->deviceHeight()) ? compareResolution.height() : compareResolution.width();
+ if (settings->deviceWidth() != compareWidth)
+ scaleFactor *= (settings->deviceWidth() / static_cast<double>(compareWidth));
+ }
m_panel->setInlineStyleProperty(CSSPropertyWebkitTransform, "scale(" + String::number(scaleFactor) + ", " + String::number(scaleFactor) + ")", false);
}
page->chrome()->setCursorHiddenUntilMouseMoves(true);
}
-#if ENABLE(TIZEN_FULLSCREEN_API)
- updateMediaControlScale();
-#endif
-
#if !ENABLE(TIZEN_GSTREAMER_VIDEO)
startHideFullscreenControlsTimer();
#endif