Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Created embedlite branch based on 9345aa8 of gecko-dev repository.
  • Loading branch information
tmeshkova committed Jan 5, 2014
1 parent 9345aa8 commit eb2dcea
Show file tree
Hide file tree
Showing 197 changed files with 13,971 additions and 212 deletions.
4 changes: 4 additions & 0 deletions config/system-headers
Expand Up @@ -1123,6 +1123,10 @@ gst/gst.h
gst/app/gstappsink.h
gst/app/gstappsrc.h
gst/video/video.h
resource/qt5/policy/audio-resource.h
resource/qt5/policy/resource-set.h
resource/qt5/policy/resource.h
resource/qt5/policy/resources.h
sys/msg.h
sys/ipc.h
sys/thr.h
Expand Down
46 changes: 42 additions & 4 deletions configure.in
Expand Up @@ -4613,6 +4613,30 @@ incorrect])
])
fi

MOZ_ENABLE_QT5FEEDBACK=
PKG_CHECK_MODULES(_QT5FEEDBACK, Qt0Feedback,
MOZ_ENABLE_QT5FEEDBACK=1,
MOZ_ENABLE_QT5FEEDBACK=)
if test "$MOZ_ENABLE_QT5FEEDBACK"; then
MOZ_ENABLE_QT5FEEDBACK=1
MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QT5FEEDBACK_CFLAGS"
MOZ_QT_LIBS="$MOZ_QT_LIBS $_QT5FEEDBACK_LIBS"
AC_DEFINE(MOZ_ENABLE_QT5FEEDBACK)
AC_SUBST(MOZ_ENABLE_QT5FEEDBACK)
fi

MOZ_ENABLE_QT5GEOPOSITION=
PKG_CHECK_MODULES(_QT5GEOPOSITION, Qt5Positioning,
MOZ_ENABLE_QT5GEOPOSITION=1,
MOZ_ENABLE_QT5GEOPOSITION=)
if test "$MOZ_ENABLE_QT5GEOPOSITION"; then
MOZ_ENABLE_QT5GEOPOSITION=1
MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QT5GEOPOSITION_CFLAGS"
MOZ_QT_LIBS="$MOZ_QT_LIBS $_QT5GEOPOSITION_LIBS"
AC_DEFINE(MOZ_ENABLE_QT5GEOPOSITION)
AC_SUBST(MOZ_ENABLE_QT5GEOPOSITION)
fi

if test "$MOZ_ENABLE_CONTENTACTION"; then
MOZ_ENABLE_CONTENTACTION=1
AC_DEFINE(MOZ_ENABLE_CONTENTACTION)
Expand Down Expand Up @@ -5596,6 +5620,18 @@ if test "$MOZ_GSTREAMER"; then
gstreamer-app-$GST_API_VERSION
gstreamer-plugins-base-$GST_API_VERSION, ,
AC_MSG_ERROR([gstreamer and gstreamer-plugins-base development packages are needed to build gstreamer backend. Install them or disable gstreamer support with --disable-gstreamer]))

PKG_CHECK_MODULES(NEMO_RESOURCE, libresourceqt5,
HAS_NEMO_RESOURCE=1,
HAS_NEMO_RESOURCE=)

if test "$HAS_NEMO_RESOURCE"; then
HAS_NEMO_RESOURCE=1
AC_DEFINE(HAS_NEMO_RESOURCE)
AC_SUBST(NEMO_RESOURCE_LIBS)
AC_SUBST(NEMO_RESOURCE_CFLAGS)
fi

if test -n "$GSTREAMER_LIBS"; then
_SAVE_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS $GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
Expand All @@ -5613,6 +5649,7 @@ fi
AC_SUBST(GSTREAMER_CFLAGS)
AC_SUBST(GSTREAMER_LIBS)
AC_SUBST(MOZ_GSTREAMER)
AC_SUBST(HAS_NEMO_RESOURCE)

