Skip to content

Commit

Permalink
Sync to latest trunk, removed dependency on qt media resource policy
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeshkova committed May 12, 2014
1 parent 2777efa commit 2604f74
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 88 deletions.
4 changes: 0 additions & 4 deletions config/system-headers
Expand Up @@ -1345,10 +1345,6 @@ 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
11 changes: 0 additions & 11 deletions configure.in
Expand Up @@ -5581,17 +5581,6 @@ if test -n "$MOZ_GSTREAMER"; then
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])
fi

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

_SAVE_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS $GSTREAMER_LIBS -lgstvideo-$GST_API_VERSION"
AC_TRY_LINK(,[return 0;],_HAVE_LIBGSTVIDEO=1,_HAVE_LIBGSTVIDEO=)
Expand Down
4 changes: 2 additions & 2 deletions content/media/Makefile.in
Expand Up @@ -4,5 +4,5 @@

include $(topsrcdir)/config/rules.mk

CFLAGS += $(GSTREAMER_CFLAGS) $(NEMO_RESOURCE_CFLAGS)
CXXFLAGS += $(GSTREAMER_CFLAGS) $(NEMO_RESOURCE_CFLAGS)
CFLAGS += $(GSTREAMER_CFLAGS)
CXXFLAGS += $(GSTREAMER_CFLAGS)
8 changes: 0 additions & 8 deletions content/media/MediaDecoder.cpp
Expand Up @@ -28,9 +28,7 @@
#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 @@ -153,9 +151,7 @@ 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 @@ -597,9 +593,7 @@ 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 @@ -687,9 +681,7 @@ void MediaDecoder::MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool
return;
}

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

