forked from xbmc/xbmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PVRClient.cpp
1840 lines (1587 loc) · 63.7 KB
/
PVRClient.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2012-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "PVRClient.h"
#include "ServiceBroker.h"
#include "addons/PVRClientMenuHooks.h"
#include "cores/VideoPlayer/DVDDemuxers/DVDDemuxUtils.h"
#include "dialogs/GUIDialogKaiToast.h"
#include "events/EventLog.h"
#include "events/NotificationEvent.h"
#include "filesystem/SpecialProtocol.h"
#include "guilib/LocalizeStrings.h"
#include "pvr/PVRDatabase.h"
#include "pvr/PVRManager.h"
#include "pvr/PVRStreamProperties.h"
#include "pvr/addons/PVRClients.h"
#include "pvr/channels/PVRChannel.h"
#include "pvr/channels/PVRChannelGroup.h"
#include "pvr/channels/PVRChannelGroupInternal.h"
#include "pvr/channels/PVRChannelGroups.h"
#include "pvr/channels/PVRChannelGroupsContainer.h"
#include "pvr/epg/Epg.h"
#include "pvr/epg/EpgContainer.h"
#include "pvr/epg/EpgInfoTag.h"
#include "pvr/recordings/PVRRecording.h"
#include "pvr/recordings/PVRRecordings.h"
#include "pvr/timers/PVRTimerInfoTag.h"
#include "pvr/timers/PVRTimerType.h"
#include "pvr/timers/PVRTimers.h"
#include "settings/AdvancedSettings.h"
#include "settings/SettingsComponent.h"
#include "utils/StringUtils.h"
#include "utils/log.h"
#include <map>
#include <memory>
#include <string>
#include <utility>
extern "C"
{
#include <libavcodec/avcodec.h>
}
using namespace ADDON;
namespace PVR
{
#define DEFAULT_INFO_STRING_VALUE "unknown"
CPVRClient::CPVRClient(const AddonInfoPtr& addonInfo)
: CAddonDll(addonInfo, ADDON_PVRDLL)
{
ResetProperties();
}
CPVRClient::~CPVRClient(void)
{
Destroy();
}
void CPVRClient::StopRunningInstance()
{
const ADDON::AddonPtr addon(GetRunningInstance());
if (addon)
{
// stop the pvr manager and stop and unload the running pvr addon. pvr manager will be restarted on demand.
CServiceBroker::GetPVRManager().Stop();
CServiceBroker::GetPVRManager().Clients()->StopClient(addon, false);
}
}
void CPVRClient::OnPreInstall()
{
// note: this method is also called on update; thus stop and unload possibly running instance
StopRunningInstance();
CAddon::OnPreInstall();
}
void CPVRClient::OnPreUnInstall()
{
StopRunningInstance();
CAddon::OnPreUnInstall();
}
ADDON::AddonPtr CPVRClient::GetRunningInstance() const
{
ADDON::AddonPtr addon;
CServiceBroker::GetPVRManager().Clients()->GetClient(ID(), addon);
return addon;
}
void CPVRClient::ResetProperties(int iClientId /* = PVR_INVALID_CLIENT_ID */)
{
CSingleLock lock(m_critSection);
/* initialise members */
m_strUserPath = CSpecialProtocol::TranslatePath(Profile());
m_strClientPath = CSpecialProtocol::TranslatePath(Path());
m_bReadyToUse = false;
m_bBlockAddonCalls = false;
m_connectionState = PVR_CONNECTION_STATE_UNKNOWN;
m_prevConnectionState = PVR_CONNECTION_STATE_UNKNOWN;
m_ignoreClient = false;
m_iClientId = iClientId;
m_iPriority = 0;
m_bPriorityFetched = false;
m_strBackendVersion = DEFAULT_INFO_STRING_VALUE;
m_strConnectionString = DEFAULT_INFO_STRING_VALUE;
m_strFriendlyName = DEFAULT_INFO_STRING_VALUE;
m_strBackendName = DEFAULT_INFO_STRING_VALUE;
m_strBackendHostname.clear();
m_menuhooks.reset();
m_timertypes.clear();
m_clientCapabilities.clear();
m_struct = {{0}};
m_struct.props.strUserPath = m_strUserPath.c_str();
m_struct.props.strClientPath = m_strClientPath.c_str();
m_struct.props.iEpgMaxDays = CServiceBroker::GetPVRManager().EpgContainer().GetFutureDaysToDisplay();
m_struct.toKodi.kodiInstance = this;
m_struct.toKodi.TransferEpgEntry = cb_transfer_epg_entry;
m_struct.toKodi.TransferChannelEntry = cb_transfer_channel_entry;
m_struct.toKodi.TransferTimerEntry = cb_transfer_timer_entry;
m_struct.toKodi.TransferRecordingEntry = cb_transfer_recording_entry;
m_struct.toKodi.AddMenuHook = cb_add_menu_hook;
m_struct.toKodi.Recording = cb_recording;
m_struct.toKodi.TriggerChannelUpdate = cb_trigger_channel_update;
m_struct.toKodi.TriggerChannelGroupsUpdate = cb_trigger_channel_groups_update;
m_struct.toKodi.TriggerTimerUpdate = cb_trigger_timer_update;
m_struct.toKodi.TriggerRecordingUpdate = cb_trigger_recording_update;
m_struct.toKodi.TriggerEpgUpdate = cb_trigger_epg_update;
m_struct.toKodi.FreeDemuxPacket = cb_free_demux_packet;
m_struct.toKodi.AllocateDemuxPacket = cb_allocate_demux_packet;
m_struct.toKodi.TransferChannelGroup = cb_transfer_channel_group;
m_struct.toKodi.TransferChannelGroupMember = cb_transfer_channel_group_member;
m_struct.toKodi.ConnectionStateChange = cb_connection_state_change;
m_struct.toKodi.EpgEventStateChange = cb_epg_event_state_change;
m_struct.toKodi.GetCodecByName = cb_get_codec_by_name;
}
ADDON_STATUS CPVRClient::Create(int iClientId)
{
ADDON_STATUS status(ADDON_STATUS_UNKNOWN);
if (iClientId <= PVR_INVALID_CLIENT_ID)
return status;
/* reset all properties to defaults */
ResetProperties(iClientId);
/* initialise the add-on */
bool bReadyToUse(false);
CLog::LogFC(LOGDEBUG, LOGPVR, "Creating PVR add-on instance '%s'", Name().c_str());
if ((status = CAddonDll::Create(ADDON_INSTANCE_PVR, &m_struct, &m_struct.props)) == ADDON_STATUS_OK)
bReadyToUse = GetAddonProperties();
m_bReadyToUse = bReadyToUse;
return status;
}
bool CPVRClient::DllLoaded(void) const
{
return CAddonDll::DllLoaded();
}
void CPVRClient::Destroy(void)
{
if (!m_bReadyToUse)
return;
m_bReadyToUse = false;
/* reset 'ready to use' to false */
CLog::LogFC(LOGDEBUG, LOGPVR, "Destroying PVR add-on instance '%s'", GetFriendlyName().c_str());
/* destroy the add-on */
CAddonDll::Destroy();
if (m_menuhooks)
m_menuhooks->Clear();
/* reset all properties to defaults */
ResetProperties();
}
void CPVRClient::Stop()
{
m_bBlockAddonCalls = true;
m_bPriorityFetched = false;
}
void CPVRClient::Continue()
{
m_bBlockAddonCalls = false;
}
void CPVRClient::ReCreate(void)
{
int iClientID(m_iClientId);
Destroy();
/* recreate the instance */
Create(iClientID);
}
bool CPVRClient::ReadyToUse(void) const
{
return m_bReadyToUse;
}
PVR_CONNECTION_STATE CPVRClient::GetConnectionState(void) const
{
CSingleLock lock(m_critSection);
return m_connectionState;
}
void CPVRClient::SetConnectionState(PVR_CONNECTION_STATE state)
{
CSingleLock lock(m_critSection);
m_prevConnectionState = m_connectionState;
m_connectionState = state;
if (m_connectionState == PVR_CONNECTION_STATE_CONNECTED)
m_ignoreClient = false;
else if (m_connectionState == PVR_CONNECTION_STATE_CONNECTING &&
m_prevConnectionState == PVR_CONNECTION_STATE_UNKNOWN)
m_ignoreClient = true;
}
PVR_CONNECTION_STATE CPVRClient::GetPreviousConnectionState(void) const
{
CSingleLock lock(m_critSection);
return m_prevConnectionState;
}
bool CPVRClient::IgnoreClient(void) const
{
CSingleLock lock(m_critSection);
return m_ignoreClient;
}
int CPVRClient::GetID(void) const
{
return m_iClientId;
}
/*!
* @brief Copy over group info from xbmcGroup to addonGroup.
* @param xbmcGroup The group on XBMC's side.
* @param addonGroup The group on the addon's side.
*/
void CPVRClient::WriteClientGroupInfo(const CPVRChannelGroup& xbmcGroup, PVR_CHANNEL_GROUP& addonGroup)
{
addonGroup = {{0}};
addonGroup.bIsRadio = xbmcGroup.IsRadio();
strncpy(addonGroup.strGroupName, xbmcGroup.GroupName().c_str(), sizeof(addonGroup.strGroupName) - 1);
}
/*!
* @brief Copy over recording info from xbmcRecording to addonRecording.
* @param xbmcRecording The recording on XBMC's side.
* @param addonRecording The recording on the addon's side.
*/
void CPVRClient::WriteClientRecordingInfo(const CPVRRecording& xbmcRecording, PVR_RECORDING& addonRecording)
{
time_t recTime;
xbmcRecording.RecordingTimeAsUTC().GetAsTime(recTime);
addonRecording = {{0}};
strncpy(addonRecording.strRecordingId, xbmcRecording.m_strRecordingId.c_str(), sizeof(addonRecording.strRecordingId) - 1);
strncpy(addonRecording.strTitle, xbmcRecording.m_strTitle.c_str(), sizeof(addonRecording.strTitle) - 1);
strncpy(addonRecording.strEpisodeName, xbmcRecording.m_strShowTitle.c_str(), sizeof(addonRecording.strEpisodeName) - 1);
addonRecording.iSeriesNumber = xbmcRecording.m_iSeason;
addonRecording.iEpisodeNumber = xbmcRecording.m_iEpisode;
addonRecording.iYear = xbmcRecording.GetYear();
strncpy(addonRecording.strDirectory, xbmcRecording.m_strDirectory.c_str(), sizeof(addonRecording.strDirectory) - 1);
strncpy(addonRecording.strPlotOutline, xbmcRecording.m_strPlotOutline.c_str(), sizeof(addonRecording.strPlotOutline) - 1);
strncpy(addonRecording.strPlot, xbmcRecording.m_strPlot.c_str(), sizeof(addonRecording.strPlot) - 1);
strncpy(addonRecording.strGenreDescription, xbmcRecording.GetGenresLabel().c_str(), sizeof(addonRecording.strGenreDescription) - 1);
strncpy(addonRecording.strChannelName, xbmcRecording.m_strChannelName.c_str(), sizeof(addonRecording.strChannelName) - 1);
strncpy(addonRecording.strIconPath, xbmcRecording.m_strIconPath.c_str(), sizeof(addonRecording.strIconPath) - 1);
strncpy(addonRecording.strThumbnailPath, xbmcRecording.m_strThumbnailPath.c_str(), sizeof(addonRecording.strThumbnailPath) - 1);
strncpy(addonRecording.strFanartPath, xbmcRecording.m_strFanartPath.c_str(), sizeof(addonRecording.strFanartPath) - 1);
addonRecording.recordingTime = recTime - CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_iPVRTimeCorrection;
addonRecording.iDuration = xbmcRecording.GetDuration();
addonRecording.iPriority = xbmcRecording.m_iPriority;
addonRecording.iLifetime = xbmcRecording.m_iLifetime;
addonRecording.iGenreType = xbmcRecording.GenreType();
addonRecording.iGenreSubType = xbmcRecording.GenreSubType();
addonRecording.iPlayCount = xbmcRecording.GetLocalPlayCount();
addonRecording.iLastPlayedPosition = lrint(xbmcRecording.GetLocalResumePoint().timeInSeconds);
addonRecording.bIsDeleted = xbmcRecording.IsDeleted();
addonRecording.iChannelUid = xbmcRecording.ChannelUid();
addonRecording.channelType = xbmcRecording.IsRadio() ? PVR_RECORDING_CHANNEL_TYPE_RADIO : PVR_RECORDING_CHANNEL_TYPE_TV;
}
/*!
* @brief Copy over timer info from xbmcTimer to addonTimer.
* @param xbmcTimer The timer on XBMC's side.
* @param addonTimer The timer on the addon's side.
*/
void CPVRClient::WriteClientTimerInfo(const CPVRTimerInfoTag& xbmcTimer, PVR_TIMER& addonTimer)
{
time_t start, end, firstDay;
xbmcTimer.StartAsUTC().GetAsTime(start);
xbmcTimer.EndAsUTC().GetAsTime(end);
xbmcTimer.FirstDayAsUTC().GetAsTime(firstDay);
std::shared_ptr<CPVREpgInfoTag> epgTag = xbmcTimer.GetEpgInfoTag();
int iPVRTimeCorrection = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_iPVRTimeCorrection;
addonTimer = {0};
addonTimer.iClientIndex = xbmcTimer.m_iClientIndex;
addonTimer.iParentClientIndex = xbmcTimer.m_iParentClientIndex;
addonTimer.state = xbmcTimer.m_state;
addonTimer.iTimerType = xbmcTimer.GetTimerType() ? xbmcTimer.GetTimerType()->GetTypeId() : PVR_TIMER_TYPE_NONE;
addonTimer.iClientChannelUid = xbmcTimer.m_iClientChannelUid;
strncpy(addonTimer.strTitle, xbmcTimer.m_strTitle.c_str(), sizeof(addonTimer.strTitle) - 1);
strncpy(addonTimer.strEpgSearchString, xbmcTimer.m_strEpgSearchString.c_str(), sizeof(addonTimer.strEpgSearchString) - 1);
addonTimer.bFullTextEpgSearch = xbmcTimer.m_bFullTextEpgSearch;
strncpy(addonTimer.strDirectory, xbmcTimer.m_strDirectory.c_str(), sizeof(addonTimer.strDirectory) - 1);
addonTimer.iPriority = xbmcTimer.m_iPriority;
addonTimer.iLifetime = xbmcTimer.m_iLifetime;
addonTimer.iMaxRecordings = xbmcTimer.m_iMaxRecordings;
addonTimer.iPreventDuplicateEpisodes = xbmcTimer.m_iPreventDupEpisodes;
addonTimer.iRecordingGroup = xbmcTimer.m_iRecordingGroup;
addonTimer.iWeekdays = xbmcTimer.m_iWeekdays;
addonTimer.startTime = start - iPVRTimeCorrection;
addonTimer.endTime = end - iPVRTimeCorrection;
addonTimer.bStartAnyTime = xbmcTimer.m_bStartAnyTime;
addonTimer.bEndAnyTime = xbmcTimer.m_bEndAnyTime;
addonTimer.firstDay = firstDay - iPVRTimeCorrection;
addonTimer.iEpgUid = epgTag ? epgTag->UniqueBroadcastID() : PVR_TIMER_NO_EPG_UID;
strncpy(addonTimer.strSummary, xbmcTimer.m_strSummary.c_str(), sizeof(addonTimer.strSummary) - 1);
addonTimer.iMarginStart = xbmcTimer.m_iMarginStart;
addonTimer.iMarginEnd = xbmcTimer.m_iMarginEnd;
addonTimer.iGenreType = epgTag ? epgTag->GenreType() : 0;
addonTimer.iGenreSubType = epgTag ? epgTag->GenreSubType() : 0;
strncpy(addonTimer.strSeriesLink, xbmcTimer.SeriesLink().c_str(), sizeof(addonTimer.strSeriesLink) - 1);
}
/*!
* @brief Copy over channel info from xbmcChannel to addonClient.
* @param xbmcChannel The channel on XBMC's side.
* @param addonChannel The channel on the addon's side.
*/
void CPVRClient::WriteClientChannelInfo(const std::shared_ptr<CPVRChannel>& xbmcChannel, PVR_CHANNEL& addonChannel)
{
addonChannel = {0};
addonChannel.iUniqueId = xbmcChannel->UniqueID();
addonChannel.iChannelNumber = xbmcChannel->ClientChannelNumber().GetChannelNumber();
addonChannel.iSubChannelNumber = xbmcChannel->ClientChannelNumber().GetSubChannelNumber();
strncpy(addonChannel.strChannelName, xbmcChannel->ClientChannelName().c_str(), sizeof(addonChannel.strChannelName) - 1);
strncpy(addonChannel.strIconPath, xbmcChannel->IconPath().c_str(), sizeof(addonChannel.strIconPath) - 1);
addonChannel.iEncryptionSystem = xbmcChannel->EncryptionSystem();
addonChannel.bIsRadio = xbmcChannel->IsRadio();
addonChannel.bIsHidden = xbmcChannel->IsHidden();
strncpy(addonChannel.strInputFormat, xbmcChannel->InputFormat().c_str(), sizeof(addonChannel.strInputFormat) - 1);
}
bool CPVRClient::GetAddonProperties(void)
{
std::string strBackendName, strConnectionString, strFriendlyName, strBackendVersion, strBackendHostname;
PVR_ADDON_CAPABILITIES addonCapabilities = {};
CPVRTimerTypes timerTypes;
/* get the capabilities */
PVR_ERROR retVal = DoAddonCall(__FUNCTION__, [&addonCapabilities](const AddonInstance* addon) {
return addon->GetAddonCapabilities(&addonCapabilities);
}, true, false);
if (retVal != PVR_ERROR_NO_ERROR)
return false;
/* get the name of the backend */
DoAddonCall(__FUNCTION__, [&strBackendName](const AddonInstance* addon) {
strBackendName = addon->GetBackendName();
return PVR_ERROR_NO_ERROR;
}, true, false);
/* get the connection string */
DoAddonCall(__FUNCTION__, [&strConnectionString](const AddonInstance* addon) {
strConnectionString = addon->GetConnectionString();
return PVR_ERROR_NO_ERROR;
}, true, false);
/* display name = backend name:connection string */
strFriendlyName = StringUtils::Format("%s:%s", strBackendName.c_str(), strConnectionString.c_str());
/* backend version number */
DoAddonCall(__FUNCTION__, [&strBackendVersion](const AddonInstance* addon) {
strBackendVersion = addon->GetBackendVersion();
return PVR_ERROR_NO_ERROR;
}, true, false);
/* backend hostname */
DoAddonCall(__FUNCTION__, [&strBackendHostname](const AddonInstance* addon) {
strBackendHostname = addon->GetBackendHostname();
return PVR_ERROR_NO_ERROR;
}, true, false);
/* timer types */
retVal = DoAddonCall(__FUNCTION__, [this, strFriendlyName, &addonCapabilities, &timerTypes](const AddonInstance* addon) {
std::unique_ptr<PVR_TIMER_TYPE[]> types_array(new PVR_TIMER_TYPE[PVR_ADDON_TIMERTYPE_ARRAY_SIZE]);
int size = PVR_ADDON_TIMERTYPE_ARRAY_SIZE;
PVR_ERROR retval = addon->GetTimerTypes(types_array.get(), &size);
if (retval == PVR_ERROR_NOT_IMPLEMENTED)
{
// begin compat section
CLog::LogF(LOGWARNING, "Add-on %s does not support timer types. It will work, but not benefit from the timer features introduced with PVR Addon API 2.0.0", strFriendlyName.c_str());
// Create standard timer types (mostly) matching the timer functionality available in Isengard.
// This is for migration only and does not make changes to the addons obsolete. Addons should
// work and benefit from some UI changes (e.g. some of the timer settings dialog enhancements),
// but all old problems/bugs due to static attributes and values will remain the same as in
// Isengard. Also, new features (like epg search) are not available to addons automatically.
// This code can be removed once all addons actually support the respective PVR Addon API version.
size = 0;
// manual one time
memset(&types_array[size], 0, sizeof(types_array[size]));
types_array[size].iId = size + 1;
types_array[size].iAttributes = PVR_TIMER_TYPE_IS_MANUAL |
PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE |
PVR_TIMER_TYPE_SUPPORTS_CHANNELS |
PVR_TIMER_TYPE_SUPPORTS_START_TIME |
PVR_TIMER_TYPE_SUPPORTS_END_TIME |
PVR_TIMER_TYPE_SUPPORTS_PRIORITY |
PVR_TIMER_TYPE_SUPPORTS_LIFETIME |
PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS;
++size;
// manual timer rule
memset(&types_array[size], 0, sizeof(types_array[size]));
types_array[size].iId = size + 1;
types_array[size].iAttributes = PVR_TIMER_TYPE_IS_MANUAL |
PVR_TIMER_TYPE_IS_REPEATING |
PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE |
PVR_TIMER_TYPE_SUPPORTS_CHANNELS |
PVR_TIMER_TYPE_SUPPORTS_START_TIME |
PVR_TIMER_TYPE_SUPPORTS_END_TIME |
PVR_TIMER_TYPE_SUPPORTS_PRIORITY |
PVR_TIMER_TYPE_SUPPORTS_LIFETIME |
PVR_TIMER_TYPE_SUPPORTS_FIRST_DAY |
PVR_TIMER_TYPE_SUPPORTS_WEEKDAYS |
PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS;
++size;
if (addonCapabilities.bSupportsEPG)
{
// One-shot epg-based
memset(&types_array[size], 0, sizeof(types_array[size]));
types_array[size].iId = size + 1;
types_array[size].iAttributes = PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE |
PVR_TIMER_TYPE_REQUIRES_EPG_TAG_ON_CREATE |
PVR_TIMER_TYPE_SUPPORTS_CHANNELS |
PVR_TIMER_TYPE_SUPPORTS_START_TIME |
PVR_TIMER_TYPE_SUPPORTS_END_TIME |
PVR_TIMER_TYPE_SUPPORTS_PRIORITY |
PVR_TIMER_TYPE_SUPPORTS_LIFETIME |
PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS;
++size;
}
retval = PVR_ERROR_NO_ERROR;
// end compat section
}
if (retval == PVR_ERROR_NO_ERROR)
{
timerTypes.reserve(size);
for (int i = 0; i < size; ++i)
{
if (types_array[i].iId == PVR_TIMER_TYPE_NONE)
{
CLog::LogF(LOGERROR, "Invalid timer type supplied by add-on '%s'. Please contact the developer of this add-on: %s", GetFriendlyName().c_str(), Author().c_str());
continue;
}
timerTypes.emplace_back(std::shared_ptr<CPVRTimerType>(new CPVRTimerType(types_array[i], m_iClientId)));
}
}
return retval;
}, addonCapabilities.bSupportsTimers, false);
if (retVal == PVR_ERROR_NOT_IMPLEMENTED)
retVal = PVR_ERROR_NO_ERROR; // timer support is optional.
/* update the members */
CSingleLock lock(m_critSection);
m_strBackendName = strBackendName;
m_strConnectionString = strConnectionString;
m_strFriendlyName = strFriendlyName;
m_strBackendVersion = strBackendVersion;
m_clientCapabilities = addonCapabilities;
m_strBackendHostname = strBackendHostname;
m_timertypes = timerTypes;
return retVal == PVR_ERROR_NO_ERROR;
}
const std::string& CPVRClient::GetBackendName(void) const
{
return m_strBackendName;
}
const std::string& CPVRClient::GetBackendVersion(void) const
{
return m_strBackendVersion;
}
const std::string& CPVRClient::GetBackendHostname(void) const
{
return m_strBackendHostname;
}
const std::string& CPVRClient::GetConnectionString(void) const
{
return m_strConnectionString;
}
const std::string& CPVRClient::GetFriendlyName(void) const
{
return m_strFriendlyName;
}
PVR_ERROR CPVRClient::GetDriveSpace(long long& iTotal, long long& iUsed)
{
/* default to 0 in case of error */
iTotal = 0;
iUsed = 0;
return DoAddonCall(__FUNCTION__, [this, &iTotal, &iUsed](const AddonInstance* addon) {
long long iTotalSpace = 0;
long long iUsedSpace = 0;
PVR_ERROR error = m_struct.toAddon.GetDriveSpace(&iTotalSpace, &iUsedSpace);
if (error == PVR_ERROR_NO_ERROR)
{
iTotal = iTotalSpace;
iUsed = iUsedSpace;
}
return error;
});
}
PVR_ERROR CPVRClient::StartChannelScan(void)
{
return DoAddonCall(__FUNCTION__, [](const AddonInstance* addon) {
return addon->OpenDialogChannelScan();
}, m_clientCapabilities.SupportsChannelScan());
}
PVR_ERROR CPVRClient::OpenDialogChannelAdd(const std::shared_ptr<CPVRChannel>& channel)
{
return DoAddonCall(__FUNCTION__, [channel](const AddonInstance* addon) {
PVR_CHANNEL addonChannel;
WriteClientChannelInfo(channel, addonChannel);
return addon->OpenDialogChannelAdd(addonChannel);
}, m_clientCapabilities.SupportsChannelSettings());
}
PVR_ERROR CPVRClient::OpenDialogChannelSettings(const std::shared_ptr<CPVRChannel>& channel)
{
return DoAddonCall(__FUNCTION__, [channel] (const AddonInstance* addon){
PVR_CHANNEL addonChannel;
WriteClientChannelInfo(channel, addonChannel);
return addon->OpenDialogChannelSettings(addonChannel);
}, m_clientCapabilities.SupportsChannelSettings());
}
PVR_ERROR CPVRClient::DeleteChannel(const std::shared_ptr<CPVRChannel>& channel)
{
return DoAddonCall(__FUNCTION__, [channel](const AddonInstance* addon) {
PVR_CHANNEL addonChannel;
WriteClientChannelInfo(channel, addonChannel);
return addon->DeleteChannel(addonChannel);
}, m_clientCapabilities.SupportsChannelSettings());
}
PVR_ERROR CPVRClient::RenameChannel(const std::shared_ptr<CPVRChannel>& channel)
{
return DoAddonCall(__FUNCTION__, [channel](const AddonInstance* addon) {
PVR_CHANNEL addonChannel;
WriteClientChannelInfo(channel, addonChannel);
return addon->RenameChannel(addonChannel);
}, m_clientCapabilities.SupportsChannelSettings());
}
PVR_ERROR CPVRClient::GetEPGForChannel(int iChannelUid, CPVREpg* epg, time_t start, time_t end)
{
return DoAddonCall(__FUNCTION__, [this, iChannelUid, epg, start, end](const AddonInstance* addon) {
ADDON_HANDLE_STRUCT handle = {0};
handle.callerAddress = this;
handle.dataAddress = epg;
int iPVRTimeCorrection = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_iPVRTimeCorrection;
return addon->GetEPGForChannel(&handle,
iChannelUid,
start ? start - iPVRTimeCorrection : 0,
end ? end - iPVRTimeCorrection : 0);
}, m_clientCapabilities.SupportsEPG());
}
PVR_ERROR CPVRClient::SetEPGTimeFrame(int iDays)
{
return DoAddonCall(__FUNCTION__, [iDays](const AddonInstance* addon) {
return addon->SetEPGTimeFrame(iDays);
}, m_clientCapabilities.SupportsEPG());
}
// This class wraps an EPG_TAG (PVR Addon API struct) to ensure that the string members of
// that struct, which are const char pointers, stay valid until the EPG_TAG gets destructed.
// Please note that this struct is also used to transfer huge amount of EPG_TAGs from
// addon to Kodi. Thus, changing the struct to contain char arrays is not recommened,
// because this would lead to huge amount of string copies when transferring epg data
// from addon to Kodi.
class CAddonEpgTag : public EPG_TAG
{
public:
CAddonEpgTag() = delete;
explicit CAddonEpgTag(const std::shared_ptr<const CPVREpgInfoTag> kodiTag) :
m_strTitle(kodiTag->Title()),
m_strPlotOutline(kodiTag->PlotOutline()),
m_strPlot(kodiTag->Plot()),
m_strOriginalTitle(kodiTag->OriginalTitle()),
m_strCast(kodiTag->DeTokenize(kodiTag->Cast())),
m_strDirector(kodiTag->DeTokenize(kodiTag->Directors())),
m_strWriter(kodiTag->DeTokenize(kodiTag->Writers())),
m_strIMDBNumber(kodiTag->IMDBNumber()),
m_strEpisodeName(kodiTag->EpisodeName()),
m_strIconPath(kodiTag->Icon()),
m_strSeriesLink(kodiTag->SeriesLink()),
m_strGenreDescription(kodiTag->GetGenresLabel())
{
time_t t;
kodiTag->StartAsUTC().GetAsTime(t);
startTime = t;
kodiTag->EndAsUTC().GetAsTime(t);
endTime = t;
kodiTag->FirstAiredAsUTC().GetAsTime(t);
firstAired = t;
iUniqueBroadcastId = kodiTag->UniqueBroadcastID();
iUniqueChannelId = kodiTag->UniqueChannelID();
iParentalRating = kodiTag->ParentalRating();
iSeriesNumber = kodiTag->SeriesNumber();
iEpisodeNumber = kodiTag->EpisodeNumber();
iEpisodePartNumber = kodiTag->EpisodePart();
iStarRating = kodiTag->StarRating();
iYear = kodiTag->Year();
iFlags = kodiTag->Flags();
iGenreType = kodiTag->GenreType();
iGenreSubType = kodiTag->GenreSubType();
strTitle = m_strTitle.c_str();
strPlotOutline = m_strPlotOutline.c_str();
strPlot = m_strPlot.c_str();
strOriginalTitle = m_strOriginalTitle.c_str();
strCast = m_strCast.c_str();
strDirector = m_strDirector.c_str();
strWriter = m_strWriter.c_str();
strIMDBNumber = m_strIMDBNumber.c_str();
strEpisodeName = m_strEpisodeName.c_str();
strIconPath = m_strIconPath.c_str();
strSeriesLink = m_strSeriesLink.c_str();
strGenreDescription = m_strGenreDescription.c_str();
}
virtual ~CAddonEpgTag() = default;
private:
std::string m_strTitle;
std::string m_strPlotOutline;
std::string m_strPlot;
std::string m_strOriginalTitle;
std::string m_strCast;
std::string m_strDirector;
std::string m_strWriter;
std::string m_strIMDBNumber;
std::string m_strEpisodeName;
std::string m_strIconPath;
std::string m_strSeriesLink;
std::string m_strGenreDescription;
};
PVR_ERROR CPVRClient::IsRecordable(const std::shared_ptr<const CPVREpgInfoTag>& tag, bool& bIsRecordable) const
{
return DoAddonCall(__FUNCTION__, [tag, &bIsRecordable](const AddonInstance* addon) {
CAddonEpgTag addonTag(tag);
return addon->IsEPGTagRecordable(&addonTag, &bIsRecordable);
}, m_clientCapabilities.SupportsRecordings() && m_clientCapabilities.SupportsEPG());
}
PVR_ERROR CPVRClient::IsPlayable(const std::shared_ptr<const CPVREpgInfoTag>& tag, bool& bIsPlayable) const
{
return DoAddonCall(__FUNCTION__, [tag, &bIsPlayable](const AddonInstance* addon) {
CAddonEpgTag addonTag(tag);
return addon->IsEPGTagPlayable(&addonTag, &bIsPlayable);
}, m_clientCapabilities.SupportsEPG());
}
void CPVRClient::WriteStreamProperties(const PVR_NAMED_VALUE* properties, unsigned int iPropertyCount, CPVRStreamProperties& props)
{
for (unsigned int i = 0; i < iPropertyCount; ++i)
{
props.emplace_back(std::make_pair(properties[i].strName, properties[i].strValue));
}
}
PVR_ERROR CPVRClient::GetEpgTagStreamProperties(const std::shared_ptr<CPVREpgInfoTag>& tag, CPVRStreamProperties& props)
{
return DoAddonCall(__FUNCTION__, [&tag, &props](const AddonInstance* addon) {
CAddonEpgTag addonTag(tag);
unsigned int iPropertyCount = PVR_STREAM_MAX_PROPERTIES;
std::unique_ptr<PVR_NAMED_VALUE[]> properties(new PVR_NAMED_VALUE[iPropertyCount]);
memset(properties.get(), 0, iPropertyCount * sizeof(PVR_NAMED_VALUE));
PVR_ERROR error = addon->GetEPGTagStreamProperties(&addonTag, properties.get(), &iPropertyCount);
if (error == PVR_ERROR_NO_ERROR)
WriteStreamProperties(properties.get(), iPropertyCount, props);
return error;
});
}
PVR_ERROR CPVRClient::GetEpgTagEdl(const std::shared_ptr<const CPVREpgInfoTag>& epgTag, std::vector<PVR_EDL_ENTRY>& edls)
{
edls.clear();
return DoAddonCall(__FUNCTION__, [&epgTag, &edls](const AddonInstance* addon) {
CAddonEpgTag addonTag(epgTag);
PVR_EDL_ENTRY edl_array[PVR_ADDON_EDL_LENGTH];
int size = PVR_ADDON_EDL_LENGTH;
PVR_ERROR error = addon->GetEPGTagEdl(&addonTag, edl_array, &size);
if (error == PVR_ERROR_NO_ERROR)
{
edls.reserve(size);
for (int i = 0; i < size; ++i)
edls.emplace_back(edl_array[i]);
}
return error;
}, m_clientCapabilities.SupportsEpgTagEdl());
}
PVR_ERROR CPVRClient::GetChannelGroupsAmount(int& iGroups)
{
iGroups = -1;
return DoAddonCall(__FUNCTION__, [&iGroups](const AddonInstance* addon) {
iGroups = addon->GetChannelGroupsAmount();
return (iGroups == -1) ? PVR_ERROR_NOT_IMPLEMENTED : PVR_ERROR_NO_ERROR;
}, m_clientCapabilities.SupportsChannelGroups());
}
PVR_ERROR CPVRClient::GetChannelGroups(CPVRChannelGroups* groups)
{
return DoAddonCall(__FUNCTION__, [this, groups](const AddonInstance* addon) {
ADDON_HANDLE_STRUCT handle = {0};
handle.callerAddress = this;
handle.dataAddress = groups;
return addon->GetChannelGroups(&handle, groups->IsRadio());
}, m_clientCapabilities.SupportsChannelGroups());
}
PVR_ERROR CPVRClient::GetChannelGroupMembers(CPVRChannelGroup* group)
{
return DoAddonCall(__FUNCTION__, [this, group](const AddonInstance* addon) {
ADDON_HANDLE_STRUCT handle = {0};
handle.callerAddress = this;
handle.dataAddress = group;
PVR_CHANNEL_GROUP tag;
WriteClientGroupInfo(*group, tag);
return addon->GetChannelGroupMembers(&handle, tag);
}, m_clientCapabilities.SupportsChannelGroups());
}
PVR_ERROR CPVRClient::GetChannelsAmount(int& iChannels)
{
iChannels = -1;
return DoAddonCall(__FUNCTION__, [&iChannels](const AddonInstance* addon) {
iChannels = addon->GetChannelsAmount();
return (iChannels == -1) ? PVR_ERROR_NOT_IMPLEMENTED : PVR_ERROR_NO_ERROR;
});
}
PVR_ERROR CPVRClient::GetChannels(CPVRChannelGroup& channels, bool radio)
{
return DoAddonCall(__FUNCTION__, [this, &channels, radio](const AddonInstance* addon) {
ADDON_HANDLE_STRUCT handle = {0};
handle.callerAddress = this;
handle.dataAddress = &channels;
return addon->GetChannels(&handle, radio);
}, (radio && m_clientCapabilities.SupportsRadio()) || (!radio && m_clientCapabilities.SupportsTV()));
}
PVR_ERROR CPVRClient::GetRecordingsAmount(bool deleted, int& iRecordings)
{
iRecordings = -1;
return DoAddonCall(__FUNCTION__, [deleted, &iRecordings](const AddonInstance* addon) {
iRecordings = addon->GetRecordingsAmount(deleted);
return (iRecordings == -1) ? PVR_ERROR_NOT_IMPLEMENTED : PVR_ERROR_NO_ERROR;
}, m_clientCapabilities.SupportsRecordings() && (!deleted || m_clientCapabilities.SupportsRecordingsUndelete()));
}
PVR_ERROR CPVRClient::GetRecordings(CPVRRecordings* results, bool deleted) {
return DoAddonCall(__FUNCTION__, [this, results, deleted](const AddonInstance* addon)
{
ADDON_HANDLE_STRUCT handle = {0};
handle.callerAddress = this;
handle.dataAddress = results;
return addon->GetRecordings(&handle, deleted);
}, m_clientCapabilities.SupportsRecordings() && (!deleted || m_clientCapabilities.SupportsRecordingsUndelete()));
}
PVR_ERROR CPVRClient::DeleteRecording(const CPVRRecording& recording)
{
return DoAddonCall(__FUNCTION__, [&recording](const AddonInstance* addon) {
PVR_RECORDING tag;
WriteClientRecordingInfo(recording, tag);
return addon->DeleteRecording(tag);
}, m_clientCapabilities.SupportsRecordings());
}
PVR_ERROR CPVRClient::UndeleteRecording(const CPVRRecording& recording)
{
return DoAddonCall(__FUNCTION__, [&recording](const AddonInstance* addon) {
PVR_RECORDING tag;
WriteClientRecordingInfo(recording, tag);
return addon->UndeleteRecording(tag);
}, m_clientCapabilities.SupportsRecordingsUndelete());
}
PVR_ERROR CPVRClient::DeleteAllRecordingsFromTrash()
{
return DoAddonCall(__FUNCTION__, [](const AddonInstance* addon) {
return addon->DeleteAllRecordingsFromTrash();
}, m_clientCapabilities.SupportsRecordingsUndelete());
}
PVR_ERROR CPVRClient::RenameRecording(const CPVRRecording& recording)
{
return DoAddonCall(__FUNCTION__, [&recording](const AddonInstance* addon) {
PVR_RECORDING tag;
WriteClientRecordingInfo(recording, tag);
return addon->RenameRecording(tag);
}, m_clientCapabilities.SupportsRecordings());
}
PVR_ERROR CPVRClient::SetRecordingLifetime(const CPVRRecording& recording)
{
return DoAddonCall(__FUNCTION__, [&recording](const AddonInstance* addon) {
PVR_RECORDING tag;
WriteClientRecordingInfo(recording, tag);
return addon->SetRecordingLifetime(&tag);
}, m_clientCapabilities.SupportsRecordingsLifetimeChange());
}
PVR_ERROR CPVRClient::SetRecordingPlayCount(const CPVRRecording& recording, int count)
{
return DoAddonCall(__FUNCTION__, [&recording, count](const AddonInstance* addon) {
PVR_RECORDING tag;
WriteClientRecordingInfo(recording, tag);
return addon->SetRecordingPlayCount(tag, count);
}, m_clientCapabilities.SupportsRecordingsPlayCount());
}
PVR_ERROR CPVRClient::SetRecordingLastPlayedPosition(const CPVRRecording& recording, int lastplayedposition)
{
return DoAddonCall(__FUNCTION__, [&recording, lastplayedposition](const AddonInstance* addon) {
PVR_RECORDING tag;
WriteClientRecordingInfo(recording, tag);
return addon->SetRecordingLastPlayedPosition(tag, lastplayedposition);
}, m_clientCapabilities.SupportsRecordingsLastPlayedPosition());
}
PVR_ERROR CPVRClient::GetRecordingLastPlayedPosition(const CPVRRecording& recording, int& iPosition)
{
iPosition = -1;
return DoAddonCall(__FUNCTION__, [&recording, &iPosition](const AddonInstance* addon) {
PVR_RECORDING tag;
WriteClientRecordingInfo(recording, tag);
iPosition = addon->GetRecordingLastPlayedPosition(tag);
return (iPosition == -1) ? PVR_ERROR_NOT_IMPLEMENTED : PVR_ERROR_NO_ERROR;
}, m_clientCapabilities.SupportsRecordingsLastPlayedPosition());
}
PVR_ERROR CPVRClient::GetRecordingEdl(const CPVRRecording& recording, std::vector<PVR_EDL_ENTRY>& edls)
{
edls.clear();
return DoAddonCall(__FUNCTION__, [&recording, &edls](const AddonInstance* addon) {
PVR_RECORDING tag;
WriteClientRecordingInfo(recording, tag);
PVR_EDL_ENTRY edl_array[PVR_ADDON_EDL_LENGTH];
int size = PVR_ADDON_EDL_LENGTH;
PVR_ERROR error = addon->GetRecordingEdl(tag, edl_array, &size);
if (error == PVR_ERROR_NO_ERROR)
{
edls.reserve(size);
for (int i = 0; i < size; ++i)
edls.emplace_back(edl_array[i]);
}
return error;
}, m_clientCapabilities.SupportsRecordingsEdl());
}
PVR_ERROR CPVRClient::GetTimersAmount(int& iTimers)
{
iTimers = -1;
return DoAddonCall(__FUNCTION__, [&iTimers](const AddonInstance* addon) {
iTimers = addon->GetTimersAmount();
return (iTimers == -1) ? PVR_ERROR_NOT_IMPLEMENTED : PVR_ERROR_NO_ERROR;
}, m_clientCapabilities.SupportsTimers());
}
PVR_ERROR CPVRClient::GetTimers(CPVRTimersContainer* results)
{
return DoAddonCall(__FUNCTION__, [this, results](const AddonInstance* addon) {
ADDON_HANDLE_STRUCT handle = {0};
handle.callerAddress = this;
handle.dataAddress = results;
return addon->GetTimers(&handle);
}, m_clientCapabilities.SupportsTimers());
}
PVR_ERROR CPVRClient::AddTimer(const CPVRTimerInfoTag& timer)
{
return DoAddonCall(__FUNCTION__, [&timer](const AddonInstance* addon) {
PVR_TIMER tag;
WriteClientTimerInfo(timer, tag);
return addon->AddTimer(tag);
}, m_clientCapabilities.SupportsTimers());
}
PVR_ERROR CPVRClient::DeleteTimer(const CPVRTimerInfoTag& timer, bool bForce /* = false */)
{
return DoAddonCall(__FUNCTION__, [&timer, bForce](const AddonInstance* addon) {
PVR_TIMER tag;
WriteClientTimerInfo(timer, tag);
return addon->DeleteTimer(tag, bForce);
}, m_clientCapabilities.SupportsTimers());
}
PVR_ERROR CPVRClient::UpdateTimer(const CPVRTimerInfoTag& timer)
{
return DoAddonCall(__FUNCTION__, [&timer](const AddonInstance* addon) {
PVR_TIMER tag;
WriteClientTimerInfo(timer, tag);
return addon->UpdateTimer(tag);
}, m_clientCapabilities.SupportsTimers());
}
PVR_ERROR CPVRClient::GetTimerTypes(CPVRTimerTypes& results) const
{
CSingleLock lock(m_critSection);
results = m_timertypes;
return PVR_ERROR_NO_ERROR;
}
PVR_ERROR CPVRClient::GetStreamReadChunkSize(int& iChunkSize)
{
return DoAddonCall(__FUNCTION__, [&iChunkSize](const AddonInstance* addon) {
return addon->GetStreamReadChunkSize(&iChunkSize);
}, m_clientCapabilities.SupportsRecordings() || m_clientCapabilities.HandlesInputStream());
}
PVR_ERROR CPVRClient::ReadLiveStream(void* lpBuf, int64_t uiBufSize, int& iRead)
{
iRead = -1;
return DoAddonCall(__FUNCTION__, [&lpBuf, uiBufSize, &iRead](const AddonInstance* addon) {
iRead = addon->ReadLiveStream(static_cast<unsigned char *>(lpBuf), static_cast<int>(uiBufSize));
return (iRead == -1) ? PVR_ERROR_NOT_IMPLEMENTED : PVR_ERROR_NO_ERROR;
});
}
PVR_ERROR CPVRClient::ReadRecordedStream(void* lpBuf, int64_t uiBufSize, int& iRead)
{
iRead = -1;
return DoAddonCall(__FUNCTION__, [&lpBuf, uiBufSize, &iRead](const AddonInstance* addon) {
iRead = addon->ReadRecordedStream(static_cast<unsigned char *>(lpBuf), static_cast<int>(uiBufSize));
return (iRead == -1) ? PVR_ERROR_NOT_IMPLEMENTED : PVR_ERROR_NO_ERROR;
});
}
PVR_ERROR CPVRClient::SeekLiveStream(int64_t iFilePosition, int iWhence, int64_t& iPosition)
{
iPosition = -1;
return DoAddonCall(__FUNCTION__, [iFilePosition, iWhence, &iPosition](const AddonInstance* addon) {
iPosition = addon->SeekLiveStream(iFilePosition, iWhence);