CPPMyth
Library to interoperate with MythTV server
Loading...
Searching...
No Matches
mythcontrol.h
1/*
2 * Copyright (C) 2014 Jean-Luc Barriere
3 *
4 * This Program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
7 * any later version.
8 *
9 * This Program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; see the file COPYING. If not, write to
16 * the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 */
21
22#ifndef MYTHCONTROL_H
23#define MYTHCONTROL_H
24
25#include "proto/mythprotomonitor.h"
26#include "mythtypes.h"
27#include "mythwsapi.h"
28
29namespace Myth
30{
31
32 class Control
33 {
34 public:
35 Control(const std::string& server, unsigned protoPort, unsigned wsapiPort, const std::string& wsapiSecurityPin);
36 Control(const std::string& server, unsigned protoPort, unsigned wsapiPort, const std::string& wsapiSecurityPin, bool frontend);
37 ~Control();
38
39 Control& WithAuthorization(const std::string& user, const std::string& password)
40 {
41 m_wsapi.WithAuthorization(user, password);
42 return *this;
43 }
44 Control& WithSSL(bool yesno)
45 {
46 m_wsapi.WithSSL(yesno);
47 return *this;
48 }
49
50 bool Open();
51 void Close();
52 bool IsOpen() { return m_monitor.IsOpen(); }
53 bool HasHanging() const { return m_monitor.HasHanging(); }
54 void CleanHanging() { m_monitor.CleanHanging(); }
55 ProtoBase::ERROR_t GetProtoError() const { return m_monitor.GetProtoError(); }
56
61 unsigned CheckService()
62 {
63 return m_wsapi.CheckService();
64 }
65
70 std::string GetServerHostName()
71 {
72 return m_wsapi.GetServerHostName();
73 }
74
79 std::string GetBaseURL()
80 {
81 return m_wsapi.GetBaseURL();
82 }
83
88 VersionPtr GetVersion()
89 {
90 return m_wsapi.GetVersion();
91 }
92
99 bool QueryFreeSpaceSummary(int64_t *total, int64_t *used)
100 {
101 return m_monitor.QueryFreeSpaceSummary(total, used);
102 }
103
109 bool QueryGenPixmap(const Program& program)
110 {
111 return m_monitor.QueryGenpixmap(program);
112 }
113
120 bool CancelNextRecording(int rnum, bool cancel)
121 {
122 return m_monitor.CancelNextRecording(rnum, cancel);
123 }
124
131 SettingPtr GetHostSetting(const std::string& key, const std::string& hostname)
132 {
133 return m_wsapi.GetHostSetting(key, hostname);
134 }
135
142 SettingPtr GetSetting(const std::string& key, bool myhost)
143 {
144 return m_wsapi.GetSetting(key, myhost);
145 }
146
152 SettingMapPtr GetHostSettings(const std::string& hostname)
153 {
154 return m_wsapi.GetHostSettings(hostname);
155 }
156
162 SettingMapPtr GetSettings(bool myhost)
163 {
164 return m_wsapi.GetSettings(myhost);
165 }
166
174 bool PutSetting(const std::string& key, const std::string& value, bool myhost)
175 {
176 return m_wsapi.PutSetting(key, value, myhost);
177 }
178
184 std::string GetBackendServerIP(const std::string& hostName);
185
191 std::string GetBackendServerIP6(const std::string& hostName);
192
198 unsigned GetBackendServerPort(const std::string& hostName);
199
206 ProgramListPtr GetRecordedList(unsigned n = 0, bool descending = false)
207 {
208 return m_wsapi.GetRecordedList(n, descending);
209 }
210
217 ProgramPtr GetRecorded(uint32_t chanid, time_t recstartts)
218 {
219 return m_wsapi.GetRecorded(chanid, recstartts);
220 }
221
227 ProgramPtr GetRecorded(uint32_t recordedid)
228 {
229 return m_wsapi.GetRecorded(recordedid);
230 }
231
238 bool UpdateRecordedWatchedStatus(const Program& program, bool watched)
239 {
240 WSServiceVersion_t wsv = m_wsapi.CheckService(WS_Dvr);
241 if (wsv.ranking >= 0x00060000)
242 return m_wsapi.UpdateRecordedWatchedStatus(program.recording.recordedId, watched);
243 return m_wsapi.UpdateRecordedWatchedStatus(program.channel.chanId, program.recording.startTs, watched);
244 }
245
253 bool DeleteRecording(const Program& program, bool forceDelete = false, bool allowRerecord = false)
254 {
255 WSServiceVersion_t wsv = m_wsapi.CheckService(WS_Dvr);
256 if (wsv.ranking >= 0x00060000)
257 return m_wsapi.DeleteRecording(program.recording.recordedId, forceDelete, allowRerecord);
258 if (wsv.ranking >= 0x00020001)
259 return m_wsapi.DeleteRecording(program.channel.chanId, program.recording.startTs, forceDelete, allowRerecord);
260 return m_monitor.DeleteRecording(program, forceDelete, allowRerecord);
261 }
262
263 bool UndeleteRecording(const Program& program)
264 {
265 WSServiceVersion_t wsv = m_wsapi.CheckService(WS_Dvr);
266 if (wsv.ranking >= 0x00060000)
267 return m_wsapi.UnDeleteRecording(program.recording.recordedId);
268 if (wsv.ranking >= 0x00020001)
269 return m_wsapi.UnDeleteRecording(program.channel.chanId, program.recording.startTs);
270 return m_monitor.UndeleteRecording(program);
271 }
272
273 bool StopRecording(const Program& program)
274 {
275 return m_monitor.StopRecording(program);
276 }
277
282 CaptureCardListPtr GetCaptureCardList()
283 {
284 return m_wsapi.GetCaptureCardList();
285 }
286
291 VideoSourceListPtr GetVideoSourceList()
292 {
293 return m_wsapi.GetVideoSourceList();
294 }
295
302 ChannelListPtr GetChannelList(uint32_t sourceid, bool onlyVisible = true)
303 {
304 return m_wsapi.GetChannelList(sourceid, onlyVisible);
305 }
306
312 ChannelPtr GetChannel(uint32_t chanid)
313 {
314 return m_wsapi.GetChannel(chanid);
315 }
316
324 ProgramMapPtr GetProgramGuide(uint32_t chanid, time_t starttime, time_t endtime)
325 {
326 return m_wsapi.GetProgramGuide(chanid, starttime, endtime);
327 }
328
335 std::map<uint32_t, ProgramMapPtr> GetProgramGuide(time_t starttime, time_t endtime)
336 {
337 return m_wsapi.GetProgramGuide(starttime, endtime);
338 }
339
344 RecordScheduleListPtr GetRecordScheduleList()
345 {
346 return m_wsapi.GetRecordScheduleList();
347 }
348
354 RecordSchedulePtr GetRecordSchedule(uint32_t recordid)
355 {
356 return m_wsapi.GetRecordSchedule(recordid);
357 }
358
365 {
366 return m_wsapi.AddRecordSchedule(record);
367 }
368
375 {
376 return m_wsapi.UpdateRecordSchedule(record);
377 }
378
384 bool DisableRecordSchedule(uint32_t recordid)
385 {
386 return m_wsapi.DisableRecordSchedule(recordid);
387 }
388
394 bool EnableRecordSchedule(uint32_t recordid)
395 {
396 return m_wsapi.EnableRecordSchedule(recordid);
397 }
398
404 bool RemoveRecordSchedule(uint32_t recordid)
405 {
406 return m_wsapi.RemoveRecordSchedule(recordid);
407 }
408
413 ProgramListPtr GetUpcomingList()
414 {
415 return m_wsapi.GetUpcomingList();
416 }
417
422 ProgramListPtr GetConflictList()
423 {
424 return m_wsapi.GetConflictList();
425 }
426
431 ProgramListPtr GetExpiringList()
432 {
433 return m_wsapi.GetExpiringList();
434 }
435
440 StringListPtr GetRecGroupList()
441 {
442 return m_wsapi.GetRecGroupList();
443 }
444
451 WSStreamPtr GetFile(const std::string& filename, const std::string& sgname)
452 {
453 return m_wsapi.GetFile(filename, sgname);
454 }
455
463 WSStreamPtr GetChannelIcon(uint32_t chanid, unsigned width = 0, unsigned height = 0)
464 {
465 return m_wsapi.GetChannelIcon(chanid, width, height);
466 }
467
475 std::string GetChannelIconUrl(uint32_t chanid, unsigned width = 0, unsigned height = 0)
476 {
477 return m_wsapi.GetChannelIconUrl(chanid, width, height);
478 }
479
487 WSStreamPtr GetPreviewImage(const Program& program, unsigned width = 0, unsigned height = 0)
488 {
489 return m_wsapi.GetPreviewImage(program.channel.chanId, program.recording.startTs, width, height);
490 }
491
499 std::string GetPreviewImageUrl(const Program& program, unsigned width = 0, unsigned height = 0)
500 {
501 return m_wsapi.GetPreviewImageUrl(program.channel.chanId, program.recording.startTs, width, height);
502 }
503
512 WSStreamPtr GetRecordingArtwork(const std::string& type, const Program& program, unsigned width = 0, unsigned height = 0)
513 {
514 return m_wsapi.GetRecordingArtwork(type, program.inetref, program.season, width, height);
515 }
516
525 std::string GetRecordingArtworkUrl(const std::string& type, const Program& program, unsigned width = 0, unsigned height = 0)
526 {
527 return m_wsapi.GetRecordingArtworkUrl(type, program.inetref, program.season, width, height);
528 }
529
536 ArtworkListPtr GetRecordingArtworkList(uint32_t chanid, time_t recstartts)
537 {
538 return m_wsapi.GetRecordingArtworkList(chanid, recstartts);
539 }
540
546 bool RefreshRecordedArtwork(Program& program);
547
554 MarkListPtr GetCutList(const Program& program, int unit = 0)
555 {
556 WSServiceVersion_t wsv = m_wsapi.CheckService(WS_Dvr);
557 if (wsv.ranking >= 0x00060001)
558 return m_wsapi.GetRecordedCutList(program.recording.recordedId, unit);
559 if (unit == 0)
560 return m_monitor.GetCutList(program);
561 else
562 return MarkListPtr(new MarkList);
563 }
564
571 MarkListPtr GetCommBreakList(const Program& program, int unit = 0)
572 {
573 WSServiceVersion_t wsv = m_wsapi.CheckService(WS_Dvr);
574 if (wsv.ranking >= 0x00060001)
575 return m_wsapi.GetRecordedCommBreak(program.recording.recordedId, unit);
576 if (unit == 0)
577 return m_monitor.GetCommBreakList(program);
578 else
579 return MarkListPtr(new MarkList);
580 }
581
587 {
588 return m_monitor.BlockShutdown();
589 }
590
596 {
597 return m_monitor.AllowShutdown();
598 }
599
606 bool SetSavedBookmark(const Program& program, int unit, int64_t value)
607 {
608 return m_wsapi.SetSavedBookmark(program.recording.recordedId, unit, value);
609 }
610
617 int64_t GetSavedBookmark(const Program& program, int unit)
618 {
619 return m_wsapi.GetSavedBookmark(program.recording.recordedId, unit);
620 }
621
622 private:
623 ProtoMonitor m_monitor;
624 WSAPI m_wsapi;
625
626 };
627
628}
629
630#endif /* MYTHCONTROL_H */
StringListPtr GetRecGroupList()
Get list of recording group.
CaptureCardListPtr GetCaptureCardList()
Get all configured capture devices.
std::string GetBaseURL()
Returns the base URL of WS-API.
Definition mythcontrol.h:79
std::string GetBackendServerIP(const std::string &hostName)
Query backend server IP.
unsigned GetBackendServerPort(const std::string &hostName)
Query backend server port for protocol commands.
ArtworkListPtr GetRecordingArtworkList(uint32_t chanid, time_t recstartts)
Get a list of artwork available for a recording by start time and channel id.
std::string GetChannelIconUrl(uint32_t chanid, unsigned width=0, unsigned height=0)
Get URL of icon for a given channel.
std::string GetPreviewImageUrl(const Program &program, unsigned width=0, unsigned height=0)
Get URL of preview thumbnail for a given recording by timestamp, chanid and starttime.
bool PutSetting(const std::string &key, const std::string &value, bool myhost)
Put setting.
ProgramMapPtr GetProgramGuide(uint32_t chanid, time_t starttime, time_t endtime)
Query the guide information for a particular time period and a channel.
unsigned CheckService()
Check availability of API services.
Definition mythcontrol.h:61
std::string GetServerHostName()
Query server host name.
Definition mythcontrol.h:70
bool AddRecordSchedule(RecordSchedule &record)
Add a new recording rule.
SettingPtr GetHostSetting(const std::string &key, const std::string &hostname)
Query setting by its key.
ChannelListPtr GetChannelList(uint32_t sourceid, bool onlyVisible=true)
Get all configured channels for a video source.
bool CancelNextRecording(int rnum, bool cancel)
Ask the backend to cancel/continue next recording.
VideoSourceListPtr GetVideoSourceList()
Get all video sources.
bool AllowShutdown()
Allows backend to shut down again after a previous call to BlockShutdown().
bool UpdateRecordedWatchedStatus(const Program &program, bool watched)
Update watched status for a recorded.
RecordSchedulePtr GetRecordSchedule(uint32_t recordid)
Get a single recording rule, by record id.
bool RefreshRecordedArtwork(Program &program)
Refresh artwork available for a recording.
ProgramPtr GetRecorded(uint32_t recordedid)
Query information on a single item from recordings.
VersionPtr GetVersion()
Query server version infos.
Definition mythcontrol.h:88
SettingPtr GetSetting(const std::string &key, bool myhost)
Query setting by its key.
bool EnableRecordSchedule(uint32_t recordid)
Enable a recording rule.
bool QueryGenPixmap(const Program &program)
Triggers preview image generation on the backend for a specified show.
bool QueryFreeSpaceSummary(int64_t *total, int64_t *used)
Queries the backend for free space summary.
Definition mythcontrol.h:99
ProgramListPtr GetConflictList()
Query information on upcoming items which will not record due to conflicts.
bool DeleteRecording(const Program &program, bool forceDelete=false, bool allowRerecord=false)
Remove a Recording from the database and disk.
bool DisableRecordSchedule(uint32_t recordid)
Disable a recording rule.
ProgramListPtr GetRecordedList(unsigned n=0, bool descending=false)
Query information on all recorded programs.
SettingMapPtr GetSettings(bool myhost)
Query all settings.
ProgramPtr GetRecorded(uint32_t chanid, time_t recstartts)
Query information on a single item from recordings.
WSStreamPtr GetRecordingArtwork(const std::string &type, const Program &program, unsigned width=0, unsigned height=0)
Get, and optionally scale, an image file of a given type (coverart, banner, fanart) for a given recor...
bool SetSavedBookmark(const Program &program, int unit, int64_t value)
Set saved bookmark for a program.
bool UpdateRecordSchedule(RecordSchedule &record)
Update a recording rule.
WSStreamPtr GetPreviewImage(const Program &program, unsigned width=0, unsigned height=0)
Get, and optionally scale, an preview thumbnail for a given recording by timestamp,...
bool RemoveRecordSchedule(uint32_t recordid)
Remove a recording rule.
ProgramListPtr GetExpiringList()
Query information on recorded programs which are set to expire.
SettingMapPtr GetHostSettings(const std::string &hostname)
Query all settings.
std::string GetRecordingArtworkUrl(const std::string &type, const Program &program, unsigned width=0, unsigned height=0)
Get an image URL of a given type (coverart, banner, fanart) for a given recording's inetref and seaso...
WSStreamPtr GetChannelIcon(uint32_t chanid, unsigned width=0, unsigned height=0)
Get the icon file for a given channel.
std::string GetBackendServerIP6(const std::string &hostName)
Query backend server IP6.
int64_t GetSavedBookmark(const Program &program, int unit)
Retrieve saved bookmark for a program.
std::map< uint32_t, ProgramMapPtr > GetProgramGuide(time_t starttime, time_t endtime)
Query the guide information for a particular time period.
RecordScheduleListPtr GetRecordScheduleList()
Query all configured recording rules.
MarkListPtr GetCommBreakList(const Program &program, int unit=0)
Request a set of commercial break marks for a recording.
ProgramListPtr GetUpcomingList()
Query information on all upcoming programs matching recording rules.
WSStreamPtr GetFile(const std::string &filename, const std::string &sgname)
Download a given file from a given storage group.
MarkListPtr GetCutList(const Program &program, int unit=0)
Request a set of cut list marks for a recording.
ChannelPtr GetChannel(uint32_t chanid)
Retrieve a single channel, by channel id.
bool BlockShutdown()
Prevents backend from shutting down until a the next call to AllowShutdown().
bool UnDeleteRecording(uint32_t chanid, time_t recstartts)
POST Dvr/UnDeleteRecording.
Definition mythwsapi.h:261
This is the main namespace that encloses all public classes.
Definition mythcontrol.h:30