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" 29 class CPVRChannelGroup;
30 class CPVRChannelGroupMember;
31 class CPVRChannelGroups;
33 class CPVRProvidersContainer;
34 class CPVRClientMenuHook;
35 class CPVRClientMenuHooks;
40 class CPVRStreamProperties;
41 class CPVRTimerInfoTag;
43 class CPVRTimersContainer;
45 #define PVR_INVALID_CLIENT_ID (-2) 55 CPVRClient(
const ADDON::AddonInfoPtr& addonInfo, ADDON::AddonInstanceId instanceId,
int clientId);
58 void OnPreInstall()
override;
59 void OnPreUnInstall()
override;
220 PVR_ERROR IsRecordable(
const std::shared_ptr<const CPVREpgInfoTag>& tag,
221 bool& bIsRecordable)
const;
229 PVR_ERROR IsPlayable(
const std::shared_ptr<const CPVREpgInfoTag>& tag,
bool& bIsPlayable)
const;
449 std::vector<PVR_EDL_ENTRY>& edls);
501 const std::vector<std::shared_ptr<CPVRTimerType>>&
GetTimerTypes()
const;
697 static const char* ToString(
const PVR_ERROR error);
726 const std::shared_ptr<CPVREpgInfoTag>& tag);
735 const std::shared_ptr<CPVRChannel>& channel);
745 const std::shared_ptr<CPVRRecording>& recording,
755 const std::shared_ptr<CPVRTimerInfoTag>& timer);
802 void ResetProperties();
808 bool GetAddonProperties();
814 bool GetAddonNameStringProperties();
823 unsigned int iPropertyCount,
831 bool CanPlayChannel(
const std::shared_ptr<CPVRChannel>& channel)
const;
836 void StopRunningInstance();
847 PVR_ERROR DoAddonCall(
const char* strFunctionName,
848 const std::function<
PVR_ERROR(
const AddonInstance*)>&
function,
849 bool bIsImplemented =
true,
850 bool bCheckReadyToUse =
true)
const;
859 static void HandleAddonCallback(
const char* strFunctionName,
861 const std::function<
void(
CPVRClient* client)>&
function,
862 bool bForceCall =
false);
875 static void cb_transfer_channel_group(
void* kodiInstance,
885 static void cb_transfer_channel_group_member(
void* kodiInstance,
895 static void cb_transfer_epg_entry(
void* kodiInstance,
905 static void cb_transfer_channel_entry(
void* kodiInstance,
915 static void cb_transfer_provider_entry(
void* kodiInstance,
925 static void cb_transfer_timer_entry(
void* kodiInstance,
935 static void cb_transfer_recording_entry(
void* kodiInstance,
944 static void cb_add_menu_hook(
void* kodiInstance,
const PVR_MENUHOOK* hook);
953 static void cb_recording_notification(
void* kodiInstance,
955 const char* strFileName,
962 static void cb_trigger_channel_update(
void* kodiInstance);
968 static void cb_trigger_provider_update(
void* kodiInstance);
974 static void cb_trigger_timer_update(
void* kodiInstance);
980 static void cb_trigger_recording_update(
void* kodiInstance);
986 static void cb_trigger_channel_groups_update(
void* kodiInstance);
993 static void cb_trigger_epg_update(
void* kodiInstance,
unsigned int iChannelUid);
1000 static void cb_free_demux_packet(
void* kodiInstance,
DEMUX_PACKET* pPacket);
1008 static DEMUX_PACKET* cb_allocate_demux_packet(
void* kodiInstance,
int iDataSize = 0);
1018 static void cb_connection_state_change(
void* kodiInstance,
1019 const char* strConnectionString,
1021 const char* strMessage);
1036 static PVR_CODEC cb_get_codec_by_name(
const void* kodiInstance,
const char* strCodecName);
1039 const int m_iClientId;
1042 std::atomic<bool> m_bBlockAddonCalls;
1043 mutable std::atomic<int> m_iAddonCalls;
1044 mutable CEvent m_allAddonCallsFinished;
1049 std::vector<std::shared_ptr<CPVRTimerType>>
1051 mutable std::optional<int> m_priority;
1054 std::string m_strBackendName;
1055 std::string m_strBackendVersion;
1056 std::string m_strConnectionString;
1057 std::string m_strBackendHostname;
1059 std::shared_ptr<CPVRClientMenuHooks> m_menuhooks;
1062 std::string m_strUserPath;
1063 std::string m_strClientPath;
1065 mutable CCriticalSection m_critSection;
PVR_ERROR GetTimersAmount(int &iTimers)
Get the total amount of timers from the backend.
Definition: PVRClient.cpp:934
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:1161
std::shared_ptr< CPVRClientMenuHooks > GetMenuHooks()
Get the client's menu hooks.
Definition: PVRClient.cpp:1532
PVR_ERROR CallSettingsMenuHook(const CPVRClientMenuHook &hook)
Call one of the settings menu hooks of the client.
Definition: PVRClient.cpp:1604
PVR_ERROR GetChannelGroups(CPVRChannelGroups *groups)
Request the list of all channel groups from the backend.
Definition: PVRClient.cpp:708
PVR_ERROR SetEPGMaxFutureDays(int iFutureDays)
Tell the client the future time frame to use when notifying epg events back to Kodi.
Definition: PVRClient.cpp:530
bool ReadyToUse() const
Definition: PVRClient.cpp:234
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:1588
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:1540
const std::vector< std::shared_ptr< CPVRTimerType > > & GetTimerTypes() const
Get the timer types supported by the backend, without updating them from the backend.
Definition: PVRClient.cpp:993
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:836
PVR_ERROR SetSpeed(int speed)
Notify the pvr addon/demuxer that Kodi wishes to change playback speed.
Definition: PVRClient.cpp:1456
void Destroy()
Destroy the instance of this add-on.
Definition: PVRClient.cpp:195
PVR_ERROR GetRecordedStreamLength(int64_t &iLength)
Get the length of the currently playing recording stream, if any.
Definition: PVRClient.cpp:1178
PVR_ERROR GetRecordingEdl(const CPVRRecording &recording, std::vector< PVR_EDL_ENTRY > &edls)
Retrieve the edit decision list (EDL) from the backend.
Definition: PVRClient.cpp:898
Definition: PVRStreamProperties.h:18
PVR_ERROR GetDriveSpace(uint64_t &iTotal, uint64_t &iUsed)
Get the disk space reported by the server.
Definition: PVRClient.cpp:424
"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:487
"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:1481
PVR_ERROR OpenRecordedStream(const std::shared_ptr< CPVRRecording > &recording)
Open a recording on the server.
Definition: PVRClient.cpp:1413
void SetPriority(int iPriority)
Set a new priority for this client.
Definition: PVRClient.cpp:1616
PVR_ERROR SignalQuality(int channelUid, PVR_SIGNAL_STATUS &qualityinfo)
Get the signal quality of the stream that's currently open.
Definition: PVRClient.cpp:1187
PVR_ERROR SeekRecordedStream(int64_t iFilePosition, int iWhence, int64_t &iPosition)
Seek in a recording stream on a backend.
Definition: PVRClient.cpp:1152
PVR_ERROR DemuxFlush()
Flush all data that's currently in the demultiplexer buffer in the add-on.
Definition: PVRClient.cpp:1279
const std::string & GetBackendHostname() const
the ip address or alias of the pvr backend server
Definition: PVRClient.cpp:401
PVR_ERROR GetStreamReadChunkSize(int &iChunkSize)
Obtain the chunk size to use when reading streams.
Definition: PVRClient.cpp:1113
PVR_ERROR UpdateTimer(const CPVRTimerInfoTag &timer)
Update the timer information on the server.
Definition: PVRClient.cpp:981
AddonInstance_PVR * GetInstanceInterface()
Get the interface table used between addon and Kodi.
Definition: PVRClient.h:796
PVR_ERROR DemuxAbort()
Abort the demultiplexer thread in the add-on.
Definition: PVRClient.cpp:1268
A container class for channel groups.
Definition: PVRChannelGroups.h:30
PVR_ERROR OnSystemSleep()
Propagate power management events to this add-on.
Definition: PVRClient.cpp:1506
PVR_ERROR DemuxReset()
Reset the demultiplexer in the add-on.
Definition: PVRClient.cpp:1257
PVR_CONNECTION_STATE
Definition: pvr_general.h:81
PVR_ERROR AddTimer(const CPVRTimerInfoTag &timer)
Add a timer on the backend.
Definition: PVRClient.cpp:957
void Continue()
Continue this add-on instance. Client add-on access is okay again after this call.
Definition: PVRClient.cpp:223
PVR_ERROR UpdateTimerTypes()
Update all timer types supported by the backend.
Definition: PVRClient.cpp:999
PVR_ERROR OpenDialogChannelSettings(const std::shared_ptr< CPVRChannel > &channel)
Request the client to open dialog about given channel settings.
Definition: PVRClient.cpp:463
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:720
void SetConnectionState(PVR_CONNECTION_STATE state)
Sets the backend connection state.
Definition: PVRClient.cpp:245
PVR_CONNECTION_STATE GetConnectionState() const
Gets the backend connection state.
Definition: PVRClient.cpp:239
PVR_ERROR DeleteAllRecordingsFromTrash()
Delete all recordings permanent which in the deleted folder on the backend.
Definition: PVRClient.cpp:826
Definition: AddonInstanceHandler.h:33
void Stop()
Stop this add-on instance. No more client add-on access after this call.
Definition: PVRClient.cpp:217
const std::string & GetBackendVersion() const
Definition: PVRClient.cpp:396
Definition: PVRClientCapabilities.h:21
PVR_ERROR ReadRecordedStream(void *lpBuf, int64_t uiBufSize, int &iRead)
Read from an open recording stream.
Definition: PVRClient.cpp:1133
"C" Times of playing stream (Live TV and recordings)
Definition: pvr_stream.h:144
const std::string & GetConnectionString() const
Definition: PVRClient.cpp:406
PVR_ERROR SetRecordingLifetime(const CPVRRecording &recording)
Set the lifetime of a recording on the backend.
Definition: PVRClient.cpp:848
PVR_ERROR PauseStream(bool bPaused)
(Un)Pause a stream.
Definition: PVRClient.cpp:1448
PVR_ERROR GetChannelGroupsAmount(int &iGroups)
Get the total amount of channel groups from the backend.
Definition: PVRClient.cpp:697
PVR_ERROR UndeleteRecording(const CPVRRecording &recording)
Undelete a recording on the backend.
Definition: PVRClient.cpp:814
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:1497
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:872
PVR_ERROR GetChannels(bool bRadio, std::vector< std::shared_ptr< CPVRChannel >> &channels)
Request the list of all channels from the backend.
Definition: PVRClient.cpp:764
PVR_ERROR SetEPGMaxPastDays(int iPastDays)
Tell the client the past time frame to use when notifying epg events back to Kodi.
Definition: PVRClient.cpp:520
PVR_ERROR GetRecordingLastPlayedPosition(const CPVRRecording &recording, int &iPosition)
Retrieve the last watched position of a recording on the backend.
Definition: PVRClient.cpp:885
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:501
PVR_ERROR GetProvidersAmount(int &iProviders)
Get the total amount of providers from the backend.
Definition: PVRClient.cpp:736
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:1227
PVR_ERROR GetProviders(CPVRProvidersContainer &providers)
Request the list of all providers from the backend.
Definition: PVRClient.cpp:744
int GetPriority() const
Get the priority of this client. Larger value means higher priority.
Definition: PVRClient.cpp:1630
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:1204
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:756
"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:1290
PVR_ERROR GetStreamProperties(PVR_STREAM_PROPERTIES *pProperties)
Get the stream properties of the stream that's currently being read.
Definition: PVRClient.cpp:1250
"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:1143
PVR_ERROR CanPauseStream(bool &bCanPause) const
Check whether PVR backend supports pausing the currently playing stream.
Definition: PVRClient.cpp:1472
const std::string & GetBackendName() const
Definition: PVRClient.cpp:391
"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:1571
const std::string GetFriendlyName() const
A friendly name used to uniquely identify the addon instance.
Definition: PVRClient.cpp:411
PVR_ERROR OpenLiveStream(const std::shared_ptr< CPVRChannel > &channel)
Open a live stream on the server.
Definition: PVRClient.cpp:1388
PVR_CONNECTION_STATE GetPreviousConnectionState() const
Gets the backend's previous connection state.
Definition: PVRClient.cpp:271
Definition: DemuxPacket.h:22
PVR_ERROR GetRecordingsAmount(bool deleted, int &iRecordings)
Get the total amount of recordings from the backend.
Definition: PVRClient.cpp:777
PVR_ERROR GetRecordingSize(const CPVRRecording &recording, int64_t &sizeInBytes)
Retrieve the size of a recording on the backend.
Definition: PVRClient.cpp:922
"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:802
const CPVRClientCapabilities & GetClientCapabilities() const
Query this add-on's capabilities.
Definition: PVRClient.h:137
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:451
Definition: PVRProviders.h:23
PVR_ERROR ReadLiveStream(void *lpBuf, int64_t uiBufSize, int &iRead)
Read from an open live stream.
Definition: PVRClient.cpp:1123
bool IsEnabled() const
Check whether this client is enabled, according to its instance/add-on configuration.
Definition: PVRClient.cpp:283
PVR_ERROR DeleteChannel(const std::shared_ptr< CPVRChannel > &channel)
Request the client to delete given channel.
Definition: PVRClient.cpp:475
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:1555
EPG_EVENT_STATE
Definition: pvr_epg.h:601
void ReCreate()
Destroy and recreate this add-on.
Definition: PVRClient.cpp:228
PVR_ERROR GetTimers(CPVRTimersContainer *results)
Request the list of all timers from the backend.
Definition: PVRClient.cpp:945
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:1440
int GetID() const
Definition: PVRClient.cpp:298
Definition: PVRChannelGroup.h:52
PVR_ERROR FillBuffer(bool mode)
Notify the pvr addon/demuxer that Kodi wishes to fill demux queue.
Definition: PVRClient.cpp:1464
Definition: PVRClient.h:52
PVR_ERROR CloseLiveStream()
Close an open live stream.
Definition: PVRClient.cpp:1432
bool IgnoreClient() const
Check whether this client should be ignored.
Definition: PVRClient.cpp:277
PVR_ERROR StartChannelScan()
Start a channel scan on the server.
Definition: PVRClient.cpp:443
PVR_ERROR GetRecordings(CPVRRecordings *results, bool deleted)
Request the list of all recordings from the backend.
Definition: PVRClient.cpp:789
PVR_ERROR DeleteTimer(const CPVRTimerInfoTag &timer, bool bForce=false)
Delete a timer on the backend.
Definition: PVRClient.cpp:969
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:1490
PVR_ERROR GetDescrambleInfo(int channelUid, PVR_DESCRAMBLE_INFO &descrambleinfo) const
Get the descramble information of the stream that's currently open.
Definition: PVRClient.cpp:1194
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:674
PVR_ERROR GetLiveStreamLength(int64_t &iLength)
Get the length of the currently playing live stream, if any.
Definition: PVRClient.cpp:1169
PVR_ERROR SetRecordingPlayCount(const CPVRRecording &recording, int count)
Set the play count of a recording on the backend.
Definition: PVRClient.cpp:860
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:655