{
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
Expand Down
26 changes: 1 addition & 25 deletions content/media/NemoResourceHandler.cpp
Expand Up @@ -6,19 +6,12 @@

#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"
#include "mozilla/Preferences.h"

using namespace ResourcePolicy;

namespace mozilla {

NemoResourceHandler* NemoResourceHandler::mGlobalHandler = nullptr;
Expand Down Expand Up @@ -92,28 +85,12 @@ 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
Expand All @@ -123,8 +100,7 @@ NemoResourceHandler::CanDestroy()
}

NemoResourceHandler::NemoResourceHandler()
: mResourceSet(nullptr)
, mCounter(0)
: mCounter(0)
{
MOZ_ASSERT(mGlobalHandler == nullptr);
mGlobalHandler = this;
Expand Down
1 change: 0 additions & 1 deletion content/media/NemoResourceHandler.h
Expand Up @@ -23,7 +23,6 @@ class NemoResourceHandler
bool CanDestroy();

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

Expand Down
22 changes: 9 additions & 13 deletions content/media/gstreamer/GStreamerReader.cpp
Expand Up @@ -65,27 +65,27 @@ typedef enum {
GST_PLAY_FLAG_SOFT_COLORBALANCE = (1 << 10)
} PlayFlags;

static const char defaultFilter[] = "capsfilter name=filter ! ";
static const char nemoFilter[] = "colorconv ! capsfilter name=filter ! ";
static bool useNemoFilter = getenv("USE_NEMO_GSTREAMER") != 0;

void* sCurrentDecoderUser = nullptr;
static bool sNoLimitOneGSTDecoder = getenv("NO_LIMIT_ONE_GST_DECODER") != 0;

void ResetIfCurrentDecoderActive(void* aCaller)
{
#ifdef HAS_NEMO_RESOURCE
if (!sNoLimitOneGSTDecoder && sCurrentDecoderUser == aCaller) {
sCurrentDecoderUser = nullptr;
}
#endif
}

bool UpdateCurrentAsActiveIfNotBusy(void* aCaller)
{
#ifdef HAS_NEMO_RESOURCE
if (!sNoLimitOneGSTDecoder && sCurrentDecoderUser != nullptr && sCurrentDecoderUser != aCaller)
{
return false;
}
sCurrentDecoderUser = aCaller;
#endif
return true;
}

Expand Down Expand Up @@ -164,9 +164,7 @@ GStreamerReader::~GStreamerReader()

void GStreamerReader::Suspend()
{
#ifdef HAS_NEMO_RESOURCE
ResetIfCurrentDecoderActive(this);
#endif
}

nsresult GStreamerReader::Init(MediaDecoderReader* aCloneDonor)
Expand All @@ -192,18 +190,16 @@ nsresult GStreamerReader::Init(MediaDecoderReader* aCloneDonor)
g_object_set(mPlayBin, "buffer-size", 0, nullptr);
mBus = gst_pipeline_get_bus(GST_PIPELINE(mPlayBin));

#ifndef HAS_NEMO_RESOURCE
mVideoSink = gst_parse_bin_from_description("capsfilter name=filter ! "
#else
mVideoSink = gst_parse_bin_from_description("colorconv ! capsfilter name=filter ! "
#endif
"appsink name=videosink sync=false max-buffers=1 "
nsAutoCString description;
description.AppendPrintf("%s %s %s", useNemoFilter ? nemoFilter : defaultFilter,
"appsink name=videosink sync=false max-buffers=1 ",
#if GST_VERSION_MAJOR >= 1
"caps=video/x-raw,format=I420"
#else
"caps=video/x-raw-yuv,format=(fourcc)I420"
#endif
, TRUE, nullptr);
);
mVideoSink = gst_parse_bin_from_description(description.get(), TRUE, nullptr);
mVideoAppSink = GST_APP_SINK(gst_bin_get_by_name(GST_BIN(mVideoSink),
"videosink"));
mAudioSink = gst_parse_bin_from_description("capsfilter name=filter ! "
Expand Down
7 changes: 3 additions & 4 deletions content/media/moz.build
Expand Up @@ -153,10 +153,9 @@ UNIFIED_SOURCES += [
'WebVTTListener.cpp',
]

if CONFIG['HAS_NEMO_RESOURCE']:
SOURCES += [
'NemoResourceHandler.cpp',
]
SOURCES += [
'NemoResourceHandler.cpp',
]

# DecoderTraits.cpp needs to be built separately because of Mac OS X headers.
# Latency.cpp needs to be built separately because it forces NSPR logging.
Expand Down
Expand Up @@ -974,7 +974,7 @@ EmbedLiteViewThreadChild::GetScrollIdentifiers(uint32_t *aPresShellIdOut, mozill
nsCOMPtr<nsIDOMDocument> domDoc;
mWebNavigation->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
return APZCCallbackHelper::GetScrollIdentifiers(doc->GetDocumentElement(), aPresShellIdOut, aViewIdOut);
return APZCCallbackHelper::GetOrCreateScrollIdentifiers(doc->GetDocumentElement(), aPresShellIdOut, aViewIdOut);
}

} // namespace embedlite
Expand Down
26 changes: 13 additions & 13 deletions embedding/embedlite/modules/EmbedLiteJSON.cpp
Expand Up @@ -59,21 +59,21 @@ JSONCreator(const jschar* aBuf, uint32_t aLen, void* aData)
nsresult
JSValToVariant(JSContext* cx, jsval& propval, nsIWritableVariant* aVariant)
{
if (JSVAL_IS_BOOLEAN(propval)) {
aVariant->SetAsBool(JSVAL_TO_BOOLEAN(propval));
} else if (JSVAL_IS_INT(propval)) {
aVariant->SetAsInt32(JSVAL_TO_INT(propval));
} else if (JSVAL_IS_DOUBLE(propval)) {
aVariant->SetAsDouble(JSVAL_TO_DOUBLE(propval));
} else if (JSVAL_IS_STRING(propval)) {
if (propval.isBoolean()) {
aVariant->SetAsBool(propval.toBoolean());
} else if (propval.isInt32()) {
aVariant->SetAsInt32(propval.toInt32());
} else if (propval.isDouble()) {
aVariant->SetAsDouble(propval.toDouble());
} else if (propval.isString()) {
JS::Rooted<JS::Value> val(cx, propval);
JSString* propvalString = JS::ToString(cx, val);
nsDependentJSString vstr;
if (!propvalString || !vstr.init(cx, propvalString)) {
return NS_ERROR_FAILURE;
}
aVariant->SetAsAString(vstr);
} else if (!JSVAL_IS_PRIMITIVE(propval)) {
} else if (!propval.isPrimitive()) {
NS_ERROR("Value is not primitive");
return NS_ERROR_FAILURE;
}
Expand Down Expand Up @@ -105,7 +105,7 @@ ParseObject(JSContext* cx, JSObject* object, nsIWritablePropertyBag2* aBag)
return NS_ERROR_FAILURE;
}

if (JSVAL_IS_PRIMITIVE(propval)) {
if (propval.isPrimitive()) {
nsCOMPtr<nsIVariant> value;
nsContentUtils::XPConnect()->JSValToVariant(cx, propval, getter_AddRefs(value));
nsCOMPtr<nsIWritablePropertyBag> bagSimple = do_QueryInterface(aBag);
Expand All @@ -121,15 +121,15 @@ ParseObject(JSContext* cx, JSObject* object, nsIWritablePropertyBag2* aBag)
JS::Rooted<JS::Value> v(cx);
if (!JS_GetElement(cx, obj, i, &v))
continue;
if (JSVAL_IS_PRIMITIVE(v)) {
if (v.isPrimitive()) {
nsCOMPtr<nsIVariant> value;
nsContentUtils::XPConnect()->JSValToVariant(cx, v, getter_AddRefs(value));
childArray.AppendElement(value);
} else {
nsCOMPtr<nsIWritableVariant> value = do_CreateInstance("@mozilla.org/variant;1");
nsCOMPtr<nsIWritablePropertyBag2> contextProps;
CreateObjectStatic(getter_AddRefs(contextProps));
JSObject* obj = JSVAL_TO_OBJECT(v);
JSObject* obj = v.toObjectOrNull();
ParseObject(cx, obj, contextProps);
value->SetAsInterface(NS_GET_IID(nsIWritablePropertyBag2), contextProps);
childArray.AppendElement(value);
Expand Down Expand Up @@ -170,12 +170,12 @@ EmbedLiteJSON::ParseJSON(nsAString const& aJson, nsIPropertyBag2** aRoot)
return NS_ERROR_FAILURE;
}

if (JSVAL_IS_PRIMITIVE(json)) {
if (json.isPrimitive()) {
NS_ERROR("We don't handle primitive values");
return NS_ERROR_FAILURE;
}

JSObject* obj = JSVAL_TO_OBJECT(json);
JSObject* obj = json.toObjectOrNull();
nsCOMPtr<nsIWritablePropertyBag2> contextProps;
if (obj) {
CreateObject(getter_AddRefs(contextProps));
Expand Down
4 changes: 2 additions & 2 deletions embedding/embedlite/utils/TabChildHelper.cpp
Expand Up @@ -215,8 +215,8 @@ TabChildHelper::Observe(nsISupports* aSubject,
nsCOMPtr<nsIDocument> doc(GetDocument());
uint32_t presShellId;
ViewID viewId;
if (APZCCallbackHelper::GetScrollIdentifiers(doc->GetDocumentElement(),
&presShellId, &viewId)) {
if (APZCCallbackHelper::GetOrCreateScrollIdentifiers(doc->GetDocumentElement(),
&presShellId, &viewId)) {
CSSRect rect;
sscanf(NS_ConvertUTF16toUTF8(aData).get(),
"{\"x\":%f,\"y\":%f,\"w\":%f,\"h\":%f}",
Expand Down
4 changes: 0 additions & 4 deletions toolkit/library/libxul.mk
Expand Up @@ -230,10 +230,6 @@ EXTRA_DSO_LDOPTS += $(GSTREAMER_LIBS)
endif
endif

ifdef HAS_NEMO_RESOURCE
EXTRA_DSO_LDOPTS += $(NEMO_RESOURCE_LIBS)
endif

# Generate GDB pretty printer-autoload files only on Linux. OSX's GDB is
# too old to support Python pretty-printers; if this changes, we could make
# this 'ifdef GNU_CC'.
Expand Down

0 comments on commit 2604f74

Please sign in to comment.