[cosmetics] update date in GPL header
[vuplus_xbmc] / lib / addons / library.xbmc.pvr / libXBMC_pvr.cpp
1 /*
2  *      Copyright (C) 2012-2013 Team XBMC
3  *      http://www.xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, write to
17  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18  *  http://www.gnu.org/copyleft/gpl.html
19  *
20  */
21
22 #define USE_DEMUX // enable including of the demuxer packet structure
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <stdarg.h>
27 #include <string>
28 #include "../../../addons/library.xbmc.pvr/libXBMC_pvr.h"
29 #include "addons/AddonCallbacks.h"
30 #include "cores/dvdplayer/DVDDemuxers/DVDDemuxPacket.h"
31
32 #ifdef _WIN32
33 #include <windows.h>
34 #define DLLEXPORT __declspec(dllexport)
35 #else
36 #define DLLEXPORT
37 #endif
38
39 using namespace std;
40
41 extern "C"
42 {
43
44 DLLEXPORT void* PVR_register_me(void *hdl)
45 {
46   CB_PVRLib *cb = NULL;
47   if (!hdl)
48     fprintf(stderr, "libXBMC_pvr-ERROR: PVRLib_register_me is called with NULL handle !!!\n");
49   else
50   {
51     cb = ((AddonCB*)hdl)->PVRLib_RegisterMe(((AddonCB*)hdl)->addonData);
52     if (!cb)
53       fprintf(stderr, "libXBMC_pvr-ERROR: PVRLib_register_me can't get callback table from XBMC !!!\n");
54   }
55   return cb;
56 }
57
58 DLLEXPORT void PVR_unregister_me(void *hdl, void* cb)
59 {
60   if (hdl && cb)
61     ((AddonCB*)hdl)->PVRLib_UnRegisterMe(((AddonCB*)hdl)->addonData, (CB_PVRLib*)cb);
62 }
63
64 DLLEXPORT void PVR_transfer_epg_entry(void *hdl, void* cb, const ADDON_HANDLE handle, const EPG_TAG *epgentry)
65 {
66   if (cb == NULL)
67     return;
68
69   ((CB_PVRLib*)cb)->TransferEpgEntry(((AddonCB*)hdl)->addonData, handle, epgentry);
70 }
71
72 DLLEXPORT void PVR_transfer_channel_entry(void *hdl, void* cb, const ADDON_HANDLE handle, const PVR_CHANNEL *chan)
73 {
74   if (cb == NULL)
75     return;
76
77   ((CB_PVRLib*)cb)->TransferChannelEntry(((AddonCB*)hdl)->addonData, handle, chan);
78 }
79
80 DLLEXPORT void PVR_transfer_timer_entry(void *hdl, void* cb, const ADDON_HANDLE handle, const PVR_TIMER *timer)
81 {
82   if (cb == NULL)
83     return;
84
85   ((CB_PVRLib*)cb)->TransferTimerEntry(((AddonCB*)hdl)->addonData, handle, timer);
86 }
87
88 DLLEXPORT void PVR_transfer_recording_entry(void *hdl, void* cb, const ADDON_HANDLE handle, const PVR_RECORDING *recording)
89 {
90   if (cb == NULL)
91     return;
92
93   ((CB_PVRLib*)cb)->TransferRecordingEntry(((AddonCB*)hdl)->addonData, handle, recording);
94 }
95
96 DLLEXPORT void PVR_add_menu_hook(void *hdl, void* cb, PVR_MENUHOOK *hook)
97 {
98   if (cb == NULL)
99     return;
100
101   ((CB_PVRLib*)cb)->AddMenuHook(((AddonCB*)hdl)->addonData, hook);
102 }
103
104 DLLEXPORT void PVR_recording(void *hdl, void* cb, const char *Name, const char *FileName, bool On)
105 {
106   if (cb == NULL)
107     return;
108
109   ((CB_PVRLib*)cb)->Recording(((AddonCB*)hdl)->addonData, Name, FileName, On);
110 }
111
112 DLLEXPORT void PVR_trigger_channel_update(void *hdl, void* cb)
113 {
114   if (cb == NULL)
115     return;
116
117   ((CB_PVRLib*)cb)->TriggerChannelUpdate(((AddonCB*)hdl)->addonData);
118 }
119
120 DLLEXPORT void PVR_trigger_channel_groups_update(void *hdl, void* cb)
121 {
122   if (cb == NULL)
123     return;
124
125   ((CB_PVRLib*)cb)->TriggerChannelGroupsUpdate(((AddonCB*)hdl)->addonData);
126 }
127
128 DLLEXPORT void PVR_trigger_timer_update(void *hdl, void* cb)
129 {
130   if (cb == NULL)
131     return;
132
133   ((CB_PVRLib*)cb)->TriggerTimerUpdate(((AddonCB*)hdl)->addonData);
134 }
135
136 DLLEXPORT void PVR_trigger_recording_update(void *hdl, void* cb)
137 {
138   if (cb == NULL)
139     return;
140
141   ((CB_PVRLib*)cb)->TriggerRecordingUpdate(((AddonCB*)hdl)->addonData);
142 }
143
144 DLLEXPORT void PVR_trigger_epg_update(void* hdl, void* cb, unsigned int iChannelUid)
145 {
146   if (cb == NULL)
147     return;
148
149   ((CB_PVRLib*)cb)->TriggerEpgUpdate(((AddonCB*)hdl)->addonData, iChannelUid);
150 }
151
152 DLLEXPORT void PVR_free_demux_packet(void *hdl, void* cb, DemuxPacket* pPacket)
153 {
154   if (cb == NULL)
155     return;
156
157   ((CB_PVRLib*)cb)->FreeDemuxPacket(((AddonCB*)hdl)->addonData, pPacket);
158 }
159
160 DLLEXPORT DemuxPacket* PVR_allocate_demux_packet(void *hdl, void* cb, int iDataSize)
161 {
162   if (cb == NULL)
163     return NULL;
164
165   return ((CB_PVRLib*)cb)->AllocateDemuxPacket(((AddonCB*)hdl)->addonData, iDataSize);
166 }
167
168 DLLEXPORT void PVR_transfer_channel_group(void *hdl, void* cb, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP *group)
169 {
170   if (cb == NULL)
171     return;
172
173   ((CB_PVRLib*)cb)->TransferChannelGroup(((AddonCB*)hdl)->addonData, handle, group);
174 }
175
176 DLLEXPORT void PVR_transfer_channel_group_member(void *hdl, void* cb, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER *member)
177 {
178   if (cb == NULL)
179     return;
180
181   ((CB_PVRLib*)cb)->TransferChannelGroupMember(((AddonCB*)hdl)->addonData, handle, member);
182 }
183
184 };