From ffca21f2743a7b367fa212799c6e2fea6190dd5d Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 3 Mar 2015 16:53:59 +0100 Subject: initial commit for kodi master --- xbmc/addons/include/NOTE | 12 + xbmc/addons/include/xbmc_addon_cpp_dll.h | 191 ++++++++ xbmc/addons/include/xbmc_addon_dll.h | 55 +++ xbmc/addons/include/xbmc_addon_types.h | 64 +++ xbmc/addons/include/xbmc_audioenc_dll.h | 61 +++ xbmc/addons/include/xbmc_audioenc_types.h | 113 +++++ xbmc/addons/include/xbmc_codec_types.h | 55 +++ xbmc/addons/include/xbmc_epg_types.h | 96 ++++ xbmc/addons/include/xbmc_pvr_dll.h | 710 ++++++++++++++++++++++++++++++ xbmc/addons/include/xbmc_pvr_types.h | 415 +++++++++++++++++ xbmc/addons/include/xbmc_scr_dll.h | 45 ++ xbmc/addons/include/xbmc_scr_types.h | 53 +++ xbmc/addons/include/xbmc_stream_utils.hpp | 264 +++++++++++ xbmc/addons/include/xbmc_vis_dll.h | 55 +++ xbmc/addons/include/xbmc_vis_types.h | 111 +++++ 15 files changed, 2300 insertions(+) create mode 100644 xbmc/addons/include/NOTE create mode 100644 xbmc/addons/include/xbmc_addon_cpp_dll.h create mode 100644 xbmc/addons/include/xbmc_addon_dll.h create mode 100644 xbmc/addons/include/xbmc_addon_types.h create mode 100644 xbmc/addons/include/xbmc_audioenc_dll.h create mode 100644 xbmc/addons/include/xbmc_audioenc_types.h create mode 100644 xbmc/addons/include/xbmc_codec_types.h create mode 100644 xbmc/addons/include/xbmc_epg_types.h create mode 100644 xbmc/addons/include/xbmc_pvr_dll.h create mode 100644 xbmc/addons/include/xbmc_pvr_types.h create mode 100644 xbmc/addons/include/xbmc_scr_dll.h create mode 100644 xbmc/addons/include/xbmc_scr_types.h create mode 100644 xbmc/addons/include/xbmc_stream_utils.hpp create mode 100644 xbmc/addons/include/xbmc_vis_dll.h create mode 100644 xbmc/addons/include/xbmc_vis_types.h (limited to 'xbmc/addons/include') diff --git a/xbmc/addons/include/NOTE b/xbmc/addons/include/NOTE new file mode 100644 index 0000000..dbcc329 --- /dev/null +++ b/xbmc/addons/include/NOTE @@ -0,0 +1,12 @@ +NOTE: + +This directory contains independent Headers to build Add-on's +without the whole XBMC source tree. The Add-on itself can add +this headers to his source tree without dependencies to any +XBMC related classes or functions. + +Also this headers are never changed without a API Version +change. + +The current PVR API version can be found in xbmc_pvr_types.h: +XBMC_PVR_API_VERSION diff --git a/xbmc/addons/include/xbmc_addon_cpp_dll.h b/xbmc/addons/include/xbmc_addon_cpp_dll.h new file mode 100644 index 0000000..3944525 --- /dev/null +++ b/xbmc/addons/include/xbmc_addon_cpp_dll.h @@ -0,0 +1,191 @@ +#ifndef __XBMC_ADDON_CPP_H__ +#define __XBMC_ADDON_CPP_H__ + +/* + * 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_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.size() == 0) + 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.size() > 0) + { + (*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); + } +}; + +#endif diff --git a/xbmc/addons/include/xbmc_addon_dll.h b/xbmc/addons/include/xbmc_addon_dll.h new file mode 100644 index 0000000..fa6415f --- /dev/null +++ b/xbmc/addons/include/xbmc_addon_dll.h @@ -0,0 +1,55 @@ +#ifndef __XBMC_ADDON_DLL_H__ +#define __XBMC_ADDON_DLL_H__ + +/* + * 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 + * . + * + */ + +#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 + +#endif diff --git a/xbmc/addons/include/xbmc_addon_types.h b/xbmc/addons/include/xbmc_addon_types.h new file mode 100644 index 0000000..bd6cbe8 --- /dev/null +++ b/xbmc/addons/include/xbmc_addon_types.h @@ -0,0 +1,64 @@ +#ifndef __XBMC_ADDON_TYPES_H__ +#define __XBMC_ADDON_TYPES_H__ + +/* + * 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 + * . + * + */ + +#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 + +#endif diff --git a/xbmc/addons/include/xbmc_audioenc_dll.h b/xbmc/addons/include/xbmc_audioenc_dll.h new file mode 100644 index 0000000..01e8d12 --- /dev/null +++ b/xbmc/addons/include/xbmc_audioenc_dll.h @@ -0,0 +1,61 @@ +#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 + * . + * + */ + +#ifndef __XBMC_AUDIOENC_H__ +#define __XBMC_AUDIOENC_H__ + +#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; + }; +}; + +#endif diff --git a/xbmc/addons/include/xbmc_audioenc_types.h b/xbmc/addons/include/xbmc_audioenc_types.h new file mode 100644 index 0000000..aa527db --- /dev/null +++ b/xbmc/addons/include/xbmc_audioenc_types.h @@ -0,0 +1,113 @@ +#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 + * . + * + */ + +#ifndef __AUDIOENC_TYPES_H__ +#define __AUDIOENC_TYPES_H__ + +#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); + }; +} + +#endif diff --git a/xbmc/addons/include/xbmc_codec_types.h b/xbmc/addons/include/xbmc_codec_types.h new file mode 100644 index 0000000..98003e0 --- /dev/null +++ b/xbmc/addons/include/xbmc_codec_types.h @@ -0,0 +1,55 @@ +#ifndef __XBMC_CODEC_TYPES_H__ +#define __XBMC_CODEC_TYPES_H__ + +/* + * 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 + * . + * + */ + +#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 + +#endif + diff --git a/xbmc/addons/include/xbmc_epg_types.h b/xbmc/addons/include/xbmc_epg_types.h new file mode 100644 index 0000000..97cea40 --- /dev/null +++ b/xbmc/addons/include/xbmc_epg_types.h @@ -0,0 +1,96 @@ +#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 + + /*! + * @brief Representation of an EPG event. + */ + typedef struct EPG_TAG { + unsigned int iUniqueBroadcastId; /*!< @brief (required) identifier for this event */ + 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 * 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 */ + const char * strRecordingId; /*!< @brief (optional) unique id of the recording on the client which represents this event */ + } ATTRIBUTE_PACKED EPG_TAG; + +#ifdef __cplusplus +} +#endif diff --git a/xbmc/addons/include/xbmc_pvr_dll.h b/xbmc/addons/include/xbmc_pvr_dll.h new file mode 100644 index 0000000..3ad46fc --- /dev/null +++ b/xbmc/addons/include/xbmc_pvr_dll.h @@ -0,0 +1,710 @@ +/* + * 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 + * . + * + */ + +#ifndef __XBMC_PVR_H__ +#define __XBMC_PVR_H__ + +#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. + * @remarks Valid implementation required. + */ + 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. + * @remarks Valid implementation required. + */ + 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 libXBMC_gui.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 libXBMC_gui.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 libXBMC_gui.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); + + //@} + /** @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); + + /*! + * @return The channel number on the backend of the live stream that's currently being read. + * @remarks Required if bHandlesInputStream or bHandlesDemuxing is set to true. Return -1 if this add-on won't provide this function. + */ + int GetCurrentClientChannel(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(); + + /*! + * 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->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->GetCurrentClientChannel = GetCurrentClientChannel; + 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; + }; +}; + +#endif diff --git a/xbmc/addons/include/xbmc_pvr_types.h b/xbmc/addons/include/xbmc_pvr_types.h new file mode 100644 index 0000000..5285bd1 --- /dev/null +++ b/xbmc/addons/include/xbmc_pvr_types.h @@ -0,0 +1,415 @@ +#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 + * . + * + */ + +#ifndef __PVRCLIENT_TYPES_H__ +#define __PVRCLIENT_TYPES_H__ + +#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 + +/* 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 "1.9.4" + +/* min. PVR API version */ +#define XBMC_PVR_MIN_API_VERSION "1.9.4" + +#ifdef __cplusplus +extern "C" { +#endif + + /*! + * @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 a new, unsaved timer */ + 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; + + /*! + * @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 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 bSupportsRecordingFolders; /*!< @brief true if the backend supports timers / recordings in folders. */ + 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 */ + double dVideoBitrate; /*!< @brief (optional) video bitrate */ + double dAudioBitrate; /*!< @brief (optional) audio bitrate */ + double dDolbyBitrate; /*!< @brief (optional) dolby bitrate */ + } 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. */ + } 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 event. + */ + typedef struct PVR_TIMER { + unsigned int iClientIndex; /*!< @brief (required) the index of this timer given by the client */ + int iClientChannelUid; /*!< @brief (required) unique identifier of the channel to record on */ + time_t startTime; /*!< @brief (required) start time of the recording in UTC. instant timers that are sent to the add-on by xbmc will have this value set to 0 */ + time_t endTime; /*!< @brief (required) end time of the recording in UTC */ + PVR_TIMER_STATE state; /*!< @brief (required) the state of this timer */ + char strTitle[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) title of this timer */ + char strDirectory[PVR_ADDON_URL_STRING_LENGTH]; /*!< @brief (optional) the 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) lifetimer of this timer in days */ + bool bIsRepeating; /*!< @brief (optional) true if this is a recurring timer */ + time_t firstDay; /*!< @brief (optional) the first day this recording is active in case of a repeating event */ + int iWeekdays; /*!< @brief (optional) weekday mask */ + int iEpgUid; /*!< @brief (optional) epg event id */ + 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 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 */ + } 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*); + 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); + int (__cdecl* GetCurrentClientChannel)(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); + } PVRClient; + +#ifdef __cplusplus +} +#endif + +#endif //__PVRCLIENT_TYPES_H__ diff --git a/xbmc/addons/include/xbmc_scr_dll.h b/xbmc/addons/include/xbmc_scr_dll.h new file mode 100644 index 0000000..c4257b4 --- /dev/null +++ b/xbmc/addons/include/xbmc_scr_dll.h @@ -0,0 +1,45 @@ +#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 + * . + * + */ + +#ifndef __XBMC_SCR_H__ +#define __XBMC_SCR_H__ + +#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; + }; +}; + +#endif diff --git a/xbmc/addons/include/xbmc_scr_types.h b/xbmc/addons/include/xbmc_scr_types.h new file mode 100644 index 0000000..fec3040 --- /dev/null +++ b/xbmc/addons/include/xbmc_scr_types.h @@ -0,0 +1,53 @@ +#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 + * . + * + */ + +#ifndef __SCREENSAVER_TYPES_H__ +#define __SCREENSAVER_TYPES_H__ + +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); + }; +} + +#endif // __SCREENSAVER_TYPES_H__ diff --git a/xbmc/addons/include/xbmc_stream_utils.hpp b/xbmc/addons/include/xbmc_stream_utils.hpp new file mode 100644 index 0000000..927fe33 --- /dev/null +++ b/xbmc/addons/include/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/include/xbmc_vis_dll.h b/xbmc/addons/include/xbmc_vis_dll.h new file mode 100644 index 0000000..c65f844 --- /dev/null +++ b/xbmc/addons/include/xbmc_vis_dll.h @@ -0,0 +1,55 @@ +#ifndef __XBMC_VIS_H__ +#define __XBMC_VIS_H__ + +/* + * 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_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; + }; +}; + +#endif diff --git a/xbmc/addons/include/xbmc_vis_types.h b/xbmc/addons/include/xbmc_vis_types.h new file mode 100644 index 0000000..e6b0ccd --- /dev/null +++ b/xbmc/addons/include/xbmc_vis_types.h @@ -0,0 +1,111 @@ +/* + * 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 + * . + * + */ + +/* + Common data structures shared between XBMC and XBMC's visualisations + */ + +#ifndef __VISUALISATION_TYPES_H__ +#define __VISUALISATION_TYPES_H__ +#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)(); + }; +} + +#endif //__VISUALISATION_TYPES_H__ -- cgit v1.2.3