11 #include "addons/binary-addons/AddonInstanceHandler.h" 12 #include "addons/kodi-dev-kit/include/kodi/c-api/addon-instance/pvr.h" 13 #include "pvr/addons/PVRClientCapabilities.h" 14 #include "threads/Event.h" 28 class CPVRChannelGroup;
29 class CPVRChannelGroupMember;
30 class CPVRChannelGroups;
32 class CPVRProvidersContainer;
33 class CPVRClientMenuHook;
34 class CPVRClientMenuHooks;
39 class CPVRStreamProperties;
40 class CPVRTimerInfoTag;
42 class CPVRTimersContainer;
44 #define PVR_INVALID_CLIENT_ID (-2) 54 CPVRClient(
const ADDON::AddonInfoPtr& addonInfo, ADDON::AddonInstanceId instanceId,
int clientId);
57 void OnPreInstall()
override;
58 void OnPreUnInstall()
override;
219 PVR_ERROR IsRecordable(
const std::shared_ptr<const CPVREpgInfoTag>& tag,
220 bool& bIsRecordable)
const;
228 PVR_ERROR IsPlayable(
const std::shared_ptr<const CPVREpgInfoTag>& tag,
bool& bIsPlayable)
const;
448 std::vector<PVR_EDL_ENTRY>& edls);
691 static const char* ToString(
const PVR_ERROR error);
720 const std::shared_ptr<CPVREpgInfoTag>& tag);
729 const std::shared_ptr<CPVRChannel>& channel);
739 const std::shared_ptr<CPVRRecording>& recording,
749 const std::shared_ptr<CPVRTimerInfoTag>& timer);
796 void ResetProperties();
802 bool GetAddonProperties();
808 bool GetAddonNameStringProperties();
817 unsigned int iPropertyCount,
825 bool CanPlayChannel(
const std::shared_ptr<CPVRChannel>& channel)
const;
830 void StopRunningInstance();
841 PVR_ERROR DoAddonCall(
const char* strFunctionName,
842 const std::function<
PVR_ERROR(
const AddonInstance*)>&
function,
843 bool bIsImplemented =
true,
844 bool bCheckReadyToUse =
true)
const;
853 static void HandleAddonCallback(
const char* strFunctionName,
855 const std::function<
void(
CPVRClient* client)>&
function,
856 bool bForceCall =
false);
869 static void cb_transfer_channel_group(
void* kodiInstance,
879 static void cb_transfer_channel_group_member(
void* kodiInstance,
889 static void cb_transfer_epg_entry(
void* kodiInstance,
899 static void cb_transfer_channel_entry(
void* kodiInstance,
909 static void cb_transfer_provider_entry(
void* kodiInstance,
919 static void cb_transfer_timer_entry(
void* kodiInstance,
929 static void cb_transfer_recording_entry(
void* kodiInstance,
938 static void cb_add_menu_hook(
void* kodiInstance,
const PVR_MENUHOOK* hook);
947 static void cb_recording_notification(
void* kodiInstance,
949 const char* strFileName,
956 static void cb_trigger_channel_update(
void* kodiInstance);
962 static void cb_trigger_provider_update(
void* kodiInstance);
968 static void cb_trigger_timer_update(
void* kodiInstance);
974 static void cb_trigger_recording_update(
void* kodiInstance);
980 static void cb_trigger_channel_groups_update(
void* kodiInstance);
987 static void cb_trigger_epg_update(
void* kodiInstance,
unsigned int iChannelUid);
994 static void cb_free_demux_packet(
void* kodiInstance,
DEMUX_PACKET* pPacket);
1002 static DEMUX_PACKET* cb_allocate_demux_packet(
void* kodiInstance,
int iDataSize = 0);
1012 static void cb_connection_state_change(
void* kodiInstance,
1013 const char* strConnectionString,
1015 const char* strMessage);
1030 static PVR_CODEC cb_get_codec_by_name(
const void* kodiInstance,
const char* strCodecName);
1033 const int m_iClientId;
1036 std::atomic<bool> m_bBlockAddonCalls;
1037 mutable std::atomic<int> m_iAddonCalls;
1038 mutable CEvent m_allAddonCallsFinished;
1043 std::vector<std::shared_ptr<CPVRTimerType>>
1045 mutable int m_iPriority;
1046 mutable bool m_bPriorityFetched;
1049 std::string m_strBackendName;
1050 std::string m_strBackendVersion;
1051 std::string m_strConnectionString;
1052 std::string m_strBackendHostname;
1054 std::shared_ptr<CPVRClientMenuHooks> m_menuhooks;
1057 std::string m_strUserPath;
1058 std::string m_strClientPath;
1060 mutable CCriticalSection m_critSection;
PVR_ERROR GetTimersAmount(int &iTimers)
Get the total amount of timers from the backend.
Definition: PVRClient.cpp:1015
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
PVR_ERROR SeekTime(double time, bool backwards, double *startpts)
Notify the pvr addon/demuxer that Kodi wishes to seek the stream by time.
Definition: PVRClient.cpp:1129
std::shared_ptr< CPVRClientMenuHooks > GetMenuHooks()
Get the client's menu hooks.
Definition: PVRClient.cpp:1494
PVR_ERROR CallSettingsMenuHook(const CPVRClientMenuHook &hook)
Call one of the settings menu hooks of the client.
Definition: PVRClient.cpp:1566
PVR_ERROR GetChannelGroups(CPVRChannelGroups *groups)
Request the list of all channel groups from the backend.
Definition: PVRClient.cpp:789
PVR_ERROR SetEPGMaxFutureDays(int iFutureDays)
Tell the client the future time frame to use when notifying epg events back to Kodi.
Definition: PVRClient.cpp:611
bool ReadyToUse() const
Definition: PVRClient.cpp:226
PVR_ERROR CallTimerMenuHook(const CPVRClientMenuHook &hook, const std::shared_ptr< CPVRTimerInfoTag > &timer)
Call one of the timer menu hooks of the client.
Definition: PVRClient.cpp:1550
PVR_ERROR CallEpgTagMenuHook(const CPVRClientMenuHook &hook, const std::shared_ptr< CPVREpgInfoTag > &tag)
Call one of the EPG tag menu hooks of the client.
Definition: PVRClient.cpp:1502
Definition: PVRRecordings.h:28
PVR_ERROR
Definition: pvr_general.h:34
PVR_ERROR RenameRecording(const CPVRRecording &recording)
Rename a recording on the backend.
Definition: PVRClient.cpp:917
PVR_ERROR SetSpeed(int speed)
Notify the pvr addon/demuxer that Kodi wishes to change playback speed.
Definition: PVRClient.cpp:1418
void Destroy()
Destroy the instance of this add-on.
Definition: PVRClient.cpp:187
PVR_ERROR GetRecordedStreamLength(int64_t &iLength)
Get the length of the currently playing recording stream, if any.
Definition: PVRClient.cpp:1146
PVR_ERROR GetRecordingEdl(const CPVRRecording &recording, std::vector< PVR_EDL_ENTRY > &edls)
Retrieve the edit decision list (EDL) from the backend.
Definition: PVRClient.cpp:979
Definition: PVRStreamProperties.h:18
PVR_ERROR GetDriveSpace(uint64_t &iTotal, uint64_t &iUsed)
Get the disk space reported by the server.
Definition: PVRClient.cpp:505
"C" PVR add-on descramble information.
Definition: pvr_channels.h:91
"C" PVR add-on channel group member.
Definition: pvr_channel_groups.h:44
"C" PVR add-on recording.
Definition: pvr_recordings.h:109
Definition: ContextMenuManager.h:24
PVR_ERROR RenameChannel(const std::shared_ptr< CPVRChannel > &channel)
Request the client to rename given channel.
Definition: PVRClient.cpp:568
"C" PVR add-on channel group member.
Definition: pvr_epg.h:622
"C" PVR add-on channel.
Definition: pvr_channels.h:40
PVR_ERROR CanSeekStream(bool &bCanSeek) const
Check whether PVR backend supports seeking for the currently playing stream.
Definition: PVRClient.cpp:1443
PVR_ERROR OpenRecordedStream(const std::shared_ptr< CPVRRecording > &recording)
Open a recording on the server.
Definition: PVRClient.cpp:1375
void SetPriority(int iPriority)
Set a new priority for this client.
Definition: PVRClient.cpp:1578
PVR_ERROR SignalQuality(int channelUid, PVR_SIGNAL_STATUS &qualityinfo)
Get the signal quality of the stream that's currently open.
Definition: PVRClient.cpp:1155
PVR_ERROR SeekRecordedStream(int64_t iFilePosition, int iWhence, int64_t &iPosition)
Seek in a recording stream on a backend.
Definition: PVRClient.cpp:1120
PVR_ERROR DemuxFlush()
Flush all data that's currently in the demultiplexer buffer in the add-on.
Definition: PVRClient.cpp:1247
const std::string & GetBackendHostname() const
the ip address or alias of the pvr backend server
Definition: PVRClient.cpp:482
PVR_ERROR GetStreamReadChunkSize(int &iChunkSize)
Obtain the chunk size to use when reading streams.
Definition: PVRClient.cpp:1081
PVR_ERROR UpdateTimer(const CPVRTimerInfoTag &timer)
Update the timer information on the server.
Definition: PVRClient.cpp:1062
AddonInstance_PVR * GetInstanceInterface()
Get the interface table used between addon and Kodi.
Definition: PVRClient.h:790
PVR_ERROR DemuxAbort()
Abort the demultiplexer thread in the add-on.
Definition: PVRClient.cpp:1236
A container class for channel groups.
Definition: PVRChannelGroups.h:26
PVR_ERROR OnSystemSleep()
Propagate power management events to this add-on.
Definition: PVRClient.cpp:1468
PVR_ERROR DemuxReset()
Reset the demultiplexer in the add-on.
Definition: PVRClient.cpp:1225
PVR_CONNECTION_STATE
Definition: pvr_general.h:81
PVR_ERROR AddTimer(const CPVRTimerInfoTag &timer)
Add a timer on the backend.
Definition: PVRClient.cpp:1038
void Continue()
Continue this add-on instance. Client add-on access is okay again after this call.
Definition: PVRClient.cpp:215
PVR_ERROR OpenDialogChannelSettings(const std::shared_ptr< CPVRChannel > &channel)
Request the client to open dialog about given channel settings.
Definition: PVRClient.cpp:544
PVR_ERROR GetChannelGroupMembers(CPVRChannelGroup *group, std::vector< std::shared_ptr< CPVRChannelGroupMember >> &groupMembers)
Request the list of all group members from the backend.
Definition: PVRClient.cpp:801
void SetConnectionState(PVR_CONNECTION_STATE state)
Sets the backend connection state.
Definition: PVRClient.cpp:237
PVR_CONNECTION_STATE GetConnectionState() const
Gets the backend connection state.
Definition: PVRClient.cpp:231
PVR_ERROR DeleteAllRecordingsFromTrash()
Delete all recordings permanent which in the deleted folder on the backend.
Definition: PVRClient.cpp:907
Definition: AddonInstanceHandler.h:33
void Stop()
Stop this add-on instance. No more client add-on access after this call.
Definition: PVRClient.cpp:209
const std::string & GetBackendVersion() const
Definition: PVRClient.cpp:477
Definition: PVRClientCapabilities.h:21
PVR_ERROR ReadRecordedStream(void *lpBuf, int64_t uiBufSize, int &iRead)
Read from an open recording stream.
Definition: PVRClient.cpp:1101
"C" Times of playing stream (Live TV and recordings)
Definition: pvr_stream.h:144
const std::string & GetConnectionString() const
Definition: PVRClient.cpp:487
PVR_ERROR SetRecordingLifetime(const CPVRRecording &recording)
Set the lifetime of a recording on the backend.
Definition: PVRClient.cpp:929
PVR_ERROR PauseStream(bool bPaused)
(Un)Pause a stream.
Definition: PVRClient.cpp:1410
PVR_ERROR GetChannelGroupsAmount(int &iGroups)
Get the total amount of channel groups from the backend.
Definition: PVRClient.cpp:778
PVR_ERROR UndeleteRecording(const CPVRRecording &recording)
Undelete a recording on the backend.
Definition: PVRClient.cpp:895
ADDON_STATUS Create()
Initialise the instance of this add-on.
Definition: PVRClient.cpp:167
"C" Representation of a named value.
Definition: pvr_defines.h:56
PVR_ERROR IsRealTimeStream(bool &bRealTime) const
Check whether the currently playing stream, if any, is a real-time stream.
Definition: PVRClient.cpp:1459
Definition: PVRTimerInfoTag.h:33
"C" PVR add-on signal status information.
Definition: pvr_channels.h:63
ADDON_STATUS
Definition: addon_base.h:137
PVR_ERROR SetRecordingLastPlayedPosition(const CPVRRecording &recording, int lastplayedposition)
Set the last watched position of a recording on the backend.
Definition: PVRClient.cpp:953
PVR_ERROR GetChannels(bool bRadio, std::vector< std::shared_ptr< CPVRChannel >> &channels)
Request the list of all channels from the backend.
Definition: PVRClient.cpp:845
PVR_ERROR SetEPGMaxPastDays(int iPastDays)
Tell the client the past time frame to use when notifying epg events back to Kodi.
Definition: PVRClient.cpp:601
PVR_ERROR GetRecordingLastPlayedPosition(const CPVRRecording &recording, int &iPosition)
Retrieve the last watched position of a recording on the backend.
Definition: PVRClient.cpp:966
PVR_ERROR GetEPGForChannel(int iChannelUid, CPVREpg *epg, time_t start, time_t end)
Request an EPG table for a channel from the client.
Definition: PVRClient.cpp:582
PVR_ERROR GetProvidersAmount(int &iProviders)
Get the total amount of providers from the backend.
Definition: PVRClient.cpp:817
PVR_ERROR GetRecordingStreamProperties(const std::shared_ptr< CPVRRecording > &recording, CPVRStreamProperties &props)
Fill the given container with the properties required for playback of the given recording. Values are obtained from the PVR backend.
Definition: PVRClient.cpp:1195
PVR_ERROR GetProviders(CPVRProvidersContainer &providers)
Request the list of all providers from the backend.
Definition: PVRClient.cpp:825
int GetPriority() const
Get the priority of this client. Larger value means higher priority.
Definition: PVRClient.cpp:1592
PVR_ERROR GetChannelStreamProperties(const std::shared_ptr< CPVRChannel > &channel, CPVRStreamProperties &props)
Fill the given container with the properties required for playback of the given channel. Values are obtained from the PVR backend.
Definition: PVRClient.cpp:1172
PVR_ERROR GetTimerTypes(std::vector< std::shared_ptr< CPVRTimerType >> &results) const
Get all timer types supported by the backend.
Definition: PVRClient.cpp:1074
Definition: PVRRecording.h:52
Definition: SmartPlayList.cpp:137
Definition: demux_packet.h:45
PVR_ERROR GetChannelsAmount(int &iChannels)
Get the total amount of channels from the backend.
Definition: PVRClient.cpp:837
"C" PVR add-on channel group.
Definition: pvr_channel_groups.h:30
PVR_ERROR DemuxRead(DemuxPacket *&packet)
Read a packet from the demultiplexer.
Definition: PVRClient.cpp:1258
PVR_ERROR GetStreamProperties(PVR_STREAM_PROPERTIES *pProperties)
Get the stream properties of the stream that's currently being read.
Definition: PVRClient.cpp:1218
"C" Stream properties
Definition: pvr_stream.h:114
PVR_ERROR SeekLiveStream(int64_t iFilePosition, int iWhence, int64_t &iPosition)
Seek in a live stream on a backend.
Definition: PVRClient.cpp:1111
PVR_ERROR CanPauseStream(bool &bCanPause) const
Check whether PVR backend supports pausing the currently playing stream.
Definition: PVRClient.cpp:1434
const std::string & GetBackendName() const
Definition: PVRClient.cpp:472
"C" PVR add-on timer event.
Definition: pvr_timers.h:339
PVR_ERROR CallRecordingMenuHook(const CPVRClientMenuHook &hook, const std::shared_ptr< CPVRRecording > &recording, bool bDeleted)
Call one of the recording menu hooks of the client.
Definition: PVRClient.cpp:1533
const std::string GetFriendlyName() const
A friendly name used to uniquely identify the addon instance.
Definition: PVRClient.cpp:492
PVR_ERROR OpenLiveStream(const std::shared_ptr< CPVRChannel > &channel)
Open a live stream on the server.
Definition: PVRClient.cpp:1350
PVR_CONNECTION_STATE GetPreviousConnectionState() const
Gets the backend's previous connection state.
Definition: PVRClient.cpp:263
Definition: DemuxPacket.h:22
PVR_ERROR GetRecordingsAmount(bool deleted, int &iRecordings)
Get the total amount of recordings from the backend.
Definition: PVRClient.cpp:858
PVR_ERROR GetRecordingSize(const CPVRRecording &recording, int64_t &sizeInBytes)
Retrieve the size of a recording on the backend.
Definition: PVRClient.cpp:1003
"C" PVR add-on provider.
Definition: pvr_providers.h:79
PVR_ERROR DeleteRecording(const CPVRRecording &recording)
Delete a recording on the backend.
Definition: PVRClient.cpp:883
const CPVRClientCapabilities & GetClientCapabilities() const
Query this add-on's capabilities.
Definition: PVRClient.h:136
Definition: pvr_stream.h:96
PVR_ERROR OpenDialogChannelAdd(const std::shared_ptr< CPVRChannel > &channel)
Request the client to open dialog about given channel to add.
Definition: PVRClient.cpp:532
Definition: PVRProviders.h:23
PVR_ERROR ReadLiveStream(void *lpBuf, int64_t uiBufSize, int &iRead)
Read from an open live stream.
Definition: PVRClient.cpp:1091
bool IsEnabled() const
Check whether this client is enabled, according to its instance/add-on configuration.
Definition: PVRClient.cpp:275
PVR_ERROR DeleteChannel(const std::shared_ptr< CPVRChannel > &channel)
Request the client to delete given channel.
Definition: PVRClient.cpp:556
PVR_ERROR CallChannelMenuHook(const CPVRClientMenuHook &hook, const std::shared_ptr< CPVRChannel > &channel)
Call one of the channel menu hooks of the client.
Definition: PVRClient.cpp:1517
EPG_EVENT_STATE
Definition: pvr_epg.h:601
void ReCreate()
Destroy and recreate this add-on.
Definition: PVRClient.cpp:220
PVR_ERROR GetTimers(CPVRTimersContainer *results)
Request the list of all timers from the backend.
Definition: PVRClient.cpp:1026
Definition: PVRTimers.h:32
Handle used to return data from the PVR add-on to CPVRClient.
Definition: pvr_defines.h:65
PVR_ERROR CloseRecordedStream()
Close an open recording stream.
Definition: PVRClient.cpp:1402
int GetID() const
Definition: PVRClient.cpp:290
Definition: PVRChannelGroup.h:46
PVR_ERROR FillBuffer(bool mode)
Notify the pvr addon/demuxer that Kodi wishes to fill demux queue.
Definition: PVRClient.cpp:1426
Definition: PVRClient.h:51
PVR_ERROR CloseLiveStream()
Close an open live stream.
Definition: PVRClient.cpp:1394
bool IgnoreClient() const
Check whether this client should be ignored.
Definition: PVRClient.cpp:269
PVR_ERROR StartChannelScan()
Start a channel scan on the server.
Definition: PVRClient.cpp:524
PVR_ERROR GetRecordings(CPVRRecordings *results, bool deleted)
Request the list of all recordings from the backend.
Definition: PVRClient.cpp:870
PVR_ERROR DeleteTimer(const CPVRTimerInfoTag &timer, bool bForce=false)
Delete a timer on the backend.
Definition: PVRClient.cpp:1050
PVR_ERROR GetStreamTimes(PVR_STREAM_TIMES *times)
Get Stream times for the currently playing stream, if any (will be moved to inputstream).
Definition: PVRClient.cpp:1452
PVR_ERROR GetDescrambleInfo(int channelUid, PVR_DESCRAMBLE_INFO &descrambleinfo) const
Get the descramble information of the stream that's currently open.
Definition: PVRClient.cpp:1162
PVR_ERROR GetEpgTagEdl(const std::shared_ptr< const CPVREpgInfoTag > &epgTag, std::vector< PVR_EDL_ENTRY > &edls)
Retrieve the edit decision list (EDL) from the backend.
Definition: PVRClient.cpp:755
PVR_ERROR GetLiveStreamLength(int64_t &iLength)
Get the length of the currently playing live stream, if any.
Definition: PVRClient.cpp:1137
PVR_ERROR SetRecordingPlayCount(const CPVRRecording &recording, int count)
Set the play count of a recording on the backend.
Definition: PVRClient.cpp:941
PVR_ERROR GetEpgTagStreamProperties(const std::shared_ptr< CPVREpgInfoTag > &tag, CPVRStreamProperties &props)
Fill the given container with the properties required for playback of the given EPG tag...
Definition: PVRClient.cpp:736