From 9fc8b732737f139d3e466510d75668ab45578960 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 8 Mar 2016 21:02:53 +0100 Subject: sync with upstream --- .../include/kodi/kodi_adsp_dll.h | 564 ++++++++++++++ .../include/kodi/kodi_adsp_types.h | 524 +++++++++++++ .../include/kodi/kodi_audiodec_dll.h | 60 ++ .../include/kodi/kodi_audiodec_types.h | 101 +++ .../include/kodi/kodi_audioengine_types.h | 165 ++++ .../include/kodi/kodi_inputstream_dll.h | 257 +++++++ .../include/kodi/kodi_inputstream_types.h | 161 ++++ .../kodi-addon-dev-kit/include/kodi/libKODI_adsp.h | 232 ++++++ .../include/kodi/libKODI_audioengine.h | 324 ++++++++ .../include/kodi/libKODI_guilib.h | 845 +++++++++++++++++++++ .../include/kodi/libKODI_inputstream.h | 150 ++++ .../include/kodi/libXBMC_addon.h | 710 +++++++++++++++++ .../include/kodi/libXBMC_codec.h | 124 +++ .../kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h | 366 +++++++++ .../include/kodi/xbmc_addon_cpp_dll.h | 189 +++++ .../include/kodi/xbmc_addon_dll.h | 52 ++ .../include/kodi/xbmc_addon_types.h | 62 ++ .../include/kodi/xbmc_audioenc_dll.h | 58 ++ .../include/kodi/xbmc_audioenc_types.h | 110 +++ .../include/kodi/xbmc_codec_types.h | 52 ++ .../include/kodi/xbmc_epg_types.h | 123 +++ .../kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h | 741 ++++++++++++++++++ .../include/kodi/xbmc_pvr_types.h | 597 +++++++++++++++ .../kodi-addon-dev-kit/include/kodi/xbmc_scr_dll.h | 42 + .../include/kodi/xbmc_scr_types.h | 50 ++ .../include/kodi/xbmc_stream_utils.hpp | 264 +++++++ .../kodi-addon-dev-kit/include/kodi/xbmc_vis_dll.h | 53 ++ .../include/kodi/xbmc_vis_types.h | 110 +++ 28 files changed, 7086 insertions(+) create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_dll.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_types.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_dll.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_types.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audioengine_types.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_adsp.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_codec.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_cpp_dll.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_dll.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_types.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_dll.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_types.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_codec_types.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_dll.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_types.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_stream_utils.hpp create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_dll.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_types.h (limited to 'xbmc/addons/kodi-addon-dev-kit/include') diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_dll.h new file mode 100644 index 0000000..c1d8238 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_dll.h @@ -0,0 +1,564 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +/*! + * @file kodi_adsp_dll.h + * @section sec1 Basic audio dsp addon interface description + * @author Team Kodi + * @date 10. May 2014 + * @version 0.1.5 + * + * @subsection sec1_1 General + * @li The basic support on the addon is supplied with the + * AE_DSP_ADDON_CAPABILITIES data which becomes asked over + * GetAddonCapabilities(...), further the addon must register his available + * modes on startup with the RegisterMode(...) callback function (see + * libKODI_adsp.h). If one of this two points is not set the addon becomes + * ignored for the chain step. + * + * @subsection sec1_2 Processing + * @li On start of new stream the addon becomes called with StreamCreate(...) + * to check about given values that it support it basically and can create + * his structure, if nothing is supported it can return AE_DSP_ERROR_IGNORE_ME. + * + * @li As next step StreamIsModeSupported(...) becomes called for every + * available and enabled modes, is separated due to more as one available mode + * on the addon is possible, if the mode is not supported it can also be return + * AE_DSP_ERROR_IGNORE_ME. + * - If mode is a resample mode and returns no error it becomes asked with + * InputResampleSampleRate(...) or OutputResampleSampleRate(...) (relevant + * to his type) about his given sample rate. + * - About the from user selected master processing mode the related addon + * becomes called now with MasterProcessSetMode(...) to handle it's + * selectionon the addon given by the own addon type identifier or by + * KODI's useddatabase id, also the currently used stream type (e.g. + * Music or Video) is send. + * - If the addon supports only one master mode it can ignore this function + * and return always AE_DSP_ERROR_NO_ERROR. + * - If the master mode is set the addon becomes asked about the from him + * given output channel layout related to up- or downmix modes, if + * nothing becomes changed on the layout it can return -1. + * - The MasterProcessSetMode(...) is also called if from user a another + * mode becomes selected. + * + * @li Then as last step shortly before the first process call becomes executed + * the addon is called one time with StreamInitialize(...) to inform that + * processing is started on the given settings. + * - This function becomes also called on all add-ons if the master process + * becomes changed. + * - Also every process after StreamInitialize on the addon mode becomes asked + * with _..._ProcessNeededSamplesize(...) about required memory size for the + * output of his data, if no other size is required it can return 0. + * + * @li From now the processing becomes handled for the different steps with + * _..._Process(...). + * - Further it becomes asked with _..._GetDelay(...) about his processing + * time as float value in seconds, needed for video and audio alignment. + * + * @li On the end of the processing if the source becomes stopped the + * StreamDestroy(...) function becomes called on all active processing add-ons. + * + * @note + * The StreamCreate(...) can be becomes called for a new stream before the + * previous was closed with StreamDestroy(...) ! To have a speed improve. + */ + +#include "xbmc_addon_dll.h" +#include "kodi_adsp_types.h" + +/*! + * Functions that the Audio DSP add-on must implement, but some can be empty. + * + * The 'remarks' field indicates which methods should be implemented, and which + * ones are optional. + */ + +extern "C" +{ + /*! @name Audio DSP add-on methods */ + //@{ + /*! + * Get the KODI_AE_DSP_API_VERSION that was used to compile this add-on. + * Used to check if this add-on is compatible with KODI. + * @return The KODI_AE_DSP_API_VERSION that was used to compile this add-on. + * @remarks Valid implementation required. + */ + const char* GetAudioDSPAPIVersion(void); + + /*! + * Get the KODI_AE_DSP_MIN_API_VERSION that was used to compile this add-on. + * Used to check if this add-on is compatible with KODI. + * @return The KODI_AE_DSP_MIN_API_VERSION that was used to compile this add-on. + * @remarks Valid implementation required. + */ + const char* GetMinimumAudioDSPAPIVersion(void); + + /*! + * @brief Get the KODI_GUI_API_VERSION that was used to compile this add-on. + * Used to check if this add-on is compatible with KODI. + * @return The KODI_GUI_API_VERSION that was used to compile this add-on. + * @remarks Valid implementation required. + */ + const char* GetGUIAPIVersion(void); + + /*! + * @brief Get the KODI_GUI_MIN_API_VERSION that was used to compile this + * add-on. + * Used to check if this add-on is compatible with KODI. + * @return The KODI_GUI_MIN_API_VERSION that was used to compile this add-on. + * @remarks Valid implementation required. + */ + const char* GetMinimumGUIAPIVersion(void); + + /*! + * @brief Get the list of features that this add-on provides. + * Called by KODI to query the add-ons capabilities. + * Used to check which options should be presented in the DSP, which methods + * to call, etc. + * All capabilities that the add-on supports should be set to true. + * @param pCapabilities The add-ons capabilities. + * @return AE_DSP_ERROR_NO_ERROR if the properties were fetched successfully. + * @remarks Valid implementation required. + */ + AE_DSP_ERROR GetAddonCapabilities(AE_DSP_ADDON_CAPABILITIES *pCapabilities); + + /*! + * @return The name reported by the back end that will be displayed in the + * UI. + * @remarks Valid implementation required. + */ + const char* GetDSPName(void); + + /*! + * @return The version string reported by the back end that will be displayed + * in the UI. + * @remarks Valid implementation required. + */ + const char* GetDSPVersion(void); + + /*! + * @brief Call one of the menu hooks (if supported). + * Supported AE_DSP_MENUHOOK instances have to be added in ADDON_Create(), + * by calling AddMenuHook() on the callback. + * @param menuhook The hook to call. + * @param item The selected item for which the hook was called. + * @return AE_DSP_ERROR_NO_ERROR if the hook was called successfully. + * @remarks Optional. Return AE_DSP_ERROR_NOT_IMPLEMENTED if this add-on + * won't provide this function. + */ + AE_DSP_ERROR CallMenuHook(const AE_DSP_MENUHOOK& menuhook, const AE_DSP_MENUHOOK_DATA &item); + //@} + + /** @name DSP processing control, used to open and close a stream + * @remarks Valid implementation required. + */ + //@{ + /*! + * @brief Set up Audio DSP with selected audio settings (use the basic + * present audio stream data format). + * Used to detect available add-ons for present stream, as example stereo + * surround upmix not needed on 5.1 audio stream. + * @param addonSettings The add-ons audio settings. + * @param pProperties The properties of the currently playing stream. + * @param handle On this becomes addon informated about stream id and can set function addresses which need on calls + * @return AE_DSP_ERROR_NO_ERROR if the properties were fetched successfully + * and data can be performed. AE_DSP_ERROR_IGNORE_ME if format is not + * supported, but without fault. + * @remarks Valid implementation required. + */ + AE_DSP_ERROR StreamCreate(const AE_DSP_SETTINGS *addonSettings, const AE_DSP_STREAM_PROPERTIES* pProperties, ADDON_HANDLE handle); + + /*! + * Remove the selected id from currently used DSP processes + * @param handle identification data for stream + * @return AE_DSP_ERROR_NO_ERROR if the becomes found and removed + * @remarks Valid implementation required. + */ + AE_DSP_ERROR StreamDestroy(const ADDON_HANDLE handle); + + /*! + * @brief Ask the add-on about a requested processing mode that it is + * supported on the current stream. Is called about every add-on mode after + * successed StreamCreate. + * @param handle identification data for stream + * @param type The processing mode type, see AE_DSP_MODE_TYPE for definitions + * @param mode_id The mode inside add-on which must be performed on call. Id + * is set from add-on by iModeNumber on AE_DSP_MODE structure during + * RegisterMode callback, + * @param unique_db_mode_id The Mode unique id generated from dsp database. + * @return AE_DSP_ERROR_NO_ERROR if the properties were fetched successfully + * or if the stream is not supported the add-on must return + * AE_DSP_ERROR_IGNORE_ME. + * @remarks Valid implementation required. + */ + AE_DSP_ERROR StreamIsModeSupported(const ADDON_HANDLE handle, AE_DSP_MODE_TYPE type, unsigned int mode_id, int unique_db_mode_id); + + /*! + * @brief Set up Audio DSP with selected audio settings (detected on data of + * first present audio packet) + * @param addonSettings The add-ons audio settings. + * @return AE_DSP_ERROR_NO_ERROR if the properties were fetched successfully. + * @remarks Valid implementation required. + */ + AE_DSP_ERROR StreamInitialize(const ADDON_HANDLE handle, const AE_DSP_SETTINGS *addonSettings); + //@} + + /** @name DSP input processing + * @remarks Only used by KODI if bSupportsInputProcess is set to true. + */ + //@{ + /*! + * @brief DSP input processing + * Can be used to have unchanged stream.. + * All DSP add-ons allowed to-do this. + * @param handle identification data for stream + * @param array_in Pointer to data memory + * @param samples Amount of samples inside array_in + * @return true if work was OK + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + bool InputProcess(const ADDON_HANDLE handle, const float **array_in, unsigned int samples); + //@} + + /** @name DSP pre-resampling + * @remarks Only used by KODI if bSupportsInputResample is set to true. + */ + //@{ + /*! + * @brief If the add-on operate with buffered arrays and the output size can + * be higher as the input it becomes asked about needed size before any + * InputResampleProcess call. + * @param handle identification data for stream + * @return The needed size of output array or 0 if no changes within it + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + unsigned int InputResampleProcessNeededSamplesize(const ADDON_HANDLE handle); + + /*! + * @brief DSP re sample processing before master. + * Here a high quality resample can be performed. + * Only one DSP add-on is allowed to-do this! + * @param handle identification data for stream + * @param array_in Pointer to input data memory + * @param array_out Pointer to output data memory + * @param samples Amount of samples inside array_in + * @return Amount of samples processed + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + unsigned int InputResampleProcess(const ADDON_HANDLE handle, float **array_in, float **array_out, unsigned int samples); + + /*! + * @brief Returns the re-sampling generated new sample rate used before the + * master process + * @param handle identification data for stream + * @return The new sample rate + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + int InputResampleSampleRate(const ADDON_HANDLE handle); + + /*! + * @brief Returns the time in seconds that it will take + * for the next added packet to be returned to KODI. + * @param handle identification data for stream + * @return the delay in seconds + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + float InputResampleGetDelay(const ADDON_HANDLE handle); + //@} + + /** @name DSP Pre processing + * @remarks Only used by KODI if bSupportsPreProcess is set to true. + */ + //@{ + /*! + * @brief If the addon operate with buffered arrays and the output size can + * be higher as the input it becomes asked about needed size before any + * PreProcess call. + * @param handle identification data for stream + * @param mode_id The mode inside add-on which must be performed on call. Id + * is set from add-on by iModeNumber on AE_DSP_MODE structure during + * RegisterMode callback and can be defined from add-on as a structure + * pointer or anything else what is needed to find it. + * @return The needed size of output array or 0 if no changes within it + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + unsigned int PreProcessNeededSamplesize(const ADDON_HANDLE handle, unsigned int mode_id); + + /*! + * @brief Returns the time in seconds that it will take + * for the next added packet to be returned to KODI. + * @param handle identification data for stream + * @param mode_id The mode inside add-on which must be performed on call. Id + * is set from add-on by iModeNumber on AE_DSP_MODE structure during + * RegisterMode callback and can be defined from add-on as a structure + * pointer or anything else what is needed to find it. + * @return the delay in seconds + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + float PreProcessGetDelay(const ADDON_HANDLE handle, unsigned int mode_id); + + /*! + * @brief DSP preprocessing + * All DSP add-ons allowed to-do this. + * @param handle identification data for stream + * @param mode_id The mode inside add-on which must be performed on call. Id + * is set from add-on by iModeNumber on AE_DSP_MODE structure during + * RegisterMode callback and can be defined from add-on as a structure + * pointer or anything else what is needed to find it. + * @param array_in Pointer to input data memory + * @param array_out Pointer to output data memory + * @param samples Amount of samples inside array_in + * @return Amount of samples processed + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + unsigned int PreProcess(const ADDON_HANDLE handle, unsigned int mode_id, float **array_in, float **array_out, unsigned int samples); + //@} + + /** @name DSP Master processing + * @remarks Only used by KODI if bSupportsMasterProcess is set to true. + */ + //@{ + /*! + * @brief Set the active master process mode + * @param handle identification data for stream + * @param type Requested stream type for the selected master mode + * @param mode_id The Mode identifier. + * @param unique_db_mode_id The Mode unique id generated from DSP database. + * @return AE_DSP_ERROR_NO_ERROR if the setup was successful + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + AE_DSP_ERROR MasterProcessSetMode(const ADDON_HANDLE handle, AE_DSP_STREAMTYPE type, unsigned int mode_id, int unique_db_mode_id); + + /*! + * @brief If the add-on operate with buffered arrays and the output size can + * be higher as the input it becomes asked about needed size before any + * MasterProcess call. + * @param handle identification data for stream + * @return The needed size of output array or 0 if no changes within it + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + unsigned int MasterProcessNeededSamplesize(const ADDON_HANDLE handle); + + /*! + * @brief Returns the time in seconds that it will take + * for the next added packet to be returned to KODI. + * @param handle identification data for stream + * @return the delay in seconds + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + float MasterProcessGetDelay(const ADDON_HANDLE handle); + + /*! + * @brief Returns the from selected master mode performed channel alignment + * @param handle identification data for stream + * @retval out_channel_present_flags the exact channel present flags after + * performed up-/downmix + * @return the amount channels + * @remarks Optional. Must be used and set if a channel up- or downmix is + * processed from the active master mode + */ + int MasterProcessGetOutChannels(const ADDON_HANDLE handle, unsigned long &out_channel_present_flags); + + /*! + * @brief Master processing becomes performed with it + * Here a channel up-mix/down-mix for stereo surround sound can be performed + * Only one DSP add-on is allowed to-do this! + * @param handle identification data for stream + * @param array_in Pointer to input data memory + * @param array_out Pointer to output data memory + * @param samples Amount of samples inside array_in + * @return Amount of samples processed + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + unsigned int MasterProcess(const ADDON_HANDLE handle, float **array_in, float **array_out, unsigned int samples); + + /*! + * Used to get a information string about the processed work to show on skin + * @return A string to show + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + const char *MasterProcessGetStreamInfoString(const ADDON_HANDLE handle); + //@} + + /** @name DSP Post processing + * @remarks Only used by KODI if bSupportsPostProcess is set to true. + */ + //@{ + /*! + * If the add-on operate with buffered arrays and the output size can be + * higher as the input it becomes asked about needed size before any + * PostProcess call. + * @param handle identification data for stream + * @param mode_id The mode inside add-on which must be performed on call. Id + * is set from add-on by iModeNumber on AE_DSP_MODE structure during + * RegisterMode callback, and can be defined from add-on as a structure + * pointer or anything else what is needed to find it. + * @return The needed size of output array or 0 if no changes within it + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + unsigned int PostProcessNeededSamplesize(const ADDON_HANDLE handle, unsigned int mode_id); + + /*! + * Returns the time in seconds that it will take + * for the next added packet to be returned to KODI. + * @param handle identification data for stream + * @param mode_id The mode inside add-on which must be performed on call. Id + * is set from add-on by iModeNumber on AE_DSP_MODE structure during + * RegisterMode callback, and can be defined from add-on as a structure + * pointer or anything else what is needed to find it. + * @return the delay in seconds + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + float PostProcessGetDelay(const ADDON_HANDLE handle, unsigned int mode_id); + + /*! + * @brief DSP post processing + * On the post processing can be things performed with additional channel + * upmix like 6.1 to 7.1 + * or frequency/volume corrections, speaker distance handling, equalizer... . + * All DSP add-ons allowed to-do this. + * @param handle identification data for stream + * @param mode_id The mode inside add-on which must be performed on call. Id + * is set from add-on by iModeNumber on AE_DSP_MODE structure during + * RegisterMode callback, and can be defined from add-on as a structure + * pointer or anything else what is needed to find it. + * @param array_in Pointer to input data memory + * @param array_out Pointer to output data memory + * @param samples Amount of samples inside array_in + * @return Amount of samples processed + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + unsigned int PostProcess(const ADDON_HANDLE handle, unsigned int mode_id, float **array_in, float **array_out, unsigned int samples); + //@} + + /** @name DSP Post re-sampling + * @remarks Only used by KODI if bSupportsOutputResample is set to true. + */ + //@{ + /*! + * @brief If the add-on operate with buffered arrays and the output size + * can be higher as the input + * it becomes asked about needed size before any OutputResampleProcess call. + * @param handle identification data for stream + * @return The needed size of output array or 0 if no changes within it + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + unsigned int OutputResampleProcessNeededSamplesize(const ADDON_HANDLE handle); + + /*! + * @brief Re-sampling after master processing becomes performed with it if + * needed, only + * one add-on can perform it. + * @param handle identification data for stream + * @param array_in Pointer to input data memory + * @param array_out Pointer to output data memory + * @param samples Amount of samples inside array_in + * @return Amount of samples processed + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + unsigned int OutputResampleProcess(const ADDON_HANDLE handle, float **array_in, float **array_out, unsigned int samples); + + /*! + * @brief Returns the re-sampling generated new sample rate used after the + * master process. + * @param handle identification data for stream + * @return The new sample rate + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + int OutputResampleSampleRate(const ADDON_HANDLE handle); + + /*! + * @brief Returns the time in seconds that it will take for the next added + * packet to be returned to KODI. + * @param handle identification data for stream + * @return the delay in seconds + * @remarks Optional. Is set by AE_DSP_ADDON_CAPABILITIES and asked with + * GetAddonCapabilities + */ + float OutputResampleGetDelay(const ADDON_HANDLE handle); + //@} + + // function to export the above structure to KODI + void __declspec(dllexport) get_addon(struct AudioDSP* pDSP) + { + pDSP->GetAudioDSPAPIVersion = GetAudioDSPAPIVersion; + pDSP->GetMinimumAudioDSPAPIVersion = GetMinimumAudioDSPAPIVersion; + pDSP->GetGUIAPIVersion = GetGUIAPIVersion; + pDSP->GetMinimumGUIAPIVersion = GetMinimumGUIAPIVersion; + pDSP->GetAddonCapabilities = GetAddonCapabilities; + pDSP->GetDSPName = GetDSPName; + pDSP->GetDSPVersion = GetDSPVersion; + pDSP->MenuHook = CallMenuHook; + + pDSP->StreamCreate = StreamCreate; + pDSP->StreamDestroy = StreamDestroy; + pDSP->StreamIsModeSupported = StreamIsModeSupported; + pDSP->StreamInitialize = StreamInitialize; + + pDSP->InputProcess = InputProcess; + + pDSP->InputResampleProcessNeededSamplesize = InputResampleProcessNeededSamplesize; + pDSP->InputResampleProcess = InputResampleProcess; + pDSP->InputResampleGetDelay = InputResampleGetDelay; + pDSP->InputResampleSampleRate = InputResampleSampleRate; + + pDSP->PreProcessNeededSamplesize = PreProcessNeededSamplesize; + pDSP->PreProcessGetDelay = PreProcessGetDelay; + pDSP->PreProcess = PreProcess; + + pDSP->MasterProcessSetMode = MasterProcessSetMode; + pDSP->MasterProcessNeededSamplesize = MasterProcessNeededSamplesize; + pDSP->MasterProcessGetDelay = MasterProcessGetDelay; + pDSP->MasterProcessGetOutChannels = MasterProcessGetOutChannels; + pDSP->MasterProcess = MasterProcess; + pDSP->MasterProcessGetStreamInfoString = MasterProcessGetStreamInfoString; + + pDSP->PostProcessNeededSamplesize = PostProcessNeededSamplesize; + pDSP->PostProcessGetDelay = PostProcessGetDelay; + pDSP->PostProcess = PostProcess; + + pDSP->OutputResampleProcessNeededSamplesize = OutputResampleProcessNeededSamplesize; + pDSP->OutputResampleProcess = OutputResampleProcess; + pDSP->OutputResampleSampleRate = OutputResampleSampleRate; + pDSP->OutputResampleGetDelay = OutputResampleGetDelay; + }; +}; + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_types.h new file mode 100644 index 0000000..6e492c8 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_adsp_types.h @@ -0,0 +1,524 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +/*! + * Common data structures shared between KODI and KODI's audio DSP add-ons + */ + +#ifdef TARGET_WINDOWS +#include +#else +#ifndef __cdecl +#define __cdecl +#endif +#ifndef __declspec +#define __declspec(X) +#endif +#endif + +#include + +#include "xbmc_addon_types.h" +#include "xbmc_codec_types.h" + +#undef ATTRIBUTE_PACKED +#undef PRAGMA_PACK_BEGIN +#undef PRAGMA_PACK_END + +#if defined(__GNUC__) +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) +#define ATTRIBUTE_PACKED __attribute__ ((packed)) +#define PRAGMA_PACK 0 +#endif +#endif + +#if !defined(ATTRIBUTE_PACKED) +#define ATTRIBUTE_PACKED +#define PRAGMA_PACK 1 +#endif + +#define AE_DSP_ADDON_STRING_LENGTH 1024 + +#define AE_DSP_STREAM_MAX_STREAMS 8 +#define AE_DSP_STREAM_MAX_MODES 32 + +/* current Audio DSP API version */ +#define KODI_AE_DSP_API_VERSION "0.1.8" + +/* min. Audio DSP API version */ +#define KODI_AE_DSP_MIN_API_VERSION "0.1.8" + +#ifdef __cplusplus +extern "C" { +#endif + + typedef unsigned int AE_DSP_STREAM_ID; + + /*! + * @brief Audio DSP add-on error codes + */ + typedef enum + { + AE_DSP_ERROR_NO_ERROR = 0, /*!< @brief no error occurred */ + AE_DSP_ERROR_UNKNOWN = -1, /*!< @brief an unknown error occurred */ + AE_DSP_ERROR_IGNORE_ME = -2, /*!< @brief the used input stream can not processed and add-on want to ignore */ + AE_DSP_ERROR_NOT_IMPLEMENTED = -3, /*!< @brief the method that KODI called is not implemented by the add-on */ + AE_DSP_ERROR_REJECTED = -4, /*!< @brief the command was rejected by the DSP */ + AE_DSP_ERROR_INVALID_PARAMETERS = -5, /*!< @brief the parameters of the method that was called are invalid for this operation */ + AE_DSP_ERROR_INVALID_SAMPLERATE = -6, /*!< @brief the processed samplerate is not supported */ + AE_DSP_ERROR_INVALID_IN_CHANNELS = -7, /*!< @brief the processed input channel format is not supported */ + AE_DSP_ERROR_INVALID_OUT_CHANNELS = -8, /*!< @brief the processed output channel format is not supported */ + AE_DSP_ERROR_FAILED = -9, /*!< @brief the command failed */ + } AE_DSP_ERROR; + + /*! + * @brief The possible DSP channels (used as pointer inside arrays) + */ + typedef enum + { + AE_DSP_CH_INVALID = -1, + AE_DSP_CH_FL = 0, + AE_DSP_CH_FR, + AE_DSP_CH_FC, + AE_DSP_CH_LFE, + AE_DSP_CH_BL, + AE_DSP_CH_BR, + AE_DSP_CH_FLOC, + AE_DSP_CH_FROC, + AE_DSP_CH_BC, + AE_DSP_CH_SL, + AE_DSP_CH_SR, + AE_DSP_CH_TFL, + AE_DSP_CH_TFR, + AE_DSP_CH_TFC, + AE_DSP_CH_TC, + AE_DSP_CH_TBL, + AE_DSP_CH_TBR, + AE_DSP_CH_TBC, + AE_DSP_CH_BLOC, + AE_DSP_CH_BROC, + + AE_DSP_CH_MAX + } AE_DSP_CHANNEL; + + /*! + * @brief Present channel flags + */ + typedef enum + { + AE_DSP_PRSNT_CH_UNDEFINED = 0, + AE_DSP_PRSNT_CH_FL = 1<<0, + AE_DSP_PRSNT_CH_FR = 1<<1, + AE_DSP_PRSNT_CH_FC = 1<<2, + AE_DSP_PRSNT_CH_LFE = 1<<3, + AE_DSP_PRSNT_CH_BL = 1<<4, + AE_DSP_PRSNT_CH_BR = 1<<5, + AE_DSP_PRSNT_CH_FLOC = 1<<6, + AE_DSP_PRSNT_CH_FROC = 1<<7, + AE_DSP_PRSNT_CH_BC = 1<<8, + AE_DSP_PRSNT_CH_SL = 1<<9, + AE_DSP_PRSNT_CH_SR = 1<<10, + AE_DSP_PRSNT_CH_TFL = 1<<11, + AE_DSP_PRSNT_CH_TFR = 1<<12, + AE_DSP_PRSNT_CH_TFC = 1<<13, + AE_DSP_PRSNT_CH_TC = 1<<14, + AE_DSP_PRSNT_CH_TBL = 1<<15, + AE_DSP_PRSNT_CH_TBR = 1<<16, + AE_DSP_PRSNT_CH_TBC = 1<<17, + AE_DSP_PRSNT_CH_BLOC = 1<<18, + AE_DSP_PRSNT_CH_BROC = 1<<19 + } AE_DSP_CHANNEL_PRESENT; + + /** + * @brief The various stream type formats + * Used for audio DSP processing to know input audio type + */ + typedef enum + { + AE_DSP_ASTREAM_INVALID = -1, + AE_DSP_ASTREAM_BASIC = 0, + AE_DSP_ASTREAM_MUSIC, + AE_DSP_ASTREAM_MOVIE, + AE_DSP_ASTREAM_GAME, + AE_DSP_ASTREAM_APP, + AE_DSP_ASTREAM_PHONE, + AE_DSP_ASTREAM_MESSAGE, + + AE_DSP_ASTREAM_AUTO, + AE_DSP_ASTREAM_MAX + } AE_DSP_STREAMTYPE; + + /*! + * @brief Add-ons supported audio stream type flags + * used on master mode information on AE_DSP_MODES to know + * on which audio stream the master mode is supported + */ + typedef enum + { + AE_DSP_PRSNT_ASTREAM_BASIC = 1<<0, + AE_DSP_PRSNT_ASTREAM_MUSIC = 1<<1, + AE_DSP_PRSNT_ASTREAM_MOVIE = 1<<2, + AE_DSP_PRSNT_ASTREAM_GAME = 1<<3, + AE_DSP_PRSNT_ASTREAM_APP = 1<<4, + AE_DSP_PRSNT_ASTREAM_MESSAGE = 1<<5, + AE_DSP_PRSNT_ASTREAM_PHONE = 1<<6, + } AE_DSP_ASTREAM_PRESENT; + + /** + * @brief The various base type formats + * Used for audio DSP processing to know input audio source + */ + typedef enum + { + AE_DSP_ABASE_INVALID = -1, + AE_DSP_ABASE_STEREO = 0, + AE_DSP_ABASE_MONO, + AE_DSP_ABASE_MULTICHANNEL, + AE_DSP_ABASE_AC3, + AE_DSP_ABASE_EAC3, + AE_DSP_ABASE_DTS, + AE_DSP_ABASE_DTSHD_MA, + AE_DSP_ABASE_DTSHD_HRA, + AE_DSP_ABASE_TRUEHD, + AE_DSP_ABASE_MLP, + AE_DSP_ABASE_FLAC, + + AE_DSP_ABASE_MAX + } AE_DSP_BASETYPE; + + + /** + * @brief The from KODI in settings requested audio process quality. + * The KODI internal used quality levels is translated to this values + * for usage on DSP processing add-ons. Is present on iQualityLevel + * inside AE_DSP_SETTINGS. + */ + typedef enum + { + AE_DSP_QUALITY_UNKNOWN = -1, /*!< @brief Unset, unknown or incorrect quality level */ + AE_DSP_QUALITY_DEFAULT = 0, /*!< @brief Engine's default quality level */ + + /* Basic quality levels */ + AE_DSP_QUALITY_LOW = 20, /*!< @brief Low quality level */ + AE_DSP_QUALITY_MID = 30, /*!< @brief Standard quality level */ + AE_DSP_QUALITY_HIGH = 50, /*!< @brief Best sound processing quality */ + + /* Optional quality levels */ + AE_DSP_QUALITY_REALLYHIGH = 100 /*!< @brief Uncompromising optional quality level, usually with unmeasurable and unnoticeable improvement */ + } AE_DSP_QUALITY; + + /*! + * @brief Audio DSP menu hook categories. + * Used to identify on AE_DSP_MENUHOOK given add-on related skin dialog/windows. + * Except AE_DSP_MENUHOOK_ALL and AE_DSP_MENUHOOK_SETTING are the menus available + * from DSP playback dialogue which can be opened over KODI file context menu and over + * button on full screen OSD window. + * + * Menu hook AE_DSP_MENUHOOK_SETTING is available from DSP processing setup dialogue. + */ + typedef enum + { + AE_DSP_MENUHOOK_UNKNOWN =-1, /*!< @brief unknown menu hook */ + AE_DSP_MENUHOOK_ALL = 0, /*!< @brief all categories */ + AE_DSP_MENUHOOK_PRE_PROCESS = 1, /*!< @brief for pre processing */ + AE_DSP_MENUHOOK_MASTER_PROCESS = 2, /*!< @brief for master processing */ + AE_DSP_MENUHOOK_POST_PROCESS = 3, /*!< @brief for post processing */ + AE_DSP_MENUHOOK_RESAMPLE = 4, /*!< @brief for re sample */ + AE_DSP_MENUHOOK_MISCELLANEOUS = 5, /*!< @brief for miscellaneous dialogues */ + AE_DSP_MENUHOOK_INFORMATION = 6, /*!< @brief dialogue to show processing information */ + AE_DSP_MENUHOOK_SETTING = 7, /*!< @brief for settings */ + } AE_DSP_MENUHOOK_CAT; + + /*! + * @brief Menu hooks that are available in the menus while playing a stream via this add-on. + */ + typedef struct AE_DSP_MENUHOOK + { + unsigned int iHookId; /*!< @brief (required) this hook's identifier */ + unsigned int iLocalizedStringId; /*!< @brief (required) the id of the label for this hook in g_localizeStrings */ + AE_DSP_MENUHOOK_CAT category; /*!< @brief (required) category of menu hook */ + unsigned int iRelevantModeId; /*!< @brief (required) except category AE_DSP_MENUHOOK_SETTING and AE_DSP_MENUHOOK_ALL must be the related mode id present here */ + bool bNeedPlayback; /*!< @brief (required) set to true if menu hook need playback and active processing */ + } ATTRIBUTE_PACKED AE_DSP_MENUHOOK; + + /*! + * @brief Properties passed to the Create() method of an add-on. + */ + typedef struct AE_DSP_PROPERTIES + { + const char* strUserPath; /*!< @brief path to the user profile */ + const char* strAddonPath; /*!< @brief path to this add-on */ + } AE_DSP_PROPERTIES; + + /*! + * @brief Audio DSP add-on capabilities. All capabilities are set to "false" as default. + * If a capability is set to true, then the corresponding methods from kodi_audiodsp_dll.h need to be implemented. + */ + typedef struct AE_DSP_ADDON_CAPABILITIES + { + bool bSupportsInputProcess; /*!< @brief true if this add-on provides audio input processing */ + bool bSupportsInputResample; /*!< @brief true if this add-on provides audio resample before master handling */ + bool bSupportsPreProcess; /*!< @brief true if this add-on provides audio pre processing */ + bool bSupportsMasterProcess; /*!< @brief true if this add-on provides audio master processing */ + bool bSupportsPostProcess; /*!< @brief true if this add-on provides audio post processing */ + bool bSupportsOutputResample; /*!< @brief true if this add-on provides audio re sample after master handling */ + } ATTRIBUTE_PACKED AE_DSP_ADDON_CAPABILITIES; + + /*! + * @brief Audio processing settings for in and out arrays + * Send on creation and before first processed audio packet to add-on + */ + typedef struct AE_DSP_SETTINGS + { + AE_DSP_STREAM_ID iStreamID; /*!< @brief id of the audio stream packets */ + AE_DSP_STREAMTYPE iStreamType; /*!< @brief the input stream type source eg, Movie or Music */ + int iInChannels; /*!< @brief the amount of input channels */ + unsigned long lInChannelPresentFlags; /*!< @brief the exact channel mapping flags of input */ + int iInFrames; /*!< @brief the input frame size from KODI */ + unsigned int iInSamplerate; /*!< @brief the basic sample rate of the audio packet */ + int iProcessFrames; /*!< @brief the processing frame size inside add-on's */ + unsigned int iProcessSamplerate; /*!< @brief the sample rate after input resample present in master processing */ + int iOutChannels; /*!< @brief the amount of output channels */ + unsigned long lOutChannelPresentFlags; /*!< @brief the exact channel mapping flags for output */ + int iOutFrames; /*!< @brief the final out frame size for KODI */ + unsigned int iOutSamplerate; /*!< @brief the final sample rate of the audio packet */ + bool bInputResamplingActive; /*!< @brief if a re-sampling is performed before master processing this flag is set to true */ + bool bStereoUpmix; /*!< @brief true if the stereo upmix setting on kodi is set */ + int iQualityLevel; /*!< @brief the from KODI selected quality level for signal processing */ + /*! + * @note about "iProcessSamplerate" and "iProcessFrames" is set from KODI after call of StreamCreate on input re sample add-on, if re-sampling + * and processing is handled inside the same add-on, this value must be ignored! + */ + } ATTRIBUTE_PACKED AE_DSP_SETTINGS; + + /*! + * @brief Stream profile properties + * Can be used to detect best master processing mode and for post processing methods. + */ +//@{ + + /*! + * @brief Dolby profile types. Given from several formats, e.g. Dolby Digital or TrueHD + * Used on AE_DSP_PROFILE_AC3_EAC3 and AE_DSP_PROFILE_MLP_TRUEHD + */ + #define AE_DSP_PROFILE_DOLBY_NONE 0 + #define AE_DSP_PROFILE_DOLBY_SURROUND 1 + #define AE_DSP_PROFILE_DOLBY_PLII 2 + #define AE_DSP_PROFILE_DOLBY_PLIIX 3 + #define AE_DSP_PROFILE_DOLBY_PLIIZ 4 + #define AE_DSP_PROFILE_DOLBY_EX 5 + #define AE_DSP_PROFILE_DOLBY_HEADPHONE 6 + + /*! + * @brief DTS/DTS HD profile types + * Used on AE_DSP_PROFILE_DTS_DTSHD + */ + #define AE_DSP_PROFILE_DTS 0 + #define AE_DSP_PROFILE_DTS_ES 1 + #define AE_DSP_PROFILE_DTS_96_24 2 + #define AE_DSP_PROFILE_DTS_HD_HRA 3 + #define AE_DSP_PROFILE_DTS_HD_MA 4 + + /*! + * @brief AC3/EAC3 based service types + * Used on AE_DSP_PROFILE_AC3_EAC3 + */ + #define AE_DSP_SERVICE_TYPE_MAIN 0 + #define AE_DSP_SERVICE_TYPE_EFFECTS 1 + #define AE_DSP_SERVICE_TYPE_VISUALLY_IMPAIRED 2 + #define AE_DSP_SERVICE_TYPE_HEARING_IMPAIRED 3 + #define AE_DSP_SERVICE_TYPE_DIALOGUE 4 + #define AE_DSP_SERVICE_TYPE_COMMENTARY 5 + #define AE_DSP_SERVICE_TYPE_EMERGENCY 6 + #define AE_DSP_SERVICE_TYPE_VOICE_OVER 7 + #define AE_DSP_SERVICE_TYPE_KARAOKE 8 + + /*! + * @brief AC3/EAC3 based room types + * Present on AE_DSP_PROFILE_AC3_EAC3 and can be used for frequency corrections + * at post processing, e.g. THX Re-Equalization + */ + #define AE_DSP_ROOM_TYPE_UNDEFINED 0 + #define AE_DSP_ROOM_TYPE_SMALL 1 + #define AE_DSP_ROOM_TYPE_LARGE 2 + + /*! + * @brief AC3/EAC3 stream profile properties + */ + //! @todo add handling for it (currently never becomes set) + typedef struct AE_DSP_PROFILE_AC3_EAC3 + { + unsigned int iProfile; /*!< defined by AE_DSP_PROFILE_DOLBY_* */ + unsigned int iServiceType; /*!< defined by AE_DSP_SERVICE_TYPE_* */ + unsigned int iRoomType; /*!< defined by AE_DSP_ROOM_TYPE_* (NOTICE: Information about it currently not supported from ffmpeg and must be implemented) */ + } ATTRIBUTE_PACKED AE_DSP_PROFILE_AC3_EAC3; + + /*! + * @brief MLP/Dolby TrueHD stream profile properties + */ + //! @todo add handling for it (currently never becomes set) + typedef struct AE_DSP_PROFILE_MLP_TRUEHD + { + unsigned int iProfile; /*!< defined by AE_DSP_PROFILE_DOLBY_* */ + } ATTRIBUTE_PACKED AE_DSP_PROFILE_MLP_TRUEHD; + + /*! + * @brief DTS/DTS HD stream profile properties + */ + //! @todo add handling for it (currently never becomes set) + typedef struct AE_DSP_PROFILE_DTS_DTSHD + { + unsigned int iProfile; /*!< defined by AE_DSP_PROFILE_DTS* */ + bool bSurroundMatrix; /*!< if set to true given 2.0 stream is surround encoded */ + } ATTRIBUTE_PACKED AE_DSP_PROFILE_DTS_DTSHD; + + union AE_DSP_PROFILE + { + AE_DSP_PROFILE_AC3_EAC3 ac3_eac3; /*!< Dolby Digital/Digital+ profile data */ + AE_DSP_PROFILE_MLP_TRUEHD mlp_truehd; /*!< MLP or Dolby TrueHD profile data */ + AE_DSP_PROFILE_DTS_DTSHD dts_dtshd; /*!< DTS/DTS-HD profile data */ + }; + //@} + + /*! + * @brief Audio DSP stream properties + * Used to check for the DSP add-on that the stream is supported, + * as example Dolby Digital Ex processing is only required on Dolby Digital with 5.1 layout + */ + typedef struct AE_DSP_STREAM_PROPERTIES + { + AE_DSP_STREAM_ID iStreamID; /*!< @brief stream id of the audio stream packets */ + AE_DSP_STREAMTYPE iStreamType; /*!< @brief the input stream type source eg, Movie or Music */ + int iBaseType; /*!< @brief the input stream base type source eg, Dolby Digital */ + const char* strName; /*!< @brief the audio stream name */ + const char* strCodecId; /*!< @brief codec id string of the audio stream */ + const char* strLanguage; /*!< @brief language id of the audio stream */ + int iIdentifier; /*!< @brief audio stream id inside player */ + int iChannels; /*!< @brief amount of basic channels */ + int iSampleRate; /*!< @brief sample rate */ + AE_DSP_PROFILE Profile; /*!< @brief current running stream profile data */ + } ATTRIBUTE_PACKED AE_DSP_STREAM_PROPERTIES; + + /*! + * @brief Audio DSP mode categories + */ + typedef enum + { + AE_DSP_MODE_TYPE_UNDEFINED = -1, /*!< @brief undefined type, never be used from add-on! */ + AE_DSP_MODE_TYPE_INPUT_RESAMPLE = 0, /*!< @brief for input re sample */ + AE_DSP_MODE_TYPE_PRE_PROCESS = 1, /*!< @brief for preprocessing */ + AE_DSP_MODE_TYPE_MASTER_PROCESS = 2, /*!< @brief for master processing */ + AE_DSP_MODE_TYPE_POST_PROCESS = 3, /*!< @brief for post processing */ + AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE = 4, /*!< @brief for output re sample */ + AE_DSP_MODE_TYPE_MAX = 5 + } AE_DSP_MODE_TYPE; + + /*! + * @brief Audio DSP master mode information + * Used to get all available modes for current input stream + */ + typedef struct AE_DSP_MODES + { + unsigned int iModesCount; /*!< @brief (required) count of how much modes are in AE_DSP_MODES */ + struct AE_DSP_MODE + { + int iUniqueDBModeId; /*!< @brief (required) the inside add-on used identifier for the mode, set by KODI's audio DSP database */ + AE_DSP_MODE_TYPE iModeType; /*!< @brief (required) the processong mode type, see AE_DSP_MODE_TYPE */ + char strModeName[AE_DSP_ADDON_STRING_LENGTH]; /*!< @brief (required) the addon name of the mode, used on KODI's logs */ + + unsigned int iModeNumber; /*!< @brief (required) number of this mode on the add-on, is used on process functions with value "mode_id" */ + unsigned int iModeSupportTypeFlags; /*!< @brief (required) flags about supported input types for this mode, see AE_DSP_ASTREAM_PRESENT */ + bool bHasSettingsDialog; /*!< @brief (required) if setting dialog(s) are available it must be set to true */ + bool bIsDisabled; /*!< @brief (optional) true if this mode is marked as disabled and not enabled default, only relevant for master processes, all other types always disabled as default */ + + unsigned int iModeName; /*!< @brief (required) the name id of the mode for this hook in g_localizeStrings */ + unsigned int iModeSetupName; /*!< @brief (optional) the name id of the mode inside settings for this hook in g_localizeStrings */ + unsigned int iModeDescription; /*!< @brief (optional) the description id of the mode for this hook in g_localizeStrings */ + unsigned int iModeHelp; /*!< @brief (optional) help string id for inside DSP settings dialog of the mode for this hook in g_localizeStrings */ + + char strOwnModeImage[AE_DSP_ADDON_STRING_LENGTH]; /*!< @brief (optional) flag image for the mode */ + char strOverrideModeImage[AE_DSP_ADDON_STRING_LENGTH]; /*!< @brief (optional) image to override KODI Image for the mode, eg. Dolby Digital with Dolby Digital Ex (only used on master modes) */ + } mode[AE_DSP_STREAM_MAX_MODES]; /*!< @brief Modes array storage */ + } ATTRIBUTE_PACKED AE_DSP_MODES; + + /*! + * @brief Audio DSP menu hook data + */ + typedef struct AE_DSP_MENUHOOK_DATA + { + AE_DSP_MENUHOOK_CAT category; /*!< @brief (required) related menuhook data category */ + union data { + AE_DSP_STREAM_ID iStreamId; /*!< @brief currently only stream id is used, is used as union to have extension possibility */ + } data; /*!< @brief related category related data */ + } ATTRIBUTE_PACKED AE_DSP_MENUHOOK_DATA; + + /*! + * @brief Structure to transfer the methods from kodi_audiodsp_dll.h to KODI + */ + struct AudioDSP + { + const char* (__cdecl* GetAudioDSPAPIVersion) (void); + const char* (__cdecl* GetMinimumAudioDSPAPIVersion) (void); + const char* (__cdecl* GetGUIAPIVersion) (void); + const char* (__cdecl* GetMinimumGUIAPIVersion) (void); + AE_DSP_ERROR (__cdecl* GetAddonCapabilities) (AE_DSP_ADDON_CAPABILITIES*); + const char* (__cdecl* GetDSPName) (void); + const char* (__cdecl* GetDSPVersion) (void); + AE_DSP_ERROR (__cdecl* MenuHook) (const AE_DSP_MENUHOOK&, const AE_DSP_MENUHOOK_DATA&); + + AE_DSP_ERROR (__cdecl* StreamCreate) (const AE_DSP_SETTINGS*, const AE_DSP_STREAM_PROPERTIES*, ADDON_HANDLE); + AE_DSP_ERROR (__cdecl* StreamDestroy) (const ADDON_HANDLE); + AE_DSP_ERROR (__cdecl* StreamIsModeSupported) (const ADDON_HANDLE, AE_DSP_MODE_TYPE, unsigned int, int); + AE_DSP_ERROR (__cdecl* StreamInitialize) (const ADDON_HANDLE, const AE_DSP_SETTINGS*); + + bool (__cdecl* InputProcess) (const ADDON_HANDLE, const float**, unsigned int); + + unsigned int (__cdecl* InputResampleProcessNeededSamplesize) (const ADDON_HANDLE); + unsigned int (__cdecl* InputResampleProcess) (const ADDON_HANDLE, float**, float**, unsigned int); + float (__cdecl* InputResampleGetDelay) (const ADDON_HANDLE); + int (__cdecl* InputResampleSampleRate) (const ADDON_HANDLE); + + unsigned int (__cdecl* PreProcessNeededSamplesize) (const ADDON_HANDLE, unsigned int); + float (__cdecl* PreProcessGetDelay) (const ADDON_HANDLE, unsigned int); + unsigned int (__cdecl* PreProcess) (const ADDON_HANDLE, unsigned int, float**, float**, unsigned int); + + AE_DSP_ERROR (__cdecl* MasterProcessSetMode) (const ADDON_HANDLE, AE_DSP_STREAMTYPE, unsigned int, int); + unsigned int (__cdecl* MasterProcessNeededSamplesize) (const ADDON_HANDLE); + float (__cdecl* MasterProcessGetDelay) (const ADDON_HANDLE); + int (__cdecl* MasterProcessGetOutChannels) (const ADDON_HANDLE, unsigned long&); + unsigned int (__cdecl* MasterProcess) (const ADDON_HANDLE, float**, float**, unsigned int); + const char* (__cdecl* MasterProcessGetStreamInfoString) (const ADDON_HANDLE); + + unsigned int (__cdecl* PostProcessNeededSamplesize) (const ADDON_HANDLE, unsigned int); + float (__cdecl* PostProcessGetDelay) (const ADDON_HANDLE, unsigned int); + unsigned int (__cdecl* PostProcess) (const ADDON_HANDLE, unsigned int, float**, float**, unsigned int); + + unsigned int (__cdecl* OutputResampleProcessNeededSamplesize)(const ADDON_HANDLE); + unsigned int (__cdecl* OutputResampleProcess) (const ADDON_HANDLE, float**, float**, unsigned int); + float (__cdecl* OutputResampleGetDelay) (const ADDON_HANDLE); + int (__cdecl* OutputResampleSampleRate) (const ADDON_HANDLE); + }; + +#ifdef __cplusplus +} +#endif + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_dll.h new file mode 100644 index 0000000..78bc3cc --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_dll.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2005-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 + * . + * + */ + +#pragma once + +#include +#include "xbmc_addon_dll.h" +#include "kodi_audiodec_types.h" + +extern "C" +{ + //! \copydoc AudioDecoder::Init + void* Init(const char* file, unsigned int filecache, int* channels, + int* samplerate, int* bitspersample, int64_t* totaltime, + int* bitrate, AEDataFormat* format, const AEChannel** channelinfo); + + //! \copydoc AudioDecoder::ReadPCM + int ReadPCM(void* context, uint8_t* buffer, int size, int* actualsize); + + //! \copydoc AudioDecoder::Seek + int64_t Seek(void* context, int64_t time); + + //! \copydoc AudioDecoder::ReadTag + bool ReadTag(const char* file, char* title, + char* artist, int* length); + + //! \copydoc AudioDecoder::TrackCount + int TrackCount(const char* file); + + //! \copydoc AudioDecoder::DeInit + bool DeInit(void* context); + + // function to export the above structure to XBMC + void __declspec(dllexport) get_addon(struct AudioDecoder* pScr) + { + pScr->Init = Init; + pScr->ReadPCM = ReadPCM; + pScr->Seek = Seek; + pScr->ReadTag = ReadTag; + pScr->TrackCount = TrackCount; + pScr->DeInit = DeInit; + }; +}; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_types.h new file mode 100644 index 0000000..82d71e5 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audiodec_types.h @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2005-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 + * . + * + */ + +#pragma once + +#include +#ifdef BUILD_KODI_ADDON +#include "AEChannelData.h" +#else +#include "cores/AudioEngine/Utils/AEChannelData.h" +#endif + +extern "C" +{ + struct AUDIODEC_INFO + { + int dummy; + }; + + struct AUDIODEC_PROPS + { + int dummy; + }; + + struct AudioDecoder + { + //! \brief Initialize a decoder + //! \param file The file to read + //! \param filecache The file cache size + //! \param channels Number of channels in output stream + //! \param samplerate Samplerate of output stream + //! \param bitspersample Bits per sample in output stream + //! \param totaltime Total time for stream + //! \param bitrate Average bitrate of input stream + //! \param format Data format for output stream + //! \param info Channel mapping for output stream + //! \return Context of output stream + //! \sa ICodec::Init + void* (__cdecl* Init) (const char* file, unsigned int filecache, + int* channels, int* samplerate, + int* bitspersample, int64_t* totaltime, + int* bitrate, AEDataFormat* format, + const AEChannel** info); + + //! \brief Produce some noise + //! \param context Context of output stream + //! \param buffer Output buffer + //! \param size Size of output buffer + //! \param actualsize Actual number of bytes written to output buffer + //! \return 0 on success, -1 on end of stream, 1 on failure + //! \sa ICodec::ReadPCM + int (__cdecl* ReadPCM) (void* context, uint8_t* buffer, int size, int* actualsize); + + + //! \brief Seek in output stream + //! \param context Context of output stream + //! \param time Time position to seek to in milliseconds + //! \return Time position seek ended up on + //! \sa ICodec::Seek + int64_t (__cdecl* Seek) (void* context, int64_t time); + + //! \brief Read tag of a file + //! \param file File to read tag for + //! \param title Title of file + //! \param artist Artist of file + //! \param length Length of file + //! \return True on success, false on failure + //! \sa IMusicInfoTagLoader::ReadTag + bool (__cdecl* ReadTag)(const char* file, char* title, + char* artist, int* length); + + //! \brief Get number of tracks in a file + //! \param file File to read tag for + //! \return Number of tracks in file + //! \sa CMusicFileDirectory + int (__cdecl* TrackCount) (const char* file); + + //! \brief Close down an output stream + //! \param context Context of stream + //! \return True on success, false on failure + //! \sa ICodec::DeInit + bool (__cdecl* DeInit)(void* context); + }; +} diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audioengine_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audioengine_types.h new file mode 100644 index 0000000..0402ace --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_audioengine_types.h @@ -0,0 +1,165 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +/*! + * Common data structures shared between KODI and KODI's binary add-ons + */ + +#ifdef BUILD_KODI_ADDON + #include "kodi/AudioEngine/AEChannelInfo.h" +#else + #include "cores/AudioEngine/Utils/AEChannelInfo.h" +#endif + +#ifdef TARGET_WINDOWS +#include +#else +#ifndef __cdecl +#define __cdecl +#endif +#ifndef __declspec +#define __declspec(X) +#endif +#endif + +#include + +#undef ATTRIBUTE_PACKED +#undef PRAGMA_PACK_BEGIN +#undef PRAGMA_PACK_END + +#if defined(__GNUC__) +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) +#define ATTRIBUTE_PACKED __attribute__ ((packed)) +#define PRAGMA_PACK 0 +#endif +#endif + +#if !defined(ATTRIBUTE_PACKED) +#define ATTRIBUTE_PACKED +#define PRAGMA_PACK 1 +#endif + +/* current Audio DSP API version */ +#define KODI_AUDIOENGINE_API_VERSION "0.0.1" + +/* min. Audio DSP API version */ +#define KODI_AUDIOENGINE_MIN_API_VERSION "0.0.1" + + +#ifdef __cplusplus +extern "C" { +#endif + + /** + * A stream handle pointer, which is only used internally by the addon stream handle + */ + typedef void AEStreamHandle; + + /** + * The audio format structure that fully defines a stream's audio information + */ + typedef struct AudioEngineFormat + { + /** + * The stream's data format (eg, AE_FMT_S16LE) + */ + enum AEDataFormat m_dataFormat; + + /** + * The stream's sample rate (eg, 48000) + */ + unsigned int m_sampleRate; + + /** + * The encoded streams sample rate if a bitstream, otherwise undefined + */ + unsigned int m_encodedRate; + + /** + * The amount of used speaker channels + */ + unsigned int m_channelCount; + + /** + * The stream's channel layout + */ + enum AEChannel m_channels[AE_CH_MAX]; + + /** + * The number of frames per period + */ + unsigned int m_frames; + + /** + * The size of one frame in bytes + */ + unsigned int m_frameSize; + + AudioEngineFormat() + { + m_dataFormat = AE_FMT_INVALID; + m_sampleRate = 0; + m_encodedRate = 0; + m_frames = 0; + m_frameSize = 0; + m_channelCount = 0; + + for (unsigned int ch = 0; ch < AE_CH_MAX; ch++) + { + m_channels[ch] = AE_CH_NULL; + } + } + + bool compareFormat(const AudioEngineFormat *fmt) + { + if (!fmt) + { + return false; + } + + if (m_dataFormat != fmt->m_dataFormat || + m_sampleRate != fmt->m_sampleRate || + m_encodedRate != fmt->m_encodedRate || + m_frames != fmt->m_frames || + m_frameSize != fmt->m_frameSize || + m_channelCount != fmt->m_channelCount) + { + return false; + } + + for (unsigned int ch = 0; ch < AE_CH_MAX; ch++) + { + if (fmt->m_channels[ch] != m_channels[ch]) + { + return false; + } + } + + return true; + } + } AudioEngineFormat; + +#ifdef __cplusplus +} +#endif + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h new file mode 100644 index 0000000..6ecf566 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_dll.h @@ -0,0 +1,257 @@ +#pragma once + +/* +* Copyright (C) 2005-2016 Team Kodi +* http://kodi.tv +* +* 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 Kodi; see the file COPYING. If not, see +* . +* +*/ + +#include "kodi_inputstream_types.h" +#include "xbmc_addon_dll.h" + +/*! +* Functions that the InputStream client add-on must implement, but some can be empty. +* +* The 'remarks' field indicates which methods should be implemented, and which ones are optional. +*/ + +extern "C" +{ + /*! + * Open a stream. + * @param props + * @return True if the stream has been opened successfully, false otherwise. + * @remarks + */ + bool Open(INPUTSTREAM& props); + + /*! + * Close an open stream. + * @remarks + */ + void Close(void); + + /*! + * Get path/url for this addon. + * @remarks + */ + const char* GetPathList(void); + + /*! + * Get Capabilities of this addon. + * @remarks + */ + struct INPUTSTREAM_CAPABILITIES GetCapabilities(); + + + /*! + * Get IDs of available streams + * @remarks + */ + INPUTSTREAM_IDS GetStreamIds(); + + /*! + * Get stream properties of a stream. + * @param streamId unique id of stream + * @return struc of stream properties + * @remarks + */ + INPUTSTREAM_INFO GetStream(int streamid); + + /*! + * Enable or disable a stream. + * A disabled stream does not send demux packets + * @param streamId unique id of stream + * @param enable true for enable, false for disable + * @remarks + */ + void EnableStream(int streamid, bool enable); + + /*! + * Enables a stream at the given PTS. + * @param streamId unique id of stream + * @param pts position in stream in microseconds + * @remarks will only be called if CAPABILITIES::m_supportsEnableAtPTS is set to true + */ + void EnableStreamAtPTS(int streamid, uint64_t pts); + + /*! + * Reset the demultiplexer in the add-on. + * @remarks Required if bHandlesDemuxing is set to true. + */ + void DemuxReset(void); + + /*! + * Abort the demultiplexer thread in the add-on. + * @remarks Required if bHandlesDemuxing is set to true. + */ + void DemuxAbort(void); + + /*! + * Flush all data that's currently in the demultiplexer buffer in the add-on. + * @remarks Required if bHandlesDemuxing is set to true. + */ + void DemuxFlush(void); + + /*! + * Read the next packet from the demultiplexer, if there is one. + * @return The next packet. + * If there is no next packet, then the add-on should return the + * packet created by calling AllocateDemuxPacket(0) on the callback. + * If the stream changed and XBMC's player needs to be reinitialised, + * then, the add-on should call AllocateDemuxPacket(0) on the + * callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and + * return the value. + * The add-on should return NULL if an error occured. + * @remarks Return NULL if this add-on won't provide this function. + */ + DemuxPacket* DemuxRead(void); + + /*! + * Notify the InputStream addon/demuxer that XBMC wishes to seek the stream by time + * Demuxer is required to set stream to an IDR frame + * @param time The absolute time since stream start + * @param backwards True to seek to keyframe BEFORE time, else AFTER + * @param startpts can be updated to point to where display should start + * @return True if the seek operation was possible + * @remarks Optional, and only used if addon has its own demuxer. + */ + bool DemuxSeekTime(int time, bool backwards, double *startpts); + + /*! + * Notify the InputStream addon/demuxer that XBMC wishes to change playback speed + * @param speed The requested playback speed + * @remarks Optional, and only used if addon has its own demuxer. + */ + void DemuxSetSpeed(int speed); + + + /*! + * Totel time in ms + * @remarks + */ + int GetTotalTime(); + + /*! + * Playing time in ms + * @remarks + */ + int GetTime(); + + /*! + * Positions inputstream to playing time given in ms + * @remarks + */ + bool PosTime(int ms); + + + /*! + * Check if the backend support pausing the currently playing stream + * This will enable/disable the pause button in XBMC based on the return value + * @return false if the InputStream addon/backend does not support pausing, true if possible + */ + bool CanPauseStream(); + + /*! + * Check if the backend supports seeking for the currently playing stream + * This will enable/disable the rewind/forward buttons in XBMC based on the return value + * @return false if the InputStream addon/backend does not support seeking, true if possible + */ + bool CanSeekStream(); + + + /*! + * Read from an open stream. + * @param pBuffer The buffer to store the data in. + * @param iBufferSize The amount of bytes to read. + * @return The amount of bytes that were actually read from the stream. + * @remarks Return -1 if this add-on won't provide this function. + */ + int ReadStream(uint8_t* pBuffer, unsigned int iBufferSize); + + /*! + * Seek in a stream. + * @param iPosition The position to seek to. + * @param iWhence ? + * @return The new position. + * @remarks Return -1 if this add-on won't provide this function. + */ + int64_t SeekStream(int64_t iPosition, int iWhence = SEEK_SET); + + /*! + * @return The position in the stream that's currently being read. + * @remarks Return -1 if this add-on won't provide this function. + */ + int64_t PositionStream(void); + + /*! + * @return The total length of the stream that's currently being read. + * @remarks Return -1 if this add-on won't provide this function. + */ + int64_t LengthStream(void); + + + /*! + * @brief Notify the InputStream addon that XBMC (un)paused the currently playing stream + */ + void PauseStream(double time); + + + /*! + * Check for real-time streaming + * @return true if current stream is real-time + */ + bool IsRealTimeStream(); + + /*! + * Called by XBMC to assign the function pointers of this add-on to pClient. + * @param pClient The struct to assign the function pointers to. + */ + void __declspec(dllexport) get_addon(struct InputStreamAddonFunctions* pClient) + { + pClient->Open = Open; + pClient->Close = Close; + pClient->GetPathList = GetPathList; + pClient->GetCapabilities = GetCapabilities; + + pClient->GetStreamIds = GetStreamIds; + pClient->GetStream = GetStream; + pClient->EnableStream = EnableStream; + pClient->EnableStreamAtPTS = EnableStreamAtPTS; + pClient->DemuxReset = DemuxReset; + pClient->DemuxAbort = DemuxAbort; + pClient->DemuxFlush = DemuxFlush; + pClient->DemuxRead = DemuxRead; + pClient->DemuxSeekTime = DemuxSeekTime; + pClient->DemuxSetSpeed = DemuxSetSpeed; + + pClient->GetTotalTime = GetTotalTime; + pClient->GetTime = GetTime; + + pClient->PosTime = PosTime; + + pClient->CanPauseStream = CanPauseStream; + pClient->CanSeekStream = CanSeekStream; + + pClient->ReadStream = ReadStream; + pClient->SeekStream = SeekStream; + pClient->PositionStream = PositionStream; + pClient->LengthStream = LengthStream; + pClient->PauseStream = PauseStream; + pClient->IsRealTimeStream = IsRealTimeStream; + }; +}; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h new file mode 100644 index 0000000..33741d8 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_inputstream_types.h @@ -0,0 +1,161 @@ +#pragma once + +/* + * Copyright (C) 2005-2016 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +#ifndef __cdecl +#define __cdecl +#endif + +#ifdef BUILD_KODI_ADDON +#include "DVDDemuxPacket.h" +#else +#include "cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h" +#endif + +extern "C" { + + // this are properties given to the addon on create + // at this time we have no parameters for the addon + typedef struct INPUTSTREAM_PROPS + { + int dummy; + } INPUTSTREAM_PROPS; + + /*! + * @brief InputStream add-on capabilities. All capabilities are set to "false" as default. + */ + typedef struct INPUTSTREAM_CAPABILITIES + { + bool m_supportsIDemux; /*!< @brief supports interface IDemux */ + bool m_supportsIPosTime; /*!< @brief supports interface IPosTime */ + bool m_supportsIDisplayTime; /*!< @brief supports interface IDisplayTime */ + bool m_supportsSeek; /*!< @brief supports seek */ + bool m_supportsPause; /*!< @brief supports pause */ + bool m_supportsEnableAtPTS; /*!< @brief supports enabling streams at a given PTS time */ + } INPUTSTREAM_CAPABILITIES; + + /*! + * @brief structure of key/value pairs passed to addon on Open() + */ + typedef struct INPUTSTREAM + { + static const unsigned int MAX_INFO_COUNT = 8; + + const char *m_strURL; + + unsigned int m_nCountInfoValues; + struct LISTITEMPROPERTY + { + const char *m_strKey; + const char *m_strValue; + } m_ListItemProperties[MAX_INFO_COUNT]; + } INPUTSTREAM; + + /*! + * @brief Array of stream IDs + */ + typedef struct INPUTSTREAM_IDS + { + static const unsigned int MAX_STREAM_COUNT = 32; + unsigned int m_streamCount; + unsigned int m_streamIds[MAX_STREAM_COUNT]; + } INPUTSTREAM_IDS; + + /*! + * @brief stream properties + */ + typedef struct INPUTSTREAM_INFO + { + enum STREAM_TYPE + { + TYPE_NONE, + TYPE_VIDEO, + TYPE_AUDIO, + TYPE_SUBTITLE, + TYPE_TELETEXT + } m_streamType; + + char m_codecName[32]; /*!< @brief (required) name of codec according to ffmpeg */ + char m_codecInternalName[32]; /*!< @brief (optional) internal name of codec (selectionstream info) */ + unsigned int m_pID; /*!< @brief (required) physical index */ + unsigned int m_Bandwidth; /*!< @brief (optional) bandwidth of the stream (selectionstream info) */ + + const uint8_t *m_ExtraData; + unsigned int m_ExtraSize; + + char m_language[4]; /*!< @brief ISO 639 3-letter language code (empty string if undefined) */ + + unsigned int m_FpsScale; /*!< @brief Scale of 1000 and a rate of 29970 will result in 29.97 fps */ + unsigned int m_FpsRate; + unsigned int m_Height; /*!< @brief height of the stream reported by the demuxer */ + unsigned int m_Width; /*!< @brief width of the stream reported by the demuxer */ + float m_Aspect; /*!< @brief display aspect of stream */ + + unsigned int m_Channels; /*!< @brief (required) amount of channels */ + unsigned int m_SampleRate; /*!< @brief (required) sample rate */ + unsigned int m_BitRate; /*!< @brief (required) bit rate */ + unsigned int m_BitsPerSample; /*!< @brief (required) bits per sample */ + unsigned int m_BlockAlign; + } INPUTSTREAM_INFO; + + /*! + * @brief Structure to transfer the methods from xbmc_inputstream_dll.h to XBMC + */ + typedef struct InputStreamAddonFunctions + { + bool (__cdecl* Open)(INPUTSTREAM&); + void (__cdecl* Close)(void); + const char* (__cdecl* GetPathList)(void); + struct INPUTSTREAM_CAPABILITIES (__cdecl* GetCapabilities)(void); + + // IDemux + struct INPUTSTREAM_IDS (__cdecl* GetStreamIds)(); + struct INPUTSTREAM_INFO (__cdecl* GetStream)(int); + void (__cdecl* EnableStream)(int, bool); + void (__cdecl* EnableStreamAtPTS)(int, uint64_t); + void (__cdecl* DemuxReset)(void); + void (__cdecl* DemuxAbort)(void); + void (__cdecl* DemuxFlush)(void); + DemuxPacket* (__cdecl* DemuxRead)(void); + bool (__cdecl* DemuxSeekTime)(int, bool, double*); + void (__cdecl* DemuxSetSpeed)(int); + + // IDisplayTime + int (__cdecl* GetTotalTime)(void); + int (__cdecl* GetTime)(void); + + // IPosTime + bool (__cdecl* PosTime)(int); + + // Seekable (mandatory) + bool (__cdecl* CanPauseStream)(void); + bool (__cdecl* CanSeekStream)(void); + + int (__cdecl* ReadStream)(uint8_t*, unsigned int); + int64_t(__cdecl* SeekStream)(int64_t, int); + int64_t (__cdecl* PositionStream)(void); + int64_t (__cdecl* LengthStream)(void); + void (__cdecl* PauseStream)(double); + bool (__cdecl* IsRealTimeStream)(void); + } InputStreamAddonFunctions; +} + + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_adsp.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_adsp.h new file mode 100644 index 0000000..46e34a6 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_adsp.h @@ -0,0 +1,232 @@ +#pragma once +/* + * Copyright (C) 2005-2014 Team KODI + * http://kodi.tv + * + * 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 KODI; see the file COPYING. If not, see + * . + * + */ + +#include +#include +#include +#include +#include +#include "kodi_adsp_types.h" +#include "libXBMC_addon.h" + +typedef void* ADSPHANDLE; + +#ifdef _WIN32 +#define ADSP_HELPER_DLL "\\library.kodi.adsp\\libKODI_adsp" ADDON_HELPER_EXT +#else +#define ADSP_HELPER_DLL_NAME "libKODI_adsp-" ADDON_HELPER_ARCH ADDON_HELPER_EXT +#define ADSP_HELPER_DLL "/library.kodi.adsp/" ADSP_HELPER_DLL_NAME +#endif + +class CAddonSoundPlay; + +class CHelper_libKODI_adsp +{ +public: + CHelper_libKODI_adsp(void) + { + m_libKODI_adsp = NULL; + m_Handle = NULL; + } + + ~CHelper_libKODI_adsp(void) + { + if (m_libKODI_adsp) + { + ADSP_unregister_me(m_Handle, m_Callbacks); + dlclose(m_libKODI_adsp); + } + } + + /*! + * @brief Resolve all callback methods + * @param handle Pointer to the add-on + * @return True when all methods were resolved, false otherwise. + */ + bool RegisterMe(void* handle) + { + m_Handle = handle; + + std::string libBasePath; + libBasePath = ((cb_array*)m_Handle)->libPath; + libBasePath += ADSP_HELPER_DLL; + +#if defined(ANDROID) + struct stat st; + if(stat(libBasePath.c_str(),&st) != 0) + { + std::string tempbin = getenv("XBMC_ANDROID_LIBS"); + libBasePath = tempbin + "/" + ADSP_HELPER_DLL_NAME; + } +#endif + + m_libKODI_adsp = dlopen(libBasePath.c_str(), RTLD_LAZY); + if (m_libKODI_adsp == NULL) + { + fprintf(stderr, "Unable to load %s\n", dlerror()); + return false; + } + + ADSP_register_me = (void* (*)(void *HANDLE)) + dlsym(m_libKODI_adsp, "ADSP_register_me"); + if (ADSP_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + ADSP_unregister_me = (void (*)(void* HANDLE, void* CB)) + dlsym(m_libKODI_adsp, "ADSP_unregister_me"); + if (ADSP_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + ADSP_add_menu_hook = (void (*)(void* HANDLE, void* CB, AE_DSP_MENUHOOK *hook)) + dlsym(m_libKODI_adsp, "ADSP_add_menu_hook"); + if (ADSP_add_menu_hook == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + ADSP_remove_menu_hook = (void (*)(void* HANDLE, void* CB, AE_DSP_MENUHOOK *hook)) + dlsym(m_libKODI_adsp, "ADSP_remove_menu_hook"); + if (ADSP_remove_menu_hook == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + ADSP_register_mode = (void (*)(void *HANDLE, void* CB, AE_DSP_MODES::AE_DSP_MODE *modes)) + dlsym(m_libKODI_adsp, "ADSP_register_mode"); + if (ADSP_register_mode == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + ADSP_unregister_mode = (void (*)(void* HANDLE, void* CB, AE_DSP_MODES::AE_DSP_MODE *modes)) + dlsym(m_libKODI_adsp, "ADSP_unregister_mode"); + if (ADSP_unregister_mode == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + ADSP_get_sound_play = (CAddonSoundPlay* (*)(void *HANDLE, void *CB, const char *filename)) + dlsym(m_libKODI_adsp, "ADSP_get_sound_play"); + if (ADSP_get_sound_play == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + ADSP_release_sound_play = (void (*)(CAddonSoundPlay* p)) + dlsym(m_libKODI_adsp, "ADSP_release_sound_play"); + if (ADSP_release_sound_play == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + m_Callbacks = ADSP_register_me(m_Handle); + return m_Callbacks != NULL; + } + + /*! + * @brief Add or replace a menu hook for the context menu for this add-on + * @param hook The hook to add + */ + void AddMenuHook(AE_DSP_MENUHOOK* hook) + { + return ADSP_add_menu_hook(m_Handle, m_Callbacks, hook); + } + + /*! + * @brief Remove a menu hook for the context menu for this add-on + * @param hook The hook to remove + */ + void RemoveMenuHook(AE_DSP_MENUHOOK* hook) + { + return ADSP_remove_menu_hook(m_Handle, m_Callbacks, hook); + } + + /*! + * @brief Add or replace master mode information inside audio dsp database. + * Becomes identifier written inside mode to iModeID if it was 0 (undefined) + * @param mode The master mode to add or update inside database + */ + void RegisterMode(AE_DSP_MODES::AE_DSP_MODE* mode) + { + return ADSP_register_mode(m_Handle, m_Callbacks, mode); + } + + /*! + * @brief Remove a master mode from audio dsp database + * @param mode The Mode to remove + */ + void UnregisterMode(AE_DSP_MODES::AE_DSP_MODE* mode) + { + return ADSP_unregister_mode(m_Handle, m_Callbacks, mode); + } + + /*! + * @brief Open a sound playing class + * @param filename The wav filename to open + */ + CAddonSoundPlay* GetSoundPlay(const char *filename) + { + return ADSP_get_sound_play(m_Handle, m_Callbacks, filename); + } + + /*! + * @brief Remove a played file class + * @param p The playback to remove + */ + void ReleaseSoundPlay(CAddonSoundPlay* p) + { + return ADSP_release_sound_play(p); + } + +protected: + void* (*ADSP_register_me)(void*); + + void (*ADSP_unregister_me)(void*, void*); + void (*ADSP_add_menu_hook)(void*, void*, AE_DSP_MENUHOOK*); + void (*ADSP_remove_menu_hook)(void*, void*, AE_DSP_MENUHOOK*); + void (*ADSP_register_mode)(void*, void*, AE_DSP_MODES::AE_DSP_MODE*); + void (*ADSP_unregister_mode)(void*, void*, AE_DSP_MODES::AE_DSP_MODE*); + CAddonSoundPlay* (*ADSP_get_sound_play)(void*, void*, const char *); + void (*ADSP_release_sound_play)(CAddonSoundPlay*); + +private: + void* m_libKODI_adsp; + void* m_Handle; + void* m_Callbacks; + struct cb_array + { + const char* libPath; + }; +}; + +class CAddonSoundPlay +{ +public: + CAddonSoundPlay(void *hdl, void *cb, const char *filename); + virtual ~CAddonSoundPlay(); + + /*! play the sound this object represents */ + virtual void Play(); + + /*! stop playing the sound this object represents */ + virtual void Stop(); + + /*! return true if the sound is currently playing */ + virtual bool IsPlaying(); + + /*! set the playback channel position of this sound, AE_DSP_CH_INVALID for all */ + virtual void SetChannel(AE_DSP_CHANNEL channel); + + /*! get the current playback volume of this sound, AE_DSP_CH_INVALID for all */ + virtual AE_DSP_CHANNEL GetChannel(); + + /*! set the playback volume of this sound */ + virtual void SetVolume(float volume); + + /*! get the current playback volume of this sound */ + virtual float GetVolume(); + +private: + std::string m_Filename; + void *m_Handle; + void *m_cb; + ADSPHANDLE m_PlayHandle; +}; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h new file mode 100644 index 0000000..f541637 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h @@ -0,0 +1,324 @@ +#pragma once +/* + * Copyright (C) 2005-2014 Team KODI + * http://kodi.tv + * + * 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 KODI; see the file COPYING. If not, see + * . + * + */ + +#include +#include +#include +#include +#include + +#include "kodi_audioengine_types.h" +#ifdef BUILD_KODI_ADDON + #include "kodi/AudioEngine/AEChannelData.h" + #include "kodi/AudioEngine/AEChannelInfo.h" + #include "kodi/AudioEngine/AEStreamData.h" +#else + #include "cores/AudioEngine/Utils/AEChannelData.h" + #include "cores/AudioEngine/Utils/AEChannelInfo.h" + #include "cores/AudioEngine/Utils/AEStreamData.h" +#endif + +#include "libXBMC_addon.h" + +#ifdef _WIN32 +#define AUDIOENGINE_HELPER_DLL "\\library.kodi.audioengine\\libKODI_audioengine" ADDON_HELPER_EXT +#else +#define AUDIOENGINE_HELPER_DLL_NAME "libKODI_audioengine-" ADDON_HELPER_ARCH ADDON_HELPER_EXT +#define AUDIOENGINE_HELPER_DLL "/library.kodi.audioengine/" AUDIOENGINE_HELPER_DLL_NAME +#endif + +class CAddonAEStream; + +class CHelper_libKODI_audioengine +{ +public: + CHelper_libKODI_audioengine(void) + { + m_libKODI_audioengine = NULL; + m_Handle = NULL; + } + + ~CHelper_libKODI_audioengine(void) + { + if (m_libKODI_audioengine) + { + AudioEngine_unregister_me(m_Handle, m_Callbacks); + dlclose(m_libKODI_audioengine); + } + } + + /*! + * @brief Resolve all callback methods + * @param handle Pointer to the add-on + * @return True when all methods were resolved, false otherwise. + */ + bool RegisterMe(void* handle) + { + m_Handle = handle; + + std::string libBasePath; + libBasePath = ((cb_array*)m_Handle)->libPath; + libBasePath += AUDIOENGINE_HELPER_DLL; + +#if defined(ANDROID) + struct stat st; + if(stat(libBasePath.c_str(),&st) != 0) + { + std::string tempbin = getenv("XBMC_ANDROID_LIBS"); + libBasePath = tempbin + "/" + AUDIOENGINE_HELPER_DLL; + } +#endif + + m_libKODI_audioengine = dlopen(libBasePath.c_str(), RTLD_LAZY); + if (m_libKODI_audioengine == NULL) + { + fprintf(stderr, "Unable to load %s\n", dlerror()); + return false; + } + + AudioEngine_register_me = (void* (*)(void *HANDLE)) + dlsym(m_libKODI_audioengine, "AudioEngine_register_me"); + if (AudioEngine_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + AudioEngine_unregister_me = (void(*)(void* HANDLE, void* CB)) + dlsym(m_libKODI_audioengine, "AudioEngine_unregister_me"); + if (AudioEngine_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + AudioEngine_MakeStream = (CAddonAEStream* (*)(void*, void*, AudioEngineFormat, unsigned int)) + dlsym(m_libKODI_audioengine, "AudioEngine_make_stream"); + if (AudioEngine_MakeStream == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + AudioEngine_FreeStream = (void(*)(CAddonAEStream*)) + dlsym(m_libKODI_audioengine, "AudioEngine_free_stream"); + if (AudioEngine_FreeStream == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + AudioEngine_GetCurrentSinkFormat = (bool(*)(void*, void*, AudioEngineFormat*)) + dlsym(m_libKODI_audioengine, "AudioEngine_get_current_sink_Format"); + if (AudioEngine_GetCurrentSinkFormat == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + m_Callbacks = AudioEngine_register_me(m_Handle); + return m_Callbacks != NULL; + } + + /** + * Creates and returns a new handle to an IAEStream in the format specified, this function should never fail + * @param DataFormat The data format the incoming audio will be in (eg, AE_FMT_S16LE) + * @param SampleRate The sample rate of the audio data (eg, 48000) + * @param ChannelLayout The order of the channels in the audio data + * @param Options A bit field of stream options (see: enum AEStreamOptions) + * @return a new Handle to an IAEStream that will accept data in the requested format + */ + CAddonAEStream* MakeStream(AudioEngineFormat Format, unsigned int Options = 0) + { + return AudioEngine_MakeStream(m_Handle, m_Callbacks, Format, Options); + } + + /** + * This method will remove the specifyed stream from the engine. + * For OSX/IOS this is essential to reconfigure the audio output. + * @param stream The stream to be altered + * @return NULL + */ + void FreeStream(CAddonAEStream **Stream) + { + AudioEngine_FreeStream(*Stream); + *Stream = NULL; + } + + /** + * Get the current sink data format + * + * @param Current sink data format. For more details see AudioEngineFormat. + * @return Returns true on success, else false. + */ + bool GetCurrentSinkFormat(AudioEngineFormat &SinkFormat) + { + return AudioEngine_GetCurrentSinkFormat(m_Handle, m_Callbacks, &SinkFormat); + } + +protected: + void* (*AudioEngine_register_me)(void*); + void (*AudioEngine_unregister_me)(void*, void*); + CAddonAEStream* (*AudioEngine_MakeStream)(void*, void*, AudioEngineFormat, unsigned int); + bool (*AudioEngine_GetCurrentSinkFormat)(void*, void*, AudioEngineFormat *SinkFormat); + void (*AudioEngine_FreeStream)(CAddonAEStream*); + +private: + void* m_libKODI_audioengine; + void* m_Handle; + void* m_Callbacks; + struct cb_array + { + const char* libPath; + }; +}; + +// Audio Engine Stream Class +class CAddonAEStream +{ +public: + CAddonAEStream(void *Addon, void *Callbacks, AEStreamHandle *StreamHandle); + virtual ~CAddonAEStream(); + + /** + * Returns the amount of space available in the stream + * @return The number of bytes AddData will consume + */ + virtual unsigned int GetSpace(); + + /** + * Add planar or interleaved PCM data to the stream + * @param Data array of pointers to the planes + * @param Offset to frame in frames + * @param Frames number of frames + * @return The number of frames consumed + */ + virtual unsigned int AddData(uint8_t* const *Data, unsigned int Offset, unsigned int Frames); + + /** + * Returns the time in seconds that it will take + * for the next added packet to be heard from the speakers. + * @return seconds + */ + virtual double GetDelay(); + + /** + * Returns if the stream is buffering + * @return True if the stream is buffering + */ + virtual bool IsBuffering(); + + /** + * Returns the time in seconds that it will take + * to underrun the cache if no sample is added. + * @return seconds + */ + virtual double GetCacheTime(); + + /** + * Returns the total time in seconds of the cache + * @return seconds + */ + virtual double GetCacheTotal(); + + /** + * Pauses the stream playback + */ + virtual void Pause(); + + /** + * Resumes the stream after pausing + */ + virtual void Resume(); + + /** + * Start draining the stream + * @note Once called AddData will not consume more data. + */ + virtual void Drain(bool Wait); + + /** + * Returns true if the is stream draining + */ + virtual bool IsDraining(); + + /** + * Returns true if the is stream has finished draining + */ + virtual bool IsDrained(); + + /** + * Flush all buffers dropping the audio data + */ + virtual void Flush(); + + /** + * Return the stream's current volume level + * @return The volume level between 0.0 and 1.0 + */ + virtual float GetVolume(); + + /** + * Set the stream's volume level + * @param volume The new volume level between 0.0 and 1.0 + */ + virtual void SetVolume(float Volume); + + /** + * Gets the stream's volume amplification in linear units. + * @return The volume amplification factor between 1.0 and 1000.0 + */ + virtual float GetAmplification(); + + /** + * Sets the stream's volume amplification in linear units. + * @param The volume amplification factor between 1.0 and 1000.0 + */ + virtual void SetAmplification(float Amplify); + + /** + * Returns the size of one audio frame in bytes (channelCount * resolution) + * @return The size in bytes of one frame + */ + virtual const unsigned int GetFrameSize() const; + + /** + * Returns the number of channels the stream is configured to accept + * @return The channel count + */ + virtual const unsigned int GetChannelCount() const; + + /** + * Returns the stream's sample rate, if the stream is using a dynamic sample rate, this value will NOT reflect any changes made by calls to SetResampleRatio() + * @return The stream's sample rate (eg, 48000) + */ + virtual const unsigned int GetSampleRate() const; + + /** + * Return the data format the stream has been configured with + * @return The stream's data format (eg, AE_FMT_S16LE) + */ + virtual const AEDataFormat GetDataFormat() const; + + /** + * Return the resample ratio + * @note This will return an undefined value if the stream is not resampling + * @return the current resample ratio or undefined if the stream is not resampling + */ + virtual double GetResampleRatio(); + + /** + * Sets the resample ratio + * @note This function may return false if the stream is not resampling, if you wish to use this be sure to set the AESTREAM_FORCE_RESAMPLE option + * @param ratio the new sample rate ratio, calculated by ((double)desiredRate / (double)GetSampleRate()) + */ + virtual void SetResampleRatio(double Ratio); + + /** + * Sginal a clock change + */ + virtual void Discontinuity(); + + private: + AEStreamHandle *m_StreamHandle; + void *m_Callbacks; + void *m_AddonHandle; +}; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h new file mode 100644 index 0000000..bdaeb4c --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_guilib.h @@ -0,0 +1,845 @@ +#pragma once +/* + * Copyright (C) 2005-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 + * . + * + */ + +#include +#include +#include +#include +#include +#include "libXBMC_addon.h" + +typedef void* GUIHANDLE; + +#ifdef _WIN32 +#define GUI_HELPER_DLL "\\library.kodi.guilib\\libKODI_guilib" ADDON_HELPER_EXT +#else +#define GUI_HELPER_DLL_NAME "libKODI_guilib-" ADDON_HELPER_ARCH ADDON_HELPER_EXT +#define GUI_HELPER_DLL "/library.kodi.guilib/" GUI_HELPER_DLL_NAME +#endif + +/* current ADDONGUI API version */ +#define KODI_GUILIB_API_VERSION "5.11.0" + +/* min. ADDONGUI API version */ +#define KODI_GUILIB_MIN_API_VERSION "5.10.0" + +#define ADDON_ACTION_PREVIOUS_MENU 10 +#define ADDON_ACTION_CLOSE_DIALOG 51 +#define ADDON_ACTION_NAV_BACK 92 + +class CAddonGUIWindow; +class CAddonGUISpinControl; +class CAddonGUIRadioButton; +class CAddonGUIProgressControl; +class CAddonListItem; +class CAddonGUIRenderingControl; +class CAddonGUISliderControl; +class CAddonGUISettingsSliderControl; + +class CHelper_libKODI_guilib +{ +public: + CHelper_libKODI_guilib() + { + m_libKODI_guilib = NULL; + m_Handle = NULL; + } + + ~CHelper_libKODI_guilib() + { + if (m_libKODI_guilib) + { + GUI_unregister_me(m_Handle, m_Callbacks); + dlclose(m_libKODI_guilib); + } + } + + bool RegisterMe(void *Handle) + { + m_Handle = Handle; + + std::string libBasePath; + libBasePath = ((cb_array*)m_Handle)->libPath; + libBasePath += GUI_HELPER_DLL; + +#if defined(ANDROID) + struct stat st; + if(stat(libBasePath.c_str(),&st) != 0) + { + std::string tempbin = getenv("XBMC_ANDROID_LIBS"); + libBasePath = tempbin + "/" + GUI_HELPER_DLL_NAME; + } +#endif + + m_libKODI_guilib = dlopen(libBasePath.c_str(), RTLD_LAZY); + if (m_libKODI_guilib == NULL) + { + fprintf(stderr, "Unable to load %s\n", dlerror()); + return false; + } + + GUI_register_me = (void* (*)(void *HANDLE)) + dlsym(m_libKODI_guilib, "GUI_register_me"); + if (GUI_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_unregister_me = (void (*)(void *HANDLE, void *CB)) + dlsym(m_libKODI_guilib, "GUI_unregister_me"); + if (GUI_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_lock = (void (*)(void *HANDLE, void *CB)) + dlsym(m_libKODI_guilib, "GUI_lock"); + if (GUI_lock == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_unlock = (void (*)(void *HANDLE, void *CB)) + dlsym(m_libKODI_guilib, "GUI_unlock"); + if (GUI_unlock == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_get_screen_height = (int (*)(void *HANDLE, void *CB)) + dlsym(m_libKODI_guilib, "GUI_get_screen_height"); + if (GUI_get_screen_height == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_get_screen_width = (int (*)(void *HANDLE, void *CB)) + dlsym(m_libKODI_guilib, "GUI_get_screen_width"); + if (GUI_get_screen_width == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_get_video_resolution = (int (*)(void *HANDLE, void *CB)) + dlsym(m_libKODI_guilib, "GUI_get_video_resolution"); + if (GUI_get_video_resolution == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_Window_create = (CAddonGUIWindow* (*)(void *HANDLE, void *CB, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog)) + dlsym(m_libKODI_guilib, "GUI_Window_create"); + if (GUI_Window_create == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_Window_destroy = (void (*)(CAddonGUIWindow* p)) + dlsym(m_libKODI_guilib, "GUI_Window_destroy"); + if (GUI_Window_destroy == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_control_get_spin = (CAddonGUISpinControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) + dlsym(m_libKODI_guilib, "GUI_control_get_spin"); + if (GUI_control_get_spin == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_control_release_spin = (void (*)(CAddonGUISpinControl* p)) + dlsym(m_libKODI_guilib, "GUI_control_release_spin"); + if (GUI_control_release_spin == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_control_get_radiobutton = (CAddonGUIRadioButton* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) + dlsym(m_libKODI_guilib, "GUI_control_get_radiobutton"); + if (GUI_control_get_radiobutton == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_control_release_radiobutton = (void (*)(CAddonGUIRadioButton* p)) + dlsym(m_libKODI_guilib, "GUI_control_release_radiobutton"); + if (GUI_control_release_radiobutton == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_control_get_progress = (CAddonGUIProgressControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) + dlsym(m_libKODI_guilib, "GUI_control_get_progress"); + if (GUI_control_get_progress == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_control_release_progress = (void (*)(CAddonGUIProgressControl* p)) + dlsym(m_libKODI_guilib, "GUI_control_release_progress"); + if (GUI_control_release_progress == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_ListItem_create = (CAddonListItem* (*)(void *HANDLE, void *CB, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path)) + dlsym(m_libKODI_guilib, "GUI_ListItem_create"); + if (GUI_ListItem_create == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_ListItem_destroy = (void (*)(CAddonListItem* p)) + dlsym(m_libKODI_guilib, "GUI_ListItem_destroy"); + if (GUI_ListItem_destroy == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_control_get_rendering = (CAddonGUIRenderingControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) + dlsym(m_libKODI_guilib, "GUI_control_get_rendering"); + if (GUI_control_get_rendering == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_control_release_rendering = (void (*)(CAddonGUIRenderingControl* p)) + dlsym(m_libKODI_guilib, "GUI_control_release_rendering"); + if (GUI_control_release_rendering == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_control_get_slider = (CAddonGUISliderControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) + dlsym(m_libKODI_guilib, "GUI_control_get_slider"); + if (GUI_control_get_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_control_release_slider = (void (*)(CAddonGUISliderControl* p)) + dlsym(m_libKODI_guilib, "GUI_control_release_slider"); + if (GUI_control_release_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_control_get_settings_slider = (CAddonGUISettingsSliderControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId)) + dlsym(m_libKODI_guilib, "GUI_control_get_settings_slider"); + if (GUI_control_get_settings_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_control_release_settings_slider = (void (*)(CAddonGUISettingsSliderControl* p)) + dlsym(m_libKODI_guilib, "GUI_control_release_settings_slider"); + if (GUI_control_release_settings_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_keyboard_show_and_get_input_with_head = (bool (*)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs)) + dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_input_with_head"); + if (GUI_dialog_keyboard_show_and_get_input_with_head == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_keyboard_show_and_get_input = (bool (*)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs)) + dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_input"); + if (GUI_dialog_keyboard_show_and_get_input == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_keyboard_show_and_get_new_password_with_head = (bool (*)(void *HANDLE, void *CB, char &newPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs)) + dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_new_password_with_head"); + if (GUI_dialog_keyboard_show_and_get_new_password_with_head == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_keyboard_show_and_get_new_password = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs)) + dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_new_password"); + if (GUI_dialog_keyboard_show_and_get_new_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_keyboard_show_and_verify_new_password_with_head = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs)) + dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_verify_new_password_with_head"); + if (GUI_dialog_keyboard_show_and_verify_new_password_with_head == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_keyboard_show_and_verify_new_password = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs)) + dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_verify_new_password"); + if (GUI_dialog_keyboard_show_and_verify_new_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_keyboard_show_and_verify_password = (int (*)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs)) + dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_verify_password"); + if (GUI_dialog_keyboard_show_and_verify_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_keyboard_show_and_get_filter = (bool (*)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs)) + dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_show_and_get_filter"); + if (GUI_dialog_keyboard_show_and_get_filter == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_keyboard_send_text_to_active_keyboard = (bool (*)(void *HANDLE, void *CB, const char *aTextString, bool closeKeyboard)) + dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_send_text_to_active_keyboard"); + if (GUI_dialog_keyboard_send_text_to_active_keyboard == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_keyboard_is_activated = (bool (*)(void *HANDLE, void *CB)) + dlsym(m_libKODI_guilib, "GUI_dialog_keyboard_is_activated"); + if (GUI_dialog_keyboard_is_activated == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_numeric_show_and_verify_new_password = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize)) + dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_verify_new_password"); + if (GUI_dialog_numeric_show_and_verify_new_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_numeric_show_and_verify_password = (int (*)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries)) + dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_verify_password"); + if (GUI_dialog_numeric_show_and_verify_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_numeric_show_and_verify_input = (bool (*)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput)) + dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_verify_input"); + if (GUI_dialog_numeric_show_and_verify_input == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_numeric_show_and_get_time = (bool (*)(void *HANDLE, void *CB, tm &time, const char *strHeading)) + dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_time"); + if (GUI_dialog_numeric_show_and_get_time == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_numeric_show_and_get_date = (bool (*)(void *HANDLE, void *CB, tm &date, const char *strHeading)) + dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_date"); + if (GUI_dialog_numeric_show_and_get_date == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_numeric_show_and_get_ipaddress = (bool (*)(void *HANDLE, void *CB, char &IPAddress, unsigned int iMaxStringSize, const char *strHeading)) + dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_ipaddress"); + if (GUI_dialog_numeric_show_and_get_ipaddress == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_numeric_show_and_get_number = (bool (*)(void *HANDLE, void *CB, char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs)) + dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_number"); + if (GUI_dialog_numeric_show_and_get_number == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_numeric_show_and_get_seconds = (bool (*)(void *HANDLE, void *CB, char &strTime, unsigned int iMaxStringSize, const char *strHeading)) + dlsym(m_libKODI_guilib, "GUI_dialog_numeric_show_and_get_seconds"); + if (GUI_dialog_numeric_show_and_get_seconds == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_filebrowser_show_and_get_file = (bool (*)(void *HANDLE, void *CB, const char *directory, const char *mask, const char *heading, char &path, unsigned int iMaxStringSize, bool useThumbs, bool useFileDirectories, bool singleList)) + dlsym(m_libKODI_guilib, "GUI_dialog_filebrowser_show_and_get_file"); + if (GUI_dialog_filebrowser_show_and_get_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_ok_show_and_get_input_single_text = (void (*)(void *HANDLE, void *CB, const char *heading, const char *text)) + dlsym(m_libKODI_guilib, "GUI_dialog_ok_show_and_get_input_single_text"); + if (GUI_dialog_ok_show_and_get_input_single_text == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_ok_show_and_get_input_line_text = (void (*)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2)) + dlsym(m_libKODI_guilib, "GUI_dialog_ok_show_and_get_input_line_text"); + if (GUI_dialog_ok_show_and_get_input_line_text == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_yesno_show_and_get_input_singletext = (bool (*)(void *HANDLE, void *CB, const char *heading, const char *text, bool& bCanceled, const char *noLabel, const char *yesLabel)) + dlsym(m_libKODI_guilib, "GUI_dialog_yesno_show_and_get_input_singletext"); + if (GUI_dialog_yesno_show_and_get_input_singletext == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_yesno_show_and_get_input_linetext = (bool (*)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel)) + dlsym(m_libKODI_guilib, "GUI_dialog_yesno_show_and_get_input_linetext"); + if (GUI_dialog_yesno_show_and_get_input_linetext == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_yesno_show_and_get_input_linebuttontext = (bool (*)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel, const char *yesLabel)) + dlsym(m_libKODI_guilib, "GUI_dialog_yesno_show_and_get_input_linebuttontext"); + if (GUI_dialog_yesno_show_and_get_input_linebuttontext == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_text_viewer = (void (*)(void *hdl, void *cb, const char *heading, const char *text)) + dlsym(m_libKODI_guilib, "GUI_dialog_text_viewer"); + if (GUI_dialog_text_viewer == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + GUI_dialog_select = (int (*)(void *hdl, void *cb, const char *heading, const char *entries[], unsigned int size, int selected)) + dlsym(m_libKODI_guilib, "GUI_dialog_select"); + if (GUI_dialog_select == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + m_Callbacks = GUI_register_me(m_Handle); + return m_Callbacks != NULL; + } + + void Lock() + { + return GUI_lock(m_Handle, m_Callbacks); + } + + void Unlock() + { + return GUI_unlock(m_Handle, m_Callbacks); + } + + int GetScreenHeight() + { + return GUI_get_screen_height(m_Handle, m_Callbacks); + } + + int GetScreenWidth() + { + return GUI_get_screen_width(m_Handle, m_Callbacks); + } + + int GetVideoResolution() + { + return GUI_get_video_resolution(m_Handle, m_Callbacks); + } + + CAddonGUIWindow* Window_create(const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog) + { + return GUI_Window_create(m_Handle, m_Callbacks, xmlFilename, defaultSkin, forceFallback, asDialog); + } + + void Window_destroy(CAddonGUIWindow* p) + { + return GUI_Window_destroy(p); + } + + CAddonGUISpinControl* Control_getSpin(CAddonGUIWindow *window, int controlId) + { + return GUI_control_get_spin(m_Handle, m_Callbacks, window, controlId); + } + + void Control_releaseSpin(CAddonGUISpinControl* p) + { + return GUI_control_release_spin(p); + } + + CAddonGUIRadioButton* Control_getRadioButton(CAddonGUIWindow *window, int controlId) + { + return GUI_control_get_radiobutton(m_Handle, m_Callbacks, window, controlId); + } + + void Control_releaseRadioButton(CAddonGUIRadioButton* p) + { + return GUI_control_release_radiobutton(p); + } + + CAddonGUIProgressControl* Control_getProgress(CAddonGUIWindow *window, int controlId) + { + return GUI_control_get_progress(m_Handle, m_Callbacks, window, controlId); + } + + void Control_releaseProgress(CAddonGUIProgressControl* p) + { + return GUI_control_release_progress(p); + } + + CAddonListItem* ListItem_create(const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path) + { + return GUI_ListItem_create(m_Handle, m_Callbacks, label, label2, iconImage, thumbnailImage, path); + } + + void ListItem_destroy(CAddonListItem* p) + { + return GUI_ListItem_destroy(p); + } + + CAddonGUIRenderingControl* Control_getRendering(CAddonGUIWindow *window, int controlId) + { + return GUI_control_get_rendering(m_Handle, m_Callbacks, window, controlId); + } + + void Control_releaseRendering(CAddonGUIRenderingControl* p) + { + return GUI_control_release_rendering(p); + } + + CAddonGUISliderControl* Control_getSlider(CAddonGUIWindow *window, int controlId) + { + return GUI_control_get_slider(m_Handle, m_Callbacks, window, controlId); + } + + void Control_releaseSlider(CAddonGUISliderControl* p) + { + return GUI_control_release_slider(p); + } + + CAddonGUISettingsSliderControl* Control_getSettingsSlider(CAddonGUIWindow *window, int controlId) + { + return GUI_control_get_settings_slider(m_Handle, m_Callbacks, window, controlId); + } + + void Control_releaseSettingsSlider(CAddonGUISettingsSliderControl* p) + { + return GUI_control_release_settings_slider(p); + } + + /*! @name GUI Keyboard functions */ + //@{ + bool Dialog_Keyboard_ShowAndGetInput(char &strText, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs = 0) + { + return GUI_dialog_keyboard_show_and_get_input_with_head(m_Handle, m_Callbacks, strText, iMaxStringSize, strHeading, allowEmptyResult, hiddenInput, autoCloseMs); + } + + bool Dialog_Keyboard_ShowAndGetInput(char &strText, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs = 0) + { + return GUI_dialog_keyboard_show_and_get_input(m_Handle, m_Callbacks, strText, iMaxStringSize, allowEmptyResult, autoCloseMs); + } + + bool Dialog_Keyboard_ShowAndGetNewPassword(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs = 0) + { + return GUI_dialog_keyboard_show_and_get_new_password_with_head(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, strHeading, allowEmptyResult, autoCloseMs); + } + + bool Dialog_Keyboard_ShowAndGetNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs = 0) + { + return GUI_dialog_keyboard_show_and_get_new_password(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, autoCloseMs); + } + + bool Dialog_Keyboard_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs = 0) + { + return GUI_dialog_keyboard_show_and_verify_new_password_with_head(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, strHeading, allowEmptyResult, autoCloseMs); + } + + bool Dialog_Keyboard_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs = 0) + { + return GUI_dialog_keyboard_show_and_verify_new_password(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, autoCloseMs); + } + + int Dialog_Keyboard_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs = 0) + { + return GUI_dialog_keyboard_show_and_verify_password(m_Handle, m_Callbacks, strPassword, iMaxStringSize, strHeading, iRetries, autoCloseMs); + } + + bool Dialog_Keyboard_ShowAndGetFilter(char &strText, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs = 0) + { + return GUI_dialog_keyboard_show_and_get_filter(m_Handle, m_Callbacks, strText, iMaxStringSize, searching, autoCloseMs); + } + + bool Dialog_Keyboard_SendTextToActiveKeyboard(const char *aTextString, bool closeKeyboard = false) + { + return GUI_dialog_keyboard_send_text_to_active_keyboard(m_Handle, m_Callbacks, aTextString, closeKeyboard); + } + + bool Dialog_Keyboard_isKeyboardActivated() + { + return GUI_dialog_keyboard_is_activated(m_Handle, m_Callbacks); + } + //@} + + /*! @name GUI Numeric functions */ + //@{ + bool Dialog_Numeric_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize) + { + return GUI_dialog_numeric_show_and_verify_new_password(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize); + } + + int Dialog_Numeric_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries) + { + return GUI_dialog_numeric_show_and_verify_password(m_Handle, m_Callbacks, strPassword, iMaxStringSize, strHeading, iRetries); + } + + bool Dialog_Numeric_ShowAndVerifyInput(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput) + { + return GUI_dialog_numeric_show_and_verify_input(m_Handle, m_Callbacks, strPassword, iMaxStringSize, strHeading, bGetUserInput); + } + + bool Dialog_Numeric_ShowAndGetTime(tm &time, const char *strHeading) + { + return GUI_dialog_numeric_show_and_get_time(m_Handle, m_Callbacks, time, strHeading); + } + + bool Dialog_Numeric_ShowAndGetDate(tm &date, const char *strHeading) + { + return GUI_dialog_numeric_show_and_get_date(m_Handle, m_Callbacks, date, strHeading); + } + + bool Dialog_Numeric_ShowAndGetIPAddress(char &strIPAddress, unsigned int iMaxStringSize, const char *strHeading) + { + return GUI_dialog_numeric_show_and_get_ipaddress(m_Handle, m_Callbacks, strIPAddress, iMaxStringSize, strHeading); + } + + bool Dialog_Numeric_ShowAndGetNumber(char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs = 0) + { + return GUI_dialog_numeric_show_and_get_number(m_Handle, m_Callbacks, strInput, iMaxStringSize, strHeading, iAutoCloseTimeoutMs); + } + + bool Dialog_Numeric_ShowAndGetSeconds(char &strTime, unsigned int iMaxStringSize, const char *strHeading) + { + return GUI_dialog_numeric_show_and_get_seconds(m_Handle, m_Callbacks, strTime, iMaxStringSize, strHeading); + } + //@} + + /*! @name GUI File browser functions */ + //@{ + bool Dialog_FileBrowser_ShowAndGetFile(const char *directory, const char *mask, const char *heading, char &strPath, unsigned int iMaxStringSize, bool useThumbs = false, bool useFileDirectories = false, bool singleList = false) + { + return GUI_dialog_filebrowser_show_and_get_file(m_Handle, m_Callbacks, directory, mask, heading, strPath, iMaxStringSize, useThumbs, useFileDirectories, singleList); + } + //@} + + /*! @name GUI OK Dialog functions */ + //@{ + void Dialog_OK_ShowAndGetInput(const char *heading, const char *text) + { + GUI_dialog_ok_show_and_get_input_single_text(m_Handle, m_Callbacks, heading, text); + } + + void Dialog_OK_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2) + { + GUI_dialog_ok_show_and_get_input_line_text(m_Handle, m_Callbacks, heading, line0, line1, line2); + } + //@} + + /*! @name GUI Yes No Dialog functions */ + //@{ + bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *text, bool& bCanceled, const char *noLabel = "", const char *yesLabel = "") + { + return GUI_dialog_yesno_show_and_get_input_singletext(m_Handle, m_Callbacks, heading, text, bCanceled, noLabel, yesLabel); + } + + bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel = "", const char *yesLabel = "") + { + return GUI_dialog_yesno_show_and_get_input_linetext(m_Handle, m_Callbacks, heading, line0, line1, line2, noLabel, yesLabel); + } + + bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel = "", const char *yesLabel = "") + { + return GUI_dialog_yesno_show_and_get_input_linebuttontext(m_Handle, m_Callbacks, heading, line0, line1, line2, bCanceled, noLabel, yesLabel); + } + //@} + + /*! @name GUI Text viewer Dialog */ + //@{ + void Dialog_TextViewer(const char *heading, const char *text) + { + return GUI_dialog_text_viewer(m_Handle, m_Callbacks, heading, text); + } + //@} + + /*! @name GUI select Dialog */ + //@{ + int Dialog_Select(const char *heading, const char *entries[], unsigned int size, int selected = -1) + { + return GUI_dialog_select(m_Handle, m_Callbacks, heading, entries, size, selected); + } + //@} + +protected: + void* (*GUI_register_me)(void *HANDLE); + void (*GUI_unregister_me)(void *HANDLE, void* CB); + void (*GUI_lock)(void *HANDLE, void* CB); + void (*GUI_unlock)(void *HANDLE, void* CB); + int (*GUI_get_screen_height)(void *HANDLE, void* CB); + int (*GUI_get_screen_width)(void *HANDLE, void* CB); + int (*GUI_get_video_resolution)(void *HANDLE, void* CB); + CAddonGUIWindow* (*GUI_Window_create)(void *HANDLE, void* CB, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog); + void (*GUI_Window_destroy)(CAddonGUIWindow* p); + CAddonGUISpinControl* (*GUI_control_get_spin)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); + void (*GUI_control_release_spin)(CAddonGUISpinControl* p); + CAddonGUIRadioButton* (*GUI_control_get_radiobutton)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); + void (*GUI_control_release_radiobutton)(CAddonGUIRadioButton* p); + CAddonGUIProgressControl* (*GUI_control_get_progress)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); + void (*GUI_control_release_progress)(CAddonGUIProgressControl* p); + CAddonListItem* (*GUI_ListItem_create)(void *HANDLE, void* CB, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path); + void (*GUI_ListItem_destroy)(CAddonListItem* p); + CAddonGUIRenderingControl* (*GUI_control_get_rendering)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); + void (*GUI_control_release_rendering)(CAddonGUIRenderingControl* p); + CAddonGUISliderControl* (*GUI_control_get_slider)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); + void (*GUI_control_release_slider)(CAddonGUISliderControl* p); + CAddonGUISettingsSliderControl* (*GUI_control_get_settings_slider)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId); + void (*GUI_control_release_settings_slider)(CAddonGUISettingsSliderControl* p); + bool (*GUI_dialog_keyboard_show_and_get_input_with_head)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs); + bool (*GUI_dialog_keyboard_show_and_get_input)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs); + bool (*GUI_dialog_keyboard_show_and_get_new_password_with_head)(void *HANDLE, void *CB, char &newPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs); + bool (*GUI_dialog_keyboard_show_and_get_new_password)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs); + bool (*GUI_dialog_keyboard_show_and_verify_new_password_with_head)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs); + bool (*GUI_dialog_keyboard_show_and_verify_new_password)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs); + int (*GUI_dialog_keyboard_show_and_verify_password)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs); + bool (*GUI_dialog_keyboard_show_and_get_filter)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs); + bool (*GUI_dialog_keyboard_send_text_to_active_keyboard)(void *HANDLE, void *CB, const char *aTextString, bool closeKeyboard); + bool (*GUI_dialog_keyboard_is_activated)(void *HANDLE, void *CB); + bool (*GUI_dialog_numeric_show_and_verify_new_password)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize); + int (*GUI_dialog_numeric_show_and_verify_password)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries); + bool (*GUI_dialog_numeric_show_and_verify_input)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput); + bool (*GUI_dialog_numeric_show_and_get_time)(void *HANDLE, void *CB, tm &time, const char *strHeading); + bool (*GUI_dialog_numeric_show_and_get_date)(void *HANDLE, void *CB, tm &date, const char *strHeading); + bool (*GUI_dialog_numeric_show_and_get_ipaddress)(void *HANDLE, void *CB, char &IPAddress, unsigned int iMaxStringSize, const char *strHeading); + bool (*GUI_dialog_numeric_show_and_get_number)(void *HANDLE, void *CB, char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs); + bool (*GUI_dialog_numeric_show_and_get_seconds)(void *HANDLE, void *CB, char &strTime, unsigned int iMaxStringSize, const char *strHeading); + bool (*GUI_dialog_filebrowser_show_and_get_file)(void *HANDLE, void *CB, const char *directory, const char *mask, const char *heading, char &path, unsigned int iMaxStringSize, bool useThumbs, bool useFileDirectories, bool singleList); + void (*GUI_dialog_ok_show_and_get_input_single_text)(void *HANDLE, void *CB, const char *heading, const char *text); + void (*GUI_dialog_ok_show_and_get_input_line_text)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2); + bool (*GUI_dialog_yesno_show_and_get_input_singletext)(void *HANDLE, void *CB, const char *heading, const char *text, bool& bCanceled, const char *noLabel, const char *yesLabel); + bool (*GUI_dialog_yesno_show_and_get_input_linetext)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel); + bool (*GUI_dialog_yesno_show_and_get_input_linebuttontext)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel, const char *yesLabel); + void (*GUI_dialog_text_viewer)(void *hdl, void *cb, const char *heading, const char *text); + int (*GUI_dialog_select)(void *hdl, void *cb, const char *heading, const char *entries[], unsigned int size, int selected); + +private: + void *m_libKODI_guilib; + void *m_Handle; + void *m_Callbacks; + struct cb_array + { + const char* libPath; + }; +}; + +class CAddonGUISpinControl +{ +public: + CAddonGUISpinControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); + virtual ~CAddonGUISpinControl(void) {} + + virtual void SetVisible(bool yesNo); + virtual void SetText(const char *label); + virtual void Clear(); + virtual void AddLabel(const char *label, int iValue); + virtual int GetValue(); + virtual void SetValue(int iValue); + +private: + CAddonGUIWindow *m_Window; + int m_ControlId; + GUIHANDLE m_SpinHandle; + void *m_Handle; + void *m_cb; +}; + +class CAddonGUIRadioButton +{ +public: + CAddonGUIRadioButton(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); + virtual ~CAddonGUIRadioButton() {} + + virtual void SetVisible(bool yesNo); + virtual void SetText(const char *label); + virtual void SetSelected(bool yesNo); + virtual bool IsSelected(); + +private: + CAddonGUIWindow *m_Window; + int m_ControlId; + GUIHANDLE m_ButtonHandle; + void *m_Handle; + void *m_cb; +}; + +class CAddonGUIProgressControl +{ +public: + CAddonGUIProgressControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); + virtual ~CAddonGUIProgressControl(void) {} + + virtual void SetPercentage(float fPercent); + virtual float GetPercentage() const; + virtual void SetInfo(int iInfo); + virtual int GetInfo() const; + virtual std::string GetDescription() const; + +private: + CAddonGUIWindow *m_Window; + int m_ControlId; + GUIHANDLE m_ProgressHandle; + void *m_Handle; + void *m_cb; +}; + +class CAddonGUISliderControl +{ +public: + CAddonGUISliderControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); + virtual ~CAddonGUISliderControl(void) {} + + virtual void SetVisible(bool yesNo); + virtual std::string GetDescription() const; + + virtual void SetIntRange(int iStart, int iEnd); + virtual void SetIntValue(int iValue); + virtual int GetIntValue() const; + virtual void SetIntInterval(int iInterval); + + virtual void SetPercentage(float fPercent); + virtual float GetPercentage() const; + + virtual void SetFloatRange(float fStart, float fEnd); + virtual void SetFloatValue(float fValue); + virtual float GetFloatValue() const; + virtual void SetFloatInterval(float fInterval); + +private: + CAddonGUIWindow *m_Window; + int m_ControlId; + GUIHANDLE m_SliderHandle; + void *m_Handle; + void *m_cb; +}; + +class CAddonGUISettingsSliderControl +{ +public: + CAddonGUISettingsSliderControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); + virtual ~CAddonGUISettingsSliderControl(void) {} + + virtual void SetVisible(bool yesNo); + virtual void SetText(const char *label); + virtual std::string GetDescription() const; + + virtual void SetIntRange(int iStart, int iEnd); + virtual void SetIntValue(int iValue); + virtual int GetIntValue() const; + virtual void SetIntInterval(int iInterval); + + virtual void SetPercentage(float fPercent); + virtual float GetPercentage() const; + + virtual void SetFloatRange(float fStart, float fEnd); + virtual void SetFloatValue(float fValue); + virtual float GetFloatValue() const; + virtual void SetFloatInterval(float fInterval); + +private: + CAddonGUIWindow *m_Window; + int m_ControlId; + GUIHANDLE m_SettingsSliderHandle; + void *m_Handle; + void *m_cb; +}; + +class CAddonListItem +{ +friend class CAddonGUIWindow; + +public: + CAddonListItem(void *hdl, void *cb, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path); + virtual ~CAddonListItem(void) {} + + virtual const char *GetLabel(); + virtual void SetLabel(const char *label); + virtual const char *GetLabel2(); + virtual void SetLabel2(const char *label); + virtual void SetIconImage(const char *image); + virtual void SetThumbnailImage(const char *image); + virtual void SetInfo(const char *Info); + virtual void SetProperty(const char *key, const char *value); + virtual const char *GetProperty(const char *key) const; + virtual void SetPath(const char *Path); + +// {(char*)"select(); +// {(char*)"isSelected(); +protected: + GUIHANDLE m_ListItemHandle; + void *m_Handle; + void *m_cb; +}; + +class CAddonGUIWindow +{ +friend class CAddonGUISpinControl; +friend class CAddonGUIRadioButton; +friend class CAddonGUIProgressControl; +friend class CAddonGUIRenderingControl; +friend class CAddonGUISliderControl; +friend class CAddonGUISettingsSliderControl; + +public: + CAddonGUIWindow(void *hdl, void *cb, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog); + virtual ~CAddonGUIWindow(); + + virtual bool Show(); + virtual void Close(); + virtual void DoModal(); + virtual bool SetFocusId(int iControlId); + virtual int GetFocusId(); + virtual bool SetCoordinateResolution(int res); + virtual void SetProperty(const char *key, const char *value); + virtual void SetPropertyInt(const char *key, int value); + virtual void SetPropertyBool(const char *key, bool value); + virtual void SetPropertyDouble(const char *key, double value); + virtual const char *GetProperty(const char *key) const; + virtual int GetPropertyInt(const char *key) const; + virtual bool GetPropertyBool(const char *key) const; + virtual double GetPropertyDouble(const char *key) const; + virtual void ClearProperties(); + virtual int GetListSize(); + virtual void ClearList(); + virtual GUIHANDLE AddStringItem(const char *name, int itemPosition = -1); + virtual void AddItem(GUIHANDLE item, int itemPosition = -1); + virtual void AddItem(CAddonListItem *item, int itemPosition = -1); + virtual void RemoveItem(int itemPosition); + virtual GUIHANDLE GetListItem(int listPos); + virtual void SetCurrentListPosition(int listPos); + virtual int GetCurrentListPosition(); + virtual void SetControlLabel(int controlId, const char *label); + virtual void MarkDirtyRegion(); + + virtual bool OnClick(int controlId); + virtual bool OnFocus(int controlId); + virtual bool OnInit(); + virtual bool OnAction(int actionId); + + GUIHANDLE m_cbhdl; + bool (*CBOnInit)(GUIHANDLE cbhdl); + bool (*CBOnFocus)(GUIHANDLE cbhdl, int controlId); + bool (*CBOnClick)(GUIHANDLE cbhdl, int controlId); + bool (*CBOnAction)(GUIHANDLE cbhdl, int actionId); + +protected: + GUIHANDLE m_WindowHandle; + void *m_Handle; + void *m_cb; +}; + +class CAddonGUIRenderingControl +{ +public: + CAddonGUIRenderingControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId); + virtual ~CAddonGUIRenderingControl(); + virtual void Init(); + + virtual bool Create(int x, int y, int w, int h, void *device); + virtual void Render(); + virtual void Stop(); + virtual bool Dirty(); + + GUIHANDLE m_cbhdl; + bool (*CBCreate)(GUIHANDLE cbhdl, int x, int y, int w, int h, void *device); + void (*CBRender)(GUIHANDLE cbhdl); + void (*CBStop)(GUIHANDLE cbhdl); + bool (*CBDirty)(GUIHANDLE cbhdl); + +private: + CAddonGUIWindow *m_Window; + int m_ControlId; + GUIHANDLE m_RenderingHandle; + void *m_Handle; + void *m_cb; +}; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h new file mode 100644 index 0000000..e0dc881 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libKODI_inputstream.h @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2005-2016 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, see + * . + * + */ + +#pragma once + +#include +#include +#include +#include +#include +#include "libXBMC_addon.h" + +#ifdef BUILD_KODI_ADDON +#include "DVDDemuxPacket.h" +#else +#include "cores/VideoPlayer/DVDDemuxers/DVDDemuxPacket.h" +#endif + +#ifdef _WIN32 +#define INPUTSTREAM_HELPER_DLL "\\library.kodi.inputstream\\libKODI_inputstream" ADDON_HELPER_EXT +#else +#define INPUTSTREAM_HELPER_DLL_NAME "libKODI_inputstream-" ADDON_HELPER_ARCH ADDON_HELPER_EXT +#define INPUTSTREAM_HELPER_DLL "/library.kodi.inputstream/" INPUTSTREAM_HELPER_DLL_NAME +#endif + +class CHelper_libKODI_inputstream +{ +public: + CHelper_libKODI_inputstream(void) + { + m_libKODI_inputstream = nullptr; + m_Handle = nullptr; + } + + ~CHelper_libKODI_inputstream(void) + { + if (m_libKODI_inputstream) + { + INPUTSTREAM_unregister_me(m_Handle, m_Callbacks); + dlclose(m_libKODI_inputstream); + } + } + + /*! + * @brief Resolve all callback methods + * @param handle Pointer to the add-on + * @return True when all methods were resolved, false otherwise. + */ + bool RegisterMe(void* handle) + { + m_Handle = handle; + + std::string libBasePath; + libBasePath = ((cb_array*)m_Handle)->libPath; + libBasePath += INPUTSTREAM_HELPER_DLL; + + m_libKODI_inputstream = dlopen(libBasePath.c_str(), RTLD_LAZY); + if (m_libKODI_inputstream == nullptr) + { + fprintf(stderr, "Unable to load %s\n", dlerror()); + return false; + } + + INPUTSTREAM_register_me = (void* (*)(void *HANDLE)) + dlsym(m_libKODI_inputstream, "INPUTSTREAM_register_me"); + if (INPUTSTREAM_register_me == nullptr) + { + fprintf(stderr, "Unable to assign function %s\n", dlerror()); + return false; + } + + INPUTSTREAM_unregister_me = (void (*)(void* HANDLE, void* CB)) + dlsym(m_libKODI_inputstream, "INPUTSTREAM_unregister_me"); + if (INPUTSTREAM_unregister_me == nullptr) + { + fprintf(stderr, "Unable to assign function %s\n", dlerror()); + return false; + } + + INPUTSTREAM_free_demux_packet = (void (*)(void* HANDLE, void* CB, DemuxPacket* pPacket)) + dlsym(m_libKODI_inputstream, "INPUTSTREAM_free_demux_packet"); + if (INPUTSTREAM_free_demux_packet == NULL) + { + fprintf(stderr, "Unable to assign function %s\n", dlerror()); + return false; + } + + INPUTSTREAM_allocate_demux_packet = (DemuxPacket* (*)(void* HANDLE, void* CB, int iDataSize)) + dlsym(m_libKODI_inputstream, "INPUTSTREAM_allocate_demux_packet"); + if (INPUTSTREAM_allocate_demux_packet == NULL) + { + fprintf(stderr, "Unable to assign function %s\n", dlerror()); + return false; + } + + m_Callbacks = INPUTSTREAM_register_me(m_Handle); + return m_Callbacks != nullptr; + } + + /*! + * @brief Allocate a demux packet. Free with FreeDemuxPacket + * @param iDataSize The size of the data that will go into the packet + * @return The allocated packet + */ + DemuxPacket* AllocateDemuxPacket(int iDataSize) + { + return INPUTSTREAM_allocate_demux_packet(m_Handle, m_Callbacks, iDataSize); + } + + /*! + * @brief Free a packet that was allocated with AllocateDemuxPacket + * @param pPacket The packet to free + */ + void FreeDemuxPacket(DemuxPacket* pPacket) + { + return INPUTSTREAM_free_demux_packet(m_Handle, m_Callbacks, pPacket); + } + +protected: + void* (*INPUTSTREAM_register_me)(void*); + void (*INPUTSTREAM_unregister_me)(void*, void*); + void (*INPUTSTREAM_free_demux_packet)(void*, void*, DemuxPacket*); + DemuxPacket* (*INPUTSTREAM_allocate_demux_packet)(void*, void*, int); + +private: + void* m_libKODI_inputstream; + void* m_Handle; + void* m_Callbacks; + struct cb_array + { + const char* libPath; + }; +}; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h new file mode 100644 index 0000000..e8d5ec7 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_addon.h @@ -0,0 +1,710 @@ +#pragma once +/* + * Copyright (C) 2005-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 + * . + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#if defined(BUILD_KODI_ADDON) +#include "IFileTypes.h" +#else +#include "filesystem/IFileTypes.h" +#endif + +struct VFSDirEntry; + +#ifdef _WIN32 // windows +#ifndef _SSIZE_T_DEFINED +typedef intptr_t ssize_t; +#define _SSIZE_T_DEFINED +#endif // !_SSIZE_T_DEFINED + +#if defined(BUILD_KODI_ADDON) +#include "p8-platform/windows/dlfcn-win32.h" +#else +#include "dlfcn-win32.h" +#endif + +#define ADDON_DLL "\\library.xbmc.addon\\libXBMC_addon" ADDON_HELPER_EXT +#define ADDON_HELPER_EXT ".dll" +#else // windows +// the ADDON_HELPER_ARCH is the platform dependend name which is used +// as part of the name of dynamic addon libraries. It has to match the +// strings which are set in configure.ac for the "ARCH" variable. +#if defined(__APPLE__) // osx +#if defined(__arm__) || defined(__aarch64__) +#define ADDON_HELPER_ARCH "arm-osx" +#else +#define ADDON_HELPER_ARCH "x86-osx" +#endif +#define ADDON_HELPER_EXT ".dylib" +#else // linux +#if defined(__x86_64__) +#define ADDON_HELPER_ARCH "x86_64-linux" +#elif defined(_POWERPC) +#define ADDON_HELPER_ARCH "powerpc-linux" +#elif defined(_POWERPC64) +#define ADDON_HELPER_ARCH "powerpc64-linux" +#elif defined(__ARMEL__) +#define ADDON_HELPER_ARCH "arm" +#elif defined(__aarch64__) +#define ADDON_HELPER_ARCH "aarch64" +#elif defined(__mips__) +#define ADDON_HELPER_ARCH "mips" +#else +#define ADDON_HELPER_ARCH "i486-linux" +#endif +#define ADDON_HELPER_EXT ".so" +#endif +#include // linux+osx +#define ADDON_DLL_NAME "libXBMC_addon-" ADDON_HELPER_ARCH ADDON_HELPER_EXT +#define ADDON_DLL "/library.xbmc.addon/" ADDON_DLL_NAME +#endif +#if defined(ANDROID) +#include +#endif + +#ifdef LOG_DEBUG +#undef LOG_DEBUG +#endif +#ifdef LOG_INFO +#undef LOG_INFO +#endif +#ifdef LOG_NOTICE +#undef LOG_NOTICE +#endif +#ifdef LOG_ERROR +#undef LOG_ERROR +#endif + +namespace ADDON +{ + typedef enum addon_log + { + LOG_DEBUG, + LOG_INFO, + LOG_NOTICE, + LOG_ERROR + } addon_log_t; + + typedef enum queue_msg + { + QUEUE_INFO, + QUEUE_WARNING, + QUEUE_ERROR + } queue_msg_t; + + class CHelper_libXBMC_addon + { + public: + CHelper_libXBMC_addon() + { + m_libXBMC_addon = NULL; + m_Handle = NULL; + } + + ~CHelper_libXBMC_addon() + { + if (m_libXBMC_addon) + { + XBMC_unregister_me(m_Handle, m_Callbacks); + dlclose(m_libXBMC_addon); + } + } + + bool RegisterMe(void *Handle) + { + m_Handle = Handle; + + std::string libBasePath; + libBasePath = ((cb_array*)m_Handle)->libPath; + libBasePath += ADDON_DLL; + +#if defined(ANDROID) + struct stat st; + if(stat(libBasePath.c_str(),&st) != 0) + { + std::string tempbin = getenv("XBMC_ANDROID_LIBS"); + libBasePath = tempbin + "/" + ADDON_DLL_NAME; + } +#endif + + m_libXBMC_addon = dlopen(libBasePath.c_str(), RTLD_LAZY); + if (m_libXBMC_addon == NULL) + { + fprintf(stderr, "Unable to load %s\n", dlerror()); + return false; + } + + XBMC_register_me = (void* (*)(void *HANDLE)) + dlsym(m_libXBMC_addon, "XBMC_register_me"); + if (XBMC_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_unregister_me = (void (*)(void* HANDLE, void* CB)) + dlsym(m_libXBMC_addon, "XBMC_unregister_me"); + if (XBMC_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_log = (void (*)(void* HANDLE, void* CB, const addon_log_t loglevel, const char *msg)) + dlsym(m_libXBMC_addon, "XBMC_log"); + if (XBMC_log == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_get_setting = (bool (*)(void* HANDLE, void* CB, const char* settingName, void *settingValue)) + dlsym(m_libXBMC_addon, "XBMC_get_setting"); + if (XBMC_get_setting == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_queue_notification = (void (*)(void* HANDLE, void* CB, const queue_msg_t loglevel, const char *msg)) + dlsym(m_libXBMC_addon, "XBMC_queue_notification"); + if (XBMC_queue_notification == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_wake_on_lan = (bool (*)(void* HANDLE, void *CB, const char *mac)) + dlsym(m_libXBMC_addon, "XBMC_wake_on_lan"); + if (XBMC_wake_on_lan == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_unknown_to_utf8 = (char* (*)(void* HANDLE, void* CB, const char* str)) + dlsym(m_libXBMC_addon, "XBMC_unknown_to_utf8"); + if (XBMC_unknown_to_utf8 == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_get_localized_string = (char* (*)(void* HANDLE, void* CB, int dwCode)) + dlsym(m_libXBMC_addon, "XBMC_get_localized_string"); + if (XBMC_get_localized_string == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_free_string = (void (*)(void* HANDLE, void* CB, char* str)) + dlsym(m_libXBMC_addon, "XBMC_free_string"); + if (XBMC_free_string == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_get_dvd_menu_language = (char* (*)(void* HANDLE, void* CB)) + dlsym(m_libXBMC_addon, "XBMC_get_dvd_menu_language"); + if (XBMC_get_dvd_menu_language == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_open_file = (void* (*)(void* HANDLE, void* CB, const char* strFileName, unsigned int flags)) + dlsym(m_libXBMC_addon, "XBMC_open_file"); + if (XBMC_open_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_open_file_for_write = (void* (*)(void* HANDLE, void* CB, const char* strFileName, bool bOverWrite)) + dlsym(m_libXBMC_addon, "XBMC_open_file_for_write"); + if (XBMC_open_file_for_write == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_read_file = (ssize_t (*)(void* HANDLE, void* CB, void* file, void* lpBuf, size_t uiBufSize)) + dlsym(m_libXBMC_addon, "XBMC_read_file"); + if (XBMC_read_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_read_file_string = (bool (*)(void* HANDLE, void* CB, void* file, char *szLine, int iLineLength)) + dlsym(m_libXBMC_addon, "XBMC_read_file_string"); + if (XBMC_read_file_string == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_write_file = (ssize_t (*)(void* HANDLE, void* CB, void* file, const void* lpBuf, size_t uiBufSize)) + dlsym(m_libXBMC_addon, "XBMC_write_file"); + if (XBMC_write_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_flush_file = (void (*)(void* HANDLE, void* CB, void* file)) + dlsym(m_libXBMC_addon, "XBMC_flush_file"); + if (XBMC_flush_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_seek_file = (int64_t (*)(void* HANDLE, void* CB, void* file, int64_t iFilePosition, int iWhence)) + dlsym(m_libXBMC_addon, "XBMC_seek_file"); + if (XBMC_seek_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_truncate_file = (int (*)(void* HANDLE, void* CB, void* file, int64_t iSize)) + dlsym(m_libXBMC_addon, "XBMC_truncate_file"); + if (XBMC_truncate_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_get_file_position = (int64_t (*)(void* HANDLE, void* CB, void* file)) + dlsym(m_libXBMC_addon, "XBMC_get_file_position"); + if (XBMC_get_file_position == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_get_file_length = (int64_t (*)(void* HANDLE, void* CB, void* file)) + dlsym(m_libXBMC_addon, "XBMC_get_file_length"); + if (XBMC_get_file_length == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_get_file_download_speed = (double(*)(void* HANDLE, void* CB, void* file)) + dlsym(m_libXBMC_addon, "XBMC_get_file_download_speed"); + if (XBMC_get_file_download_speed == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_close_file = (void (*)(void* HANDLE, void* CB, void* file)) + dlsym(m_libXBMC_addon, "XBMC_close_file"); + if (XBMC_close_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_get_file_chunk_size = (int (*)(void* HANDLE, void* CB, void* file)) + dlsym(m_libXBMC_addon, "XBMC_get_file_chunk_size"); + if (XBMC_get_file_chunk_size == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_file_exists = (bool (*)(void* HANDLE, void* CB, const char *strFileName, bool bUseCache)) + dlsym(m_libXBMC_addon, "XBMC_file_exists"); + if (XBMC_file_exists == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_stat_file = (int (*)(void* HANDLE, void* CB, const char *strFileName, struct __stat64* buffer)) + dlsym(m_libXBMC_addon, "XBMC_stat_file"); + if (XBMC_stat_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_delete_file = (bool (*)(void* HANDLE, void* CB, const char *strFileName)) + dlsym(m_libXBMC_addon, "XBMC_delete_file"); + if (XBMC_delete_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_can_open_directory = (bool (*)(void* HANDLE, void* CB, const char* strURL)) + dlsym(m_libXBMC_addon, "XBMC_can_open_directory"); + if (XBMC_can_open_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_create_directory = (bool (*)(void* HANDLE, void* CB, const char* strPath)) + dlsym(m_libXBMC_addon, "XBMC_create_directory"); + if (XBMC_create_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_directory_exists = (bool (*)(void* HANDLE, void* CB, const char* strPath)) + dlsym(m_libXBMC_addon, "XBMC_directory_exists"); + if (XBMC_directory_exists == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_remove_directory = (bool (*)(void* HANDLE, void* CB, const char* strPath)) + dlsym(m_libXBMC_addon, "XBMC_remove_directory"); + if (XBMC_remove_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_get_directory = (bool (*)(void* HANDLE, void* CB, const char* strPath, const char* mask, VFSDirEntry** items, unsigned int* num_items)) + dlsym(m_libXBMC_addon, "XBMC_get_directory"); + if (XBMC_get_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_free_directory = (void (*)(void* HANDLE, void* CB, VFSDirEntry* items, unsigned int num_items)) + dlsym(m_libXBMC_addon, "XBMC_free_directory"); + if (XBMC_free_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_curl_create = (void* (*)(void *HANDLE, void* CB, const char* strURL)) + dlsym(m_libXBMC_addon, "XBMC_curl_create"); + if (XBMC_curl_create == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_curl_add_option = (bool (*)(void *HANDLE, void* CB, void *file, XFILE::CURLOPTIONTYPE type, const char* name, const char *value)) + dlsym(m_libXBMC_addon, "XBMC_curl_add_option"); + if (XBMC_curl_add_option == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + XBMC_curl_open = (bool (*)(void *HANDLE, void* CB, void *file, unsigned int flags)) + dlsym(m_libXBMC_addon, "XBMC_curl_open"); + if (XBMC_curl_open == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + m_Callbacks = XBMC_register_me(m_Handle); + return m_Callbacks != NULL; + } + + /*! + * @brief Add a message to XBMC's log. + * @param loglevel The log level of the message. + * @param format The format of the message to pass to XBMC. + */ + void Log(const addon_log_t loglevel, const char *format, ... ) + { + char buffer[16384]; + va_list args; + va_start (args, format); + vsprintf (buffer, format, args); + va_end (args); + return XBMC_log(m_Handle, m_Callbacks, loglevel, buffer); + } + + /*! + * @brief Get a settings value for this add-on. + * @param settingName The name of the setting to get. + * @param settingValue The value. + * @return True if the settings was fetched successfully, false otherwise. + */ + bool GetSetting(const char* settingName, void *settingValue) + { + return XBMC_get_setting(m_Handle, m_Callbacks, settingName, settingValue); + } + + /*! + * @brief Queue a notification in the GUI. + * @param type The message type. + * @param format The format of the message to pass to display in XBMC. + */ + void QueueNotification(const queue_msg_t type, const char *format, ... ) + { + char buffer[16384]; + va_list args; + va_start (args, format); + vsprintf (buffer, format, args); + va_end (args); + return XBMC_queue_notification(m_Handle, m_Callbacks, type, buffer); + } + + /*! + * @brief Send WakeOnLan magic packet. + * @param mac Network address of the host to wake. + * @return True if the magic packet was successfully sent, false otherwise. + */ + bool WakeOnLan(const char* mac) + { + return XBMC_wake_on_lan(m_Handle, m_Callbacks, mac); + } + + /*! + * @brief Translate a string with an unknown encoding to UTF8. + * @param str The string to translate. + * @return The string translated to UTF8. Must be freed by calling FreeString() when done. + */ + char* UnknownToUTF8(const char* str) + { + return XBMC_unknown_to_utf8(m_Handle, m_Callbacks, str); + } + + /*! + * @brief Get a localised message. + * @param dwCode The code of the message to get. + * @return The message. Must be freed by calling FreeString() when done. + */ + char* GetLocalizedString(int dwCode) + { + return XBMC_get_localized_string(m_Handle, m_Callbacks, dwCode); + } + + + /*! + * @brief Get the DVD menu language. + * @return The language. Must be freed by calling FreeString() when done. + */ + char* GetDVDMenuLanguage() + { + return XBMC_get_dvd_menu_language(m_Handle, m_Callbacks); + } + + /*! + * @brief Free the memory used by str + * @param str The string to free + */ + void FreeString(char* str) + { + return XBMC_free_string(m_Handle, m_Callbacks, str); + } + + /*! + * @brief Open the file with filename via XBMC's CFile. Needs to be closed by calling CloseFile() when done. + * @param strFileName The filename to open. + * @param flags The flags to pass. Documented in XBMC's File.h + * @return A handle for the file, or NULL if it couldn't be opened. + */ + void* OpenFile(const char* strFileName, unsigned int flags) + { + return XBMC_open_file(m_Handle, m_Callbacks, strFileName, flags); + } + + /*! + * @brief Open the file with filename via XBMC's CFile in write mode. Needs to be closed by calling CloseFile() when done. + * @param strFileName The filename to open. + * @param bOverWrite True to overwrite, false otherwise. + * @return A handle for the file, or NULL if it couldn't be opened. + */ + void* OpenFileForWrite(const char* strFileName, bool bOverWrite) + { + return XBMC_open_file_for_write(m_Handle, m_Callbacks, strFileName, bOverWrite); + } + + /*! + * @brief Read from an open file. + * @param file The file handle to read from. + * @param lpBuf The buffer to store the data in. + * @param uiBufSize The size of the buffer. + * @return number of successfully read bytes if any bytes were read and stored in + * buffer, zero if no bytes are available to read (end of file was reached) + * or undetectable error occur, -1 in case of any explicit error + */ + ssize_t ReadFile(void* file, void* lpBuf, size_t uiBufSize) + { + return XBMC_read_file(m_Handle, m_Callbacks, file, lpBuf, uiBufSize); + } + + /*! + * @brief Read a string from an open file. + * @param file The file handle to read from. + * @param szLine The buffer to store the data in. + * @param iLineLength The size of the buffer. + * @return True when a line was read, false otherwise. + */ + bool ReadFileString(void* file, char *szLine, int iLineLength) + { + return XBMC_read_file_string(m_Handle, m_Callbacks, file, szLine, iLineLength); + } + + /*! + * @brief Write to a file opened in write mode. + * @param file The file handle to write to. + * @param lpBuf The data to write. + * @param uiBufSize Size of the data to write. + * @return number of successfully written bytes if any bytes were written, + * zero if no bytes were written and no detectable error occur, + * -1 in case of any explicit error + */ + ssize_t WriteFile(void* file, const void* lpBuf, size_t uiBufSize) + { + return XBMC_write_file(m_Handle, m_Callbacks, file, lpBuf, uiBufSize); + } + + /*! + * @brief Flush buffered data. + * @param file The file handle to flush the data for. + */ + void FlushFile(void* file) + { + return XBMC_flush_file(m_Handle, m_Callbacks, file); + } + + /*! + * @brief Seek in an open file. + * @param file The file handle to see in. + * @param iFilePosition The new position. + * @param iWhence Seek argument. See stdio.h for possible values. + * @return The new position. + */ + int64_t SeekFile(void* file, int64_t iFilePosition, int iWhence) + { + return XBMC_seek_file(m_Handle, m_Callbacks, file, iFilePosition, iWhence); + } + + /*! + * @brief Truncate a file to the requested size. + * @param file The file handle to truncate. + * @param iSize The new max size. + * @return New size? + */ + int TruncateFile(void* file, int64_t iSize) + { + return XBMC_truncate_file(m_Handle, m_Callbacks, file, iSize); + } + + /*! + * @brief The current position in an open file. + * @param file The file handle to get the position for. + * @return The requested position. + */ + int64_t GetFilePosition(void* file) + { + return XBMC_get_file_position(m_Handle, m_Callbacks, file); + } + + /*! + * @brief Get the file size of an open file. + * @param file The file to get the size for. + * @return The requested size. + */ + int64_t GetFileLength(void* file) + { + return XBMC_get_file_length(m_Handle, m_Callbacks, file); + } + + /*! + * @brief Get the download speed of an open file if available. + * @param file The file to get the size for. + * @return The download speed in seconds. + */ + double GetFileDownloadSpeed(void* file) + { + return XBMC_get_file_download_speed(m_Handle, m_Callbacks, file); + } + + /*! + * @brief Close an open file. + * @param file The file handle to close. + */ + void CloseFile(void* file) + { + return XBMC_close_file(m_Handle, m_Callbacks, file); + } + + /*! + * @brief Get the chunk size for an open file. + * @param file the file handle to get the size for. + * @return The requested size. + */ + int GetFileChunkSize(void* file) + { + return XBMC_get_file_chunk_size(m_Handle, m_Callbacks, file); + } + + /*! + * @brief Check if a file exists. + * @param strFileName The filename to check. + * @param bUseCache Check in file cache. + * @return true if the file exists false otherwise. + */ + bool FileExists(const char *strFileName, bool bUseCache) + { + return XBMC_file_exists(m_Handle, m_Callbacks, strFileName, bUseCache); + } + + /*! + * @brief Reads file status. + * @param strFileName The filename to read the status from. + * @param buffer The file status is written into this buffer. + * @return The file status was successfully read. + */ + int StatFile(const char *strFileName, struct __stat64* buffer) + { + return XBMC_stat_file(m_Handle, m_Callbacks, strFileName, buffer); + } + + /*! + * @brief Deletes a file. + * @param strFileName The filename to delete. + * @return The file was successfully deleted. + */ + bool DeleteFile(const char *strFileName) + { + return XBMC_delete_file(m_Handle, m_Callbacks, strFileName); + } + + /*! + * @brief Checks whether a directory can be opened. + * @param strUrl The URL of the directory to check. + * @return True when it can be opened, false otherwise. + */ + bool CanOpenDirectory(const char* strUrl) + { + return XBMC_can_open_directory(m_Handle, m_Callbacks, strUrl); + } + + /*! + * @brief Creates a directory. + * @param strPath Path to the directory. + * @return True when it was created, false otherwise. + */ + bool CreateDirectory(const char *strPath) + { + return XBMC_create_directory(m_Handle, m_Callbacks, strPath); + } + + /*! + * @brief Checks if a directory exists. + * @param strPath Path to the directory. + * @return True when it exists, false otherwise. + */ + bool DirectoryExists(const char *strPath) + { + return XBMC_directory_exists(m_Handle, m_Callbacks, strPath); + } + + /*! + * @brief Removes a directory. + * @param strPath Path to the directory. + * @return True when it was removed, false otherwise. + */ + bool RemoveDirectory(const char *strPath) + { + return XBMC_remove_directory(m_Handle, m_Callbacks, strPath); + } + + /*! + * @brief Lists a directory. + * @param strPath Path to the directory. + * @param mask File mask + * @param items The directory entries + * @param num_items Number of entries in directory + * @return True if listing was successful, false otherwise. + */ + bool GetDirectory(const char *strPath, const char* mask, VFSDirEntry** items, unsigned int* num_items) + { + return XBMC_get_directory(m_Handle, m_Callbacks, strPath, mask, items, num_items); + } + + /*! + * @brief Free a directory list + * @param items The directory entries + * @param num_items Number of entries in directory + */ + void FreeDirectory(VFSDirEntry* items, unsigned int num_items) + { + return XBMC_free_directory(m_Handle, m_Callbacks, items, num_items); + } + + /*! + * @brief Create a Curl representation + * @param strURL the URL of the Type. + */ + void* CURLCreate(const char* strURL) + { + return XBMC_curl_create(m_Handle, m_Callbacks, strURL); + } + + /*! + * @brief Adds options to the curl file created with CURLCeate + * @param file file pointer to the file returned by CURLCeate + * @param type option type to set + * @param name name of the option + * @param value value of the option + */ + bool CURLAddOption(void* file, XFILE::CURLOPTIONTYPE type, const char* name, const char * value) + { + return XBMC_curl_add_option(m_Handle, m_Callbacks, file, type, name, value); + } + + /*! + * @brief Opens the curl file created with CURLCeate + * @param file file pointer to the file returned by CURLCeate + * @param flags one or more bitwise or combinded flags form XFILE + */ + bool CURLOpen(void* file, unsigned int flags) + { + return XBMC_curl_open(m_Handle, m_Callbacks, file, flags); + } + + protected: + void* (*XBMC_register_me)(void *HANDLE); + void (*XBMC_unregister_me)(void *HANDLE, void* CB); + void (*XBMC_log)(void *HANDLE, void* CB, const addon_log_t loglevel, const char *msg); + bool (*XBMC_get_setting)(void *HANDLE, void* CB, const char* settingName, void *settingValue); + void (*XBMC_queue_notification)(void *HANDLE, void* CB, const queue_msg_t type, const char *msg); + bool (*XBMC_wake_on_lan)(void *HANDLE, void* CB, const char* mac); + char* (*XBMC_unknown_to_utf8)(void *HANDLE, void* CB, const char* str); + char* (*XBMC_get_localized_string)(void *HANDLE, void* CB, int dwCode); + char* (*XBMC_get_dvd_menu_language)(void *HANDLE, void* CB); + void (*XBMC_free_string)(void *HANDLE, void* CB, char* str); + void* (*XBMC_open_file)(void *HANDLE, void* CB, const char* strFileName, unsigned int flags); + void* (*XBMC_open_file_for_write)(void *HANDLE, void* CB, const char* strFileName, bool bOverWrite); + ssize_t (*XBMC_read_file)(void *HANDLE, void* CB, void* file, void* lpBuf, size_t uiBufSize); + bool (*XBMC_read_file_string)(void *HANDLE, void* CB, void* file, char *szLine, int iLineLength); + ssize_t(*XBMC_write_file)(void *HANDLE, void* CB, void* file, const void* lpBuf, size_t uiBufSize); + void (*XBMC_flush_file)(void *HANDLE, void* CB, void* file); + int64_t (*XBMC_seek_file)(void *HANDLE, void* CB, void* file, int64_t iFilePosition, int iWhence); + int (*XBMC_truncate_file)(void *HANDLE, void* CB, void* file, int64_t iSize); + int64_t (*XBMC_get_file_position)(void *HANDLE, void* CB, void* file); + int64_t (*XBMC_get_file_length)(void *HANDLE, void* CB, void* file); + double(*XBMC_get_file_download_speed)(void *HANDLE, void* CB, void* file); + void (*XBMC_close_file)(void *HANDLE, void* CB, void* file); + int (*XBMC_get_file_chunk_size)(void *HANDLE, void* CB, void* file); + bool (*XBMC_file_exists)(void *HANDLE, void* CB, const char *strFileName, bool bUseCache); + int (*XBMC_stat_file)(void *HANDLE, void* CB, const char *strFileName, struct __stat64* buffer); + bool (*XBMC_delete_file)(void *HANDLE, void* CB, const char *strFileName); + bool (*XBMC_can_open_directory)(void *HANDLE, void* CB, const char* strURL); + bool (*XBMC_create_directory)(void *HANDLE, void* CB, const char* strPath); + bool (*XBMC_directory_exists)(void *HANDLE, void* CB, const char* strPath); + bool (*XBMC_remove_directory)(void *HANDLE, void* CB, const char* strPath); + bool (*XBMC_get_directory)(void *HANDLE, void* CB, const char* strPath, const char* mask, VFSDirEntry** items, unsigned int* num_items); + void (*XBMC_free_directory)(void *HANDLE, void* CB, VFSDirEntry* items, unsigned int num_items); + void* (*XBMC_curl_create)(void *HANDLE, void* CB, const char* strURL); + bool (*XBMC_curl_add_option)(void *HANDLE, void* CB, void *file, XFILE::CURLOPTIONTYPE type, const char* name, const char *value); + bool (*XBMC_curl_open)(void *m_Handle, void *m_Callbacks, void *file, unsigned int flags); + + private: + void *m_libXBMC_addon; + void *m_Handle; + void *m_Callbacks; + struct cb_array + { + const char* libPath; + }; + }; +}; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_codec.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_codec.h new file mode 100644 index 0000000..3853f08 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_codec.h @@ -0,0 +1,124 @@ +#pragma once +/* + * Copyright (C) 2005-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 + * . + * + */ + +#include +#include +#include +#include +#include +#include "xbmc_codec_types.h" +#include "libXBMC_addon.h" + +#ifdef _WIN32 +#define CODEC_HELPER_DLL "\\library.xbmc.codec\\libXBMC_codec" ADDON_HELPER_EXT +#else +#define CODEC_HELPER_DLL_NAME "libXBMC_codec-" ADDON_HELPER_ARCH ADDON_HELPER_EXT +#define CODEC_HELPER_DLL "/library.xbmc.codec/" CODEC_HELPER_DLL_NAME +#endif + +class CHelper_libXBMC_codec +{ +public: + CHelper_libXBMC_codec(void) + { + m_libXBMC_codec = NULL; + m_Handle = NULL; + } + + ~CHelper_libXBMC_codec(void) + { + if (m_libXBMC_codec) + { + CODEC_unregister_me(m_Handle, m_Callbacks); + dlclose(m_libXBMC_codec); + } + } + + /*! + * @brief Resolve all callback methods + * @param handle Pointer to the add-on + * @return True when all methods were resolved, false otherwise. + */ + bool RegisterMe(void* handle) + { + m_Handle = handle; + + std::string libBasePath; + libBasePath = ((cb_array*)m_Handle)->libPath; + libBasePath += CODEC_HELPER_DLL; + +#if defined(ANDROID) + struct stat st; + if(stat(libBasePath.c_str(),&st) != 0) + { + std::string tempbin = getenv("XBMC_ANDROID_LIBS"); + libBasePath = tempbin + "/" + CODEC_HELPER_DLL_NAME; + } +#endif + + m_libXBMC_codec = dlopen(libBasePath.c_str(), RTLD_LAZY); + if (m_libXBMC_codec == NULL) + { + fprintf(stderr, "Unable to load %s\n", dlerror()); + return false; + } + + CODEC_register_me = (void* (*)(void *HANDLE)) + dlsym(m_libXBMC_codec, "CODEC_register_me"); + if (CODEC_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + CODEC_unregister_me = (void (*)(void* HANDLE, void* CB)) + dlsym(m_libXBMC_codec, "CODEC_unregister_me"); + if (CODEC_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + CODEC_get_codec_by_name = (xbmc_codec_t (*)(void* HANDLE, void* CB, const char* strCodecName)) + dlsym(m_libXBMC_codec, "CODEC_get_codec_by_name"); + if (CODEC_get_codec_by_name == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + m_Callbacks = CODEC_register_me(m_Handle); + return m_Callbacks != NULL; + } + + /*! + * @brief Get the codec id used by XBMC + * @param strCodecName The name of the codec + * @return The codec_id, or a codec_id with 0 values when not supported + */ + xbmc_codec_t GetCodecByName(const char* strCodecName) + { + return CODEC_get_codec_by_name(m_Handle, m_Callbacks, strCodecName); + } + +protected: + void* (*CODEC_register_me)(void*); + void (*CODEC_unregister_me)(void*, void*); + xbmc_codec_t (*CODEC_get_codec_by_name)(void *HANDLE, void* CB, const char* strCodecName); + +private: + void* m_libXBMC_codec; + void* m_Handle; + void* m_Callbacks; + struct cb_array + { + const char* libPath; + }; +}; + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h new file mode 100644 index 0000000..3e3d479 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/libXBMC_pvr.h @@ -0,0 +1,366 @@ +#pragma once +/* + * Copyright (C) 2005-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 + * . + * + */ + +#include +#include +#include +#include +#include +#include "xbmc_pvr_types.h" +#include "libXBMC_addon.h" + +#ifdef _WIN32 +#define PVR_HELPER_DLL "\\library.xbmc.pvr\\libXBMC_pvr" ADDON_HELPER_EXT +#else +#define PVR_HELPER_DLL_NAME "libXBMC_pvr-" ADDON_HELPER_ARCH ADDON_HELPER_EXT +#define PVR_HELPER_DLL "/library.xbmc.pvr/" PVR_HELPER_DLL_NAME +#endif + +#define DVD_TIME_BASE 1000000 +#define DVD_NOPTS_VALUE (-1LL<<52) // should be possible to represent in both double and __int64 + +class CHelper_libXBMC_pvr +{ +public: + CHelper_libXBMC_pvr(void) + { + m_libXBMC_pvr = NULL; + m_Handle = NULL; + } + + ~CHelper_libXBMC_pvr(void) + { + if (m_libXBMC_pvr) + { + PVR_unregister_me(m_Handle, m_Callbacks); + dlclose(m_libXBMC_pvr); + } + } + + /*! + * @brief Resolve all callback methods + * @param handle Pointer to the add-on + * @return True when all methods were resolved, false otherwise. + */ + bool RegisterMe(void* handle) + { + m_Handle = handle; + + std::string libBasePath; + libBasePath = ((cb_array*)m_Handle)->libPath; + libBasePath += PVR_HELPER_DLL; + +#if defined(ANDROID) + struct stat st; + if(stat(libBasePath.c_str(),&st) != 0) + { + std::string tempbin = getenv("XBMC_ANDROID_LIBS"); + libBasePath = tempbin + "/" + PVR_HELPER_DLL_NAME; + } +#endif + + m_libXBMC_pvr = dlopen(libBasePath.c_str(), RTLD_LAZY); + if (m_libXBMC_pvr == NULL) + { + fprintf(stderr, "Unable to load %s\n", dlerror()); + return false; + } + + PVR_register_me = (void* (*)(void *HANDLE)) + dlsym(m_libXBMC_pvr, "PVR_register_me"); + if (PVR_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_unregister_me = (void (*)(void* HANDLE, void* CB)) + dlsym(m_libXBMC_pvr, "PVR_unregister_me"); + if (PVR_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_transfer_epg_entry = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const EPG_TAG *epgentry)) + dlsym(m_libXBMC_pvr, "PVR_transfer_epg_entry"); + if (PVR_transfer_epg_entry == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_transfer_channel_entry = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_CHANNEL *chan)) + dlsym(m_libXBMC_pvr, "PVR_transfer_channel_entry"); + if (PVR_transfer_channel_entry == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_transfer_timer_entry = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_TIMER *timer)) + dlsym(m_libXBMC_pvr, "PVR_transfer_timer_entry"); + if (PVR_transfer_timer_entry == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_transfer_recording_entry = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_RECORDING *recording)) + dlsym(m_libXBMC_pvr, "PVR_transfer_recording_entry"); + if (PVR_transfer_recording_entry == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_add_menu_hook = (void (*)(void* HANDLE, void* CB, PVR_MENUHOOK *hook)) + dlsym(m_libXBMC_pvr, "PVR_add_menu_hook"); + if (PVR_add_menu_hook == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_recording = (void (*)(void* HANDLE, void* CB, const char *Name, const char *FileName, bool On)) + dlsym(m_libXBMC_pvr, "PVR_recording"); + if (PVR_recording == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_trigger_timer_update = (void (*)(void* HANDLE, void* CB)) + dlsym(m_libXBMC_pvr, "PVR_trigger_timer_update"); + if (PVR_trigger_timer_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_trigger_recording_update = (void (*)(void* HANDLE, void* CB)) + dlsym(m_libXBMC_pvr, "PVR_trigger_recording_update"); + if (PVR_trigger_recording_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_trigger_channel_update = (void (*)(void* HANDLE, void* CB)) + dlsym(m_libXBMC_pvr, "PVR_trigger_channel_update"); + if (PVR_trigger_channel_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_trigger_channel_groups_update = (void (*)(void* HANDLE, void* CB)) + dlsym(m_libXBMC_pvr, "PVR_trigger_channel_groups_update"); + if (PVR_trigger_channel_groups_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_trigger_epg_update = (void (*)(void* HANDLE, void* CB, unsigned int iChannelUid)) + dlsym(m_libXBMC_pvr, "PVR_trigger_epg_update"); + if (PVR_trigger_epg_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_transfer_channel_group = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP *group)) + dlsym(m_libXBMC_pvr, "PVR_transfer_channel_group"); + if (PVR_transfer_channel_group == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_transfer_channel_group_member = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER *member)) + dlsym(m_libXBMC_pvr, "PVR_transfer_channel_group_member"); + if (PVR_transfer_channel_group_member == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + +#ifdef USE_DEMUX + PVR_free_demux_packet = (void (*)(void* HANDLE, void* CB, DemuxPacket* pPacket)) + dlsym(m_libXBMC_pvr, "PVR_free_demux_packet"); + if (PVR_free_demux_packet == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_allocate_demux_packet = (DemuxPacket* (*)(void* HANDLE, void* CB, int iDataSize)) + dlsym(m_libXBMC_pvr, "PVR_allocate_demux_packet"); + if (PVR_allocate_demux_packet == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } +#endif + + PVR_connection_state_change = (void (*)(void* HANDLE, void* CB, const char *strConnectionString, PVR_CONNECTION_STATE newState, const char *strMessage)) + dlsym(m_libXBMC_pvr, "PVR_connection_state_change"); + if (PVR_connection_state_change == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + PVR_epg_event_state_change = (void (*)(void* HANDLE, void* CB, EPG_TAG* tag, unsigned int iUniqueChannelId, EPG_EVENT_STATE newState)) + dlsym(m_libXBMC_pvr, "PVR_epg_event_state_change"); + if (PVR_epg_event_state_change == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; } + + m_Callbacks = PVR_register_me(m_Handle); + return m_Callbacks != NULL; + } + + /*! + * @brief Transfer an EPG tag from the add-on to XBMC + * @param handle The handle parameter that XBMC used when requesting the EPG data + * @param entry The entry to transfer to XBMC + */ + void TransferEpgEntry(const ADDON_HANDLE handle, const EPG_TAG* entry) + { + return PVR_transfer_epg_entry(m_Handle, m_Callbacks, handle, entry); + } + + /*! + * @brief Transfer a channel entry from the add-on to XBMC + * @param handle The handle parameter that XBMC used when requesting the channel list + * @param entry The entry to transfer to XBMC + */ + void TransferChannelEntry(const ADDON_HANDLE handle, const PVR_CHANNEL* entry) + { + return PVR_transfer_channel_entry(m_Handle, m_Callbacks, handle, entry); + } + + /*! + * @brief Transfer a timer entry from the add-on to XBMC + * @param handle The handle parameter that XBMC used when requesting the timers list + * @param entry The entry to transfer to XBMC + */ + void TransferTimerEntry(const ADDON_HANDLE handle, const PVR_TIMER* entry) + { + return PVR_transfer_timer_entry(m_Handle, m_Callbacks, handle, entry); + } + + /*! + * @brief Transfer a recording entry from the add-on to XBMC + * @param handle The handle parameter that XBMC used when requesting the recordings list + * @param entry The entry to transfer to XBMC + */ + void TransferRecordingEntry(const ADDON_HANDLE handle, const PVR_RECORDING* entry) + { + return PVR_transfer_recording_entry(m_Handle, m_Callbacks, handle, entry); + } + + /*! + * @brief Transfer a channel group from the add-on to XBMC. The group will be created if it doesn't exist. + * @param handle The handle parameter that XBMC used when requesting the channel groups list + * @param entry The entry to transfer to XBMC + */ + void TransferChannelGroup(const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP* entry) + { + return PVR_transfer_channel_group(m_Handle, m_Callbacks, handle, entry); + } + + /*! + * @brief Transfer a channel group member entry from the add-on to XBMC. The channel will be added to the group if the group can be found. + * @param handle The handle parameter that XBMC used when requesting the channel group members list + * @param entry The entry to transfer to XBMC + */ + void TransferChannelGroupMember(const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER* entry) + { + return PVR_transfer_channel_group_member(m_Handle, m_Callbacks, handle, entry); + } + + /*! + * @brief Add or replace a menu hook for the context menu for this add-on + * @param hook The hook to add + */ + void AddMenuHook(PVR_MENUHOOK* hook) + { + return PVR_add_menu_hook(m_Handle, m_Callbacks, hook); + } + + /*! + * @brief Display a notification in XBMC that a recording started or stopped on the server + * @param strRecordingName The name of the recording to display + * @param strFileName The filename of the recording + * @param bOn True when recording started, false when it stopped + */ + void Recording(const char* strRecordingName, const char* strFileName, bool bOn) + { + return PVR_recording(m_Handle, m_Callbacks, strRecordingName, strFileName, bOn); + } + + /*! + * @brief Request XBMC to update it's list of timers + */ + void TriggerTimerUpdate(void) + { + return PVR_trigger_timer_update(m_Handle, m_Callbacks); + } + + /*! + * @brief Request XBMC to update it's list of recordings + */ + void TriggerRecordingUpdate(void) + { + return PVR_trigger_recording_update(m_Handle, m_Callbacks); + } + + /*! + * @brief Request XBMC to update it's list of channels + */ + void TriggerChannelUpdate(void) + { + return PVR_trigger_channel_update(m_Handle, m_Callbacks); + } + + /*! + * @brief Schedule an EPG update for the given channel channel + * @param iChannelUid The unique id of the channel for this add-on + */ + void TriggerEpgUpdate(unsigned int iChannelUid) + { + return PVR_trigger_epg_update(m_Handle, m_Callbacks, iChannelUid); + } + + /*! + * @brief Request XBMC to update it's list of channel groups + */ + void TriggerChannelGroupsUpdate(void) + { + return PVR_trigger_channel_groups_update(m_Handle, m_Callbacks); + } + +#ifdef USE_DEMUX + /*! + * @brief Free a packet that was allocated with AllocateDemuxPacket + * @param pPacket The packet to free + */ + void FreeDemuxPacket(DemuxPacket* pPacket) + { + return PVR_free_demux_packet(m_Handle, m_Callbacks, pPacket); + } + + /*! + * @brief Allocate a demux packet. Free with FreeDemuxPacket + * @param iDataSize The size of the data that will go into the packet + * @return The allocated packet + */ + DemuxPacket* AllocateDemuxPacket(int iDataSize) + { + return PVR_allocate_demux_packet(m_Handle, m_Callbacks, iDataSize); + } +#endif + + /*! + * @brief Notify a state change for a PVR backend connection + * @param strConnectionString The connection string reported by the backend that can be displayed in the UI. + * @param newState The new state. + * @param strMessage A localized addon-defined string representing the new state, that can be displayed + * in the UI or NULL if the Kodi-defined default string for the new state shall be displayed. + */ + void ConnectionStateChange(const char *strConnectionString, PVR_CONNECTION_STATE newState, const char *strMessage) + { + return PVR_connection_state_change(m_Handle, m_Callbacks, strConnectionString, newState, strMessage); + } + + /*! + * @brief Notify a state change for an EPG event + * @param tag The EPG event. + * @param iUniqueChannelId The unique id of the channel for the EPG event + * @param newState The new state. For EPG_EVENT_CREATED and EPG_EVENT_UPDATED, tag must be filled with all available + * event data, not just a delta. For EPG_EVENT_DELETED, it is sufficient to fill EPG_TAG.iUniqueBroadcastId + */ + void EpgEventStateChange(EPG_TAG *tag, unsigned int iUniqueChannelId, EPG_EVENT_STATE newState) + { + return PVR_epg_event_state_change(m_Handle, m_Callbacks, tag, iUniqueChannelId, newState); + } + +protected: + void* (*PVR_register_me)(void*); + void (*PVR_unregister_me)(void*, void*); + void (*PVR_transfer_epg_entry)(void*, void*, const ADDON_HANDLE, const EPG_TAG*); + void (*PVR_transfer_channel_entry)(void*, void*, const ADDON_HANDLE, const PVR_CHANNEL*); + void (*PVR_transfer_timer_entry)(void*, void*, const ADDON_HANDLE, const PVR_TIMER*); + void (*PVR_transfer_recording_entry)(void*, void*, const ADDON_HANDLE, const PVR_RECORDING*); + void (*PVR_add_menu_hook)(void*, void*, PVR_MENUHOOK*); + void (*PVR_recording)(void*, void*, const char*, const char*, bool); + void (*PVR_trigger_channel_update)(void*, void*); + void (*PVR_trigger_channel_groups_update)(void*, void*); + void (*PVR_trigger_timer_update)(void*, void*); + void (*PVR_trigger_recording_update)(void* , void*); + void (*PVR_trigger_epg_update)(void*, void*, unsigned int); + void (*PVR_transfer_channel_group)(void*, void*, const ADDON_HANDLE, const PVR_CHANNEL_GROUP*); + void (*PVR_transfer_channel_group_member)(void*, void*, const ADDON_HANDLE, const PVR_CHANNEL_GROUP_MEMBER*); +#ifdef USE_DEMUX + void (*PVR_free_demux_packet)(void*, void*, DemuxPacket*); + DemuxPacket* (*PVR_allocate_demux_packet)(void*, void*, int); +#endif + void (*PVR_connection_state_change)(void*, void*, const char*, PVR_CONNECTION_STATE, const char*); + void (*PVR_epg_event_state_change)(void*, void*, EPG_TAG*, unsigned int, EPG_EVENT_STATE); + +private: + void* m_libXBMC_pvr; + void* m_Handle; + void* m_Callbacks; + struct cb_array + { + const char* libPath; + }; +}; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_cpp_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_cpp_dll.h new file mode 100644 index 0000000..2eb972e --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_cpp_dll.h @@ -0,0 +1,189 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +#include "xbmc_addon_types.h" + +#include +#include +#include + +class DllSetting +{ +public: + enum SETTING_TYPE { NONE=0, CHECK, SPIN }; + + DllSetting(SETTING_TYPE t, const char *n, const char *l) + { + id = NULL; + label = NULL; + if (n) + { + id = new char[strlen(n)+1]; + strcpy(id, n); + } + if (l) + { + label = new char[strlen(l)+1]; + strcpy(label, l); + } + current = 0; + type = t; + } + + DllSetting(const DllSetting &rhs) // copy constructor + { + id = NULL; + label = NULL; + if (rhs.id) + { + id = new char[strlen(rhs.id)+1]; + strcpy(id, rhs.id); + } + if (rhs.label) + { + label = new char[strlen(rhs.label)+1]; + strcpy(label, rhs.label); + } + current = rhs.current; + type = rhs.type; + for (unsigned int i = 0; i < rhs.entry.size(); i++) + { + char *lab = new char[strlen(rhs.entry[i]) + 1]; + strcpy(lab, rhs.entry[i]); + entry.push_back(lab); + } + } + + ~DllSetting() + { + delete[] id; + delete[] label; + for (unsigned int i=0; i < entry.size(); i++) + delete[] entry[i]; + } + + void AddEntry(const char *label) + { + if (!label || type != SPIN) return; + char *lab = new char[strlen(label) + 1]; + strcpy(lab, label); + entry.push_back(lab); + } + + // data members + SETTING_TYPE type; + char* id; + char* label; + int current; + std::vector entry; +}; + +class DllUtils +{ +public: + + static unsigned int VecToStruct(std::vector &vecSet, ADDON_StructSetting*** sSet) + { + *sSet = NULL; + if (vecSet.empty()) + return 0; + + unsigned int uiElements=0; + + *sSet = (ADDON_StructSetting**)malloc(vecSet.size()*sizeof(ADDON_StructSetting*)); + for(unsigned int i=0;iid = NULL; + (*sSet)[i]->label = NULL; + uiElements++; + + if (vecSet[i].id && vecSet[i].label) + { + (*sSet)[i]->id = strdup(vecSet[i].id); + (*sSet)[i]->label = strdup(vecSet[i].label); + (*sSet)[i]->type = vecSet[i].type; + (*sSet)[i]->current = vecSet[i].current; + (*sSet)[i]->entry_elements = 0; + (*sSet)[i]->entry = NULL; + if(vecSet[i].type == DllSetting::SPIN && !vecSet[i].entry.empty()) + { + (*sSet)[i]->entry = (char**)malloc(vecSet[i].entry.size()*sizeof(char**)); + for(unsigned int j=0;j 0) + { + (*sSet)[i]->entry[j] = strdup(vecSet[i].entry[j]); + (*sSet)[i]->entry_elements++; + } + } + } + } + } + return uiElements; + } + + static void StructToVec(unsigned int iElements, ADDON_StructSetting*** sSet, std::vector *vecSet) + { + if(iElements == 0) + return; + + vecSet->clear(); + for(unsigned int i=0;itype, (*sSet)[i]->id, (*sSet)[i]->label); + if((*sSet)[i]->type == DllSetting::SPIN) + { + for(unsigned int j=0;j<(*sSet)[i]->entry_elements;j++) + { + vSet.AddEntry((*sSet)[i]->entry[j]); + } + } + vSet.current = (*sSet)[i]->current; + vecSet->push_back(vSet); + } + } + + static void FreeStruct(unsigned int iElements, ADDON_StructSetting*** sSet) + { + if(iElements == 0) + return; + + for(unsigned int i=0;itype == DllSetting::SPIN) + { + for(unsigned int j=0;j<(*sSet)[i]->entry_elements;j++) + { + free((*sSet)[i]->entry[j]); + } + free((*sSet)[i]->entry); + } + free((*sSet)[i]->id); + free((*sSet)[i]->label); + free((*sSet)[i]); + } + free(*sSet); + } +}; + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_dll.h new file mode 100644 index 0000000..ff7194f --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_dll.h @@ -0,0 +1,52 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +#ifdef TARGET_WINDOWS +#include +#else +#ifndef __cdecl +#define __cdecl +#endif +#ifndef __declspec +#define __declspec(X) +#endif +#endif + +#include "xbmc_addon_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + ADDON_STATUS __declspec(dllexport) ADDON_Create(void *callbacks, void* props); + void __declspec(dllexport) ADDON_Stop(); + void __declspec(dllexport) ADDON_Destroy(); + ADDON_STATUS __declspec(dllexport) ADDON_GetStatus(); + bool __declspec(dllexport) ADDON_HasSettings(); + unsigned int __declspec(dllexport) ADDON_GetSettings(ADDON_StructSetting ***sSet); + ADDON_STATUS __declspec(dllexport) ADDON_SetSetting(const char *settingName, const void *settingValue); + void __declspec(dllexport) ADDON_FreeSettings(); + void __declspec(dllexport) ADDON_Announce(const char *flag, const char *sender, const char *message, const void *data); + +#ifdef __cplusplus +}; +#endif diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_types.h new file mode 100644 index 0000000..2ceb5c5 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_addon_types.h @@ -0,0 +1,62 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +enum ADDON_STATUS +{ + ADDON_STATUS_OK, + ADDON_STATUS_LOST_CONNECTION, + ADDON_STATUS_NEED_RESTART, + ADDON_STATUS_NEED_SETTINGS, + ADDON_STATUS_UNKNOWN, + ADDON_STATUS_NEED_SAVEDSETTINGS, + ADDON_STATUS_PERMANENT_FAILURE /**< permanent failure, like failing to resolve methods */ +}; + +typedef struct +{ + int type; + char* id; + char* label; + int current; + char** entry; + unsigned int entry_elements; +} ADDON_StructSetting; + +/*! + * @brief Handle used to return data from the PVR add-on to CPVRClient + */ +struct ADDON_HANDLE_STRUCT +{ + void *callerAddress; /*!< address of the caller */ + void *dataAddress; /*!< address to store data in */ + int dataIdentifier; /*!< parameter to pass back when calling the callback */ +}; +typedef ADDON_HANDLE_STRUCT *ADDON_HANDLE; + +#ifdef __cplusplus +}; +#endif + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_dll.h new file mode 100644 index 0000000..932d34f --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_dll.h @@ -0,0 +1,58 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +#include +#include "xbmc_addon_dll.h" +#include "xbmc_audioenc_types.h" + +extern "C" +{ + //! \copydoc AudioEncoder::Create + void* Create(audioenc_callbacks *callbacks); + + //! \copydoc AudioEncoder::Start + bool Start(void* context, int iInChannels, int iInRate, int iInBits, + const char* title, const char* artist, + const char* albumartist, const char* album, + const char* year, const char* track, + const char* genre, const char* comment, int iTrackLength); + + //! \copydoc AudioEncoder::Encode + int Encode(void* context, int nNumBytesRead, uint8_t* pbtStream); + + //! \copydoc AudioEncoder::Finish + bool Finish(void* context); + + //! \copydoc AudioEncoder::Free + void Free(void* context); + + // function to export the above structure to XBMC + void __declspec(dllexport) get_addon(struct AudioEncoder* pScr) + { + pScr->Create = Create; + pScr->Start = Start; + pScr->Encode = Encode; + pScr->Finish = Finish; + pScr->Free = Free; + }; +}; + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_types.h new file mode 100644 index 0000000..df5164e --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_audioenc_types.h @@ -0,0 +1,110 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +#ifdef TARGET_WINDOWS +#include +#else +#ifndef __cdecl +#define __cdecl +#endif +#ifndef __declspec +#define __declspec(X) +#endif +#endif + +#include + +extern "C" +{ + struct AUDIOENC_INFO + { + int dummy; + }; + + struct AUDIOENC_PROPS + { + int dummy; + }; + + typedef int (*audioenc_write_callback)(void* opaque, uint8_t* data, int len); + typedef int64_t (*audioenc_seek_callback)(void* opaque, int64_t pos, int whence); + + typedef struct + { + void* opaque; + audioenc_write_callback write; + audioenc_seek_callback seek; + } audioenc_callbacks; + + struct AudioEncoder + { + /*! \brief Create encoder context + \param callbacks Pointer to audioenc_callbacks structure. + \return opaque pointer to encoder context, to be passed to other methods. + \sa IEncoder::Init + */ + void (*(__cdecl *Create) (audioenc_callbacks* callbacks)); + + /*! \brief Start encoder + \param context Encoder context from Create. + \param iInChannels Number of channels + \param iInRate Sample rate of input data + \param iInBits Bits per sample in input data + \param title The title of the song + \param artist The artist of the song + \param albumartist The albumartist of the song + \param year The year of the song + \param track The track number of the song + \param genre The genre of the song + \param comment A comment to attach to the song + \param iTrackLength Total track length in seconds + \sa IEncoder::Init + */ + bool (__cdecl* Start) (void* context, int iInChannels, int iInRate, int iInBits, + const char* title, const char* artist, + const char* albumartist, const char* album, + const char* year, const char* track, + const char* genre, const char* comment, + int iTrackLength); + + /*! \brief Encode a chunk of audio + \param context Encoder context from Create. + \param nNumBytesRead Number of bytes in input buffer + \param pbtStream the input buffer + \return Number of bytes consumed + \sa IEncoder::Encode + */ + int (__cdecl* Encode) (void* context, int nNumBytesRead, uint8_t* pbtStream); + + /*! \brief Finalize encoding + \param context Encoder context from Create. + \return True on success, false on failure. + */ + bool (__cdecl* Finish) (void* context); + + /*! \brief Free encoder context + \param context Encoder context to free. + */ + void (__cdecl* Free)(void* context); + }; +} + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_codec_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_codec_types.h new file mode 100644 index 0000000..01e7548 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_codec_types.h @@ -0,0 +1,52 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned int xbmc_codec_id_t; + +typedef enum +{ + XBMC_CODEC_TYPE_UNKNOWN = -1, + XBMC_CODEC_TYPE_VIDEO, + XBMC_CODEC_TYPE_AUDIO, + XBMC_CODEC_TYPE_DATA, + XBMC_CODEC_TYPE_SUBTITLE, + XBMC_CODEC_TYPE_RDS, + XBMC_CODEC_TYPE_NB +} xbmc_codec_type_t; + +typedef struct +{ + xbmc_codec_type_t codec_type; + xbmc_codec_id_t codec_id; +} xbmc_codec_t; + +#define XBMC_INVALID_CODEC_ID 0 +#define XBMC_INVALID_CODEC { XBMC_CODEC_TYPE_UNKNOWN, XBMC_INVALID_CODEC_ID } + +#ifdef __cplusplus +}; +#endif + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h new file mode 100644 index 0000000..9460952 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_epg_types.h @@ -0,0 +1,123 @@ +#pragma once +/* + * Copyright (C) 2005-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 + * . + * + */ + +#include +#include + +#undef ATTRIBUTE_PACKED +#undef PRAGMA_PACK_BEGIN +#undef PRAGMA_PACK_END + +#if defined(__GNUC__) +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) +#define ATTRIBUTE_PACKED __attribute__ ((packed)) +#define PRAGMA_PACK 0 +#endif +#endif + +#if !defined(ATTRIBUTE_PACKED) +#define ATTRIBUTE_PACKED +#define PRAGMA_PACK 1 +#endif + +/*! @name EPG entry content event types */ +//@{ +/* These IDs come from the DVB-SI EIT table "content descriptor" + * Also known under the name "E-book genre assignments" + */ +#define EPG_EVENT_CONTENTMASK_UNDEFINED 0x00 +#define EPG_EVENT_CONTENTMASK_MOVIEDRAMA 0x10 +#define EPG_EVENT_CONTENTMASK_NEWSCURRENTAFFAIRS 0x20 +#define EPG_EVENT_CONTENTMASK_SHOW 0x30 +#define EPG_EVENT_CONTENTMASK_SPORTS 0x40 +#define EPG_EVENT_CONTENTMASK_CHILDRENYOUTH 0x50 +#define EPG_EVENT_CONTENTMASK_MUSICBALLETDANCE 0x60 +#define EPG_EVENT_CONTENTMASK_ARTSCULTURE 0x70 +#define EPG_EVENT_CONTENTMASK_SOCIALPOLITICALECONOMICS 0x80 +#define EPG_EVENT_CONTENTMASK_EDUCATIONALSCIENCE 0x90 +#define EPG_EVENT_CONTENTMASK_LEISUREHOBBIES 0xA0 +#define EPG_EVENT_CONTENTMASK_SPECIAL 0xB0 +#define EPG_EVENT_CONTENTMASK_USERDEFINED 0xF0 +//@} + +/* Set EPGTAG.iGenreType to EPG_GENRE_USE_STRING to transfer genre strings to XBMC */ +#define EPG_GENRE_USE_STRING 0x100 + +#ifdef __cplusplus +extern "C" { +#endif + + /* EPG_TAG.iFlags values */ + const unsigned int EPG_TAG_FLAG_UNDEFINED = 0x00000000; /*!< @brief nothing special to say about this entry */ + const unsigned int EPG_TAG_FLAG_IS_SERIES = 0x00000001; /*!< @brief this EPG entry is part of a series */ + + /* Special EPG_TAG.iUniqueBroadcastId value */ + + /*! + * @brief special EPG_TAG.iUniqueBroadcastId value to indicate that a tag has not a valid EPG event uid. + */ + const unsigned int EPG_TAG_INVALID_UID = 0; + + /*! + * @brief EPG event states. Used with EpgEventStateChange callback. + */ + typedef enum + { + EPG_EVENT_CREATED = 0, /*!< @brief event created */ + EPG_EVENT_UPDATED = 1, /*!< @brief event updated */ + EPG_EVENT_DELETED = 2, /*!< @brief event deleted */ + } EPG_EVENT_STATE; + + /*! + * @brief Representation of an EPG event. + */ + typedef struct EPG_TAG { + unsigned int iUniqueBroadcastId; /*!< @brief (required) identifier for this event. Valid uids must be greater than EPG_TAG_INVALID_UID. */ + const char * strTitle; /*!< @brief (required) this event's title */ + unsigned int iChannelNumber; /*!< @brief (required) the number of the channel this event occurs on */ + time_t startTime; /*!< @brief (required) start time in UTC */ + time_t endTime; /*!< @brief (required) end time in UTC */ + const char * strPlotOutline; /*!< @brief (optional) plot outline */ + const char * strPlot; /*!< @brief (optional) plot */ + const char * strOriginalTitle; /*!< @brief (optional) originaltitle */ + const char * strCast; /*!< @brief (optional) cast */ + const char * strDirector; /*!< @brief (optional) director */ + const char * strWriter; /*!< @brief (optional) writer */ + int iYear; /*!< @brief (optional) year */ + const char * strIMDBNumber; /*!< @brief (optional) IMDBNumber */ + const char * strIconPath; /*!< @brief (optional) icon path */ + int iGenreType; /*!< @brief (optional) genre type */ + int iGenreSubType; /*!< @brief (optional) genre sub type */ + const char * strGenreDescription; /*!< @brief (optional) genre. Will be used only when iGenreType = EPG_GENRE_USE_STRING */ + time_t firstAired; /*!< @brief (optional) first aired in UTC */ + int iParentalRating; /*!< @brief (optional) parental rating */ + int iStarRating; /*!< @brief (optional) star rating */ + bool bNotify; /*!< @brief (optional) notify the user when this event starts */ + int iSeriesNumber; /*!< @brief (optional) series number */ + int iEpisodeNumber; /*!< @brief (optional) episode number */ + int iEpisodePartNumber; /*!< @brief (optional) episode part number */ + const char * strEpisodeName; /*!< @brief (optional) episode name */ + unsigned int iFlags; /*!< @brief (optional) bit field of independent flags associated with the EPG entry */ + } ATTRIBUTE_PACKED EPG_TAG; + +#ifdef __cplusplus +} +#endif diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h new file mode 100644 index 0000000..8b54ea6 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_dll.h @@ -0,0 +1,741 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +#include "xbmc_addon_dll.h" +#include "xbmc_pvr_types.h" + +/*! + * Functions that the PVR client add-on must implement, but some can be empty. + * + * The 'remarks' field indicates which methods should be implemented, and which ones are optional. + */ + +extern "C" +{ + /*! @name PVR add-on methods */ + //@{ + /*! + * Get the XBMC_PVR_API_VERSION that was used to compile this add-on. + * Used to check if this add-on is compatible with XBMC. + * @return The XBMC_PVR_API_VERSION that was used to compile this add-on. + * @remarks Valid implementation required. + */ + const char* GetPVRAPIVersion(void); + + /*! + * Get the XBMC_PVR_MIN_API_VERSION that was used to compile this add-on. + * Used to check if this add-on is compatible with XBMC. + * @return The XBMC_PVR_MIN_API_VERSION that was used to compile this add-on. + * @remarks Valid implementation required. + */ + const char* GetMininumPVRAPIVersion(void); + + /*! + * Get the XBMC_GUI_API_VERSION that was used to compile this add-on. + * Used to check if this add-on is compatible with XBMC. + * @return The XBMC_GUI_API_VERSION that was used to compile this add-on or empty string if this add-on does not depend on Kodi GUI API. + * @remarks Valid implementation required. + * @note see libKODI_guilib.h about related parts + */ + const char* GetGUIAPIVersion(void); + + /*! + * Get the XBMC_GUI_MIN_API_VERSION that was used to compile this add-on. + * Used to check if this add-on is compatible with XBMC. + * @return The XBMC_GUI_MIN_API_VERSION that was used to compile this add-on or empty string if this add-on does not depend on Kodi GUI API. + * @remarks Valid implementation required. + * @note see libKODI_guilib.h about related parts + */ + const char* GetMininumGUIAPIVersion(void); + + /*! + * Get the list of features that this add-on provides. + * Called by XBMC to query the add-on's capabilities. + * Used to check which options should be presented in the UI, which methods to call, etc. + * All capabilities that the add-on supports should be set to true. + * @param pCapabilities The add-on's capabilities. + * @return PVR_ERROR_NO_ERROR if the properties were fetched successfully. + * @remarks Valid implementation required. + */ + PVR_ERROR GetAddonCapabilities(PVR_ADDON_CAPABILITIES *pCapabilities); + + /*! + * @return The name reported by the backend that will be displayed in the UI. + * @remarks Valid implementation required. + */ + const char* GetBackendName(void); + + /*! + * @return The version string reported by the backend that will be displayed in the UI. + * @remarks Valid implementation required. + */ + const char* GetBackendVersion(void); + + /*! + * @return The connection string reported by the backend that will be displayed in the UI. + * @remarks Valid implementation required. + */ + const char* GetConnectionString(void); + + /*! + * Get the disk space reported by the backend (if supported). + * @param iTotal The total disk space in bytes. + * @param iUsed The used disk space in bytes. + * @return PVR_ERROR_NO_ERROR if the drive space has been fetched successfully. + * @remarks Optional. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR GetDriveSpace(long long* iTotal, long long* iUsed); + + /*! + * Call one of the menu hooks (if supported). + * Supported PVR_MENUHOOK instances have to be added in ADDON_Create(), by calling AddMenuHook() on the callback. + * @param menuhook The hook to call. + * @param item The selected item for which the hook was called. + * @return PVR_ERROR_NO_ERROR if the hook was called successfully. + * @remarks Optional. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR CallMenuHook(const PVR_MENUHOOK& menuhook, const PVR_MENUHOOK_DATA &item); + //@} + + /*! @name PVR EPG methods + * @remarks Only used by XBMC if bSupportsEPG is set to true. + */ + //@{ + /*! + * Request the EPG for a channel from the backend. + * EPG entries are added to XBMC by calling TransferEpgEntry() on the callback. + * @param handle Handle to pass to the callback method. + * @param channel The channel to get the EPG table for. + * @param iStart Get events after this time (UTC). + * @param iEnd Get events before this time (UTC). + * @return PVR_ERROR_NO_ERROR if the table has been fetched successfully. + * @remarks Required if bSupportsEPG is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR GetEPGForChannel(ADDON_HANDLE handle, const PVR_CHANNEL& channel, time_t iStart, time_t iEnd); + //@} + + /*! @name PVR channel group methods + * @remarks Only used by XBMC is bSupportsChannelGroups is set to true. + * If a group or one of the group members changes after the initial import, or if a new one was added, then the add-on + * should call TriggerChannelGroupsUpdate() + */ + //@{ + /*! + * Get the total amount of channel groups on the backend if it supports channel groups. + * @return The amount of channels, or -1 on error. + * @remarks Required if bSupportsChannelGroups is set to true. Return -1 if this add-on won't provide this function. + */ + int GetChannelGroupsAmount(void); + + /*! + * Request the list of all channel groups from the backend if it supports channel groups. + * Channel group entries are added to XBMC by calling TransferChannelGroup() on the callback. + * @param handle Handle to pass to the callback method. + * @param bRadio True to get the radio channel groups, false to get the TV channel groups. + * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. + * @remarks Required if bSupportsChannelGroups is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR GetChannelGroups(ADDON_HANDLE handle, bool bRadio); + + /*! + * Request the list of all group members of a group from the backend if it supports channel groups. + * Member entries are added to XBMC by calling TransferChannelGroupMember() on the callback. + * @param handle Handle to pass to the callback method. + * @param group The group to get the members for. + * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. + * @remarks Required if bSupportsChannelGroups is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR GetChannelGroupMembers(ADDON_HANDLE handle, const PVR_CHANNEL_GROUP& group); + //@} + + /** @name PVR channel methods + * @remarks Either bSupportsTV or bSupportsRadio is required to be set to true. + * If a channel changes after the initial import, or if a new one was added, then the add-on + * should call TriggerChannelUpdate() + */ + //@{ + /*! + * Show the channel scan dialog if this backend supports it. + * @return PVR_ERROR_NO_ERROR if the dialog was displayed successfully. + * @remarks Required if bSupportsChannelScan is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + * @note see libKODI_guilib.h about related parts + */ + PVR_ERROR OpenDialogChannelScan(void); + + /*! + * @return The total amount of channels on the backend, or -1 on error. + * @remarks Valid implementation required. + */ + int GetChannelsAmount(void); + + /*! + * Request the list of all channels from the backend. + * Channel entries are added to XBMC by calling TransferChannelEntry() on the callback. + * @param handle Handle to pass to the callback method. + * @param bRadio True to get the radio channels, false to get the TV channels. + * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. + * @remarks If bSupportsTV is set to true, a valid result set needs to be provided for bRadio = false. + * If bSupportsRadio is set to true, a valid result set needs to be provided for bRadio = true. + * At least one of these two must provide a valid result set. + */ + PVR_ERROR GetChannels(ADDON_HANDLE handle, bool bRadio); + + /*! + * Delete a channel from the backend. + * @param channel The channel to delete. + * @return PVR_ERROR_NO_ERROR if the channel has been deleted successfully. + * @remarks Required if bSupportsChannelSettings is set to true. + */ + PVR_ERROR DeleteChannel(const PVR_CHANNEL& channel); + + /*! + * Rename a channel on the backend. + * @param channel The channel to rename, containing the new channel name. + * @return PVR_ERROR_NO_ERROR if the channel has been renamed successfully. + * @remarks Optional, and only used if bSupportsChannelSettings is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR RenameChannel(const PVR_CHANNEL& channel); + + /*! + * Move a channel to another channel number on the backend. + * @param channel The channel to move, containing the new channel number. + * @return PVR_ERROR_NO_ERROR if the channel has been moved successfully. + * @remarks Optional, and only used if bSupportsChannelSettings is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR MoveChannel(const PVR_CHANNEL& channel); + + /*! + * Show the channel settings dialog, if supported by the backend. + * @param channel The channel to show the dialog for. + * @return PVR_ERROR_NO_ERROR if the dialog has been displayed successfully. + * @remarks Required if bSupportsChannelSettings is set to true. + * @note see libKODI_guilib.h about related parts + */ + PVR_ERROR OpenDialogChannelSettings(const PVR_CHANNEL& channel); + + /*! + * Show the dialog to add a channel on the backend, if supported by the backend. + * @param channel The channel to add. + * @return PVR_ERROR_NO_ERROR if the channel has been added successfully. + * @remarks Required if bSupportsChannelSettings is set to true. + * @note see libKODI_guilib.h about related parts + */ + PVR_ERROR OpenDialogChannelAdd(const PVR_CHANNEL& channel); + //@} + + /** @name PVR recording methods + * @remarks Only used by XBMC is bSupportsRecordings is set to true. + * If a recording changes after the initial import, or if a new one was added, + * then the add-on should call TriggerRecordingUpdate() + */ + //@{ + /*! + * @return The total amount of recordings on the backend or -1 on error. + * @param deleted if set return deleted recording (called if bSupportsRecordingsUndelete set to true) + * @remarks Required if bSupportsRecordings is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + int GetRecordingsAmount(bool deleted); + + /*! + * Request the list of all recordings from the backend, if supported. + * Recording entries are added to XBMC by calling TransferRecordingEntry() on the callback. + * @param handle Handle to pass to the callback method. + * @param deleted if set return deleted recording (called if bSupportsRecordingsUndelete set to true) + * @return PVR_ERROR_NO_ERROR if the recordings have been fetched successfully. + * @remarks Required if bSupportsRecordings is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR GetRecordings(ADDON_HANDLE handle, bool deleted); + + /*! + * Delete a recording on the backend. + * @param recording The recording to delete. + * @return PVR_ERROR_NO_ERROR if the recording has been deleted successfully. + * @remarks Optional, and only used if bSupportsRecordings is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR DeleteRecording(const PVR_RECORDING& recording); + + /*! + * Undelete a recording on the backend. + * @param recording The recording to undelete. + * @return PVR_ERROR_NO_ERROR if the recording has been undeleted successfully. + * @remarks Optional, and only used if bSupportsRecordingsUndelete is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR UndeleteRecording(const PVR_RECORDING& recording); + + /*! + * @brief Delete all recordings permanent which in the deleted folder on the backend. + * @return PVR_ERROR_NO_ERROR if the recordings has been deleted successfully. + */ + PVR_ERROR DeleteAllRecordingsFromTrash(); + + /*! + * Rename a recording on the backend. + * @param recording The recording to rename, containing the new name. + * @return PVR_ERROR_NO_ERROR if the recording has been renamed successfully. + * @remarks Optional, and only used if bSupportsRecordings is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR RenameRecording(const PVR_RECORDING& recording); + + /*! + * Set the play count of a recording on the backend. + * @param recording The recording to change the play count. + * @param count Play count. + * @return PVR_ERROR_NO_ERROR if the recording's play count has been set successfully. + * @remarks Required if bSupportsRecordingPlayCount is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR SetRecordingPlayCount(const PVR_RECORDING& recording, int count); + + /*! + * Set the last watched position of a recording on the backend. + * @param recording The recording. + * @param position The last watched position in seconds + * @return PVR_ERROR_NO_ERROR if the position has been stored successfully. + * @remarks Required if bSupportsLastPlayedPosition is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR SetRecordingLastPlayedPosition(const PVR_RECORDING& recording, int lastplayedposition); + + /*! + * Retrieve the last watched position of a recording on the backend. + * @param recording The recording. + * @return The last watched position in seconds or -1 on error + * @remarks Required if bSupportsRecordingPlayCount is set to true. Return -1 if this add-on won't provide this function. + */ + int GetRecordingLastPlayedPosition(const PVR_RECORDING& recording); + + /*! + * Retrieve the edit decision list (EDL) of a recording on the backend. + * @param recording The recording. + * @param edl out: The function has to write the EDL list into this array. + * @param size in: The maximum size of the EDL, out: the actual size of the EDL. + * @return PVR_ERROR_NO_ERROR if the EDL was successfully read. + * @remarks Required if bSupportsRecordingEdl is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR GetRecordingEdl(const PVR_RECORDING&, PVR_EDL_ENTRY edl[], int *size); + + /*! + * Retrieve the timer types supported by the backend. + * @param types out: The function has to write the definition of the supported timer types into this array. + * @param typesCount in: The maximum size of the list, out: the actual size of the list. default: PVR_ADDON_TIMERTYPE_ARRAY_SIZE + * @return PVR_ERROR_NO_ERROR if the types were successfully written to the array. + * @remarks Required if bSupportsTimers is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR GetTimerTypes(PVR_TIMER_TYPE types[], int *typesCount); + + //@} + /** @name PVR timer methods + * @remarks Only used by XBMC is bSupportsTimers is set to true. + * If a timer changes after the initial import, or if a new one was added, + * then the add-on should call TriggerTimerUpdate() + */ + //@{ + /*! + * @return The total amount of timers on the backend or -1 on error. + * @remarks Required if bSupportsTimers is set to true. Return -1 if this add-on won't provide this function. + */ + int GetTimersAmount(void); + + /*! + * Request the list of all timers from the backend if supported. + * Timer entries are added to XBMC by calling TransferTimerEntry() on the callback. + * @param handle Handle to pass to the callback method. + * @return PVR_ERROR_NO_ERROR if the list has been fetched successfully. + * @remarks Required if bSupportsTimers is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR GetTimers(ADDON_HANDLE handle); + + /*! + * Add a timer on the backend. + * @param timer The timer to add. + * @return PVR_ERROR_NO_ERROR if the timer has been added successfully. + * @remarks Required if bSupportsTimers is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR AddTimer(const PVR_TIMER& timer); + + /*! + * Delete a timer on the backend. + * @param timer The timer to delete. + * @param bForceDelete Set to true to delete a timer that is currently recording a program. + * @return PVR_ERROR_NO_ERROR if the timer has been deleted successfully. + * @remarks Required if bSupportsTimers is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR DeleteTimer(const PVR_TIMER& timer, bool bForceDelete); + + /*! + * Update the timer information on the backend. + * @param timer The timer to update. + * @return PVR_ERROR_NO_ERROR if the timer has been updated successfully. + * @remarks Required if bSupportsTimers is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR UpdateTimer(const PVR_TIMER& timer); + + //@} + + /** @name PVR live stream methods, used to open and close a stream to a channel, and optionally perform read operations on the stream */ + //@{ + /*! + * Open a live stream on the backend. + * @param channel The channel to stream. + * @return True if the stream has been opened successfully, false otherwise. + * @remarks Required if bHandlesInputStream or bHandlesDemuxing is set to true. Return false if this add-on won't provide this function. + */ + bool OpenLiveStream(const PVR_CHANNEL& channel); + + /*! + * Close an open live stream. + * @remarks Required if bHandlesInputStream or bHandlesDemuxing is set to true. + */ + void CloseLiveStream(void); + + /*! + * Read from an open live stream. + * @param pBuffer The buffer to store the data in. + * @param iBufferSize The amount of bytes to read. + * @return The amount of bytes that were actually read from the stream. + * @remarks Required if bHandlesInputStream is set to true. Return -1 if this add-on won't provide this function. + */ + int ReadLiveStream(unsigned char* pBuffer, unsigned int iBufferSize); + + /*! + * Seek in a live stream on a backend that supports timeshifting. + * @param iPosition The position to seek to. + * @param iWhence ? + * @return The new position. + * @remarks Optional, and only used if bHandlesInputStream is set to true. Return -1 if this add-on won't provide this function. + */ + long long SeekLiveStream(long long iPosition, int iWhence = SEEK_SET); + + /*! + * @return The position in the stream that's currently being read. + * @remarks Optional, and only used if bHandlesInputStream is set to true. Return -1 if this add-on won't provide this function. + */ + long long PositionLiveStream(void); + + /*! + * @return The total length of the stream that's currently being read. + * @remarks Optional, and only used if bHandlesInputStream is set to true. Return -1 if this add-on won't provide this function. + */ + long long LengthLiveStream(void); + + /*! + * Switch to another channel. Only to be called when a live stream has already been opened. + * @param channel The channel to switch to. + * @return True if the switch was successful, false otherwise. + * @remarks Required if bHandlesInputStream or bHandlesDemuxing is set to true. Return false if this add-on won't provide this function. + */ + bool SwitchChannel(const PVR_CHANNEL& channel); + + /*! + * Get the signal status of the stream that's currently open. + * @param signalStatus The signal status. + * @return True if the signal status has been read successfully, false otherwise. + * @remarks Optional, and only used if bHandlesInputStream or bHandlesDemuxing is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR SignalStatus(PVR_SIGNAL_STATUS& signalStatus); + + /*! + * Get the stream URL for a channel from the backend. Used by the MediaPortal add-on. + * @param channel The channel to get the stream URL for. + * @return The requested URL. + * @remarks Optional, and only used if bHandlesInputStream is set to true. Return NULL if this add-on won't provide this function. + */ + const char* GetLiveStreamURL(const PVR_CHANNEL& channel); + + /*! + * Get the stream properties of the stream that's currently being read. + * @param pProperties The properties of the currently playing stream. + * @return PVR_ERROR_NO_ERROR if the properties have been fetched successfully. + * @remarks Required if bHandlesInputStream or bHandlesDemuxing is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR GetStreamProperties(PVR_STREAM_PROPERTIES* pProperties); + //@} + + /** @name PVR recording stream methods, used to open and close a stream to a recording, and perform read operations on the stream. + * @remarks This will only be used if the backend doesn't provide a direct URL in the recording tag. + */ + //@{ + /*! + * Open a stream to a recording on the backend. + * @param recording The recording to open. + * @return True if the stream has been opened successfully, false otherwise. + * @remarks Optional, and only used if bSupportsRecordings is set to true. Return false if this add-on won't provide this function. + */ + bool OpenRecordedStream(const PVR_RECORDING& recording); + + /*! + * Close an open stream from a recording. + * @remarks Optional, and only used if bSupportsRecordings is set to true. + */ + void CloseRecordedStream(void); + + /*! + * Read from a recording. + * @param pBuffer The buffer to store the data in. + * @param iBufferSize The amount of bytes to read. + * @return The amount of bytes that were actually read from the stream. + * @remarks Optional, and only used if bSupportsRecordings is set to true, but required if OpenRecordedStream() is implemented. Return -1 if this add-on won't provide this function. + */ + int ReadRecordedStream(unsigned char* pBuffer, unsigned int iBufferSize); + + /*! + * Seek in a recorded stream. + * @param iPosition The position to seek to. + * @param iWhence ? + * @return The new position. + * @remarks Optional, and only used if bSupportsRecordings is set to true. Return -1 if this add-on won't provide this function. + */ + long long SeekRecordedStream(long long iPosition, int iWhence = SEEK_SET); + + /*! + * @return The position in the stream that's currently being read. + * @remarks Optional, and only used if bSupportsRecordings is set to true. Return -1 if this add-on won't provide this function. + */ + long long PositionRecordedStream(void); + + /*! + * @return The total length of the stream that's currently being read. + * @remarks Optional, and only used if bSupportsRecordings is set to true. Return -1 if this add-on won't provide this function. + */ + long long LengthRecordedStream(void); + //@} + + /** @name PVR demultiplexer methods + * @remarks Only used by XBMC is bHandlesDemuxing is set to true. + */ + //@{ + /*! + * Reset the demultiplexer in the add-on. + * @remarks Required if bHandlesDemuxing is set to true. + */ + void DemuxReset(void); + + /*! + * Abort the demultiplexer thread in the add-on. + * @remarks Required if bHandlesDemuxing is set to true. + */ + void DemuxAbort(void); + + /*! + * Flush all data that's currently in the demultiplexer buffer in the add-on. + * @remarks Required if bHandlesDemuxing is set to true. + */ + void DemuxFlush(void); + + /*! + * Read the next packet from the demultiplexer, if there is one. + * @return The next packet. + * If there is no next packet, then the add-on should return the + * packet created by calling AllocateDemuxPacket(0) on the callback. + * If the stream changed and XBMC's player needs to be reinitialised, + * then, the add-on should call AllocateDemuxPacket(0) on the + * callback, and set the streamid to DMX_SPECIALID_STREAMCHANGE and + * return the value. + * The add-on should return NULL if an error occured. + * @remarks Required if bHandlesDemuxing is set to true. Return NULL if this add-on won't provide this function. + */ + DemuxPacket* DemuxRead(void); + //@} + + /*! + * Delay to use when using switching channels for add-ons not providing an input stream. + * If the add-on does provide an input stream, then this method will not be called. + * Those add-ons can do that in OpenLiveStream() if needed. + * @return The delay in milliseconds. + */ + unsigned int GetChannelSwitchDelay(void); + + /*! + * Check if the backend support pausing the currently playing stream + * This will enable/disable the pause button in XBMC based on the return value + * @return false if the PVR addon/backend does not support pausing, true if possible + */ + bool CanPauseStream(); + + /*! + * Check if the backend supports seeking for the currently playing stream + * This will enable/disable the rewind/forward buttons in XBMC based on the return value + * @return false if the PVR addon/backend does not support seeking, true if possible + */ + bool CanSeekStream(); + + /*! + * @brief Notify the pvr addon that XBMC (un)paused the currently playing stream + */ + void PauseStream(bool bPaused); + + /*! + * Notify the pvr addon/demuxer that XBMC wishes to seek the stream by time + * @param time The absolute time since stream start + * @param backwards True to seek to keyframe BEFORE time, else AFTER + * @param startpts can be updated to point to where display should start + * @return True if the seek operation was possible + * @remarks Optional, and only used if addon has its own demuxer. Return False if this add-on won't provide this function. + */ + bool SeekTime(int time, bool backwards, double *startpts); + + /*! + * Notify the pvr addon/demuxer that XBMC wishes to change playback speed + * @param speed The requested playback speed + * @remarks Optional, and only used if addon has its own demuxer. + */ + void SetSpeed(int speed); + + /*! + * Get actual playing time from addon. With timeshift enabled this is + * different to live. + * @return time as UTC + */ + time_t GetPlayingTime(); + + /*! + * Get time of oldest packet in timeshift buffer + * @return time as UTC + */ + time_t GetBufferTimeStart(); + + /*! + * Get time of latest packet in timeshift buffer + * @return time as UTC + */ + time_t GetBufferTimeEnd(); + + /*! + * Get the hostname of the pvr backend server + * @return hostname as ip address or alias. If backend does not + * utilize a server, return empty string. + */ + const char* GetBackendHostname(); + + /*! + * Check if timeshift is active + * @return true if timeshift is active + */ + bool IsTimeshifting(); + + /*! + * Check for real-time streaming + * @return true if current stream is real-time + */ + bool IsRealTimeStream(); + + /*! + * Tell the client the time frame to use when notifying epg events back to Kodi. The client might push epg events asynchronously + * to Kodi using the callback function EpgEventStateChange. To be able to only push events that are actually of interest for Kodi, + * client needs to know about the epg time frame Kodi uses. Kodi calls this function once after the client add-on has been sucessfully + * initialized and then everytime the time frame value changes. + * @param iDays number of days from "now". EPG_TIMEFRAME_UNLIMITED means that Kodi is interested in all epg events, regardless of event times. + * @return PVR_ERROR_NO_ERROR if new value was successfully set. + * @remarks Required if bSupportsEPG is set to true. Return PVR_ERROR_NOT_IMPLEMENTED if this add-on won't provide this function. + */ + PVR_ERROR SetEPGTimeFrame(int iDays); + + /*! + * Called by XBMC to assign the function pointers of this add-on to pClient. + * @param pClient The struct to assign the function pointers to. + */ + void __declspec(dllexport) get_addon(struct PVRClient* pClient) + { + pClient->GetPVRAPIVersion = GetPVRAPIVersion; + pClient->GetMininumPVRAPIVersion = GetMininumPVRAPIVersion; + pClient->GetGUIAPIVersion = GetGUIAPIVersion; + pClient->GetMininumGUIAPIVersion = GetMininumGUIAPIVersion; + pClient->GetAddonCapabilities = GetAddonCapabilities; + pClient->GetStreamProperties = GetStreamProperties; + pClient->GetConnectionString = GetConnectionString; + pClient->GetBackendName = GetBackendName; + pClient->GetBackendVersion = GetBackendVersion; + pClient->GetDriveSpace = GetDriveSpace; + pClient->OpenDialogChannelScan = OpenDialogChannelScan; + pClient->MenuHook = CallMenuHook; + + pClient->GetEpg = GetEPGForChannel; + + pClient->GetChannelGroupsAmount = GetChannelGroupsAmount; + pClient->GetChannelGroups = GetChannelGroups; + pClient->GetChannelGroupMembers = GetChannelGroupMembers; + + pClient->GetChannelsAmount = GetChannelsAmount; + pClient->GetChannels = GetChannels; + pClient->DeleteChannel = DeleteChannel; + pClient->RenameChannel = RenameChannel; + pClient->MoveChannel = MoveChannel; + pClient->OpenDialogChannelSettings = OpenDialogChannelSettings; + pClient->OpenDialogChannelAdd = OpenDialogChannelAdd; + + pClient->GetRecordingsAmount = GetRecordingsAmount; + pClient->GetRecordings = GetRecordings; + pClient->DeleteRecording = DeleteRecording; + pClient->UndeleteRecording = UndeleteRecording; + pClient->DeleteAllRecordingsFromTrash = DeleteAllRecordingsFromTrash; + pClient->RenameRecording = RenameRecording; + pClient->SetRecordingPlayCount = SetRecordingPlayCount; + pClient->SetRecordingLastPlayedPosition = SetRecordingLastPlayedPosition; + pClient->GetRecordingLastPlayedPosition = GetRecordingLastPlayedPosition; + pClient->GetRecordingEdl = GetRecordingEdl; + + pClient->GetTimerTypes = GetTimerTypes; + pClient->GetTimersAmount = GetTimersAmount; + pClient->GetTimers = GetTimers; + pClient->AddTimer = AddTimer; + pClient->DeleteTimer = DeleteTimer; + pClient->UpdateTimer = UpdateTimer; + + pClient->OpenLiveStream = OpenLiveStream; + pClient->CloseLiveStream = CloseLiveStream; + pClient->ReadLiveStream = ReadLiveStream; + pClient->SeekLiveStream = SeekLiveStream; + pClient->PositionLiveStream = PositionLiveStream; + pClient->LengthLiveStream = LengthLiveStream; + pClient->SwitchChannel = SwitchChannel; + pClient->SignalStatus = SignalStatus; + pClient->GetLiveStreamURL = GetLiveStreamURL; + pClient->GetChannelSwitchDelay = GetChannelSwitchDelay; + pClient->CanPauseStream = CanPauseStream; + pClient->PauseStream = PauseStream; + pClient->CanSeekStream = CanSeekStream; + pClient->SeekTime = SeekTime; + pClient->SetSpeed = SetSpeed; + + pClient->OpenRecordedStream = OpenRecordedStream; + pClient->CloseRecordedStream = CloseRecordedStream; + pClient->ReadRecordedStream = ReadRecordedStream; + pClient->SeekRecordedStream = SeekRecordedStream; + pClient->PositionRecordedStream = PositionRecordedStream; + pClient->LengthRecordedStream = LengthRecordedStream; + + pClient->DemuxReset = DemuxReset; + pClient->DemuxAbort = DemuxAbort; + pClient->DemuxFlush = DemuxFlush; + pClient->DemuxRead = DemuxRead; + + pClient->GetPlayingTime = GetPlayingTime; + pClient->GetBufferTimeStart = GetBufferTimeStart; + pClient->GetBufferTimeEnd = GetBufferTimeEnd; + + pClient->GetBackendHostname = GetBackendHostname; + + pClient->IsTimeshifting = IsTimeshifting; + pClient->IsRealTimeStream = IsRealTimeStream; + + pClient->SetEPGTimeFrame = SetEPGTimeFrame; + }; +}; + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h new file mode 100644 index 0000000..83bb13a --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h @@ -0,0 +1,597 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +#ifdef TARGET_WINDOWS +#include +#else +#ifndef __cdecl +#define __cdecl +#endif +#ifndef __declspec +#define __declspec(X) +#endif +#endif +#include +#include + +#include "xbmc_addon_types.h" +#include "xbmc_epg_types.h" +#include "xbmc_codec_types.h" + +/*! @note Define "USE_DEMUX" at compile time if demuxing in the PVR add-on is used. + * Also XBMC's "DVDDemuxPacket.h" file must be in the include path of the add-on, + * and the add-on should set bHandlesDemuxing to true. + */ +#ifdef USE_DEMUX +#include "DVDDemuxPacket.h" +#else +struct DemuxPacket; +#endif + +#undef ATTRIBUTE_PACKED +#undef PRAGMA_PACK_BEGIN +#undef PRAGMA_PACK_END + +#if defined(__GNUC__) +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) +#define ATTRIBUTE_PACKED __attribute__ ((packed)) +#define PRAGMA_PACK 0 +#endif +#endif + +#if !defined(ATTRIBUTE_PACKED) +#define ATTRIBUTE_PACKED +#define PRAGMA_PACK 1 +#endif + +#define PVR_ADDON_NAME_STRING_LENGTH 1024 +#define PVR_ADDON_URL_STRING_LENGTH 1024 +#define PVR_ADDON_DESC_STRING_LENGTH 1024 +#define PVR_ADDON_INPUT_FORMAT_STRING_LENGTH 32 +#define PVR_ADDON_EDL_LENGTH 32 +#define PVR_ADDON_TIMERTYPE_ARRAY_SIZE 32 +#define PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE 512 +#define PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE_SMALL 128 +#define PVR_ADDON_TIMERTYPE_STRING_LENGTH 64 + +/* using the default avformat's MAX_STREAMS value to be safe */ +#define PVR_STREAM_MAX_STREAMS 20 + +/* current PVR API version */ +#define XBMC_PVR_API_VERSION "5.0.0" + +/* min. PVR API version */ +#define XBMC_PVR_MIN_API_VERSION "5.0.0" + +#ifdef __cplusplus +extern "C" { +#endif + + /*! + * @brief numeric PVR timer type definitions (PVR_TIMER.iTimerType values) + */ + const unsigned int PVR_TIMER_TYPE_NONE = 0; /*!< @brief "Null" value for a numeric timer type. */ + + /*! + * @brief special PVR_TIMER.iClientIndex value to indicate that a timer has not (yet) a valid client index. + */ + const unsigned int PVR_TIMER_NO_CLIENT_INDEX = 0; /*!< @brief timer has not (yet) a valid client index. */ + + /*! + * @brief special PVR_TIMER.iParentClientIndex value to indicate that a timer has no parent. + */ + const unsigned int PVR_TIMER_NO_PARENT = PVR_TIMER_NO_CLIENT_INDEX; /*!< @brief timer has no parent; it was not scheduled by a repeating timer. */ + + /*! + * @brief special PVR_TIMER.iEpgUid value to indicate that a timer has no EPG event uid. + */ + const unsigned int PVR_TIMER_NO_EPG_UID = EPG_TAG_INVALID_UID; /*!< @brief timer has no EPG event uid. */ + + /*! + * @brief special PVR_TIMER.iClientChannelUid value to indicate "any channel". Useful for some repeating timer types. + */ + const int PVR_TIMER_ANY_CHANNEL = -1; /*!< @brief denotes "any channel", not a specific one. */ + + /*! + * @brief PVR timer type attributes (PVR_TIMER_TYPE.iAttributes values) + */ + const unsigned int PVR_TIMER_TYPE_ATTRIBUTE_NONE = 0x00000000; + + const unsigned int PVR_TIMER_TYPE_IS_MANUAL = 0x00000001; /*!< @brief defines whether this is a type for manual (time-based) or epg-based timers */ + const unsigned int PVR_TIMER_TYPE_IS_REPEATING = 0x00000002; /*!< @brief defines whether this is a type for repeating or one-shot timers */ + const unsigned int PVR_TIMER_TYPE_IS_READONLY = 0x00000004; /*!< @brief timers of this type must not be edited by Kodi */ + const unsigned int PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES = 0x00000008; /*!< @brief timers of this type must not be created by Kodi. All other operations are allowed, though */ + + const unsigned int PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE = 0x00000010; /*!< @brief this type supports enabling/disabling of the timer (PVR_TIMER.state SCHEDULED|DISBALED) */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_CHANNELS = 0x00000020; /*!< @brief this type supports channels (PVR_TIMER.iClientChannelUid) */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_START_TIME = 0x00000040; /*!< @brief this type supports a recording start time (PVR_TIMER.startTime) */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH = 0x00000080; /*!< @brief this type supports matching epg episode title using PVR_TIMER.strEpgSearchString */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_FULLTEXT_EPG_MATCH = 0x00000100; /*!< @brief this type supports matching "more" epg data (not just episode title) using PVR_TIMER.strEpgSearchString. Setting FULLTEXT_EPG_MATCH implies TITLE_EPG_MATCH */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_FIRST_DAY = 0x00000200; /*!< @brief this type supports a first day the timer gets active (PVR_TIMER.firstday) */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_WEEKDAYS = 0x00000400; /*!< @brief this type supports weekdays for defining the recording schedule (PVR_TIMER.iWeekdays) */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_RECORD_ONLY_NEW_EPISODES = 0x00000800; /*!< @brief this type supports the "record only new episodes" feature (PVR_TIMER.iPreventDuplicateEpisodes) */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN = 0x00001000; /*!< @brief this type supports pre and post record time (PVR_TIMER.iMarginStart, PVR_TIMER.iMarginEnd) */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_PRIORITY = 0x00002000; /*!< @brief this type supports recording priority (PVR_TIMER.iPriority) */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_LIFETIME = 0x00004000; /*!< @brief this type supports recording lifetime (PVR_TIMER.iLifetime) */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS = 0x00008000; /*!< @brief this type supports placing recordings in user defined folders (PVR_TIMER.strDirectory) */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_RECORDING_GROUP = 0x00010000; /*!< @brief this type supports a list of recording groups (PVR_TIMER.iRecordingGroup) */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_END_TIME = 0x00020000; /*!< @brief this type supports a recording end time (PVR_TIMER.endTime) */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_START_ANYTIME = 0x00040000; /*!< @brief enables an 'Any Time' over-ride option for startTime (using PVR_TIMER.bStartAnyTime) */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_END_ANYTIME = 0x00080000; /*!< @brief enables a separate 'Any Time' over-ride for endTime (using PVR_TIMER.bEndAnyTime) */ + const unsigned int PVR_TIMER_TYPE_SUPPORTS_MAX_RECORDINGS = 0x00100000; /*!< @brief this type supports specifying a maximum recordings setting' (PVR_TIMER.iMaxRecordings) */ + const unsigned int PVR_TIMER_TYPE_REQUIRES_EPG_TAG_ON_CREATE = 0x00200000; /*!< @brief this type shold not appear on any create menus which don't provide an associated EPG tag */ + const unsigned int PVR_TIMER_TYPE_FORBIDS_EPG_TAG_ON_CREATE = 0x00400000; /*!< @brief this type should not appear on any create menus which provide an associated EPG tag */ + const unsigned int PVR_TIMER_TYPE_REQUIRES_EPG_SERIES_ON_CREATE = 0x00800000; /*!< @brief this type should not appear on any create menus unless associated with an EPG tag with 'series' attributes (EPG_TAG.iFlags & EPG_TAG_FLAG_IS_SERIES || EPG_TAG.iSeriesNumber > 0 || EPG_TAG.iEpisodeNumber > 0 || EPG_TAG.iEpisodePartNumber > 0). Implies PVR_TIMER_TYPE_REQUIRES_EPG_TAG_ON_CREATE */ + + /*! + * @brief PVR timer weekdays (PVR_TIMER.iWeekdays values) + */ + const unsigned int PVR_WEEKDAY_NONE = 0x00; + const unsigned int PVR_WEEKDAY_MONDAY = 0x01; + const unsigned int PVR_WEEKDAY_TUESDAY = 0x02; + const unsigned int PVR_WEEKDAY_WEDNESDAY = 0x04; + const unsigned int PVR_WEEKDAY_THURSDAY = 0x08; + const unsigned int PVR_WEEKDAY_FRIDAY = 0x10; + const unsigned int PVR_WEEKDAY_SATURDAY = 0x20; + const unsigned int PVR_WEEKDAY_SUNDAY = 0x40; + const unsigned int PVR_WEEKDAY_ALLDAYS = PVR_WEEKDAY_MONDAY | PVR_WEEKDAY_TUESDAY | PVR_WEEKDAY_WEDNESDAY | + PVR_WEEKDAY_THURSDAY | PVR_WEEKDAY_FRIDAY | PVR_WEEKDAY_SATURDAY | + PVR_WEEKDAY_SUNDAY; + + /*! + * @brief timeframe value for use with SetEPGTimeFrame function to indicate "no timeframe". + */ + const int EPG_TIMEFRAME_UNLIMITED = -1; + + /*! + * @brief special PVR_TIMER.iClientChannelUid and PVR_RECORDING.iChannelUid value to indicate that no channel uid is available. + */ + const int PVR_CHANNEL_INVALID_UID = -1; /*!< @brief denotes that no channel uid is avaliable. */ + + /*! + * @brief PVR add-on error codes + */ + typedef enum + { + PVR_ERROR_NO_ERROR = 0, /*!< @brief no error occurred */ + PVR_ERROR_UNKNOWN = -1, /*!< @brief an unknown error occurred */ + PVR_ERROR_NOT_IMPLEMENTED = -2, /*!< @brief the method that XBMC called is not implemented by the add-on */ + PVR_ERROR_SERVER_ERROR = -3, /*!< @brief the backend reported an error, or the add-on isn't connected */ + PVR_ERROR_SERVER_TIMEOUT = -4, /*!< @brief the command was sent to the backend, but the response timed out */ + PVR_ERROR_REJECTED = -5, /*!< @brief the command was rejected by the backend */ + PVR_ERROR_ALREADY_PRESENT = -6, /*!< @brief the requested item can not be added, because it's already present */ + PVR_ERROR_INVALID_PARAMETERS = -7, /*!< @brief the parameters of the method that was called are invalid for this operation */ + PVR_ERROR_RECORDING_RUNNING = -8, /*!< @brief a recording is running, so the timer can't be deleted without doing a forced delete */ + PVR_ERROR_FAILED = -9, /*!< @brief the command failed */ + } PVR_ERROR; + + /*! + * @brief PVR timer states + */ + typedef enum + { + PVR_TIMER_STATE_NEW = 0, /*!< @brief the timer was just created on the backend and is not yet active. This state must not be used for timers just created on the client side. */ + PVR_TIMER_STATE_SCHEDULED = 1, /*!< @brief the timer is scheduled for recording */ + PVR_TIMER_STATE_RECORDING = 2, /*!< @brief the timer is currently recordings */ + PVR_TIMER_STATE_COMPLETED = 3, /*!< @brief the recording completed successfully */ + PVR_TIMER_STATE_ABORTED = 4, /*!< @brief recording started, but was aborted */ + PVR_TIMER_STATE_CANCELLED = 5, /*!< @brief the timer was scheduled, but was canceled */ + PVR_TIMER_STATE_CONFLICT_OK = 6, /*!< @brief the scheduled timer conflicts with another one, but will be recorded */ + PVR_TIMER_STATE_CONFLICT_NOK = 7, /*!< @brief the scheduled timer conflicts with another one and won't be recorded */ + PVR_TIMER_STATE_ERROR = 8, /*!< @brief the timer is scheduled, but can't be recorded for some reason */ + PVR_TIMER_STATE_DISABLED = 9, /*!< @brief the timer was disabled by the user, can be enabled via setting the state to PVR_TIMER_STATE_SCHEDULED */ + } PVR_TIMER_STATE; + + /*! + * @brief PVR menu hook categories + */ + typedef enum + { + PVR_MENUHOOK_UNKNOWN =-1, /*!< @brief unknown menu hook */ + PVR_MENUHOOK_ALL = 0, /*!< @brief all categories */ + PVR_MENUHOOK_CHANNEL = 1, /*!< @brief for channels */ + PVR_MENUHOOK_TIMER = 2, /*!< @brief for timers */ + PVR_MENUHOOK_EPG = 3, /*!< @brief for EPG */ + PVR_MENUHOOK_RECORDING = 4, /*!< @brief for recordings */ + PVR_MENUHOOK_DELETED_RECORDING = 5, /*!< @brief for deleted recordings */ + PVR_MENUHOOK_SETTING = 6, /*!< @brief for settings */ + } PVR_MENUHOOK_CAT; + + /*! + * @brief PVR backend connection states. Used with ConnectionStateChange callback. + */ + typedef enum + { + PVR_CONNECTION_STATE_UNKNOWN = 0, /*!< @brief unknown state (e.g. not yet tried to connect) */ + PVR_CONNECTION_STATE_SERVER_UNREACHABLE = 1, /*!< @brief backend server is not reachable (e.g. server not existing or network down)*/ + PVR_CONNECTION_STATE_SERVER_MISMATCH = 2, /*!< @brief backend server is reachable, but there is not the expected type of server running (e.g. HTSP required, but FTP running at given server:port) */ + PVR_CONNECTION_STATE_VERSION_MISMATCH = 3, /*!< @brief backend server is reachable, but server version does not match client requirements */ + PVR_CONNECTION_STATE_ACCESS_DENIED = 4, /*!< @brief backend server is reachable, but denies client access (e.g. due to wrong credentials) */ + PVR_CONNECTION_STATE_CONNECTED = 5, /*!< @brief connection to backend server is established */ + PVR_CONNECTION_STATE_DISCONNECTED = 6, /*!< @brief no connection to backend server (e.g. due to network errors or client initiated disconnect)*/ + } PVR_CONNECTION_STATE; + + /*! + * @brief Properties passed to the Create() method of an add-on. + */ + typedef struct PVR_PROPERTIES + { + const char* strUserPath; /*!< @brief path to the user profile */ + const char* strClientPath; /*!< @brief path to this add-on */ + } PVR_PROPERTIES; + + /*! + * @brief PVR add-on capabilities. All capabilities are set to "false" as default. + * If a capabilty is set to true, then the corresponding methods from xbmc_pvr_dll.h need to be implemented. + */ + typedef struct PVR_ADDON_CAPABILITIES + { + bool bSupportsEPG; /*!< @brief true if the add-on provides EPG information */ + bool bSupportsTV; /*!< @brief true if this add-on provides TV channels */ + bool bSupportsRadio; /*!< @brief true if this add-on supports radio channels */ + bool bSupportsRecordings; /*!< @brief true if this add-on supports playback of recordings stored on the backend */ + bool bSupportsRecordingsUndelete; /*!< @brief true if this add-on supports undelete of recordings stored on the backend */ + bool bSupportsTimers; /*!< @brief true if this add-on supports the creation and editing of timers */ + bool bSupportsChannelGroups; /*!< @brief true if this add-on supports channel groups */ + bool bSupportsChannelScan; /*!< @brief true if this add-on support scanning for new channels on the backend */ + bool bSupportsChannelSettings; /*!< @brief true if this add-on supports the following functions: DeleteChannel, RenameChannel, MoveChannel, DialogChannelSettings and DialogAddChannel */ + bool bHandlesInputStream; /*!< @brief true if this add-on provides an input stream. false if XBMC handles the stream. */ + bool bHandlesDemuxing; /*!< @brief true if this add-on demultiplexes packets. */ + bool bSupportsRecordingPlayCount; /*!< @brief true if the backend supports play count for recordings. */ + bool bSupportsLastPlayedPosition; /*!< @brief true if the backend supports store/retrieve of last played position for recordings. */ + bool bSupportsRecordingEdl; /*!< @brief true if the backend supports retrieving an edit decision list for recordings. */ + } ATTRIBUTE_PACKED PVR_ADDON_CAPABILITIES; + + /*! + * @brief PVR stream properties + */ + typedef struct PVR_STREAM_PROPERTIES + { + unsigned int iStreamCount; + struct PVR_STREAM + { + unsigned int iPhysicalId; /*!< @brief (required) physical index */ + xbmc_codec_type_t iCodecType; /*!< @brief (required) codec type this stream */ + xbmc_codec_id_t iCodecId; /*!< @brief (required) codec id of this stream */ + char strLanguage[4]; /*!< @brief (required) language id */ + int iIdentifier; /*!< @brief (required) stream id */ + int iFPSScale; /*!< @brief (required) scale of 1000 and a rate of 29970 will result in 29.97 fps */ + int iFPSRate; /*!< @brief (required) FPS rate */ + int iHeight; /*!< @brief (required) height of the stream reported by the demuxer */ + int iWidth; /*!< @brief (required) width of the stream reported by the demuxer */ + float fAspect; /*!< @brief (required) display aspect ratio of the stream */ + int iChannels; /*!< @brief (required) amount of channels */ + int iSampleRate; /*!< @brief (required) sample rate */ + int iBlockAlign; /*!< @brief (required) block alignment */ + int iBitRate; /*!< @brief (required) bit rate */ + int iBitsPerSample; /*!< @brief (required) bits per sample */ + } stream[PVR_STREAM_MAX_STREAMS]; /*!< @brief (required) the streams */ + } ATTRIBUTE_PACKED PVR_STREAM_PROPERTIES; + + /*! + * @brief Signal status information + */ + typedef struct PVR_SIGNAL_STATUS + { + char strAdapterName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) name of the adapter that's being used */ + char strAdapterStatus[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) status of the adapter that's being used */ + char strServiceName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) name of the current service */ + char strProviderName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) name of the current service's provider */ + char strMuxName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) name of the current mux */ + int iSNR; /*!< @brief (optional) signal/noise ratio */ + int iSignal; /*!< @brief (optional) signal strength */ + long iBER; /*!< @brief (optional) bit error rate */ + long iUNC; /*!< @brief (optional) uncorrected blocks */ + } ATTRIBUTE_PACKED PVR_SIGNAL_STATUS; + + /*! + * @brief Menu hooks that are available in the context menus while playing a stream via this add-on. + * And in the Live TV settings dialog + */ + typedef struct PVR_MENUHOOK + { + unsigned int iHookId; /*!< @brief (required) this hook's identifier */ + unsigned int iLocalizedStringId; /*!< @brief (required) the id of the label for this hook in g_localizeStrings */ + PVR_MENUHOOK_CAT category; /*!< @brief (required) category of menu hook */ + } ATTRIBUTE_PACKED PVR_MENUHOOK; + + /*! + * @brief Representation of a TV or radio channel. + */ + typedef struct PVR_CHANNEL + { + unsigned int iUniqueId; /*!< @brief (required) unique identifier for this channel */ + bool bIsRadio; /*!< @brief (required) true if this is a radio channel, false if it's a TV channel */ + unsigned int iChannelNumber; /*!< @brief (optional) channel number of this channel on the backend */ + unsigned int iSubChannelNumber; /*!< @brief (optional) sub channel number of this channel on the backend (ATSC) */ + char strChannelName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) channel name given to this channel */ + char strInputFormat[PVR_ADDON_INPUT_FORMAT_STRING_LENGTH]; /*!< @brief (optional) input format type. types can be found in ffmpeg/libavformat/allformats.c + leave empty if unknown */ + char strStreamURL[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) the URL to use to access this channel. + leave empty to use this add-on to access the stream. + set to a path that's supported by XBMC otherwise. */ + unsigned int iEncryptionSystem; /*!< @brief (optional) the encryption ID or CaID of this channel */ + char strIconPath[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) path to the channel icon (if present) */ + bool bIsHidden; /*!< @brief (optional) true if this channel is marked as hidden */ + } ATTRIBUTE_PACKED PVR_CHANNEL; + + typedef struct PVR_CHANNEL_GROUP + { + char strGroupName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (required) name of this channel group */ + bool bIsRadio; /*!< @brief (required) true if this is a radio channel group, false otherwise. */ + unsigned int iPosition; /*!< @brief (optional) sort position of the group (0 indicates that the backend doesn't support sorting of groups) */ + } ATTRIBUTE_PACKED PVR_CHANNEL_GROUP; + + typedef struct PVR_CHANNEL_GROUP_MEMBER + { + char strGroupName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (required) name of the channel group to add the channel to */ + unsigned int iChannelUniqueId; /*!< @brief (required) unique id of the member */ + unsigned int iChannelNumber; /*!< @brief (optional) channel number within the group */ + } ATTRIBUTE_PACKED PVR_CHANNEL_GROUP_MEMBER; + + /*! + * @brief Representation of a timer's attribute integer value. + */ + typedef struct PVR_TIMER_TYPE_ATTRIBUTE_INT_VALUE + { + int iValue; /*!< @brief (required) an integer value for a certain timer attribute */ + char strDescription[PVR_ADDON_TIMERTYPE_STRING_LENGTH]; /*!< @brief (optional) a localized string describing the value. If left blank, Kodi will + generate a suitable representation (like the integer value as string) */ + } ATTRIBUTE_PACKED PVR_TIMER_TYPE_ATTRIBUTE_INT_VALUE; + + /*! + * @brief Representation of a timer type. + */ + typedef struct PVR_TIMER_TYPE + { + unsigned int iId; /*!< @brief (required) this type's identifier. Ids must be > PVR_TIMER_TYPE_NONE. */ + unsigned int iAttributes; /*!< @brief (required) defines the attributes for this type (PVR_TIMER_TYPE_* constants). */ + char strDescription[PVR_ADDON_TIMERTYPE_STRING_LENGTH]; /*!< @brief (optional) a short localized string describing the purpose of the type. (e.g. + "Any time at this channel if title matches"). If left blank, Kodi will generate a + description based on the attributes REPEATING and MANUAL. (e.g. "Repeating EPG-based." */ + /* priority value definitions */ + unsigned int iPrioritiesSize; /*!< @brief (required) Count of possible values for PVR_TMER.iPriority. 0 means priority + is not supported by this timer type or no own value definition wanted, but to use Kodi defaults + of 1..100. */ + PVR_TIMER_TYPE_ATTRIBUTE_INT_VALUE + priorities[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE]; /*!< @brief (optional) Array containing the possible values for PVR_TMER.iPriority. Must be + filled if iPrioritiesSize > 0 */ + int iPrioritiesDefault; /*!< @brief (optional) The default value for PVR_TMER.iPriority. Must be filled if iPrioritiesSize > 0 */ + + /* lifetime value definitions */ + unsigned int iLifetimesSize; /*!< @brief (required) Count of possible values for PVR_TMER.iLifetime. 0 means lifetime + is not supported by this timer type or no own value definition wanted, but to use Kodi defaults + of 1..365. */ + PVR_TIMER_TYPE_ATTRIBUTE_INT_VALUE + lifetimes[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE]; /*!< @brief (optional) Array containing the possible values for PVR_TMER.iLifetime. Must be + filled if iLifetimesSize > 0 */ + int iLifetimesDefault; /*!< @brief (optional) The default value for PVR_TMER.iLifetime. Must be filled if iLifetimesSize > 0 */ + + /* prevent duplicate episodes value definitions */ + unsigned int iPreventDuplicateEpisodesSize; /*!< @brief (required) Count of possible values for PVR_TMER.iPreventDuplicateEpisodes. 0 means duplicate + episodes prevention is not supported by this timer type or no own value definition wanted, but to use + Kodi defaults. */ + PVR_TIMER_TYPE_ATTRIBUTE_INT_VALUE + preventDuplicateEpisodes[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE]; + /*!< @brief (optional) Array containing the possible values for PVR_TMER.iPreventDuplicateEpisodes.. Must + be filled if iPreventDuplicateEpisodesSize > 0 */ + unsigned int iPreventDuplicateEpisodesDefault; /*!< @brief (optional) The default value for PVR_TMER.iPreventDuplicateEpisodesSize. Must be filled if iPreventDuplicateEpisodesSize > 0 */ + + /* recording folder list value definitions */ + unsigned int iRecordingGroupSize; /*!< @brief (required) Count of possible values of PVR_TIMER.iRecordingGroup. 0 means folder lists are not supported by this timer type */ + PVR_TIMER_TYPE_ATTRIBUTE_INT_VALUE + recordingGroup[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE]; + /*!< @brief (optional) Array containing the possible values of PVR_TMER.iRecordingGroup. Must be filled if iRecordingGroupSize > 0 */ + unsigned int iRecordingGroupDefault; /*!< @brief (optional) The default value for PVR_TIMER.iRecordingGroup. Must be filled in if PVR_TIMER.iRecordingGroupSize > 0 */ + + /* max recordings value definitions */ + unsigned int iMaxRecordingsSize; /*!< @brief (required) Count of possible values of PVR_TIMER.iMaxRecordings. 0 means max recordings are not supported by this timer type */ + PVR_TIMER_TYPE_ATTRIBUTE_INT_VALUE + maxRecordings[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE_SMALL]; + /*!< @brief (optional) Array containing the possible values of PVR_TMER.iMaxRecordings. */ + int iMaxRecordingsDefault; /*!< @brief (optional) The default value for PVR_TIMER.iMaxRecordings. Must be filled in if PVR_TIMER.iMaxRecordingsSize > 0 */ + + } ATTRIBUTE_PACKED PVR_TIMER_TYPE; + + /*! + * @brief Representation of a timer event. + */ + typedef struct PVR_TIMER { + unsigned int iClientIndex; /*!< @brief (required) the index of this timer given by the client. PVR_TIMER_NO_CLIENT_INDEX indicates that the index was not yet set by the client, for example for new timers created by + Kodi and passed the first time to the client. A valid index must be greater than PVR_TIMER_NO_CLIENT_INDEX. */ + unsigned int iParentClientIndex; /*!< @brief (optional) for timers scheduled by a repeating timer, the index of the repeating timer that scheduled this timer (it's PVR_TIMER.iClientIndex value). Use PVR_TIMER_NO_PARENT + to indicate that this timer was no scheduled by a repeating timer. */ + int iClientChannelUid; /*!< @brief (optional) unique identifier of the channel to record on. PVR_TIMER_ANY_CHANNEL will denote "any channel", not a specific one. PVR_CHANNEL_INVALID_UID denotes that channel uid is not available.*/ + time_t startTime; /*!< @brief (optional) start time of the recording in UTC. Instant timers that are sent to the add-on by Kodi will have this value set to 0.*/ + time_t endTime; /*!< @brief (optional) end time of the recording in UTC. */ + bool bStartAnyTime; /*!< @brief (optional) for EPG based (not Manual) timers indicates startTime does not apply. Default = false */ + bool bEndAnyTime; /*!< @brief (optional) for EPG based (not Manual) timers indicates endTime does not apply. Default = false */ + PVR_TIMER_STATE state; /*!< @brief (required) the state of this timer */ + unsigned int iTimerType; /*!< @brief (required) the type of this timer. It is private to the addon and can be freely defined by the addon. The value must be greater than PVR_TIMER_TYPE_NONE. + Kodi does not interpret this value (except for checking for PVR_TIMER_TYPE_NONE), but will pass the right id to the addon with every PVR_TIMER instance, thus the addon easily can determine + the timer type. */ + char strTitle[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (required) a title for this timer */ + char strEpgSearchString[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) a string used to search epg data for repeating epg-based timers. Format is backend-dependent, for example regexp */ + bool bFullTextEpgSearch; /*!< @brief (optional) indicates, whether strEpgSearchString is to match against the epg episode title only or also against "other" epg data (backend-dependent) */ + char strDirectory[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) the (relative) directory where the recording will be stored in */ + char strSummary[PVR_ADDON_DESC_STRING_LENGTH]; /*!< @brief (optional) the summary for this timer */ + int iPriority; /*!< @brief (optional) the priority of this timer */ + int iLifetime; /*!< @brief (optional) lifetime of recordings created by this timer. > 0 days after which recordings will be deleted by the backend, < 0 addon defined integer list reference, == 0 disabled */ + int iMaxRecordings; /*!< @brief (optional) maximum number of recordings this timer shall create. > 0 number of recordings, < 0 addon defined integer list reference, == 0 disabled */ + unsigned int iRecordingGroup; /*!< @brief (optional) integer ref to addon/backend defined list of recording groups*/ + time_t firstDay; /*!< @brief (optional) the first day this timer is active, for repeating timers */ + unsigned int iWeekdays; /*!< @brief (optional) week days, for repeating timers */ + unsigned int iPreventDuplicateEpisodes; /*!< @brief (optional) 1 if backend should only record new episodes in case of a repeating epg-based timer, 0 if all episodes shall be recorded (no duplicate detection). Actual algorithm for + duplicate detection is defined by the backend. Addons may define own values for different duplicate detection algorithms, thus this is not just a bool.*/ + unsigned int iEpgUid; /*!< @brief (optional) EPG event id associated with this timer. Valid ids must be greater than EPG_TAG_INVALID_UID. */ + unsigned int iMarginStart; /*!< @brief (optional) if set, the backend starts the recording iMarginStart minutes before startTime. */ + unsigned int iMarginEnd; /*!< @brief (optional) if set, the backend ends the recording iMarginEnd minutes after endTime. */ + int iGenreType; /*!< @brief (optional) genre type */ + int iGenreSubType; /*!< @brief (optional) genre sub type */ + } ATTRIBUTE_PACKED PVR_TIMER; + + /*! + * @brief Representation of a recording. + */ + typedef struct PVR_RECORDING { + char strRecordingId[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (required) unique id of the recording on the client. */ + char strTitle[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (required) the title of this recording */ + char strEpisodeName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) episode name (also known as subtitle) */ + int iSeriesNumber; /*!< @brief (optional) series number (usually called season). Set to "0" for specials/pilot. For 'invalid' see iEpisodeNumber or set to -1 */ + int iEpisodeNumber; /*!< @brief (optional) episode number within the "iSeriesNumber" season. For 'invalid' set to -1 or iSeriesNumber=iEpisodeNumber=0 to show both are invalid */ + int iYear; /*!< @brief (optional) year of first release (use to identify a specific movie re-make) / first airing for TV shows. Set to '0' for invalid. */ + + char strStreamURL[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (required) stream URL to access this recording */ + char strDirectory[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) directory of this recording on the client */ + char strPlotOutline[PVR_ADDON_DESC_STRING_LENGTH]; /*!< @brief (optional) plot outline */ + char strPlot[PVR_ADDON_DESC_STRING_LENGTH]; /*!< @brief (optional) plot */ + char strChannelName[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) channel name */ + char strIconPath[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) icon path */ + char strThumbnailPath[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) thumbnail path */ + char strFanartPath[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) fanart path */ + time_t recordingTime; /*!< @brief (optional) start time of the recording */ + int iDuration; /*!< @brief (optional) duration of the recording in seconds */ + int iPriority; /*!< @brief (optional) priority of this recording (from 0 - 100) */ + int iLifetime; /*!< @brief (optional) life time in days of this recording */ + int iGenreType; /*!< @brief (optional) genre type */ + int iGenreSubType; /*!< @brief (optional) genre sub type */ + int iPlayCount; /*!< @brief (optional) play count of this recording on the client */ + int iLastPlayedPosition; /*!< @brief (optional) last played position of this recording on the client */ + bool bIsDeleted; /*!< @brief (optional) shows this recording is deleted and can be undelete */ + unsigned int iEpgEventId; /*!< @brief (optional) EPG event id associated with this recording. Valid ids must be greater than EPG_TAG_INVALID_UID. */ + int iChannelUid; /*!< @brief (optional) unique identifier of the channel for this recording. PVR_CHANNEL_INVALID_UID denotes that channel uid is not available. */ + } ATTRIBUTE_PACKED PVR_RECORDING; + + /*! + * @brief Edit definition list (EDL) + */ + typedef enum + { + PVR_EDL_TYPE_CUT = 0, /*!< @brief cut (completly remove content) */ + PVR_EDL_TYPE_MUTE = 1, /*!< @brief mute audio */ + PVR_EDL_TYPE_SCENE = 2, /*!< @brief scene markers (chapter seeking) */ + PVR_EDL_TYPE_COMBREAK = 3 /*!< @brief commercial breaks */ + } PVR_EDL_TYPE; + + typedef struct PVR_EDL_ENTRY + { + int64_t start; // ms + int64_t end; // ms + PVR_EDL_TYPE type; + } ATTRIBUTE_PACKED PVR_EDL_ENTRY; + + /*! + * @brief PVR menu hook data + */ + typedef struct PVR_MENUHOOK_DATA + { + PVR_MENUHOOK_CAT cat; + union data { + int iEpgUid; + PVR_CHANNEL channel; + PVR_TIMER timer; + PVR_RECORDING recording; + } data; + } ATTRIBUTE_PACKED PVR_MENUHOOK_DATA; + + /*! + * @brief Structure to transfer the methods from xbmc_pvr_dll.h to XBMC + */ + typedef struct PVRClient + { + const char* (__cdecl* GetPVRAPIVersion)(void); + const char* (__cdecl* GetMininumPVRAPIVersion)(void); + const char* (__cdecl* GetGUIAPIVersion)(void); + const char* (__cdecl* GetMininumGUIAPIVersion)(void); + PVR_ERROR (__cdecl* GetAddonCapabilities)(PVR_ADDON_CAPABILITIES*); + PVR_ERROR (__cdecl* GetStreamProperties)(PVR_STREAM_PROPERTIES*); + const char* (__cdecl* GetBackendName)(void); + const char* (__cdecl* GetBackendVersion)(void); + const char* (__cdecl* GetConnectionString)(void); + PVR_ERROR (__cdecl* GetDriveSpace)(long long*, long long*); + PVR_ERROR (__cdecl* MenuHook)(const PVR_MENUHOOK&, const PVR_MENUHOOK_DATA&); + PVR_ERROR (__cdecl* GetEpg)(ADDON_HANDLE, const PVR_CHANNEL&, time_t, time_t); + int (__cdecl* GetChannelGroupsAmount)(void); + PVR_ERROR (__cdecl* GetChannelGroups)(ADDON_HANDLE, bool); + PVR_ERROR (__cdecl* GetChannelGroupMembers)(ADDON_HANDLE, const PVR_CHANNEL_GROUP&); + PVR_ERROR (__cdecl* OpenDialogChannelScan)(void); + int (__cdecl* GetChannelsAmount)(void); + PVR_ERROR (__cdecl* GetChannels)(ADDON_HANDLE, bool); + PVR_ERROR (__cdecl* DeleteChannel)(const PVR_CHANNEL&); + PVR_ERROR (__cdecl* RenameChannel)(const PVR_CHANNEL&); + PVR_ERROR (__cdecl* MoveChannel)(const PVR_CHANNEL&); + PVR_ERROR (__cdecl* OpenDialogChannelSettings)(const PVR_CHANNEL&); + PVR_ERROR (__cdecl* OpenDialogChannelAdd)(const PVR_CHANNEL&); + int (__cdecl* GetRecordingsAmount)(bool); + PVR_ERROR (__cdecl* GetRecordings)(ADDON_HANDLE, bool); + PVR_ERROR (__cdecl* DeleteRecording)(const PVR_RECORDING&); + PVR_ERROR (__cdecl* UndeleteRecording)(const PVR_RECORDING&); + PVR_ERROR (__cdecl* DeleteAllRecordingsFromTrash)(void); + PVR_ERROR (__cdecl* RenameRecording)(const PVR_RECORDING&); + PVR_ERROR (__cdecl* SetRecordingPlayCount)(const PVR_RECORDING&, int); + PVR_ERROR (__cdecl* SetRecordingLastPlayedPosition)(const PVR_RECORDING&, int); + int (__cdecl* GetRecordingLastPlayedPosition)(const PVR_RECORDING&); + PVR_ERROR (__cdecl* GetRecordingEdl)(const PVR_RECORDING&, PVR_EDL_ENTRY[], int*); + PVR_ERROR (__cdecl* GetTimerTypes)(PVR_TIMER_TYPE[], int*); + int (__cdecl* GetTimersAmount)(void); + PVR_ERROR (__cdecl* GetTimers)(ADDON_HANDLE); + PVR_ERROR (__cdecl* AddTimer)(const PVR_TIMER&); + PVR_ERROR (__cdecl* DeleteTimer)(const PVR_TIMER&, bool); + PVR_ERROR (__cdecl* UpdateTimer)(const PVR_TIMER&); + bool (__cdecl* OpenLiveStream)(const PVR_CHANNEL&); + void (__cdecl* CloseLiveStream)(void); + int (__cdecl* ReadLiveStream)(unsigned char*, unsigned int); + long long (__cdecl* SeekLiveStream)(long long, int); + long long (__cdecl* PositionLiveStream)(void); + long long (__cdecl* LengthLiveStream)(void); + bool (__cdecl* SwitchChannel)(const PVR_CHANNEL&); + PVR_ERROR (__cdecl* SignalStatus)(PVR_SIGNAL_STATUS&); + const char* (__cdecl* GetLiveStreamURL)(const PVR_CHANNEL&); + bool (__cdecl* OpenRecordedStream)(const PVR_RECORDING&); + void (__cdecl* CloseRecordedStream)(void); + int (__cdecl* ReadRecordedStream)(unsigned char*, unsigned int); + long long (__cdecl* SeekRecordedStream)(long long, int); + long long (__cdecl* PositionRecordedStream)(void); + long long (__cdecl* LengthRecordedStream)(void); + void (__cdecl* DemuxReset)(void); + void (__cdecl* DemuxAbort)(void); + void (__cdecl* DemuxFlush)(void); + DemuxPacket* (__cdecl* DemuxRead)(void); + unsigned int (__cdecl* GetChannelSwitchDelay)(void); + bool (__cdecl* CanPauseStream)(void); + void (__cdecl* PauseStream)(bool); + bool (__cdecl* CanSeekStream)(void); + bool (__cdecl* SeekTime)(int, bool, double*); + void (__cdecl* SetSpeed)(int); + time_t (__cdecl* GetPlayingTime)(void); + time_t (__cdecl* GetBufferTimeStart)(void); + time_t (__cdecl* GetBufferTimeEnd)(void); + const char* (__cdecl* GetBackendHostname)(void); + bool (__cdecl* IsTimeshifting)(void); + bool (__cdecl* IsRealTimeStream)(void); + PVR_ERROR (__cdecl* SetEPGTimeFrame)(int); + } PVRClient; + +#ifdef __cplusplus +} +#endif + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_dll.h new file mode 100644 index 0000000..8652a0a --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_dll.h @@ -0,0 +1,42 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +#include "xbmc_addon_dll.h" +#include "xbmc_scr_types.h" + +extern "C" +{ + + // Functions that your visualisation must implement + void Start(); + void Render(); + void GetInfo(SCR_INFO* pInfo); + + // function to export the above structure to XBMC + void __declspec(dllexport) get_addon(struct ScreenSaver* pScr) + { + pScr->Start = Start; + pScr->Render = Render; + pScr->GetInfo = GetInfo; + }; +}; + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_types.h new file mode 100644 index 0000000..5785b25 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_scr_types.h @@ -0,0 +1,50 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +extern "C" +{ + struct SCR_INFO + { + int dummy; + }; + + struct SCR_PROPS + { + void *device; + int x; + int y; + int width; + int height; + float pixelRatio; + const char *name; + const char *presets; + const char *profile; + }; + + struct ScreenSaver + { + void (__cdecl* Start) (); + void (__cdecl* Render) (); + void (__cdecl* GetInfo)(SCR_INFO *info); + }; +} + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_stream_utils.hpp b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_stream_utils.hpp new file mode 100644 index 0000000..099776a --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_stream_utils.hpp @@ -0,0 +1,264 @@ +#pragma once +/* + * Copyright (C) 2005-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 + * . + * + */ + +#include "xbmc_pvr_types.h" +#include +#include + +namespace ADDON +{ + /** + * Represents a single stream. It extends the PODS to provide some operators + * overloads. + */ + class XbmcPvrStream : public PVR_STREAM_PROPERTIES::PVR_STREAM + { + public: + XbmcPvrStream() + { + Clear(); + } + + XbmcPvrStream(const XbmcPvrStream &other) + { + memcpy(this, &other, sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); + } + + XbmcPvrStream& operator=(const XbmcPvrStream &other) + { + memcpy(this, &other, sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); + return *this; + } + + /** + * Compares this stream based on another stream + * @param other + * @return + */ + inline bool operator==(const XbmcPvrStream &other) const + { + return iPhysicalId == other.iPhysicalId && iCodecId == other.iCodecId; + } + + /** + * Compares this stream with another one so that video streams are sorted + * before any other streams and the others are sorted by the physical ID + * @param other + * @return + */ + bool operator<(const XbmcPvrStream &other) const + { + if (iCodecType == XBMC_CODEC_TYPE_VIDEO) + return true; + else if (other.iCodecType != XBMC_CODEC_TYPE_VIDEO) + return iPhysicalId < other.iPhysicalId; + else + return false; + } + + /** + * Clears the stream + */ + void Clear() + { + memset(this, 0, sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); + iCodecId = XBMC_INVALID_CODEC_ID; + iCodecType = XBMC_CODEC_TYPE_UNKNOWN; + } + + /** + * Checks whether the stream has been cleared + * @return + */ + inline bool IsCleared() const + { + return iCodecId == XBMC_INVALID_CODEC_ID && + iCodecType == XBMC_CODEC_TYPE_UNKNOWN; + } + }; + + class XbmcStreamProperties + { + public: + typedef std::vector stream_vector; + + XbmcStreamProperties(void) + { + // make sure the vector won't have to resize itself later + m_streamVector = new stream_vector(); + m_streamVector->reserve(PVR_STREAM_MAX_STREAMS); + } + + virtual ~XbmcStreamProperties(void) + { + delete m_streamVector; + } + + /** + * Resets the streams + */ + void Clear(void) + { + m_streamVector->clear(); + m_streamIndex.clear(); + } + + /** + * Returns the index of the stream with the specified physical ID, or -1 if + * there no stream is found. This method is called very often which is why + * we keep a separate map for this. + * @param iPhysicalId + * @return + */ + int GetStreamId(unsigned int iPhysicalId) const + { + std::map::const_iterator it = m_streamIndex.find(iPhysicalId); + if (it != m_streamIndex.end()) + return it->second; + + return -1; + } + + /** + * Returns the stream with the specified physical ID, or null if no such + * stream exists + * @param iPhysicalId + * @return + */ + XbmcPvrStream* GetStreamById(unsigned int iPhysicalId) const + { + int position = GetStreamId(iPhysicalId); + return position != -1 ? &m_streamVector->at(position) : NULL; + } + + /** + * Populates the specified stream with the stream having the specified + * physical ID. If the stream is not found only target stream's physical ID + * will be populated. + * @param iPhysicalId + * @param stream + */ + void GetStreamData(unsigned int iPhysicalId, XbmcPvrStream* stream) + { + XbmcPvrStream *foundStream = GetStreamById(iPhysicalId); + if (foundStream) + *stream = *foundStream; + else + { + stream->iIdentifier = -1; + stream->iPhysicalId = iPhysicalId; + } + } + + /** + * Populates props with the current streams and returns whether there are + * any streams at the moment or not. + * @param props + * @return + */ + bool GetProperties(PVR_STREAM_PROPERTIES* props) + { + unsigned int i = 0; + for (stream_vector::const_iterator it = m_streamVector->begin(); + it != m_streamVector->end(); ++it, ++i) + { + memcpy(&props->stream[i], &(*it), sizeof(PVR_STREAM_PROPERTIES::PVR_STREAM)); + } + + props->iStreamCount = m_streamVector->size(); + return (props->iStreamCount > 0); + } + + /** + * Merges new streams into the current list of streams. Identical streams + * will retain their respective indexes and new streams will replace unused + * indexes or be appended. + * @param newStreams + */ + void UpdateStreams(stream_vector &newStreams) + { + // sort the new streams + std::sort(newStreams.begin(), newStreams.end()); + + // ensure we never have more than PVR_STREAMS_MAX_STREAMS streams + if (newStreams.size() > PVR_STREAM_MAX_STREAMS) + { + while (newStreams.size() > PVR_STREAM_MAX_STREAMS) + newStreams.pop_back(); + + XBMC->Log(LOG_ERROR, "%s - max amount of streams reached", __FUNCTION__); + } + + stream_vector::iterator newStreamPosition; + for (stream_vector::iterator it = m_streamVector->begin(); it != m_streamVector->end(); ++it) + { + newStreamPosition = std::find(newStreams.begin(), newStreams.end(), *it); + + // if the current stream no longer exists we clear it, otherwise we + // copy it and remove it from newStreams + if (newStreamPosition == newStreams.end()) + it->Clear(); + else + { + *it = *newStreamPosition; + newStreams.erase(newStreamPosition); + } + } + + // replace cleared streams with new streams + for (stream_vector::iterator it = m_streamVector->begin(); + it != m_streamVector->end() && !newStreams.empty(); ++it) + { + if (it->IsCleared()) + { + *it = newStreams.front(); + newStreams.erase(newStreams.begin()); + } + } + + // append any remaining new streams + m_streamVector->insert(m_streamVector->end(), newStreams.begin(), newStreams.end()); + + // remove trailing cleared streams + while (m_streamVector->back().IsCleared()) + m_streamVector->pop_back(); + + // update the index + UpdateIndex(); + } + + private: + stream_vector *m_streamVector; + std::map m_streamIndex; + + /** + * Updates the stream index + */ + void UpdateIndex() + { + m_streamIndex.clear(); + + int i = 0; + for (stream_vector::const_iterator it = m_streamVector->begin(); it != m_streamVector->end(); ++it, ++i) + m_streamIndex[it->iPhysicalId] = i; + } + }; +} diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_dll.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_dll.h new file mode 100644 index 0000000..50452c2 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_dll.h @@ -0,0 +1,53 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +#include "xbmc_addon_dll.h" +#include "xbmc_vis_types.h" + +extern "C" +{ + // Functions that your visualisation must implement + void Start(int iChannels, int iSamplesPerSec, int iBitsPerSample, const char* szSongName); + void AudioData(const float* pAudioData, int iAudioDataLength, float *pFreqData, int iFreqDataLength); + void Render(); + bool OnAction(long action, const void *param); + void GetInfo(VIS_INFO* pInfo); + unsigned int GetPresets(char ***presets); + unsigned GetPreset(); + unsigned int GetSubModules(char ***presets); + bool IsLocked(); + + // function to export the above structure to XBMC + void __declspec(dllexport) get_addon(struct Visualisation* pVisz) + { + pVisz->Start = Start; + pVisz->AudioData = AudioData; + pVisz->Render = Render; + pVisz->OnAction = OnAction; + pVisz->GetInfo = GetInfo; + pVisz->GetPresets = GetPresets; + pVisz->GetPreset = GetPreset; + pVisz->GetSubModules = GetSubModules; + pVisz->IsLocked = IsLocked; + }; +}; + diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_types.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_types.h new file mode 100644 index 0000000..708ffef --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/xbmc_vis_types.h @@ -0,0 +1,110 @@ +#pragma once + +/* + * Copyright (C) 2005-2015 Team Kodi + * http://kodi.tv + * + * 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 Kodi; see the file COPYING. If not, see + * . + * + */ + +/* + Common data structures shared between Kodi and Kodi's visualisations + */ + +#include + +extern "C" +{ + struct VIS_INFO + { + int bWantsFreq; + int iSyncDelay; + }; + + struct VIS_PROPS + { + void *device; + int x; + int y; + int width; + int height; + float pixelRatio; + const char *name; + const char *presets; + const char *profile; + const char *submodule; + }; + + enum VIS_ACTION + { + VIS_ACTION_NONE = 0, + VIS_ACTION_NEXT_PRESET, + VIS_ACTION_PREV_PRESET, + VIS_ACTION_LOAD_PRESET, + VIS_ACTION_RANDOM_PRESET, + VIS_ACTION_LOCK_PRESET, + VIS_ACTION_RATE_PRESET_PLUS, + VIS_ACTION_RATE_PRESET_MINUS, + VIS_ACTION_UPDATE_ALBUMART, + VIS_ACTION_UPDATE_TRACK + }; + + class VisTrack + { + public: + VisTrack() + { + title = artist = album = albumArtist = NULL; + genre = comment = lyrics = reserved1 = reserved2 = NULL; + trackNumber = discNumber = duration = year = 0; + rating = 0; + reserved3 = reserved4 = 0; + } + + const char *title; + const char *artist; + const char *album; + const char *albumArtist; + const char *genre; + const char *comment; + const char *lyrics; + const char *reserved1; + const char *reserved2; + + int trackNumber; + int discNumber; + int duration; + int year; + char rating; + int reserved3; + int reserved4; + }; + + struct Visualisation + { + void (__cdecl* Start)(int iChannels, int iSamplesPerSec, int iBitsPerSample, const char* szSongName); + void (__cdecl* AudioData)(const float* pAudioData, int iAudioDataLength, float *pFreqData, int iFreqDataLength); + void (__cdecl* Render) (); + void (__cdecl* GetInfo)(VIS_INFO *info); + bool (__cdecl* OnAction)(long flags, const void *param); + int (__cdecl* HasPresets)(); + unsigned int (__cdecl *GetPresets)(char ***presets); + unsigned int (__cdecl *GetPreset)(); + unsigned int (__cdecl *GetSubModules)(char ***modules); + bool (__cdecl* IsLocked)(); + }; +} + -- cgit v1.2.3