if test -n "$MOZ_GSTREAMER"; then
AC_DEFINE(MOZ_GSTREAMER)
Expand Down Expand Up @@ -6171,7 +6208,7 @@ MOZ_ARG_DISABLE_BOOL(webapp-runtime,
[ --disable-webapp-runtime Disable Web App Runtime],
MOZ_WEBAPP_RUNTIME=,
MOZ_WEBAPP_RUNTIME=1)
if test "$MOZ_WIDGET_TOOLKIT" != "windows" -a "$MOZ_WIDGET_TOOLKIT" != "cocoa" -a "$MOZ_WIDGET_TOOLKIT" != "gtk2"; then
if test "$MOZ_WIDGET_TOOLKIT" != "windows" -a "$MOZ_WIDGET_TOOLKIT" != "cocoa" -a "$MOZ_WIDGET_TOOLKIT" != "gtk2" -a "$MOZ_WIDGET_TOOLKIT" != "qt"; then
MOZ_WEBAPP_RUNTIME=
fi
if test "$OS_ARCH" = "WINNT" -a -z "$MAKENSISU" -a -n "$CROSS_COMPILE"; then
Expand Down Expand Up @@ -7901,10 +7938,11 @@ if test "$MOZ_TREE_CAIRO"; then
XLIB_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_SURFACE 1"
XLIB_XRENDER_SURFACE_FEATURE="#define CAIRO_HAS_XLIB_XRENDER_SURFACE 1"
PS_SURFACE_FEATURE="#define CAIRO_HAS_PS_SURFACE 1"
FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
MOZ_ENABLE_CAIRO_FT=1
CAIRO_FT_CFLAGS="$FT2_CFLAGS"
fi
FT_FONT_FEATURE="#define CAIRO_HAS_FT_FONT 1"
MOZ_ENABLE_CAIRO_FT=1
CAIRO_FT_CFLAGS="$FT2_CFLAGS"

case "$MOZ_WIDGET_TOOLKIT" in
qt)
QT_SURFACE_FEATURE="#define CAIRO_HAS_QT_SURFACE 1"
Expand Down
8 changes: 7 additions & 1 deletion content/html/content/src/HTMLMediaElement.cpp
Expand Up @@ -2874,7 +2874,13 @@ void HTMLMediaElement::FirstFrameLoaded(bool aResourceFullyLoaded)
!HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay) &&
mPreloadAction == HTMLMediaElement::PRELOAD_METADATA) {
mSuspendedAfterFirstFrame = true;
mDecoder->Suspend();
#ifdef HAS_NEMO_RESOURCE
static bool doSuspendOnFirstFrame = getenv("DO_SUSPEND_ON_FIRST_FRAME") != 0;
if (doSuspendOnFirstFrame)
#endif
{
mDecoder->Suspend();
}
} else if (mLoadedFirstFrame &&
mDownloadSuspendedByCache &&
mDecoder &&
Expand Down
4 changes: 4 additions & 0 deletions content/media/MP3FrameParser.cpp
Expand Up @@ -502,6 +502,10 @@ int64_t MP3FrameParser::GetDuration()
return -1; // Not a single frame decoded yet
}

if (mSamplesPerSecond == 0) {
return -1; // Not a single frame decoded yet
}

