diff options
author | Rainer Hochecker <fernetmenta@online.de> | 2016-02-09 18:01:44 +0100 |
---|---|---|
committer | Rainer Hochecker <fernetmenta@online.de> | 2016-03-05 08:38:18 +0100 |
commit | e3760717b838909387a9f14438c23c38df4d5c7c (patch) | |
tree | a35c061e8ebe2b9b6b19a67827cff061c876ff96 /lib | |
parent | 0540ad644c26a66376a5714ac722fe64a5bd1e3c (diff) |
add callback lib for inputstream
Diffstat (limited to 'lib')
-rw-r--r-- | lib/addons/library.kodi.inputstream/Makefile.in | 29 | ||||
-rw-r--r-- | lib/addons/library.kodi.inputstream/libKODI_inputstream.cpp | 77 |
2 files changed, 106 insertions, 0 deletions
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 <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string> +#include "addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h" +#include "addons/AddonCallbacks.h" + +#ifdef _WIN32 +#include <windows.h> +#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); +} + +}; |