From b3d195f0188758a14875a5a2f270e4fd190a679f Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 17 Apr 2018 00:15:38 +0200 Subject: sync with upstream --- .../include/kodi/addon-instance/AudioDSP.h | 1288 -------------------- .../include/kodi/addon-instance/CMakeLists.txt | 3 +- .../include/kodi/addon-instance/Peripheral.h | 162 ++- .../include/kodi/addon-instance/PeripheralUtils.h | 220 +++- .../include/kodi/addon-instance/VFS.h | 6 +- .../include/kodi/addon-instance/VideoCodec.h | 2 +- .../include/kodi/addon-instance/Visualization.h | 2 +- 7 files changed, 330 insertions(+), 1353 deletions(-) delete mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDSP.h (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance') diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDSP.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDSP.h deleted file mode 100644 index 3587a33..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/AudioDSP.h +++ /dev/null @@ -1,1288 +0,0 @@ -#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 "../AddonBase.h" - -#define AE_DSP_STREAM_MAX_STREAMS 8 -#define AE_DSP_STREAM_MAX_MODES 32 - -/*! - * @file Addon.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 - * GetCapabilities(...), further the addon must register his available - * modes on startup with the RegisterMode(...) callback function. - * 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. - */ - -namespace kodi { namespace addon { class CInstanceAudioDSP; }} - -extern "C" { - - typedef void* ADSPHANDLE; - - 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<globalSingleInstance != nullptr) - throw std::logic_error("kodi::addon::CInstanceAudioDSP: Creation of more as one in single instance way is not allowed!"); - - SetAddonStruct(CAddonBase::m_interface->firstKodiInstance); - CAddonBase::m_interface->globalSingleInstance = this; - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// @brief Class constructor - /// - /// @param[in] instance The from Kodi given instance given be - /// add-on CreateInstance call with instance - /// id ADDON_INSTANCE_ADSP. - /// - explicit CInstanceAudioDSP(KODI_HANDLE instance) - : IAddonInstance(ADDON_INSTANCE_ADSP) - { - if (CAddonBase::m_interface->globalSingleInstance != nullptr) - throw std::logic_error("kodi::addon::CInstanceAudioDSP: Creation of multiple together with single instance way is not allowed!"); - - SetAddonStruct(instance); - } - //-------------------------------------------------------------------------- - - /*! @name Audio DSP add-on methods */ - //@{ - //========================================================================== - /// - /// @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 capabilities The add-ons capabilities. - /// @remarks Valid implementation required. - /// - virtual void GetCapabilities(AE_DSP_ADDON_CAPABILITIES& capabilities) = 0; - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @return The name reported by the back end that will be displayed in the - /// UI. - /// @remarks Valid implementation required. - /// - virtual std::string GetDSPName() = 0; - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @return The version string reported by the back end that will be displayed - /// in the UI. - /// @remarks Valid implementation required. - /// - virtual std::string GetDSPVersion() = 0; - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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. - /// - virtual AE_DSP_ERROR MenuHook(const AE_DSP_MENUHOOK& menuhook, const AE_DSP_MENUHOOK_DATA& item) { return AE_DSP_ERROR_NOT_IMPLEMENTED; } - //-------------------------------------------------------------------------- - //@} - - //========================================================================== - /// @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 properties 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. - /// - virtual AE_DSP_ERROR StreamCreate(const AE_DSP_SETTINGS& addonSettings, const AE_DSP_STREAM_PROPERTIES& properties, ADDON_HANDLE handle) = 0; - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// 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. - /// - virtual AE_DSP_ERROR StreamDestroy(const ADDON_HANDLE handle) = 0; - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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. - /// - virtual AE_DSP_ERROR StreamIsModeSupported(const ADDON_HANDLE handle, AE_DSP_MODE_TYPE type, unsigned int mode_id, int unique_db_mode_id) = 0; - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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. - /// - virtual AE_DSP_ERROR StreamInitialize(const ADDON_HANDLE handle, const AE_DSP_SETTINGS& addonSettings) = 0; - //-------------------------------------------------------------------------- - - //@} - - /// @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 - /// GetCapabilities - /// - virtual bool InputProcess(const ADDON_HANDLE handle, const float** array_in, unsigned int samples) { return true; } - //-------------------------------------------------------------------------- - //@} - - /// @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 - /// GetCapabilities - /// - virtual unsigned int InputResampleProcessNeededSamplesize(const ADDON_HANDLE handle) { return 0; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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 - /// GetCapabilities - /// - virtual unsigned int InputResampleProcess(const ADDON_HANDLE handle, const float** array_in, float** array_out, unsigned int samples) { return 0; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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 - /// GetCapabilities - /// - virtual int InputResampleSampleRate(const ADDON_HANDLE handle) { return 0; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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 - /// GetCapabilities - /// - virtual float InputResampleGetDelay(const ADDON_HANDLE handle) { return 0.0f; } - //-------------------------------------------------------------------------- - //@} - - /** @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 - /// GetCapabilities - /// - virtual unsigned int PreProcessNeededSamplesize(const ADDON_HANDLE handle, unsigned int mode_id) { return 0; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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 - /// GetCapabilities - /// - virtual float PreProcessGetDelay(const ADDON_HANDLE handle, unsigned int mode_id) { return 0.0f; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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 - /// GetCapabilities - /// - virtual unsigned int PreProcess(const ADDON_HANDLE handle, unsigned int mode_id, const float** array_in, float** array_out, unsigned int samples) { return 0; } - //-------------------------------------------------------------------------- - //@} - - /** @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 - /// GetCapabilities - /// - virtual AE_DSP_ERROR MasterProcessSetMode(const ADDON_HANDLE handle, AE_DSP_STREAMTYPE type, unsigned int mode_id, int unique_db_mode_id) { return AE_DSP_ERROR_NOT_IMPLEMENTED; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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 - /// GetCapabilities - /// - virtual unsigned int MasterProcessNeededSamplesize(const ADDON_HANDLE handle) { return 0; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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 - /// GetCapabilities - /// - virtual float MasterProcessGetDelay(const ADDON_HANDLE handle) { return 0.0f; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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 - /// - virtual int MasterProcessGetOutChannels(const ADDON_HANDLE handle, unsigned long& out_channel_present_flags) { return 0; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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 - /// GetCapabilities - /// - virtual unsigned int MasterProcess(const ADDON_HANDLE handle, const float** array_in, float** array_out, unsigned int samples) { return 0; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// 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 - /// GetCapabilities - /// - virtual std::string MasterProcessGetStreamInfoString(const ADDON_HANDLE handle) { return ""; } - //-------------------------------------------------------------------------- - //@} - - /** @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 - /// GetCapabilities - /// - virtual unsigned int PostProcessNeededSamplesize(const ADDON_HANDLE handle, unsigned int mode_id) { return 0; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// 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 - /// GetCapabilities - /// - virtual float PostProcessGetDelay(const ADDON_HANDLE handle, unsigned int mode_id) { return 0.0f; } - //-------------------------------------------------------------------------- - - //========================================================================== - - /// - /// @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 - /// GetCapabilities - /// - virtual unsigned int PostProcess(const ADDON_HANDLE handle, unsigned int mode_id, const float** array_in, float** array_out, unsigned int samples) { return 0; } - - //-------------------------------------------------------------------------- - //@} - - /** @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 - /// GetCapabilities - /// - virtual unsigned int OutputResampleProcessNeededSamplesize(const ADDON_HANDLE handle) { return 0; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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 - /// GetCapabilities - /// - virtual unsigned int OutputResampleProcess(const ADDON_HANDLE handle, const float** array_in, float** array_out, unsigned int samples) { return 0; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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 - /// GetCapabilities - /// - virtual int OutputResampleSampleRate(const ADDON_HANDLE handle) { return 0; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// @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 - /// GetCapabilities - /// - virtual float OutputResampleGetDelay(const ADDON_HANDLE handle) { return 0.0f; } - //-------------------------------------------------------------------------- - //@} - - //========================================================================== - /// - /// @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 m_instanceData->toKodi.add_menu_hook(m_instanceData->toKodi.kodiInstance, 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 m_instanceData->toKodi.remove_menu_hook(m_instanceData->toKodi.kodiInstance, 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 m_instanceData->toKodi.register_mode(m_instanceData->toKodi.kodiInstance, 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 m_instanceData->toKodi.unregister_mode(m_instanceData->toKodi.kodiInstance, mode); - } - //-------------------------------------------------------------------------- - - private: - void SetAddonStruct(KODI_HANDLE instance) - { - if (instance == nullptr) - throw std::logic_error("kodi::addon::CInstanceAudioDSP: Null pointer instance passed."); - - m_instanceData = static_cast(instance); - - m_instanceData->toAddon.get_capabilities = ADDON_GetCapabilities; - m_instanceData->toAddon.get_dsp_name = ADDON_GetDSPName; - m_instanceData->toAddon.get_dsp_version = ADDON_GetDSPVersion; - m_instanceData->toAddon.menu_hook = ADDON_MenuHook; - - m_instanceData->toAddon.stream_create = ADDON_StreamCreate; - m_instanceData->toAddon.stream_destroy = ADDON_StreamDestroy; - m_instanceData->toAddon.stream_is_mode_supported = ADDON_StreamIsModeSupported; - m_instanceData->toAddon.stream_initialize = ADDON_StreamInitialize; - - m_instanceData->toAddon.input_process = ADDON_InputProcess; - - m_instanceData->toAddon.input_resample_process_needed_samplesize = ADDON_InputResampleProcessNeededSamplesize; - m_instanceData->toAddon.input_resample_process = ADDON_InputResampleProcess; - m_instanceData->toAddon.input_resample_get_delay = ADDON_InputResampleGetDelay; - m_instanceData->toAddon.input_resample_samplerate = ADDON_InputResampleSampleRate; - - m_instanceData->toAddon.pre_process_needed_samplesize = ADDON_PreProcessNeededSamplesize; - m_instanceData->toAddon.pre_process_get_delay = ADDON_PreProcessGetDelay; - m_instanceData->toAddon.pre_process = ADDON_PreProcess; - - m_instanceData->toAddon.master_process_set_mode = ADDON_MasterProcessSetMode; - m_instanceData->toAddon.master_process_needed_samplesize = ADDON_MasterProcessNeededSamplesize; - m_instanceData->toAddon.master_process_get_delay = ADDON_MasterProcessGetDelay; - m_instanceData->toAddon.master_process_get_out_channels = ADDON_MasterProcessGetOutChannels; - m_instanceData->toAddon.master_process = ADDON_MasterProcess; - m_instanceData->toAddon.master_process_get_stream_info_string = ADDON_MasterProcessGetStreamInfoString; - - m_instanceData->toAddon.post_process_needed_samplesize = ADDON_PostProcessNeededSamplesize; - m_instanceData->toAddon.post_process_get_delay = ADDON_PostProcessGetDelay; - m_instanceData->toAddon.post_process = ADDON_PostProcess; - - m_instanceData->toAddon.output_resample_process_needed_samplesize = ADDON_OutputResampleProcessNeededSamplesize; - m_instanceData->toAddon.output_resample_process = ADDON_OutputResampleProcess; - m_instanceData->toAddon.output_resample_get_delay = ADDON_OutputResampleGetDelay; - m_instanceData->toAddon.output_resample_samplerate = ADDON_OutputResampleSampleRate; - } - - static inline void ADDON_GetCapabilities(AddonInstance_AudioDSP const* instance, AE_DSP_ADDON_CAPABILITIES *capabilities) - { - instance->toAddon.addonInstance->GetCapabilities(*capabilities); - } - - static inline const char* ADDON_GetDSPName(AddonInstance_AudioDSP const* instance) - { - instance->toAddon.addonInstance->m_dspName = instance->toAddon.addonInstance->GetDSPName(); - return instance->toAddon.addonInstance->m_dspName.c_str(); - } - - static inline const char* ADDON_GetDSPVersion(AddonInstance_AudioDSP const* instance) - { - instance->toAddon.addonInstance->m_dspVersion = instance->toAddon.addonInstance->GetDSPVersion(); - return instance->toAddon.addonInstance->m_dspVersion.c_str(); - } - - static inline AE_DSP_ERROR ADDON_MenuHook(AddonInstance_AudioDSP const* instance, const AE_DSP_MENUHOOK* menuhook, const AE_DSP_MENUHOOK_DATA* item) - { - return instance->toAddon.addonInstance->MenuHook(*menuhook, *item); - } - - static inline AE_DSP_ERROR ADDON_StreamCreate(AddonInstance_AudioDSP const* instance, const AE_DSP_SETTINGS *addonSettings, const AE_DSP_STREAM_PROPERTIES* properties, ADDON_HANDLE handle) - { - return instance->toAddon.addonInstance->StreamCreate(*addonSettings, *properties, handle); - } - - static inline AE_DSP_ERROR ADDON_StreamDestroy(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle) - { - return instance->toAddon.addonInstance->StreamDestroy(handle); - } - - static inline AE_DSP_ERROR ADDON_StreamIsModeSupported(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, AE_DSP_MODE_TYPE type, unsigned int mode_id, int unique_db_mode_id) - { - return instance->toAddon.addonInstance->StreamIsModeSupported(handle, type, mode_id, unique_db_mode_id); - } - - static inline AE_DSP_ERROR ADDON_StreamInitialize(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, const AE_DSP_SETTINGS *addonSettings) - { - return instance->toAddon.addonInstance->StreamInitialize(handle, *addonSettings); - } - - static inline bool ADDON_InputProcess(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, const float** array_in, unsigned int samples) - { - return instance->toAddon.addonInstance->InputProcess(handle, array_in, samples); - } - - static inline unsigned int ADDON_InputResampleProcessNeededSamplesize(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle) - { - return instance->toAddon.addonInstance->InputResampleProcessNeededSamplesize(handle); - } - - static inline unsigned int ADDON_InputResampleProcess(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, const float** array_in, float** array_out, unsigned int samples) - { - return instance->toAddon.addonInstance->InputResampleProcess(handle, array_in, array_out, samples); - } - - static inline int ADDON_InputResampleSampleRate(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle) - { - return instance->toAddon.addonInstance->InputResampleSampleRate(handle); - } - - static inline float ADDON_InputResampleGetDelay(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle) - { - return instance->toAddon.addonInstance->InputResampleGetDelay(handle); - } - - static inline unsigned int ADDON_PreProcessNeededSamplesize(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, unsigned int mode_id) - { - return instance->toAddon.addonInstance->PreProcessNeededSamplesize(handle, mode_id); - } - - static inline float ADDON_PreProcessGetDelay(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, unsigned int mode_id) - { - return instance->toAddon.addonInstance->PreProcessGetDelay(handle, mode_id); - } - - static inline unsigned int ADDON_PreProcess(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, unsigned int mode_id, const float** array_in, float** array_out, unsigned int samples) - { - return instance->toAddon.addonInstance->PreProcess(handle, mode_id, array_in, array_out, samples); - } - - static inline AE_DSP_ERROR ADDON_MasterProcessSetMode(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, AE_DSP_STREAMTYPE type, unsigned int mode_id, int unique_db_mode_id) - { - return instance->toAddon.addonInstance->MasterProcessSetMode(handle, type, mode_id, unique_db_mode_id); - } - - static inline unsigned int ADDON_MasterProcessNeededSamplesize(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle) - { - return instance->toAddon.addonInstance->MasterProcessNeededSamplesize(handle); - } - - static inline float ADDON_MasterProcessGetDelay(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle) - { - return instance->toAddon.addonInstance->MasterProcessGetDelay(handle); - } - - static inline int ADDON_MasterProcessGetOutChannels(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, unsigned long* out_channel_present_flags) - { - return instance->toAddon.addonInstance->MasterProcessGetOutChannels(handle, *out_channel_present_flags); - } - - static inline unsigned int ADDON_MasterProcess(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, const float** array_in, float** array_out, unsigned int samples) - { - return instance->toAddon.addonInstance->MasterProcess(handle, array_in, array_out, samples); - } - - static inline const char* ADDON_MasterProcessGetStreamInfoString(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle) - { - instance->toAddon.addonInstance->m_streamInfoString = instance->toAddon.addonInstance->MasterProcessGetStreamInfoString(handle); - return instance->toAddon.addonInstance->m_streamInfoString.c_str(); - } - - static inline unsigned int ADDON_PostProcessNeededSamplesize(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, unsigned int mode_id) - { - return instance->toAddon.addonInstance->PostProcessNeededSamplesize(handle, mode_id); - } - - static inline float ADDON_PostProcessGetDelay(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, unsigned int mode_id) - { - return instance->toAddon.addonInstance->PostProcessGetDelay(handle, mode_id); - } - - static inline unsigned int ADDON_PostProcess(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, unsigned int mode_id, const float** array_in, float** array_out, unsigned int samples) - { - return instance->toAddon.addonInstance->PostProcess(handle, mode_id, array_in, array_out, samples); - } - - static inline unsigned int ADDON_OutputResampleProcessNeededSamplesize(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle) - { - return instance->toAddon.addonInstance->OutputResampleProcessNeededSamplesize(handle); - } - - static inline unsigned int ADDON_OutputResampleProcess(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle, const float** array_in, float** array_out, unsigned int samples) - { - return instance->toAddon.addonInstance->OutputResampleProcess(handle, array_in, array_out, samples); - } - - static inline int ADDON_OutputResampleSampleRate(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle) - { - return instance->toAddon.addonInstance->OutputResampleSampleRate(handle); - } - - static inline float ADDON_OutputResampleGetDelay(AddonInstance_AudioDSP const* instance, const ADDON_HANDLE handle) - { - return instance->toAddon.addonInstance->OutputResampleGetDelay(handle); - } - - std::string m_dspName; - std::string m_dspVersion; - std::string m_streamInfoString; - AddonInstance_AudioDSP* m_instanceData; - }; - -} /* namespace addon */ -} /* namespace kodi */ diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt index ba4f889..44aaf05 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/CMakeLists.txt @@ -1,5 +1,4 @@ -set(HEADERS AudioDSP.h - AudioDecoder.h +set(HEADERS AudioDecoder.h AudioEncoder.h ImageDecoder.h Inputstream.h diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h index 0dae06c..75be27e 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h @@ -34,6 +34,10 @@ extern "C" /// @name Peripheral types ///{ + + /*! + * @brief API error codes + */ typedef enum PERIPHERAL_ERROR { PERIPHERAL_NO_ERROR = 0, // no error occurred @@ -45,6 +49,9 @@ extern "C" PERIPHERAL_ERROR_CONNECTION_FAILED = -6, // peripherals are connected, but command was interrupted } PERIPHERAL_ERROR; + /*! + * @brief Peripheral types + */ typedef enum PERIPHERAL_TYPE { PERIPHERAL_TYPE_UNKNOWN, @@ -52,6 +59,9 @@ extern "C" PERIPHERAL_TYPE_KEYBOARD, } PERIPHERAL_TYPE; + /*! + * @brief Information shared between peripherals + */ typedef struct PERIPHERAL_INFO { PERIPHERAL_TYPE type; /*!< @brief type of peripheral */ @@ -63,8 +73,6 @@ extern "C" /*! * @brief Peripheral add-on capabilities. - * If a capability is set to true, then the corresponding methods from - * kodi_peripheral_dll.h need to be implemented. */ typedef struct PERIPHERAL_CAPABILITIES { @@ -77,6 +85,10 @@ extern "C" /// @name Event types ///{ + + /*! + * @brief Types of events that can be sent and received + */ typedef enum PERIPHERAL_EVENT_TYPE { PERIPHERAL_EVENT_TYPE_NONE, /*!< @brief unknown event */ @@ -86,12 +98,18 @@ extern "C" PERIPHERAL_EVENT_TYPE_SET_MOTOR, /*!< @brief set the state for joystick rumble motor */ } PERIPHERAL_EVENT_TYPE; + /*! + * @brief States a button can have + */ typedef enum JOYSTICK_STATE_BUTTON { JOYSTICK_STATE_BUTTON_UNPRESSED = 0x0, /*!< @brief button is released */ JOYSTICK_STATE_BUTTON_PRESSED = 0x1, /*!< @brief button is pressed */ } JOYSTICK_STATE_BUTTON; + /*! + * @brief States a D-pad (also called a hat) can have + */ typedef enum JOYSTICK_STATE_HAT { JOYSTICK_STATE_HAT_UNPRESSED = 0x0, /*!< @brief no directions are pressed */ @@ -106,7 +124,7 @@ extern "C" } JOYSTICK_STATE_HAT; /*! - * @brief value in the closed interval [-1.0, 1.0] + * @brief Axis value in the closed interval [-1.0, 1.0] * * The axis state uses the XInput coordinate system: * - Negative values signify down or to the left @@ -114,13 +132,25 @@ extern "C" */ typedef float JOYSTICK_STATE_AXIS; + /*! + * @brief Motor value in the closed interval [0.0, 1.0] + */ typedef float JOYSTICK_STATE_MOTOR; + /*! + * @brief Event information + */ typedef struct PERIPHERAL_EVENT { - unsigned int peripheral_index; - PERIPHERAL_EVENT_TYPE type; - unsigned int driver_index; + /*! @brief Index of the peripheral handling/receiving the event */ + unsigned int peripheral_index; + + /*! @brief Type of the event used to determine which enum field to access below */ + PERIPHERAL_EVENT_TYPE type; + + /*! @brief The index of the event source */ + unsigned int driver_index; + JOYSTICK_STATE_BUTTON driver_button_state; JOYSTICK_STATE_HAT driver_hat_state; JOYSTICK_STATE_AXIS driver_axis_state; @@ -130,6 +160,10 @@ extern "C" /// @name Joystick types ///{ + + /*! + * @brief Info specific to joystick peripherals + */ typedef struct JOYSTICK_INFO { PERIPHERAL_INFO peripheral; /*!< @brief peripheral info for this joystick */ @@ -142,6 +176,15 @@ extern "C" bool supports_poweroff; /*!< @brief whether the joystick supports being powered off */ } ATTRIBUTE_PACKED JOYSTICK_INFO; + /*! + * @brief Driver input primitives + * + * Mapping lower-level driver values to higher-level controller features is + * non-injective; two triggers can share a single axis. + * + * To handle this, driver values are subdivided into "primitives" that map + * injectively to higher-level features. + */ typedef enum JOYSTICK_DRIVER_PRIMITIVE_TYPE { JOYSTICK_DRIVER_PRIMITIVE_TYPE_UNKNOWN, @@ -149,13 +192,22 @@ extern "C" JOYSTICK_DRIVER_PRIMITIVE_TYPE_HAT_DIRECTION, JOYSTICK_DRIVER_PRIMITIVE_TYPE_SEMIAXIS, JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR, + JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY, + JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON, + JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION, } JOYSTICK_DRIVER_PRIMITIVE_TYPE; + /*! + * @brief Button primitive + */ typedef struct JOYSTICK_DRIVER_BUTTON { int index; } ATTRIBUTE_PACKED JOYSTICK_DRIVER_BUTTON; + /*! + * @brief Hat direction + */ typedef enum JOYSTICK_DRIVER_HAT_DIRECTION { JOYSTICK_DRIVER_HAT_UNKNOWN, @@ -165,12 +217,18 @@ extern "C" JOYSTICK_DRIVER_HAT_DOWN, } JOYSTICK_DRIVER_HAT_DIRECTION; + /*! + * @brief Hat direction primitive + */ typedef struct JOYSTICK_DRIVER_HAT { int index; JOYSTICK_DRIVER_HAT_DIRECTION direction; } ATTRIBUTE_PACKED JOYSTICK_DRIVER_HAT; + /*! + * @brief Semiaxis direction + */ typedef enum JOYSTICK_DRIVER_SEMIAXIS_DIRECTION { JOYSTICK_DRIVER_SEMIAXIS_NEGATIVE = -1, /*!< @brief negative half of the axis */ @@ -178,6 +236,9 @@ extern "C" JOYSTICK_DRIVER_SEMIAXIS_POSITIVE = 1, /*!< @brief positive half of the axis */ } JOYSTICK_DRIVER_SEMIAXIS_DIRECTION; + /*! + * @brief Semiaxis primitive + */ typedef struct JOYSTICK_DRIVER_SEMIAXIS { int index; @@ -186,11 +247,70 @@ extern "C" unsigned int range; } ATTRIBUTE_PACKED JOYSTICK_DRIVER_SEMIAXIS; + /*! + * @brief Motor primitive + */ typedef struct JOYSTICK_DRIVER_MOTOR { int index; } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOTOR; + /*! + * @brief Keyboard key primitive + */ + typedef struct JOYSTICK_DRIVER_KEY + { + char keycode[16]; + } ATTRIBUTE_PACKED JOYSTICK_DRIVER_KEY; + + /*! + * @brief Mouse buttons + */ + typedef enum JOYSTICK_DRIVER_MOUSE_INDEX + { + JOYSTICK_DRIVER_MOUSE_INDEX_UNKNOWN, + JOYSTICK_DRIVER_MOUSE_INDEX_LEFT, + JOYSTICK_DRIVER_MOUSE_INDEX_RIGHT, + JOYSTICK_DRIVER_MOUSE_INDEX_MIDDLE, + JOYSTICK_DRIVER_MOUSE_INDEX_BUTTON4, + JOYSTICK_DRIVER_MOUSE_INDEX_BUTTON5, + JOYSTICK_DRIVER_MOUSE_INDEX_WHEEL_UP, + JOYSTICK_DRIVER_MOUSE_INDEX_WHEEL_DOWN, + JOYSTICK_DRIVER_MOUSE_INDEX_HORIZ_WHEEL_LEFT, + JOYSTICK_DRIVER_MOUSE_INDEX_HORIZ_WHEEL_RIGHT, + } JOYSTICK_DRIVER_MOUSE_INDEX; + + /*! + * @brief Mouse button primitive + */ + typedef struct JOYSTICK_DRIVER_MOUSE_BUTTON + { + JOYSTICK_DRIVER_MOUSE_INDEX button; + } ATTRIBUTE_PACKED JOYSTICK_DRIVER_MOUSE_BUTTON; + + /*! + * @brief Relative pointer direction + */ + typedef enum JOYSTICK_DRIVER_RELPOINTER_DIRECTION + { + JOYSTICK_DRIVER_RELPOINTER_UNKNOWN, + JOYSTICK_DRIVER_RELPOINTER_LEFT, + JOYSTICK_DRIVER_RELPOINTER_RIGHT, + JOYSTICK_DRIVER_RELPOINTER_UP, + JOYSTICK_DRIVER_RELPOINTER_DOWN, + } JOYSTICK_DRIVER_RELPOINTER_DIRECTION; + + /*! + * @brief Relative pointer direction primitive + */ + typedef struct JOYSTICK_DRIVER_RELPOINTER + { + JOYSTICK_DRIVER_RELPOINTER_DIRECTION direction; + } ATTRIBUTE_PACKED JOYSTICK_DRIVER_RELPOINTER; + + /*! + * @brief Driver primitive struct + */ typedef struct JOYSTICK_DRIVER_PRIMITIVE { JOYSTICK_DRIVER_PRIMITIVE_TYPE type; @@ -200,9 +320,18 @@ extern "C" struct JOYSTICK_DRIVER_HAT hat; struct JOYSTICK_DRIVER_SEMIAXIS semiaxis; struct JOYSTICK_DRIVER_MOTOR motor; + struct JOYSTICK_DRIVER_KEY key; + struct JOYSTICK_DRIVER_MOUSE_BUTTON mouse; + struct JOYSTICK_DRIVER_RELPOINTER relpointer; }; } ATTRIBUTE_PACKED JOYSTICK_DRIVER_PRIMITIVE; + /*! + * @brief Controller feature + * + * Controller features are an abstraction over driver values. Each feature + * maps to one or more driver primitives. + */ typedef enum JOYSTICK_FEATURE_TYPE { JOYSTICK_FEATURE_TYPE_UNKNOWN, @@ -214,11 +343,15 @@ extern "C" JOYSTICK_FEATURE_TYPE_ABSPOINTER, JOYSTICK_FEATURE_TYPE_WHEEL, JOYSTICK_FEATURE_TYPE_THROTTLE, + JOYSTICK_FEATURE_TYPE_KEY, } JOYSTICK_FEATURE_TYPE; + /*! + * @brief Indices used to access a feature's driver primitives + */ typedef enum JOYSTICK_FEATURE_PRIMITIVE { - // Scalar feature + // Scalar feature (a button, hat direction or semiaxis) JOYSTICK_SCALAR_PRIMITIVE = 0, // Analog stick @@ -243,10 +376,25 @@ extern "C" JOYSTICK_THROTTLE_UP = 0, JOYSTICK_THROTTLE_DOWN = 1, + // Key + JOYSTICK_KEY_PRIMITIVE = 0, + + // Mouse button + JOYSTICK_MOUSE_BUTTON = 0, + + // Relative pointer direction + JOYSTICK_RELPOINTER_UP = 0, + JOYSTICK_RELPOINTER_DOWN = 1, + JOYSTICK_RELPOINTER_RIGHT = 2, + JOYSTICK_RELPOINTER_LEFT = 3, + // Maximum number of primitives JOYSTICK_PRIMITIVE_MAX = 4, } JOYSTICK_FEATURE_PRIMITIVE; + /*! + * @brief Mapping between higher-level controller feature and its driver primitives + */ typedef struct JOYSTICK_FEATURE { char* name; diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h index 3c4cab3..c2efc05 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/PeripheralUtils.h @@ -23,8 +23,8 @@ #include // Requires c++11 #include -#include #include +#include #include #define PERIPHERAL_SAFE_DELETE(x) do { delete (x); (x) = NULL; } while (0) @@ -164,62 +164,70 @@ namespace addon class PeripheralEvent { public: - PeripheralEvent(void) : - m_event() + PeripheralEvent(void) { } PeripheralEvent(unsigned int peripheralIndex, unsigned int buttonIndex, JOYSTICK_STATE_BUTTON state) : - m_event() + m_type(PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON), + m_peripheralIndex(peripheralIndex), + m_driverIndex(buttonIndex), + m_buttonState(state) { - SetType(PERIPHERAL_EVENT_TYPE_DRIVER_BUTTON); - SetPeripheralIndex(peripheralIndex); - SetDriverIndex(buttonIndex); - SetButtonState(state); } PeripheralEvent(unsigned int peripheralIndex, unsigned int hatIndex, JOYSTICK_STATE_HAT state) : - m_event() + m_type(PERIPHERAL_EVENT_TYPE_DRIVER_HAT), + m_peripheralIndex(peripheralIndex), + m_driverIndex(hatIndex), + m_hatState(state) { - SetType(PERIPHERAL_EVENT_TYPE_DRIVER_HAT); - SetPeripheralIndex(peripheralIndex); - SetDriverIndex(hatIndex); - SetHatState(state); } PeripheralEvent(unsigned int peripheralIndex, unsigned int axisIndex, JOYSTICK_STATE_AXIS state) : - m_event() + m_type(PERIPHERAL_EVENT_TYPE_DRIVER_AXIS), + m_peripheralIndex(peripheralIndex), + m_driverIndex(axisIndex), + m_axisState(state) { - SetType(PERIPHERAL_EVENT_TYPE_DRIVER_AXIS); - SetPeripheralIndex(peripheralIndex); - SetDriverIndex(axisIndex); - SetAxisState(state); } explicit PeripheralEvent(const PERIPHERAL_EVENT& event) : - m_event(event) - { - } - - PERIPHERAL_EVENT_TYPE Type(void) const { return m_event.type; } - unsigned int PeripheralIndex(void) const { return m_event.peripheral_index; } - unsigned int DriverIndex(void) const { return m_event.driver_index; } - JOYSTICK_STATE_BUTTON ButtonState(void) const { return m_event.driver_button_state; } - JOYSTICK_STATE_HAT HatState(void) const { return m_event.driver_hat_state; } - JOYSTICK_STATE_AXIS AxisState(void) const { return m_event.driver_axis_state; } - JOYSTICK_STATE_MOTOR MotorState(void) const { return m_event.motor_state; } - - void SetType(PERIPHERAL_EVENT_TYPE type) { m_event.type = type; } - void SetPeripheralIndex(unsigned int index) { m_event.peripheral_index = index; } - void SetDriverIndex(unsigned int index) { m_event.driver_index = index; } - void SetButtonState(JOYSTICK_STATE_BUTTON state) { m_event.driver_button_state = state; } - void SetHatState(JOYSTICK_STATE_HAT state) { m_event.driver_hat_state = state; } - void SetAxisState(JOYSTICK_STATE_AXIS state) { m_event.driver_axis_state = state; } - void SetMotorState(JOYSTICK_STATE_MOTOR state) { m_event.motor_state = state; } + m_type(event.type), + m_peripheralIndex(event.peripheral_index), + m_driverIndex(event.driver_index), + m_buttonState(event.driver_button_state), + m_hatState(event.driver_hat_state), + m_axisState(event.driver_axis_state), + m_motorState(event.motor_state) + { + } + + PERIPHERAL_EVENT_TYPE Type(void) const { return m_type; } + unsigned int PeripheralIndex(void) const { return m_peripheralIndex; } + unsigned int DriverIndex(void) const { return m_driverIndex; } + JOYSTICK_STATE_BUTTON ButtonState(void) const { return m_buttonState; } + JOYSTICK_STATE_HAT HatState(void) const { return m_hatState; } + JOYSTICK_STATE_AXIS AxisState(void) const { return m_axisState; } + JOYSTICK_STATE_MOTOR MotorState(void) const { return m_motorState; } + + void SetType(PERIPHERAL_EVENT_TYPE type) { m_type = type; } + void SetPeripheralIndex(unsigned int index) { m_peripheralIndex = index; } + void SetDriverIndex(unsigned int index) { m_driverIndex = index; } + void SetButtonState(JOYSTICK_STATE_BUTTON state) { m_buttonState = state; } + void SetHatState(JOYSTICK_STATE_HAT state) { m_hatState = state; } + void SetAxisState(JOYSTICK_STATE_AXIS state) { m_axisState = state; } + void SetMotorState(JOYSTICK_STATE_MOTOR state) { m_motorState = state; } void ToStruct(PERIPHERAL_EVENT& event) const { - event = m_event; + event.type = m_type; + event.peripheral_index = m_peripheralIndex; + event.driver_index = m_driverIndex; + event.driver_button_state = m_buttonState; + event.driver_hat_state = m_hatState; + event.driver_axis_state = m_axisState; + event.motor_state = m_motorState; } static void FreeStruct(PERIPHERAL_EVENT& event) @@ -228,7 +236,13 @@ namespace addon } private: - PERIPHERAL_EVENT m_event; + PERIPHERAL_EVENT_TYPE m_type = PERIPHERAL_EVENT_TYPE_NONE; + unsigned int m_peripheralIndex = 0; + unsigned int m_driverIndex = 0; + JOYSTICK_STATE_BUTTON m_buttonState = JOYSTICK_STATE_BUTTON_UNPRESSED; + JOYSTICK_STATE_HAT m_hatState = JOYSTICK_STATE_HAT_UNPRESSED; + JOYSTICK_STATE_AXIS m_axisState = 0.0f; + JOYSTICK_STATE_MOTOR m_motorState = 0.0f; }; typedef PeripheralVector PeripheralEvents; @@ -298,9 +312,6 @@ namespace addon unsigned int MotorCount(void) const { return m_motorCount; } bool SupportsPowerOff(void) const { return m_supportsPowerOff; } - // Derived property: Counts are unknown if all are zero - bool AreElementCountsKnown(void) const { return m_buttonCount != 0 || m_hatCount != 0 || m_axisCount != 0; } - void SetProvider(const std::string& provider) { m_provider = provider; } void SetRequestedPort(int requestedPort) { m_requestedPort = requestedPort; } void SetButtonCount(unsigned int buttonCount) { m_buttonCount = buttonCount; } @@ -352,6 +363,9 @@ namespace addon * 2) a hat direction * 3) a semiaxis (either the positive or negative half of an axis) * 4) a motor + * 5) a keyboard key + * 6) a mouse button + * 7) a relative pointer direction * * The type determines the fields in use: * @@ -370,6 +384,15 @@ namespace addon * * Motor: * - driver index + * + * Key: + * - key code + * + * Mouse button: + * - driver index + * + * Relative pointer direction: + * - relative pointer direction */ struct DriverPrimitive { @@ -383,7 +406,8 @@ namespace addon m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), m_center(0), m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN), - m_range(1) + m_range(1), + m_relPointerDirection(JOYSTICK_DRIVER_RELPOINTER_UNKNOWN) { } @@ -397,12 +421,13 @@ namespace addon m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), m_center(0), m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN), - m_range(1) + m_range(1), + m_relPointerDirection(JOYSTICK_DRIVER_RELPOINTER_UNKNOWN) { } /*! - * \brief Construct a driver primitive representing a button + * \brief Construct a driver primitive representing a joystick button */ static DriverPrimitive CreateButton(unsigned int buttonIndex) { @@ -419,7 +444,8 @@ namespace addon m_hatDirection(direction), m_center(0), m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN), - m_range(1) + m_range(1), + m_relPointerDirection(JOYSTICK_DRIVER_RELPOINTER_UNKNOWN) { } @@ -433,7 +459,8 @@ namespace addon m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), m_center(center), m_semiAxisDirection(direction), - m_range(range) + m_range(range), + m_relPointerDirection(JOYSTICK_DRIVER_RELPOINTER_UNKNOWN) { } @@ -445,13 +472,52 @@ namespace addon return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR, motorIndex); } + /*! + * \brief Construct a driver primitive representing a key on a keyboard + */ + DriverPrimitive(std::string keycode) : + m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY), + m_driverIndex(0), + m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), + m_center(0), + m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN), + m_range(1), + m_keycode(std::move(keycode)), + m_relPointerDirection(JOYSTICK_DRIVER_RELPOINTER_UNKNOWN) + { + } + + /*! + * \brief Construct a driver primitive representing a mouse button + */ + static DriverPrimitive CreateMouseButton(JOYSTICK_DRIVER_MOUSE_INDEX buttonIndex) + { + return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON, static_cast(buttonIndex)); + } + + /*! + * \brief Construct a driver primitive representing one of the four + * direction in which a relative pointer can move + */ + DriverPrimitive(JOYSTICK_DRIVER_RELPOINTER_DIRECTION direction) : + m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION), + m_driverIndex(0), + m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), + m_center(0), + m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN), + m_range(1), + m_relPointerDirection(direction) + { + } + explicit DriverPrimitive(const JOYSTICK_DRIVER_PRIMITIVE& primitive) : m_type(primitive.type), m_driverIndex(0), m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), m_center(0), m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN), - m_range(1) + m_range(1), + m_relPointerDirection(JOYSTICK_DRIVER_RELPOINTER_UNKNOWN) { switch (m_type) { @@ -479,6 +545,21 @@ namespace addon m_driverIndex = primitive.motor.index; break; } + case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY: + { + m_keycode = primitive.key.keycode; + break; + } + case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON: + { + m_driverIndex = primitive.mouse.button; + break; + } + case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION: + { + m_relPointerDirection = primitive.relpointer.direction; + break; + } default: break; } @@ -490,6 +571,9 @@ namespace addon int Center(void) const { return m_center; } JOYSTICK_DRIVER_SEMIAXIS_DIRECTION SemiAxisDirection(void) const { return m_semiAxisDirection; } unsigned int Range(void) const { return m_range; } + const std::string& Keycode(void) const { return m_keycode; } + JOYSTICK_DRIVER_MOUSE_INDEX MouseIndex(void) const { return static_cast(m_driverIndex); } + JOYSTICK_DRIVER_RELPOINTER_DIRECTION RelPointerDirection(void) const { return m_relPointerDirection; } bool operator==(const DriverPrimitive& other) const { @@ -498,7 +582,6 @@ namespace addon switch (m_type) { case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: - case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: { return m_driverIndex == other.m_driverIndex; } @@ -514,6 +597,22 @@ namespace addon m_semiAxisDirection == other.m_semiAxisDirection && m_range == other.m_range; } + case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY: + { + return m_keycode == other.m_keycode; + } + case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: + { + return m_driverIndex == other.m_driverIndex; + } + case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON: + { + return m_driverIndex == other.m_driverIndex; + } + case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION: + { + return m_relPointerDirection == other.m_relPointerDirection; + } default: break; } @@ -550,6 +649,23 @@ namespace addon driver_primitive.motor.index = m_driverIndex; break; } + case JOYSTICK_DRIVER_PRIMITIVE_TYPE_KEY: + { + const size_t size = sizeof(driver_primitive.key.keycode); + std::strncpy(driver_primitive.key.keycode, m_keycode.c_str(), size - 1); + driver_primitive.key.keycode[size - 1] = '\0'; + break; + } + case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOUSE_BUTTON: + { + driver_primitive.mouse.button = static_cast(m_driverIndex); + break; + } + case JOYSTICK_DRIVER_PRIMITIVE_TYPE_RELPOINTER_DIRECTION: + { + driver_primitive.relpointer.direction = m_relPointerDirection; + break; + } default: break; } @@ -567,6 +683,8 @@ namespace addon int m_center; JOYSTICK_DRIVER_SEMIAXIS_DIRECTION m_semiAxisDirection; unsigned int m_range; + std::string m_keycode; + JOYSTICK_DRIVER_RELPOINTER_DIRECTION m_relPointerDirection; }; typedef PeripheralVector DriverPrimitives; @@ -584,6 +702,7 @@ namespace addon * 6) absolute pointer * 7) wheel * 8) throttle + * 9) keyboard key * * [1] All three driver primitives (buttons, hats and axes) have a state that * can be represented using a single scalar value. For this reason, @@ -598,7 +717,7 @@ namespace addon JoystickFeature(const std::string& name = "", JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN) : m_name(name), m_type(type), - m_primitives() + m_primitives{} { } @@ -672,4 +791,3 @@ namespace addon } /* namespace addon */ } /* namespace kodi */ - diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h index 8e688d7..637a991 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VFS.h @@ -547,7 +547,7 @@ namespace addon entries[i].properties = nullptr; } *retEntries = entries; - *num_entries = addonEntries.size(); + *num_entries = static_cast(addonEntries.size()); } return ret; } @@ -586,7 +586,7 @@ namespace addon strncpy(rootpath, cppRootPath.c_str(), ADDON_STANDARD_STRING_LENGTH); VFSDirEntry* entries = static_cast(malloc(sizeof(VFSDirEntry) * addonEntries.size())); - for (unsigned int i = 0; i < addonEntries.size(); ++i) + for (size_t i = 0; i < addonEntries.size(); ++i) { entries[i].label = strdup(addonEntries[i].Label().c_str()); entries[i].title = strdup(addonEntries[i].Title().c_str()); @@ -610,7 +610,7 @@ namespace addon entries[i].properties = nullptr; } *retEntries = entries; - *num_entries = addonEntries.size(); + *num_entries = static_cast(addonEntries.size()); } return ret; } diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h index eb4351e..8a8779a 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/VideoCodec.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2017 Team XBMC - * http://xbmc.org + * 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 diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h index 452085a..a2bef15 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Visualization.h @@ -745,7 +745,7 @@ namespace addon addon->toAddon.addonInstance->m_instanceData->toKodi.transfer_preset(addon->toKodi.kodiInstance, it.c_str()); } - return presets.size(); + return static_cast(presets.size()); } inline static int ADDON_GetActivePreset(const AddonInstance_Visualization* addon) -- cgit v1.2.3