From e3760717b838909387a9f14438c23c38df4d5c7c Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Tue, 9 Feb 2016 18:01:44 +0100 Subject: add callback lib for inputstream --- lib/addons/library.kodi.inputstream/Makefile.in | 29 ++++++++ .../libKODI_inputstream.cpp | 77 ++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 lib/addons/library.kodi.inputstream/Makefile.in create mode 100644 lib/addons/library.kodi.inputstream/libKODI_inputstream.cpp (limited to 'lib') diff --git a/lib/addons/library.kodi.inputstream/Makefile.in b/lib/addons/library.kodi.inputstream/Makefile.in new file mode 100644 index 0000000000..0d14a2e0e1 --- /dev/null +++ b/lib/addons/library.kodi.inputstream/Makefile.in @@ -0,0 +1,29 @@ +ARCH=@ARCH@ +INCLUDES=-I. -I../../../xbmc/addons/include -I../../../xbmc +DEFINES+= +CXXFLAGS=-fPIC +LIBNAME=libKODI_inputstream +OBJS=$(LIBNAME).o + +ifeq ($(findstring osx,$(ARCH)), osx) +LIB_SHARED=../../../addons/library.kodi.inputstream/$(LIBNAME)-$(ARCH).dylib +else +LIB_SHARED=../../../addons/library.kodi.inputstream/$(LIBNAME)-$(ARCH).so +endif + +all: $(LIB_SHARED) + +$(LIB_SHARED): $(OBJS) +ifeq ($(findstring osx,$(ARCH)), osx) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -dynamiclib -o $@ $(OBJS) +else + $(CXX) $(CFLAGS) $(LDFLAGS) -shared -g -o $(LIB_SHARED) $(OBJS) +endif + +CLEAN_FILES = \ + $(LIB_SHARED) \ + +DISTCLEAN_FILES= \ + Makefile \ + +include ../../../Makefile.include diff --git a/lib/addons/library.kodi.inputstream/libKODI_inputstream.cpp b/lib/addons/library.kodi.inputstream/libKODI_inputstream.cpp new file mode 100644 index 0000000000..3ec5bcbbae --- /dev/null +++ b/lib/addons/library.kodi.inputstream/libKODI_inputstream.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2012-2013 Team XBMC + * http://www.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, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#include +#include +#include +#include +#include "addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h" +#include "addons/AddonCallbacks.h" + +#ifdef _WIN32 +#include +#define DLLEXPORT __declspec(dllexport) +#else +#define DLLEXPORT +#endif + +using namespace std; + +extern "C" +{ + +DLLEXPORT void* INPUTSTREAM_register_me(void *hdl) +{ + CB_INPUTSTREAMLib *cb = nullptr; + if (!hdl) + fprintf(stderr, "libKODI_inputstream-ERROR: %s is called with NULL handle\n", __FUNCTION__); + else + { + cb = ((AddonCB*)hdl)->INPUTSTREAMLib_RegisterMe(((AddonCB*)hdl)->addonData); + if (!cb) + fprintf(stderr, "libKODI_inputstream--ERROR: %s can't get callback table from KODI\n", __FUNCTION__); + } + return cb; +} + +DLLEXPORT void INPUTSTREAM_unregister_me(void *hdl, void* cb) +{ + if (hdl && cb) + ((AddonCB*)hdl)->INPUTSTREAMLib_UnRegisterMe(((AddonCB*)hdl)->addonData, (CB_INPUTSTREAMLib*)cb); +} + +DLLEXPORT DemuxPacket* INPUTSTREAM_allocate_demux_packet(void *hdl, void* cb, int iDataSize) +{ + if (cb == NULL) + return NULL; + + return ((CB_INPUTSTREAMLib*)cb)->AllocateDemuxPacket(((AddonCB*)hdl)->addonData, iDataSize); +} + +DLLEXPORT void INPUTSTREAM_free_demux_packet(void *hdl, void* cb, DemuxPacket* pPacket) +{ + if (cb == NULL) + return; + + ((CB_INPUTSTREAMLib*)cb)->FreeDemuxPacket(((AddonCB*)hdl)->addonData, pPacket); +} + +}; -- cgit v1.2.3