aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.in18
-rw-r--r--configure.in6
-rw-r--r--xbmc/DllPaths_generated_android.h.in1
-rw-r--r--xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp4
-rw-r--r--xbmc/cores/VideoRenderers/LinuxRendererGLES.h6
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h4
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.cpp64
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.h11
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/DllLibStageFrightCodec.h83
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in19
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/Makefile.in49
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.cpp86
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.h45
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.cpp (renamed from xbmc/cores/dvdplayer/DVDCodecs/Video/StageFrightVideo.cpp)118
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.h (renamed from xbmc/cores/dvdplayer/DVDCodecs/Video/StageFrightVideo.h)6
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideoPrivate.cpp (renamed from xbmc/cores/dvdplayer/DVDCodecs/Video/StageFrightVideoPrivate.cpp)45
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideoPrivate.h (renamed from xbmc/cores/dvdplayer/DVDCodecs/Video/StageFrightVideoPrivate.h)5
17 files changed, 449 insertions, 121 deletions
diff --git a/Makefile.in b/Makefile.in
index 72acd89b17..76d6396386 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -14,7 +14,11 @@ XBMCTEX_DIRS= \
DVDPCODECS_DIRS= \
lib \
- lib/libdvd
+ lib/libdvd
+
+ifeq (@USE_LIBSTAGEFRIGHT@,1)
+DVDPCODECS_DIRS += xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS
+endif
DVDPLAYER_ARCHIVES=xbmc/cores/dvdplayer/DVDPlayer.a \
xbmc/cores/dvdplayer/DVDCodecs/DVDCodecs.a \
@@ -329,7 +333,7 @@ all : $(FINAL_TARGETS)
include Makefile.include
.PHONY : dllloader exports visualizations screensavers eventclients papcodecs \
- dvdpcodecs imagelib codecs externals force skins libaddon check \
+ dvdpcodecs dvdpextcodecs imagelib codecs externals force skins libaddon check \
testframework testsuite
# hack targets to keep build system up to date
@@ -402,6 +406,14 @@ libaddon: exports
dvdpcodecs: dllloader
$(MAKE) -C lib
$(MAKE) -C lib/libdvd
+
+ifeq (@USE_LIBSTAGEFRIGHT@,1)
+dvdpextcodecs: libxbmc.so
+ $(MAKE) -C xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS
+else
+dvdpextcodecs:
+endif
+
eventclients:
ifeq ($(findstring osx,@ARCH@), osx)
ifneq ($(findstring arm,@ARCH@), arm)
@@ -442,7 +454,7 @@ ifeq (@USE_PVR_ADDONS@,1)
$(MAKE) -C pvr-addons
endif
-codecs: papcodecs dvdpcodecs
+codecs: papcodecs dvdpcodecs dvdpextcodecs
libs: libhdhomerun imagelib libexif system/libcpluff-@ARCH@.so $(CMYTH)
diff --git a/configure.in b/configure.in
index 9b7c7dcb15..8af09f9f85 100644
--- a/configure.in
+++ b/configure.in
@@ -39,6 +39,7 @@ AC_DEFUN([XB_ADD_CODEC],
AC_MSG_CHECKING([for $2])
case $add_codecs in
*$2*)
+ use_codec_$2="yes"
AC_SUBST([USE_$1], 1)
AC_DEFINE([HAS_$1], 1, [using $2])
AC_MSG_RESULT([enabling $2])
@@ -1966,7 +1967,6 @@ case $add_codecs in
XB_ADD_CODEC([LIBAMCODEC], [amcodec])
;;
*libstagefright*)
- LIBS+="-L${prefix}/opt/android-libs -lstdc++ -lutils -lcutils -lstagefright -lbinder -lui -lgui"
XB_ADD_CODEC([LIBSTAGEFRIGHT], [libstagefright])
;;
*)
@@ -2564,6 +2564,10 @@ if test "$use_skin_touched" = "yes"; then
OUTPUT_FILES="$OUTPUT_FILES addons/skin.touched/media/Makefile"
fi
+if test "$use_codec_libstagefright" = "yes"; then
+OUTPUT_FILES="$OUTPUT_FILES xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/Makefile"
+fi
+
OUTPUT_FILES="$OUTPUT_FILES \
xbmc/interfaces/python/Makefile \
xbmc/interfaces/python/test/Makefile"
diff --git a/xbmc/DllPaths_generated_android.h.in b/xbmc/DllPaths_generated_android.h.in
index 4754b5e6ab..e77c1bc0e8 100644
--- a/xbmc/DllPaths_generated_android.h.in
+++ b/xbmc/DllPaths_generated_android.h.in
@@ -73,6 +73,7 @@
#define DLL_PATH_LIBDVDNAV "libdvdnav-@ARCH@.so"
#define DLL_PATH_LIBMPEG2 "@MPEG2_SONAME@"
#define DLL_PATH_LIBMAD "@MAD_SONAME@"
+#define DLL_PATH_LIBSTAGEFRIGHTICS "libXBMCvcodec_stagefrightICS-@ARCH@.so"
/* ffmpeg */
#define DLL_PATH_LIBAVCODEC "libavcodec-54-@ARCH@.so"
diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
index 196e460fd1..46f4442b43 100644
--- a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
+++ b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
@@ -68,7 +68,7 @@
#include <EGL/eglext.h>
#include "windowing/egl/EGLWrapper.h"
#include "android/activity/XBMCApp.h"
-#include "DVDCodecs/Video/StageFrightVideo.h"
+#include "DVDCodecs/Video/DVDVideoCodecStageFright.h"
// EGL extension functions
static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
@@ -2605,7 +2605,7 @@ void CLinuxRendererGLES::AddProcessor(struct __CVBuffer *cvBufferRef, int index)
}
#endif
#ifdef HAS_LIBSTAGEFRIGHT
-void CLinuxRendererGLES::AddProcessor(CStageFrightVideo* stf, EGLImageKHR eglimg, int index)
+void CLinuxRendererGLES::AddProcessor(CDVDVideoCodecStageFright* stf, EGLImageKHR eglimg, int index)
{
#ifdef DEBUG_VERBOSE
unsigned int time = XbmcThreads::SystemClockMillis();
diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGLES.h b/xbmc/cores/VideoRenderers/LinuxRendererGLES.h
index 687b7c9ce1..15f7d7b6e6 100644
--- a/xbmc/cores/VideoRenderers/LinuxRendererGLES.h
+++ b/xbmc/cores/VideoRenderers/LinuxRendererGLES.h
@@ -40,7 +40,7 @@ class CBaseTexture;
namespace Shaders { class BaseYUV2RGBShader; }
namespace Shaders { class BaseVideoFilterShader; }
class COpenMaxVideo;
-class CStageFrightVideo;
+class CDVDVideoCodecStageFright;
class CDVDMediaCodecInfo;
typedef std::vector<int> Features;
@@ -167,7 +167,7 @@ public:
virtual void AddProcessor(struct __CVBuffer *cvBufferRef, int index);
#endif
#ifdef HAS_LIBSTAGEFRIGHT
- virtual void AddProcessor(CStageFrightVideo* stf, EGLImageKHR eglimg, int index);
+ virtual void AddProcessor(CDVDVideoCodecStageFright* stf, EGLImageKHR eglimg, int index);
#endif
#if defined(TARGET_ANDROID)
// mediaCodec
@@ -278,7 +278,7 @@ protected:
struct __CVBuffer *cvBufferRef;
#endif
#ifdef HAS_LIBSTAGEFRIGHT
- CStageFrightVideo* stf;
+ CDVDVideoCodecStageFright* stf;
EGLImageKHR eglimg;
#endif
#if defined(TARGET_ANDROID)
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
index baee6e0dad..b78f779328 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
@@ -38,7 +38,7 @@ namespace VDPAU { class CVdpauRenderPicture; }
class COpenMax;
class COpenMaxVideo;
struct OpenMaxVideoBuffer;
-class CStageFrightVideo;
+class CDVDVideoCodecStageFright;
class CDVDMediaCodecInfo;
typedef void* EGLImageKHR;
@@ -75,7 +75,7 @@ struct DVDVideoPicture
};
struct {
- CStageFrightVideo* stf;
+ CDVDVideoCodecStageFright* stf;
EGLImageKHR eglimg;
};
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.cpp
index a5d9b171c7..ee7fbe0ee4 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.cpp
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.cpp
@@ -31,17 +31,27 @@
#include "settings/Settings.h"
#include "DVDStreamInfo.h"
#include "DVDVideoCodecStageFright.h"
-#include "StageFrightVideo.h"
#include "utils/log.h"
+#include "windowing/WindowingFactory.h"
+#include "settings/AdvancedSettings.h"
+
+#include "DllLibStageFrightCodec.h"
#define CLASSNAME "CDVDVideoCodecStageFright"
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
+
+DllLibStageFrightCodec* CDVDVideoCodecStageFright::m_stf_dll = NULL;
+
CDVDVideoCodecStageFright::CDVDVideoCodecStageFright()
: CDVDVideoCodec()
- , m_stf_decoder(NULL), m_converter(NULL), m_convert_bitstream(false)
+ , m_convert_bitstream(false), m_converter(NULL)
+ , m_stf_handle(NULL)
{
m_pFormatName = "stf-xxxx";
+
+ if (!m_stf_dll)
+ m_stf_dll = new DllLibStageFrightCodec;
}
CDVDVideoCodecStageFright::~CDVDVideoCodecStageFright()
@@ -94,21 +104,18 @@ bool CDVDVideoCodecStageFright::Open(CDVDStreamInfo &hints, CDVDCodecOptions &op
break;
}
- m_stf_decoder = new CStageFrightVideo;
- if (!m_stf_decoder->Open(hints))
+ if (!(m_stf_dll && m_stf_dll->Load()))
+ return false;
+ m_stf_dll->EnableDelayedUnload(false);
+
+ m_stf_handle = m_stf_dll->create_stf(&g_Windowing, &g_advancedSettings);
+
+ if (!m_stf_dll->stf_Open(m_stf_handle, hints))
{
CLog::Log(LOGERROR,
"%s::%s - failed to open, codec(%d), profile(%d), level(%d)",
CLASSNAME, __func__, hints.codec, hints.profile, hints.level);
- delete m_stf_decoder;
- m_stf_decoder = NULL;
-
- if (m_converter)
- {
- m_converter->Close();
- delete m_converter;
- m_converter = NULL;
- }
+ Dispose();
return false;
}
@@ -126,17 +133,17 @@ void CDVDVideoCodecStageFright::Dispose()
delete m_converter;
m_converter = NULL;
}
- if (m_stf_decoder)
+ if (m_stf_handle)
{
- m_stf_decoder->Close();
- delete m_stf_decoder;
- m_stf_decoder = NULL;
+ m_stf_dll->stf_Close(m_stf_handle);
+ m_stf_dll->destroy_stf(m_stf_handle);
+ m_stf_handle = NULL;
}
}
void CDVDVideoCodecStageFright::SetDropState(bool bDrop)
{
- m_stf_decoder->SetDropState(bDrop);
+ m_stf_dll->stf_SetDropState(m_stf_handle, bDrop);
}
int CDVDVideoCodecStageFright::Decode(uint8_t *pData, int iSize, double dts, double pts)
@@ -163,29 +170,30 @@ int CDVDVideoCodecStageFright::Decode(uint8_t *pData, int iSize, double dts, dou
CLog::Log(LOGDEBUG, ">>> decode conversion - tm:%d\n", XbmcThreads::SystemClockMillis() - time);
#endif
- rtn = m_stf_decoder->Decode(demuxer_content, demuxer_bytes, dts, pts);
+ rtn = m_stf_dll->stf_Decode(m_stf_handle, demuxer_content, demuxer_bytes, dts, pts);
return rtn;
}
void CDVDVideoCodecStageFright::Reset(void)
{
- m_stf_decoder->Reset();
+ m_stf_dll->stf_Reset(m_stf_handle);
}
bool CDVDVideoCodecStageFright::GetPicture(DVDVideoPicture* pDvdVideoPicture)
{
- return m_stf_decoder->GetPicture(pDvdVideoPicture);
+ pDvdVideoPicture->stf = this;
+ return m_stf_dll->stf_GetPicture(m_stf_handle, pDvdVideoPicture);
}
bool CDVDVideoCodecStageFright::ClearPicture(DVDVideoPicture* pDvdVideoPicture)
{
- return m_stf_decoder->ClearPicture(pDvdVideoPicture);
+ return m_stf_dll->stf_ClearPicture(m_stf_handle, pDvdVideoPicture);
}
void CDVDVideoCodecStageFright::SetSpeed(int iSpeed)
{
- m_stf_decoder->SetSpeed(iSpeed);
+ m_stf_dll->stf_SetSpeed(m_stf_handle, iSpeed);
}
int CDVDVideoCodecStageFright::GetDataSize(void)
@@ -198,4 +206,14 @@ double CDVDVideoCodecStageFright::GetTimeSize(void)
return 0;
}
+void CDVDVideoCodecStageFright::LockBuffer(EGLImageKHR eglimg)
+{
+ m_stf_dll->stf_LockBuffer(m_stf_handle, eglimg);
+}
+
+void CDVDVideoCodecStageFright::ReleaseBuffer(EGLImageKHR eglimg)
+{
+ m_stf_dll->stf_ReleaseBuffer(m_stf_handle, eglimg);
+}
+
#endif
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.h
index 95e32c6bd4..5289651817 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.h
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecStageFright.h
@@ -24,7 +24,8 @@
#include "DVDVideoCodec.h"
#include "utils/BitstreamConverter.h"
-class CStageFrightVideo;
+class DllLibStageFrightCodec;
+
class CDVDVideoCodecStageFright : public CDVDVideoCodec
{
public:
@@ -45,12 +46,16 @@ public:
virtual int GetDataSize(void);
virtual double GetTimeSize(void);
+ virtual void LockBuffer(EGLImageKHR eglimg);
+ virtual void ReleaseBuffer(EGLImageKHR eglimg);
+
protected:
const char *m_pFormatName;
- CStageFrightVideo *m_stf_decoder;
-
bool m_convert_bitstream;
CBitstreamConverter *m_converter;
+
+ static DllLibStageFrightCodec* m_stf_dll;
+ void * m_stf_handle;
};
#endif
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DllLibStageFrightCodec.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DllLibStageFrightCodec.h
new file mode 100644
index 0000000000..442746b8a4
--- /dev/null
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DllLibStageFrightCodec.h
@@ -0,0 +1,83 @@
+#pragma once
+
+/*
+ * Copyright (C) 2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
+#include "config.h"
+#endif
+
+#include "DynamicDll.h"
+#include "DVDVideoCodec.h"
+
+class CWinSystemEGL;
+class CAdvancedSettings;
+
+class DllLibStageFrightCodecInterface
+{
+public:
+ virtual ~DllLibStageFrightCodecInterface() {}
+
+ virtual void* create_stf(CWinSystemEGL* windowing, CAdvancedSettings* advsettings)=0;
+ virtual void destroy_stf(void*)=0;
+
+ virtual bool stf_Open(void*, CDVDStreamInfo &hints) = 0;
+ virtual void stf_Close(void*) = 0;
+ virtual int stf_Decode(void*, uint8_t *pData, int iSize, double dts, double pts) = 0;
+ virtual void stf_Reset(void*) = 0;
+ virtual bool stf_GetPicture(void*, DVDVideoPicture *pDvdVideoPicture) = 0;
+ virtual bool stf_ClearPicture(void*, DVDVideoPicture* pDvdVideoPicture) = 0;
+ virtual void stf_SetDropState(void*, bool bDrop) = 0;
+ virtual void stf_SetSpeed(void*, int iSpeed) = 0;
+
+ virtual void stf_LockBuffer(void*, EGLImageKHR eglimg) = 0;
+ virtual void stf_ReleaseBuffer(void*, EGLImageKHR eglimg) = 0;
+};
+
+class DllLibStageFrightCodec : public DllDynamic, DllLibStageFrightCodecInterface
+{
+ DECLARE_DLL_WRAPPER(DllLibStageFrightCodec, DLL_PATH_LIBSTAGEFRIGHTICS)
+ DEFINE_METHOD2(void*, create_stf, (CWinSystemEGL* p1, CAdvancedSettings* p2))
+ DEFINE_METHOD1(void, destroy_stf, (void* p1))
+ DEFINE_METHOD2(bool, stf_Open, (void* p1, CDVDStreamInfo &p2))
+ DEFINE_METHOD1(void, stf_Close, (void* p1))
+ DEFINE_METHOD5(int, stf_Decode, (void* p1, uint8_t *p2, int p3, double p4, double p5))
+ DEFINE_METHOD1(void, stf_Reset, (void* p1))
+ DEFINE_METHOD2(bool, stf_GetPicture, (void* p1, DVDVideoPicture * p2))
+ DEFINE_METHOD2(bool, stf_ClearPicture, (void* p1, DVDVideoPicture * p2))
+ DEFINE_METHOD2(void, stf_SetDropState, (void* p1, bool p2))
+ DEFINE_METHOD2(void, stf_SetSpeed, (void* p1, int p2))
+ DEFINE_METHOD2(void, stf_LockBuffer, (void* p1, EGLImageKHR p2))
+ DEFINE_METHOD2(void, stf_ReleaseBuffer, (void* p1, EGLImageKHR p2))
+ BEGIN_METHOD_RESOLVE()
+ RESOLVE_METHOD(create_stf)
+ RESOLVE_METHOD(destroy_stf)
+ RESOLVE_METHOD(stf_Open)
+ RESOLVE_METHOD(stf_Close)
+ RESOLVE_METHOD(stf_Decode)
+ RESOLVE_METHOD(stf_Reset)
+ RESOLVE_METHOD(stf_GetPicture)
+ RESOLVE_METHOD(stf_ClearPicture)
+ RESOLVE_METHOD(stf_SetDropState)
+ RESOLVE_METHOD(stf_SetSpeed)
+ RESOLVE_METHOD(stf_LockBuffer)
+ RESOLVE_METHOD(stf_ReleaseBuffer)
+ END_METHOD_RESOLVE()
+};
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in b/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in
index b0819a8475..23261f188c 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in
@@ -22,18 +22,6 @@ SRCS += OpenMax.cpp
SRCS += OpenMaxVideo.cpp
SRCS += DVDVideoCodecOpenMax.cpp
endif
-ifeq (@USE_LIBSTAGEFRIGHT@,1)
-SRCS += StageFrightVideo.cpp
-SRCS += StageFrightVideoPrivate.cpp
-SRCS += DVDVideoCodecStageFright.cpp
-INCLUDES += -I${prefix}/opt/android-source/frameworks/base/include
-INCLUDES += -I${prefix}/opt/android-source/frameworks/base/native/include
-INCLUDES += -I${prefix}/opt/android-source/frameworks/base/include/media/stagefright
-INCLUDES += -I${prefix}/opt/android-source/frameworks/base/include/media/stagefright/openmax
-INCLUDES += -I${prefix}/opt/android-source/system/core/include
-INCLUDES += -I${prefix}/opt/android-source/libhardware/include
-endif
-
ifeq (@USE_LIBAMCODEC@,1)
SRCS += AMLCodec.cpp
SRCS += DVDVideoCodecAmlogic.cpp
@@ -44,13 +32,12 @@ endif
ifeq (@USE_ANDROID@,1)
SRCS += DVDVideoCodecAndroidMediaCodec.cpp
endif
+ifeq (@USE_LIBSTAGEFRIGHT@,1)
+SRCS += DVDVideoCodecStageFright.cpp
+endif
LIB=Video.a
include @abs_top_srcdir@/Makefile.include
-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
-ifeq (@USE_LIBSTAGEFRIGHT@,1)
-CXXFLAGS += -Wno-multichar -fno-rtti
-endif
-
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/Makefile.in b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/Makefile.in
new file mode 100644
index 0000000000..81d7b6ed4e
--- /dev/null
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/Makefile.in
@@ -0,0 +1,49 @@
+ARCH=@ARCH@
+
+INCLUDES+=-I@abs_top_srcdir@/xbmc/cores/dvdplayer
+INCLUDES+=-I..
+
+SRCS += StageFrightInterface.cpp
+SRCS += StageFrightVideo.cpp
+SRCS += StageFrightVideoPrivate.cpp
+INCLUDES += -I${prefix}/opt/android-source/frameworks/base/include
+INCLUDES += -I${prefix}/opt/android-source/frameworks/base/native/include
+INCLUDES += -I${prefix}/opt/android-source/frameworks/base/include/media/stagefright
+INCLUDES += -I${prefix}/opt/android-source/frameworks/base/include/media/stagefright/openmax
+INCLUDES += -I${prefix}/opt/android-source/system/core/include
+INCLUDES += -I${prefix}/opt/android-source/libhardware/include
+
+LIBNAME=libXBMCvcodec_stagefrightICS
+LIB_SHARED=@abs_top_srcdir@/system/players/dvdplayer/$(LIBNAME)-$(ARCH).so
+
+LIBS += -landroid -lEGL -lGLESv2 -L${prefix}/opt/android-libs -lstdc++ -lutils -lcutils -lstagefright -lbinder -lui -lgui -L@abs_top_srcdir@ -lxbmc
+
+all: $(LIB_SHARED)
+
+include @abs_top_srcdir@/Makefile.include
+-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
+
+JNICXXFLAGS = $(CXXFLAGS) -std=gnu++0x -Wextra
+STFCXXFLAGS = $(CXXFLAGS) -Wno-multichar -fno-rtti -fPIC
+
+$(LIB_SHARED): $(OBJS)
+ $(CXX) $(STFCXXFLAGS) $(LDFLAGS) -shared -Wl,-no-undefined -g -o $(LIB_SHARED) $(OBJS) $(LIBS)
+
+StageFrightVideo.o: StageFrightVideo.cpp
+ $(CXX) -MF $*.d -MD -c $(STFCXXFLAGS) $(DEFINES) $(INCLUDES) $< -o $@
+
+StageFrightVideoPrivate.o: StageFrightVideoPrivate.cpp
+ $(CXX) -MF $*.d -MD -c $(STFCXXFLAGS) $(DEFINES) $(INCLUDES) $< -o $@
+
+Surface.o: Surface.cpp
+ $(CXX) -MF $*.d -MD -c $(JNICXXFLAGS) $(DEFINES) $(INCLUDES) $< -o $@
+
+SurfaceTexture.o: SurfaceTexture.cpp
+ $(CXX) -MF $*.d -MD -c $(JNICXXFLAGS) $(DEFINES) $(INCLUDES) $< -o $@
+
+CLEAN_FILES = \
+ $(LIB_SHARED) \
+
+DISTCLEAN_FILES= \
+ Makefile \
+
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.cpp
new file mode 100644
index 0000000000..b2305d7449
--- /dev/null
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistfribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distfributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "StageFrightInterface.h"
+#include "StageFrightVideo.h"
+
+#include "windowing/WindowingFactory.h"
+#include "settings/AdvancedSettings.h"
+
+void* create_stf(CWinSystemEGL* windowing, CAdvancedSettings* advsettings)
+{
+ return (void*)new CStageFrightVideo(windowing, advsettings);
+}
+
+void destroy_stf(void* stf)
+{
+ delete (CStageFrightVideo*)stf;
+}
+
+bool stf_Open(void* stf, CDVDStreamInfo &hints)
+{
+ return ((CStageFrightVideo*)stf)->Open(hints);
+}
+
+void stf_Close(void* stf)
+{
+ ((CStageFrightVideo*)stf)->Close();
+}
+
+int stf_Decode(void* stf, uint8_t *pData, int iSize, double dts, double pts)
+{
+ return ((CStageFrightVideo*)stf)->Decode(pData, iSize, dts, pts);
+}
+
+void stf_Reset(void* stf)
+{
+ ((CStageFrightVideo*)stf)->Reset();
+}
+
+bool stf_GetPicture(void* stf, DVDVideoPicture *pDvdVideoPicture)
+{
+ return ((CStageFrightVideo*)stf)->GetPicture(pDvdVideoPicture);
+}
+
+bool stf_ClearPicture(void* stf, DVDVideoPicture* pDvdVideoPicture)
+{
+ return ((CStageFrightVideo*)stf)->ClearPicture(pDvdVideoPicture);
+}
+
+void stf_SetDropState(void* stf, bool bDrop)
+{
+ ((CStageFrightVideo*)stf)->SetDropState(bDrop);
+}
+
+void stf_SetSpeed(void* stf, int iSpeed)
+{
+ ((CStageFrightVideo*)stf)->SetSpeed(iSpeed);
+}
+
+void stf_LockBuffer(void* stf, EGLImageKHR eglimg)
+{
+ ((CStageFrightVideo*)stf)->LockBuffer(eglimg);
+}
+
+void stf_ReleaseBuffer(void* stf, EGLImageKHR eglimg)
+{
+ ((CStageFrightVideo*)stf)->ReleaseBuffer(eglimg);
+}
+
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.h
new file mode 100644
index 0000000000..6c4eebf63d
--- /dev/null
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightInterface.h
@@ -0,0 +1,45 @@
+#pragma once
+
+/*
+ * Copyright (C) 2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "DVDVideoCodec.h"
+
+class CStageFrightVideo;
+class CWinSystemEGL;
+class CAdvancedSettings;
+
+extern "C"
+{
+ void* create_stf(CWinSystemEGL* windowing, CAdvancedSettings* advsettings);
+ void destroy_stf(void*);
+
+ bool stf_Open(void*, CDVDStreamInfo &hints);
+ void stf_Close(void*);
+ int stf_Decode(void*, uint8_t *pData, int iSize, double dts, double pts);
+ void stf_Reset(void*);
+ bool stf_GetPicture(void*, DVDVideoPicture *pDvdVideoPicture);
+ bool stf_ClearPicture(void*, DVDVideoPicture* pDvdVideoPicture);
+ void stf_SetDropState(void*, bool bDrop);
+ void stf_SetSpeed(void*, int iSpeed);
+
+ void stf_LockBuffer(void*, EGLImageKHR eglimg);
+ void stf_ReleaseBuffer(void*, EGLImageKHR eglimg);
+}
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/StageFrightVideo.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.cpp
index 4060f3bc65..1165525904 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/StageFrightVideo.cpp
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.cpp
@@ -40,6 +40,7 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "windowing/egl/EGLWrapper.h"
+#include "windowing/WindowingFactory.h"
#include <new>
@@ -228,34 +229,25 @@ public:
if (frame->status == OK)
{
+ frame->width = p->width;
+ frame->height = p->height;
+ frame->pts = 0;
+
sp<MetaData> outFormat = p->decoder->getFormat();
outFormat->findInt32(kKeyWidth , &w);
outFormat->findInt32(kKeyHeight, &h);
- if (!outFormat->findInt32(kKeyDisplayWidth , &dw))
- dw = w;
- if (!outFormat->findInt32(kKeyDisplayHeight, &dh))
- dh = h;
-
- if (!outFormat->findInt32(kKeyIsSyncFrame, &keyframe))
- keyframe = 0;
- if (!outFormat->findInt32(kKeyIsUnreadable, &unreadable))
- unreadable = 0;
-
- frame->pts = 0;
-
// The OMX.SEC decoder doesn't signal the modified width/height
- if (p->decoder_component && !strncmp(p->decoder_component, "OMX.SEC", 7) &&
- (w & 15 || h & 15))
+ if (p->decoder_component && (w & 15 || h & 15) && !strncmp(p->decoder_component, "OMX.SEC", 7))
{
if (((w + 15)&~15) * ((h + 15)&~15) * 3/2 == frame->medbuf->range_length())
{
w = (w + 15)&~15;
h = (h + 15)&~15;
+ frame->width = w;
+ frame->height = h;
}
}
- frame->width = w;
- frame->height = h;
frame->medbuf->meta_data()->findInt64(kKeyTime, &(frame->pts));
}
else if (frame->status == INFO_FORMAT_CHANGED)
@@ -267,7 +259,7 @@ public:
outFormat->findInt32(kKeyHeight, &p->height);
cropLeft = cropTop = cropRight = cropBottom = 0;
- if (!outFormat->findRect(kKeyCropRect, &cropLeft, &cropTop, &cropRight, &cropBottom))
+ if (!outFormat->findRect(kKeyCropRect, &cropLeft, &cropTop, &cropRight, &cropBottom))
{
p->x = 0;
p->y = 0;
@@ -409,6 +401,21 @@ public:
/***********************************************************/
+CStageFrightVideo::CStageFrightVideo(CWinSystemEGL* windowing, CAdvancedSettings* advsettings)
+{
+#if defined(DEBUG_VERBOSE)
+ CLog::Log(LOGDEBUG, "%s::ctor: %d\n", CLASSNAME, sizeof(CStageFrightVideo));
+#endif
+ p = new CStageFrightVideoPrivate;
+ p->m_g_Windowing = windowing;
+ p->m_g_advancedSettings = advsettings;
+}
+
+CStageFrightVideo::~CStageFrightVideo()
+{
+ delete p;
+}
+
bool CStageFrightVideo::Open(CDVDStreamInfo &hints)
{
#if defined(DEBUG_VERBOSE)
@@ -423,12 +430,10 @@ bool CStageFrightVideo::Open(CDVDStreamInfo &hints)
CLog::Log(LOGERROR, "%s::%s - %s\n", CLASSNAME, __func__,"null size, cannot handle");
return false;
}
-
- p = new CStageFrightVideoPrivate;
p->width = hints.width;
p->height = hints.height;
- if (g_advancedSettings.m_stagefrightConfig.useSwRenderer)
+ if (p->m_g_advancedSettings->m_stagefrightConfig.useSwRenderer)
p->quirks |= QuirkSWRender;
sp<MetaData> outFormat;
@@ -438,26 +443,27 @@ bool CStageFrightVideo::Open(CDVDStreamInfo &hints)
p->meta = new MetaData;
if (p->meta == NULL)
{
- goto fail;
+ CLog::Log(LOGERROR, "%s::%s - %s\n", CLASSNAME, __func__,"cannot allocate MetaData");
+ return false;
}
const char* mimetype;
switch (hints.codec)
{
case CODEC_ID_H264:
- if (g_advancedSettings.m_stagefrightConfig.useAVCcodec == 0)
+ if (p->m_g_advancedSettings->m_stagefrightConfig.useAVCcodec == 0)
return false;
mimetype = MEDIA_MIMETYPE_VIDEO_AVC;
if ( *(char*)hints.extradata == 1 )
p->meta->setData(kKeyAVCC, kTypeAVCC, hints.extradata, hints.extrasize);
break;
case CODEC_ID_MPEG4:
- if (g_advancedSettings.m_stagefrightConfig.useMP4codec == 0)
+ if (p->m_g_advancedSettings->m_stagefrightConfig.useMP4codec == 0)
return false;
mimetype = MEDIA_MIMETYPE_VIDEO_MPEG4;
break;
case CODEC_ID_MPEG2VIDEO:
- if (g_advancedSettings.m_stagefrightConfig.useMPEG2codec == 0)
+ if (p->m_g_advancedSettings->m_stagefrightConfig.useMPEG2codec == 0)
return false;
mimetype = MEDIA_MIMETYPE_VIDEO_MPEG2;
break;
@@ -465,13 +471,13 @@ bool CStageFrightVideo::Open(CDVDStreamInfo &hints)
case CODEC_ID_VP6:
case CODEC_ID_VP6F:
case CODEC_ID_VP8:
- if (g_advancedSettings.m_stagefrightConfig.useVPXcodec == 0)
+ if (p->m_g_advancedSettings->m_stagefrightConfig.useVPXcodec == 0)
return false;
mimetype = MEDIA_MIMETYPE_VIDEO_VPX;
break;
case CODEC_ID_VC1:
case CODEC_ID_WMV3:
- if (g_advancedSettings.m_stagefrightConfig.useVC1codec == 0)
+ if (p->m_g_advancedSettings->m_stagefrightConfig.useVC1codec == 0)
return false;
mimetype = MEDIA_MIMETYPE_VIDEO_WMV;
break;
@@ -491,7 +497,8 @@ bool CStageFrightVideo::Open(CDVDStreamInfo &hints)
if (p->source == NULL || p->client == NULL)
{
- goto fail;
+ CLog::Log(LOGERROR, "%s::%s - %s\n", CLASSNAME, __func__,"Cannot obtain source / client");
+ return false;
}
if (p->client->connect() != OK)
@@ -499,7 +506,7 @@ bool CStageFrightVideo::Open(CDVDStreamInfo &hints)
delete p->client;
p->client = NULL;
CLog::Log(LOGERROR, "%s::%s - %s\n", CLASSNAME, __func__,"Cannot connect OMX client");
- goto fail;
+ return false;
}
if ((p->quirks & QuirkSWRender) == 0)
@@ -514,14 +521,14 @@ bool CStageFrightVideo::Open(CDVDStreamInfo &hints)
if (!(p->decoder != NULL && p->decoder->start() == OK))
{
p->decoder = NULL;
- goto fail;
+ return false;
}
outFormat = p->decoder->getFormat();
if (!outFormat->findInt32(kKeyWidth, &p->width) || !outFormat->findInt32(kKeyHeight, &p->height)
|| !outFormat->findInt32(kKeyColorFormat, &p->videoColorFormat))
- goto fail;
+ return false;
const char *component;
if (outFormat->findCString(kKeyDecoderComponent, &component))
@@ -533,13 +540,13 @@ bool CStageFrightVideo::Open(CDVDStreamInfo &hints)
{
// On some platforms, software decoders are returned anyway
CLog::Log(LOGERROR, "%s::%s - %s\n", CLASSNAME, __func__,"Blacklisted component (software)");
- goto fail;
+ return false;
}
- else if (!strncmp(component, "OMX.Nvidia.mp4.decode", 21) && g_advancedSettings.m_stagefrightConfig.useMP4codec != 1)
+ else if (!strncmp(component, "OMX.Nvidia.mp4.decode", 21) && p->m_g_advancedSettings->m_stagefrightConfig.useMP4codec != 1)
{
// Has issues with some XVID encoded MP4. Only fails after actual decoding starts...
CLog::Log(LOGERROR, "%s::%s - %s\n", CLASSNAME, __func__,"Blacklisted component (MP4)");
- goto fail;
+ return false;
}
}
@@ -576,20 +583,6 @@ bool CStageFrightVideo::Open(CDVDStreamInfo &hints)
#endif
return true;
-
-fail:
- if (p->decoder != 0)
- p->decoder->stop();
- if (p->client)
- {
- p->client->disconnect();
- delete p->client;
- }
- if (p->decoder_component)
- free(&p->decoder_component);
- if ((p->quirks & QuirkSWRender) == 0)
- p->UninitStagefrightSurface();
- return false;
}
/*** Decode ***/
@@ -612,7 +605,7 @@ int CStageFrightVideo::Decode(uint8_t *pData, int iSize, double dts, double pts
return VC_ERROR;
frame->status = OK;
- if (g_advancedSettings.m_stagefrightConfig.useInputDTS)
+ if (p->m_g_advancedSettings->m_stagefrightConfig.useInputDTS)
frame->pts = (dts != DVD_NOPTS_VALUE) ? pts_dtoi(dts) : ((pts != DVD_NOPTS_VALUE) ? pts_dtoi(pts) : 0);
else
frame->pts = (pts != DVD_NOPTS_VALUE) ? pts_dtoi(pts) : ((dts != DVD_NOPTS_VALUE) ? pts_dtoi(dts) : 0);
@@ -708,7 +701,6 @@ bool CStageFrightVideo::GetPicture(DVDVideoPicture* pDvdVideoPicture)
pDvdVideoPicture->iDisplayWidth = frame->width;
pDvdVideoPicture->iDisplayHeight = frame->height;
pDvdVideoPicture->iFlags = DVP_FLAG_ALLOCATED;
- pDvdVideoPicture->stf = this;
pDvdVideoPicture->eglimg = EGL_NO_IMAGE_KHR;
if (status != OK)
@@ -827,8 +819,10 @@ void CStageFrightVideo::Close()
#if defined(DEBUG_VERBOSE)
CLog::Log(LOGDEBUG, "Stopping omxcodec\n");
#endif
- p->decoder->stop();
- p->client->disconnect();
+ if (p->decoder != NULL)
+ p->decoder->stop();
+ if (p->client)
+ p->client->disconnect();
#if defined(DEBUG_VERBOSE)
CLog::Log(LOGDEBUG, "Cleaning IN(%d)\n", p->in_queue.size());
@@ -843,22 +837,30 @@ void CStageFrightVideo::Close()
frame->medbuf->release();
free(frame);
}
+
+#if defined(DEBUG_VERBOSE)
+ CLog::Log(LOGDEBUG, "Cleaning libstagefright\n", p->in_queue.size());
+#endif
+ if ((p->quirks & QuirkSWRender) == 0)
+ p->UninitStagefrightSurface();
+#if defined(DEBUG_VERBOSE)
+ CLog::Log(LOGDEBUG, "Final Cleaning\n", p->in_queue.size());
+#endif
if (p->decoder_component)
free(&p->decoder_component);
delete p->client;
- if ((p->quirks & QuirkSWRender) == 0)
- p->UninitStagefrightSurface();
-
for (int i=0; i<INBUFCOUNT; ++i)
{
- p->inbuf[i]->setObserver(NULL);
- p->inbuf[i]->release();
+ if (p->inbuf[i])
+ {
+ p->inbuf[i]->setObserver(NULL);
+ p->inbuf[i]->release();
+ p->inbuf[i] = NULL;
+ }
}
-
- delete p;
}
void CStageFrightVideo::Reset(void)
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/StageFrightVideo.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.h
index 7e3cfd5884..4ddc310e2b 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/StageFrightVideo.h
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideo.h
@@ -24,6 +24,8 @@
#include "cores/dvdplayer/DVDStreamInfo.h"
#include "DVDVideoCodec.h"
+class CWinSystemEGL;
+class CAdvancedSettings;
class CStageFrightVideoPrivate;
namespace android { class MediaBuffer; }
@@ -31,8 +33,8 @@ namespace android { class MediaBuffer; }
class CStageFrightVideo
{
public:
- CStageFrightVideo() {};
- virtual ~CStageFrightVideo() {};
+ CStageFrightVideo(CWinSystemEGL* windowing, CAdvancedSettings* advsettings);
+ virtual ~CStageFrightVideo();
bool Open(CDVDStreamInfo &hints);
void Close(void);
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/StageFrightVideoPrivate.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideoPrivate.cpp
index 996a38d425..ab638a099e 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/StageFrightVideoPrivate.cpp
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideoPrivate.cpp
@@ -19,6 +19,8 @@
*/
/***************************************************************************/
+//#define DEBUG_VERBOSE 1
+
#include "StageFrightVideoPrivate.h"
#include <EGL/egl.h>
@@ -27,11 +29,14 @@
#include <GLES2/gl2ext.h>
#include "windowing/egl/EGLWrapper.h"
#include "windowing/WindowingFactory.h"
+#include "settings/AdvancedSettings.h"
#include "utils/log.h"
#include "android/jni/Surface.h"
#include "android/jni/SurfaceTexture.h"
+#define CLASSNAME "CStageFrightVideoPrivate"
+
GLint glerror;
#define CheckEglError(x) while((glerror = eglGetError()) != EGL_SUCCESS) CLog::Log(LOGERROR, "EGL error in %s: %x",x, glerror);
#define CheckGlError(x) while((glerror = glGetError()) != GL_NO_ERROR) CLog::Log(LOGERROR, "GL error in %s: %x",x, glerror);
@@ -61,7 +66,6 @@ CStageFrightVideoPrivate::CStageFrightVideoPrivate()
, texwidth(-1), texheight(-1)
, client(NULL), decoder(NULL), decoder_component(NULL)
, drop_state(false), resetting(false)
- , mVideoNativeWindow(NULL)
{
if (!eglCreateImageKHR)
eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) CEGLWrapper::GetProcAddress("eglCreateImageKHR");
@@ -69,6 +73,9 @@ CStageFrightVideoPrivate::CStageFrightVideoPrivate()
eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) CEGLWrapper::GetProcAddress("eglDestroyImageKHR");
if (!glEGLImageTargetTexture2DOES)
glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) CEGLWrapper::GetProcAddress("glEGLImageTargetTexture2DOES");
+
+ for (int i=0; i<INBUFCOUNT; ++i)
+ inbuf[i] = NULL;
}
void CStageFrightVideoPrivate::signalBufferReturned(MediaBuffer *buffer)
@@ -224,27 +231,32 @@ void CStageFrightVideoPrivate::OES_shader_setUp()
void CStageFrightVideoPrivate::InitializeEGL(int w, int h)
{
+#if defined(DEBUG_VERBOSE)
+ CLog::Log(LOGDEBUG, "%s: >>> InitializeEGL: w:%d; h:%d\n", CLASSNAME, w, h);
+#endif
texwidth = w;
texheight = h;
- if (!g_Windowing.IsExtSupported("GL_TEXTURE_NPOT"))
+ if (!m_g_Windowing->IsExtSupported("GL_TEXTURE_NPOT"))
{
texwidth = NP2(texwidth);
texheight = NP2(texheight);
}
eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+ if (eglDisplay == EGL_NO_DISPLAY)
+ CLog::Log(LOGERROR, "%s: InitializeEGL: no display\n", CLASSNAME);
eglBindAPI(EGL_OPENGL_ES_API);
EGLint contextAttributes[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
- eglContext = eglCreateContext(eglDisplay, g_Windowing.GetEGLConfig(), EGL_NO_CONTEXT, contextAttributes);
+ eglContext = eglCreateContext(eglDisplay, m_g_Windowing->GetEGLConfig(), EGL_NO_CONTEXT, contextAttributes);
EGLint pbufferAttribs[] = {
EGL_WIDTH, texwidth,
EGL_HEIGHT, texheight,
EGL_NONE
};
- eglSurface = eglCreatePbufferSurface(eglDisplay, g_Windowing.GetEGLConfig(), pbufferAttribs);
+ eglSurface = eglCreatePbufferSurface(eglDisplay, m_g_Windowing->GetEGLConfig(), pbufferAttribs);
eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
CheckGlError("stf init");
@@ -279,12 +291,15 @@ void CStageFrightVideoPrivate::InitializeEGL(int w, int h)
eglInitialized = true;
#if defined(DEBUG_VERBOSE)
- CLog::Log(LOGDEBUG, "%s: >>> Initialized EGL: w:%d; h:%d\n", CLASSNAME, texwidth, texheight);
+ CLog::Log(LOGDEBUG, "%s: <<< InitializeEGL: w:%d; h:%d\n", CLASSNAME, texwidth, texheight);
#endif
}
void CStageFrightVideoPrivate::UninitializeEGL()
{
+#if defined(DEBUG_VERBOSE)
+ CLog::Log(LOGDEBUG, "%s: >>> UninitializeEGL\n", CLASSNAME);
+#endif
fbo.Cleanup();
for (int i=0; i<NUMFBOTEX; ++i)
{
@@ -305,11 +320,12 @@ void CStageFrightVideoPrivate::UninitializeEGL()
bool CStageFrightVideoPrivate::InitStagefrightSurface()
{
+#if defined(DEBUG_VERBOSE)
+ CLog::Log(LOGDEBUG, "%s: >>> InitStagefrightSurface\n", CLASSNAME);
+#endif
if (mVideoNativeWindow != NULL)
return true;
- JNIEnv* env = xbmc_jnienv();
-
mVideoTextureId = -1;
glGenTextures(1, &mVideoTextureId);
@@ -323,14 +339,21 @@ bool CStageFrightVideoPrivate::InitStagefrightSurface()
mSurfTexture = new CJNISurfaceTexture(mVideoTextureId);
mSurface = new CJNISurface(*mSurfTexture);
+ JNIEnv* env = xbmc_jnienv();
mVideoNativeWindow = ANativeWindow_fromSurface(env, mSurface->get_raw());
native_window_api_connect(mVideoNativeWindow.get(), NATIVE_WINDOW_API_MEDIA);
+#if defined(DEBUG_VERBOSE)
+ CLog::Log(LOGDEBUG, "%s: <<< InitStagefrightSurface\n", CLASSNAME);
+#endif
return true;
}
void CStageFrightVideoPrivate::UninitStagefrightSurface()
{
+#if defined(DEBUG_VERBOSE)
+ CLog::Log(LOGDEBUG, "%s: >>> UninitStagefrightSurface\n", CLASSNAME);
+#endif
if (mVideoNativeWindow == NULL)
return;
@@ -338,10 +361,16 @@ void CStageFrightVideoPrivate::UninitStagefrightSurface()
ANativeWindow_release(mVideoNativeWindow.get());
mVideoNativeWindow = NULL;
+ mSurface->release();
+ mSurfTexture->release();
+
delete mSurface;
delete mSurfTexture;
glDeleteTextures(1, &mVideoTextureId);
+#if defined(DEBUG_VERBOSE)
+ CLog::Log(LOGDEBUG, "%s: <<< UninitStagefrightSurface\n", CLASSNAME);
+#endif
}
void CStageFrightVideoPrivate::UpdateStagefrightTexture()
@@ -351,6 +380,6 @@ void CStageFrightVideoPrivate::UpdateStagefrightTexture()
void CStageFrightVideoPrivate::GetStagefrightTransformMatrix(float* transformMatrix)
{
- mSurfTexture->getTransformMatrix(transformMatrix);
+ mSurfTexture->getTransformMatrix(transformMatrix);
}
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/StageFrightVideoPrivate.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideoPrivate.h
index 2f9886f17b..d10ef41354 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/StageFrightVideoPrivate.h
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/libstagefrightICS/StageFrightVideoPrivate.h
@@ -54,6 +54,8 @@
class CStageFrightDecodeThread;
class CJNISurface;
class CJNISurfaceTexture;
+class CWinSystemEGL;
+class CAdvancedSettings;
using namespace android;
@@ -107,6 +109,9 @@ public:
GLint mTexSamplerHandle;
GLint mTexMatrixHandle;
+ CWinSystemEGL* m_g_Windowing;
+ CAdvancedSettings* m_g_advancedSettings;
+
CFrameBufferObject fbo;
EGLDisplay eglDisplay;
EGLSurface eglSurface;