return FALSE;
}
+#if ENABLE(TIZEN_GSTREAMER_VIDEO) && (!ENABLE(TIZEN_ACCELERATED_COMPOSITING) || !USE(TIZEN_TEXTURE_MAPPER) || !ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) || CPU(X86) || CPU(X86_64))
static void mediaPlayerPrivateRepaintCallback(WebKitVideoSink*, GstBuffer *buffer, MediaPlayerPrivateGStreamer* playerPrivate)
{
playerPrivate->triggerRepaint(buffer);
}
+#endif
#if ENABLE(TIZEN_ACCELERATED_COMPOSITING) && USE(TIZEN_TEXTURE_MAPPER) && ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
static GstBusSyncReply mediaPlayerPrivateSyncHandler(GstBus* bus, GstMessage* message, MediaPlayerPrivateGStreamer* playerPrivate)
static ASM_cb_result_t MediaPlayerAudioSessionEventSourcePause(ASM_event_sources_t eventSource, void* callbackData)
{
MediaPlayer* player = static_cast<MediaPlayer*>(callbackData);
+ HTMLMediaElement* element = static_cast<HTMLMediaElement*>(player->mediaPlayerClient());
+
if (!player)
return ASM_CB_RES_IGNORE;
switch (eventSource) {
case ASM_EVENT_SOURCE_CALL_START:
case ASM_EVENT_SOURCE_ALARM_START:
- case ASM_EVENT_SOURCE_EARJACK_UNPLUG:
case ASM_EVENT_SOURCE_MEDIA:
case ASM_EVENT_SOURCE_EMERGENCY_START:
case ASM_EVENT_SOURCE_OTHER_PLAYER_APP:
case ASM_EVENT_SOURCE_RESOURCE_CONFLICT:
- player->pause();
- return ASM_CB_RES_PAUSE;
+ case ASM_EVENT_SOURCE_EARJACK_UNPLUG:
+ if (!player->url().string().contains("camera://")) {
+ element->pause();
+ return ASM_CB_RES_PAUSE;
+ }
default:
return ASM_CB_RES_NONE;
}
static ASM_cb_result_t MediaPlayerAudioSessionEventSourcePlay(ASM_event_sources_t eventSource, void* callbackData)
{
MediaPlayer* player = static_cast<MediaPlayer*>(callbackData);
+ HTMLMediaElement* element = static_cast<HTMLMediaElement*>(player->mediaPlayerClient());
+
if (!player)
return ASM_CB_RES_IGNORE;
switch (eventSource) {
case ASM_EVENT_SOURCE_ALARM_END:
- if (!player->hasVideo()) {
- player->play();
+ if (!element->isVideo() && !player->url().string().contains("camera://")) {
+ element->play();
return ASM_CB_RES_PLAYING;
}
return ASM_CB_RES_NONE;
MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player)
: m_player(player)
, m_webkitVideoSink(0)
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+ , m_videoSinkBin(0)
+#endif
, m_fpsSink(0)
, m_source(0)
, m_seekTime(0)
, m_audioTimerHandler(0)
, m_videoTimerHandler(0)
, m_webkitAudioSink(0)
+ , m_totalBytes(-1)
#if ENABLE(TIZEN_ACCELERATED_COMPOSITING) && USE(TIZEN_TEXTURE_MAPPER)
, m_videoLayer(VideoLayerTizen::create(static_cast<HTMLMediaElement*>(player->mediaPlayerClient())))
#endif // ENABLE(TIZEN_ACCELERATED_COMPOSITING) && USE(TIZEN_TEXTURE_MAPPER)
#if ENABLE(TIZEN_GSTREAMER_AUDIO)
, m_audioSessionManager(AudioSessionManagerGStreamerTizen::createAudioSessionManager())
#endif
- , m_totalBytes(-1)
, m_originalPreloadWasAutoAndWasOverridden(false)
, m_preservesPitch(false)
#if ENABLE(TIZEN_GSTREAMER_VIDEO)
, m_suspendTime(0)
- , m_videoSinkBin(0)
#endif
{
}
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);
LOG_MEDIA_MESSAGE("Load %s", cleanUrl.utf8().data());
+#if ENABLE(TIZEN_MEDIA_STREAM)
+ // Workaround modification for getUserMedia.
+ // When 'playing' event is fired videoWidth and videoHeight are not available.
+ // Set m_videoSize as frame size which comes from webkitCameraSource.
+ // This size is fixed.
+ if (isLocalMediaStream())
+ if (gst_element_factory_find("camerasrc"))
+ m_videoSize = IntSize(480, 640);
+ else
+ m_videoSize = IntSize(640, 480);
+#endif
+
if (m_preload == MediaPlayer::None) {
LOG_MEDIA_MESSAGE("Delaying load.");
m_delayingLoad = true;
void MediaPlayerPrivateGStreamer::play()
{
#if ENABLE(TIZEN_GSTREAMER_AUDIO)
- if (m_audioSessionManager && !m_audioSessionManager->setSoundState(ASM_STATE_PLAYING))
+ if (!m_audioSessionManager->setSoundState(ASM_STATE_PLAYING) && !isLocalMediaStream())
return;
#endif
if (changePipelineState(GST_STATE_PLAYING)) {
void MediaPlayerPrivateGStreamer::pause()
{
#if ENABLE(TIZEN_GSTREAMER_AUDIO)
- if (m_audioSessionManager && !m_audioSessionManager->setSoundState(ASM_STATE_PAUSE))
+ if (!m_audioSessionManager->setSoundState(ASM_STATE_PAUSE) && !isLocalMediaStream())
return;
#endif
if (m_isEndReached)
} else {
m_seeking = true;
m_seekTime = time;
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+ if (m_seekTime != m_mediaDuration)
+ m_isEndReached = false;
+#endif
}
}
}
LOG_MEDIA_MESSAGE("Natural size: %" G_GUINT64_FORMAT "x%" G_GUINT64_FORMAT, width, height);
- m_videoSize = IntSize(static_cast<int>(width), static_cast<int>(height));
+#if ENABLE(TIZEN_ACCELERATED_COMPOSITING) && USE(TIZEN_TEXTURE_MAPPER) && ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) && USE(ACCELERATED_VIDEO_VAAPI)
+ if (!m_displaySize.isEmpty())
+ m_videoSize = scaleHDVideoToDisplaySize(static_cast<int>(width), static_cast<int>(height), m_displaySize.width(), m_displaySize.height());
+ else
+#endif
+ m_videoSize = IntSize(static_cast<int>(width), static_cast<int>(height));
return m_videoSize;
}
m_hasVideo = videoTracks > 0;
-#if ENABLE(TIZEN_ACCELERATED_COMPOSITING) && USE(TIZEN_TEXTURE_MAPPER) && ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
- int width;
- int height;
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+ int width, height;
if (gst_video_get_size(m_videoSinkPad.get(), &width, &height)) {
IntSize size(width, height);
if (m_videoSize != size) {
m_videoSize = IntSize();
+#if ENABLE(TIZEN_ACCELERATED_COMPOSITING) && USE(TIZEN_TEXTURE_MAPPER) && ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
m_videoLayer->setOverlay(naturalSize());
+#endif
}
}
-#endif
+
+ m_player->mediaPlayerClient()->mediaPlayerEngineUpdated(m_player);
+#else // ENABLE(TIZEN_GSTREAMER_VIDEO)
m_videoSize = IntSize();
m_player->mediaPlayerClient()->mediaPlayerEngineUpdated(m_player);
+#endif
}
void MediaPlayerPrivateGStreamer::audioChanged()
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(m_playBin.get()), GST_DEBUG_GRAPH_SHOW_ALL, dotFileName.data());
#if ENABLE(TIZEN_GSTREAMER_VIDEO)
- if (m_suspendTime > 0 && newState == GST_STATE_PAUSED) {
- seek(m_suspendTime);
+ HTMLMediaElement* element = static_cast<HTMLMediaElement*>(player()->mediaPlayerClient());
+ if (element->suspended() && newState == GST_STATE_PAUSED) {
+ if (m_suspendTime > 0 && !(isLocalMediaStream() || m_isEndReached))
+ seek(m_suspendTime);
m_suspendTime = 0;
m_player->mediaPlayerClient()->setSuspended(false);
}
-
- HTMLMediaElement* element = static_cast<HTMLMediaElement*>(player()->mediaPlayerClient());
- if (element->isVideo()) {
- if (oldState == GST_STATE_PAUSED && newState == GST_STATE_PLAYING)
- power_lock_state(POWER_STATE_NORMAL, 0);
- else if (oldState == GST_STATE_PLAYING && newState == GST_STATE_PAUSED)
- power_unlock_state(POWER_STATE_NORMAL);
- }
#endif
}
break;
// On-disk buffering was attempted but the media is live. This
// can't work so disable on-disk buffering and reset the
// pipeline.
+
+#if ENABLE(TIZEN_MEDIA_STREAM)
+ if (state == GST_STATE_READY && isLiveStream() && m_preload == MediaPlayer::Auto && !isLocalMediaStream()) {
+#else
if (state == GST_STATE_READY && isLiveStream() && m_preload == MediaPlayer::Auto) {
+#endif
setPreload(MediaPlayer::None);
gst_element_set_state(m_playBin.get(), GST_STATE_NULL);
gst_element_set_state(m_playBin.get(), GST_STATE_PAUSED);
}
// A live stream was paused, reset the pipeline.
+#if ENABLE(TIZEN_MEDIA_STREAM)
+ if (state == GST_STATE_PAUSED && pending == GST_STATE_PLAYING && isLiveStream() && !isLocalMediaStream()) {
+#else
if (state == GST_STATE_PAUSED && pending == GST_STATE_PLAYING && isLiveStream()) {
+#endif
gst_element_set_state(m_playBin.get(), GST_STATE_NULL);
gst_element_set_state(m_playBin.get(), GST_STATE_PLAYING);
#if ENABLE(TIZEN_GSTREAMER_AUDIO)
// HTMLMediaElement. In some cases like reverse playback the
// position is not always reported as 0 for instance.
float now = currentTime();
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+ if (now > 0 && now != duration()) {
+#else
if (now > 0 && now <= duration() && m_mediaDuration != now) {
+#endif
m_mediaDurationKnown = true;
m_mediaDuration = now;
m_player->durationChanged();
HTMLMediaElement* element = static_cast<HTMLMediaElement*>(player()->mediaPlayerClient());
if (element->isVideo())
power_unlock_state(POWER_STATE_NORMAL);
-
#endif
}
}
void MediaPlayerPrivateGStreamer::cacheDuration()
{
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+ float previousDuration = m_mediaDuration;
+#endif
// Reset cached media duration
m_mediaDuration = 0;
gst_element_get_state(m_playBin.get(), &state, 0, 0);
float newDuration = duration();
+#if ENABLE(TIZEN_GSTREAMER_VIDEO)
+ if (state > GST_STATE_READY) {
+ // Don't set m_mediaDurationKnown yet if the pipeline is not
+ // paused. This allows duration() query to fail at least once
+ // before playback starts and duration becomes known.
+ m_mediaDurationKnown = !isinf(newDuration);
+ }
+
+ if (!isinf(newDuration))
+ m_mediaDuration = newDuration;
+ else
+ m_mediaDuration = previousDuration;
+#else
if (state <= GST_STATE_READY) {
// Don't set m_mediaDurationKnown yet if the pipeline is not
// paused. This allows duration() query to fail at least once
if (!isinf(newDuration))
m_mediaDuration = newDuration;
+#endif
}
void MediaPlayerPrivateGStreamer::durationChanged()
"video/ogg",
"video/quicktime",
"video/vivo",
+#if !ENABLE(TIZEN_GSTREAMER_VIDEO)
"video/webm",
+#endif
"video/x-cdxa",
"video/x-dirac",
"video/x-dv",
g_object_set(m_playBin.get(), "video-sink", fakeSink, NULL);
}
#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());
-#endif
-
+#else
createAudioSink();
+#endif
}
#if ENABLE(TIZEN_ACCELERATED_COMPOSITING) && USE(TIZEN_TEXTURE_MAPPER)
m_videoLayer->paintCurrentFrameInContext(context, rect);
}
+#if USE(ACCELERATED_VIDEO_VAAPI)
+// Other device doesn't prefer such optimization, so enclose it in USE(ACCELERATED_VIDEO_VAAPI) macro
+IntSize MediaPlayerPrivateGStreamer::scaleHDVideoToDisplaySize(int videoWidth, int videoHeight, int displayWidth, int displayHeight) const
+{
+ int fitWidth, fitHeight;
+
+#if ENABLE(TIZEN_DLOG_SUPPORT)
+ TIZEN_LOGI("videoWidth: %d, videoHeight: %d, displayWidth: %d, displayHeight: %d ", videoWidth, videoHeight, displayWidth, displayHeight);
+#endif
+ fitWidth = videoWidth;
+ fitHeight = videoHeight;
+ if (displayWidth > 0 && displayHeight > 0) {
+ // In case video is rotated, we always use a 'better'
+ // orientation (landscape or portrait) to calculate fitWidth/fitHeight.
+ // It means we use a bigger size which doesn't lose quality
+ // in either landscape or portrait orientation
+ if ((videoWidth > videoHeight && displayWidth < displayHeight)
+ || (videoWidth < videoHeight && displayWidth > displayHeight)) {
+ int tmp;
+ tmp = displayWidth;
+ displayWidth = displayHeight;
+ displayHeight = tmp;
+ }
+
+ if (videoWidth > displayWidth || videoHeight > displayHeight) {
+ if (videoWidth * displayHeight > videoHeight * displayWidth) {
+ fitWidth = displayWidth;
+ fitHeight = videoHeight * displayWidth / videoWidth;
+ ASSERT(fitHeight <= displayHeight);
+ } else {
+ fitWidth = videoWidth * displayHeight / videoHeight;
+ fitHeight = displayHeight;
+ ASSERT(fitWidth <= displayWidth);
+ }
+ }
+ }
+
+ return IntSize(fitWidth, fitHeight);
+}
+#endif
void MediaPlayerPrivateGStreamer::xWindowIdPrepared(GstMessage* message)
{
- int width;
- int height;
- gst_structure_get_int(message->structure, "video-width", &width);
- gst_structure_get_int(message->structure, "video-height", &height);
+ // It is called in streaming thread.
+ // It should be used only to set window handle to video sink.
+
+ int videoWidth, videoHeight;
+ gst_structure_get_int(message->structure, "video-width", &videoWidth);
+ gst_structure_get_int(message->structure, "video-height", &videoHeight);
#if ENABLE(TIZEN_DLOG_SUPPORT)
- TIZEN_LOGI("Width: %d, Height: %d", width, height);
+ TIZEN_LOGI("videoWidth: %d, videoHeight: %d", videoWidth, videoHeight);
#endif
- IntSize size(width, height);
- m_videoSize = size;
- m_videoLayer->setOverlay(size);
+#if USE(ACCELERATED_VIDEO_VAAPI)
+ int displayWidth, displayHeight;
+ gst_structure_get_int(message->structure, "display-width", &displayWidth);
+ gst_structure_get_int(message->structure, "display-height", &displayHeight);
+
+ m_displaySize = IntSize(displayWidth, displayHeight);
+ m_videoSize = scaleHDVideoToDisplaySize(videoWidth, videoHeight, displayWidth, displayHeight);
+#else
+ m_videoSize = IntSize(videoWidth, videoHeight);
+#endif
+ m_videoLayer->setOverlay(m_videoSize);
}
+
#endif // ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
#endif // ENABLE(TIZEN_ACCELERATED_COMPOSITING) && USE(TIZEN_TEXTURE_MAPPER)
void MediaPlayerPrivateGStreamer::resume()
{
- gst_element_set_state(m_playBin.get(), GST_STATE_PAUSED);
+ if (isLocalMediaStream()) {
+ gst_element_set_state(m_playBin.get(), GST_STATE_PLAYING);
#if ENABLE(TIZEN_GSTREAMER_AUDIO)
- if (m_audioSessionManager)
- m_audioSessionManager->setSoundState(ASM_STATE_PAUSE);
+ if (m_audioSessionManager)
+ m_audioSessionManager->setSoundState(ASM_STATE_PLAYING);
#endif
+ } else {
+ gst_element_set_state(m_playBin.get(), GST_STATE_PAUSED);
+#if ENABLE(TIZEN_GSTREAMER_AUDIO)
+ if (m_audioSessionManager)
+ m_audioSessionManager->setSoundState(ASM_STATE_PAUSE);
+#endif
+ }
}
-#endif
+bool MediaPlayerPrivateGStreamer::isLocalMediaStream()
+{
+ if (m_url.string().contains("camera://"))
+ return true;
+ else
+ return false;
+}
+#endif // ENABLE(TIZEN_GSTREAMER_VIDEO)
}