double frames;
if (mNumFrames < 0) {
// Estimate the number of frames in the stream based on the average frame
Expand Down
4 changes: 2 additions & 2 deletions content/media/Makefile.in
Expand Up @@ -4,7 +4,7 @@

include $(topsrcdir)/config/rules.mk

CFLAGS += $(GSTREAMER_CFLAGS)
CXXFLAGS += $(GSTREAMER_CFLAGS)
CFLAGS += $(GSTREAMER_CFLAGS) $(NEMO_RESOURCE_CFLAGS)
CXXFLAGS += $(GSTREAMER_CFLAGS) $(NEMO_RESOURCE_CFLAGS)

AudioNodeEngineNEON.$(OBJ_SUFFIX): CXXFLAGS += -mfpu=neon
13 changes: 13 additions & 0 deletions content/media/MediaDecoder.cpp
Expand Up @@ -27,6 +27,9 @@
#ifdef MOZ_WMF
#include "WMFDecoder.h"
#endif
#ifdef HAS_NEMO_RESOURCE
#include "NemoResourceHandler.h"
#endif

using namespace mozilla::layers;
using namespace mozilla::dom;
Expand Down Expand Up @@ -143,6 +146,9 @@ void MediaDecoder::SetDormantIfNecessary(bool aDormant)
void MediaDecoder::Pause()
{
MOZ_ASSERT(NS_IsMainThread());
#ifdef HAS_NEMO_RESOURCE
NemoResourceHandler::ReleaseResources(this);
#endif
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
if ((mPlayState == PLAY_STATE_LOADING && mIsDormant) || mPlayState == PLAY_STATE_SEEKING || mPlayState == PLAY_STATE_ENDED) {
mNextState = PLAY_STATE_PAUSED;
Expand Down Expand Up @@ -598,6 +604,9 @@ nsresult MediaDecoder::Play()
NS_ASSERTION(mDecoderStateMachine != nullptr, "Should have state machine.");
nsresult res = ScheduleStateMachineThread();
NS_ENSURE_SUCCESS(res,res);
#ifdef HAS_NEMO_RESOURCE
NemoResourceHandler::AquireResources(this);
#endif
if ((mPlayState == PLAY_STATE_LOADING && mIsDormant) || mPlayState == PLAY_STATE_SEEKING) {
mNextState = PLAY_STATE_PLAYING;
return NS_OK;
Expand Down Expand Up @@ -766,6 +775,10 @@ void MediaDecoder::MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool
return;
}

#ifdef HAS_NEMO_RESOURCE
NemoResourceHandler::MediaInfo(this, aHasAudio, aHasVideo);
#endif

{
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
if (mPlayState == PLAY_STATE_LOADING && mIsDormant && !mIsExitingDormant) {
Expand Down
132 changes: 132 additions & 0 deletions content/media/NemoResourceHandler.cpp
@@ -0,0 +1,132 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "NemoResourceHandler.h"

#include <QtCore/QCoreApplication>
#define signals Q_SIGNALS
#define slots Q_SLOTS
#include <policy/audio-resource.h>
#include <policy/resource-set.h>
#include "nsThreadUtils.h"
#include "mozilla/Services.h"
#include "nsIObserverService.h"
#include "nsStringGlue.h"

using namespace ResourcePolicy;

namespace mozilla {

NemoResourceHandler* NemoResourceHandler::mGlobalHandler = nullptr;

void
NemoResourceHandler::AquireResources(void* aHolder)
{
MOZ_ASSERT(NS_IsMainThread());
if (mGlobalHandler == nullptr)
{
mGlobalHandler = new NemoResourceHandler();
}

mGlobalHandler->Aquire();

nsCOMPtr<nsIObserverService> obs =
mozilla::services::GetObserverService();
if (obs) {
nsString data;
data.AppendPrintf("{ \"owner\" : \"%p\", \"state\": \"play\" }", aHolder);
obs->NotifyObservers(nullptr, "media-decoder-info", data.get());
}
}

void
NemoResourceHandler::ReleaseResources(void* aHolder)
{
MOZ_ASSERT(NS_IsMainThread());
if (!mGlobalHandler) {
return;
}

mGlobalHandler->Release();

nsCOMPtr<nsIObserverService> obs =
mozilla::services::GetObserverService();
if (obs) {
nsString data;
data.AppendPrintf("{ \"owner\" : \"%p\", \"state\": \"pause\" }", aHolder);
obs->NotifyObservers(nullptr, "media-decoder-info", data.get());
}

if (mGlobalHandler->CanDestroy())
{
delete mGlobalHandler;
mGlobalHandler = nullptr;
}
}

void
NemoResourceHandler::MediaInfo(void* aHolder, bool aHasAudio, bool aHasVideo)
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIObserverService> obs =
mozilla::services::GetObserverService();
if (obs) {
nsString data;
data.AppendPrintf("{ \"owner\" : \"%p\", \"state\": \"meta\", \"a\" : %i, \"v\" : %i }", aHolder, aHasAudio, aHasVideo);
obs->NotifyObservers(nullptr, "media-decoder-info", data.get());
}
}

void
NemoResourceHandler::Aquire()
{
mCounter++;
if (mCounter > 0 && !mResourceSet)
{
ResourceSet* set = new ResourcePolicy::ResourceSet("player");
ResourcePolicy::AudioResource *audioResource = new ResourcePolicy::AudioResource("player");
audioResource->setProcessID(QCoreApplication::applicationPid());
audioResource->setStreamTag("media.name", "*");
set->addResourceObject(audioResource);
set->addResource(ResourcePolicy::VideoPlaybackType);
set->acquire();
mResourceSet = set;
}
}

void
NemoResourceHandler::Release()
{
mCounter--;
if (mCounter == 0 && mResourceSet)
{
delete static_cast<ResourceSet*>(mResourceSet);
mResourceSet = nullptr;
}
}

bool
NemoResourceHandler::CanDestroy()
{
return mCounter <= 0;
}

NemoResourceHandler::NemoResourceHandler()
: mResourceSet(nullptr)
, mCounter(0)
{
MOZ_ASSERT(mGlobalHandler == nullptr);
mGlobalHandler = this;
}

NemoResourceHandler::~NemoResourceHandler()
{
MOZ_ASSERT(mGlobalHandler != nullptr);
mGlobalHandler = nullptr;
}

} // namespace mozilla

32 changes: 32 additions & 0 deletions content/media/NemoResourceHandler.h
@@ -0,0 +1,32 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef NEMO_RESOURCE_HANDLER
#define NEMO_RESOURCE_HANDLER

namespace mozilla {

class NemoResourceHandler
{
public:
static void AquireResources(void* aHolder);
static void ReleaseResources(void* aHolder);
static void MediaInfo(void* aHolder, bool aHasAudio, bool aHasVideo);
private:
NemoResourceHandler();
virtual ~NemoResourceHandler();
void Aquire();
void Release();
bool CanDestroy();

static NemoResourceHandler* mGlobalHandler;
void* mResourceSet;
int mCounter;
};

} // namespace mozilla

#endif // NEMO_RESOURCE_HANDLER

0 comments on commit eb2dcea

Please sign in to comment.