dfe74ee31bc157f55ea0999910ff20a541f5e858
[vuplus_xbmc] / xbmc / pvr / channels / PVRChannel.cpp
1 /*
2  *      Copyright (C) 2012-2013 Team XBMC
3  *      http://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, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "FileItem.h"
22 #include "guilib/LocalizeStrings.h"
23 #include "utils/log.h"
24 #include "Util.h"
25 #include "filesystem/File.h"
26 #include "utils/StringUtils.h"
27 #include "threads/SingleLock.h"
28
29 #include "pvr/channels/PVRChannelGroupInternal.h"
30 #include "epg/EpgContainer.h"
31 #include "pvr/timers/PVRTimers.h"
32 #include "pvr/PVRDatabase.h"
33 #include "pvr/PVRManager.h"
34 #include "pvr/addons/PVRClients.h"
35
36 using namespace PVR;
37 using namespace EPG;
38
39 bool CPVRChannel::operator==(const CPVRChannel &right) const
40 {
41   return (m_bIsRadio  == right.m_bIsRadio &&
42           m_iUniqueId == right.m_iUniqueId &&
43           m_iClientId == right.m_iClientId);
44 }
45
46 bool CPVRChannel::operator!=(const CPVRChannel &right) const
47 {
48   return !(*this == right);
49 }
50
51 CPVRChannel::CPVRChannel(bool bRadio /* = false */)
52 {
53   m_iChannelId              = -1;
54   m_bIsRadio                = bRadio;
55   m_bIsHidden               = false;
56   m_bIsUserSetIcon          = false;
57   m_bIsLocked               = false;
58   m_strIconPath             = StringUtils::EmptyString;
59   m_strChannelName          = StringUtils::EmptyString;
60   m_bIsVirtual              = false;
61   m_iLastWatched            = 0;
62   m_bChanged                = false;
63   m_iCachedChannelNumber    = 0;
64
65   m_iEpgId                  = -1;
66   m_bEPGCreated             = false;
67   m_bEPGEnabled             = true;
68   m_strEPGScraper           = "client";
69
70   m_iUniqueId               = -1;
71   m_iClientId               = -1;
72   m_iClientChannelNumber    = -1;
73   m_strClientChannelName    = StringUtils::EmptyString;
74   m_strInputFormat          = StringUtils::EmptyString;
75   m_strStreamURL            = StringUtils::EmptyString;
76   m_strFileNameAndPath      = StringUtils::EmptyString;
77   m_iClientEncryptionSystem = -1;
78   UpdateEncryptionName();
79 }
80
81 CPVRChannel::CPVRChannel(const PVR_CHANNEL &channel, unsigned int iClientId)
82 {
83   m_iChannelId              = -1;
84   m_bIsRadio                = channel.bIsRadio;
85   m_bIsHidden               = channel.bIsHidden;
86   m_bIsUserSetIcon          = false;
87   m_bIsLocked               = false;
88   m_strIconPath             = channel.strIconPath;
89   m_strChannelName          = channel.strChannelName;
90   m_iUniqueId               = channel.iUniqueId;
91   m_iClientChannelNumber    = channel.iChannelNumber;
92   m_strClientChannelName    = channel.strChannelName;
93   m_strInputFormat          = channel.strInputFormat;
94   m_strStreamURL            = channel.strStreamURL;
95   m_iClientEncryptionSystem = channel.iEncryptionSystem;
96   m_iCachedChannelNumber    = 0;
97   m_iClientId               = iClientId;
98   m_strFileNameAndPath      = StringUtils::EmptyString;
99   m_bIsVirtual              = false;
100   m_iLastWatched            = 0;
101   m_bEPGEnabled             = !channel.bIsHidden;
102   m_strEPGScraper           = "client";
103   m_iEpgId                  = -1;
104   m_bEPGCreated             = false;
105   m_bChanged                = false;
106
107   if (m_strChannelName.IsEmpty())
108     m_strChannelName.Format("%s %d", g_localizeStrings.Get(19029), m_iUniqueId);
109
110   UpdateEncryptionName();
111 }
112
113 CPVRChannel::CPVRChannel(const CPVRChannel &channel)
114 {
115   *this = channel;
116 }
117
118 CPVRChannel &CPVRChannel::operator=(const CPVRChannel &channel)
119 {
120   m_iChannelId              = channel.m_iChannelId;
121   m_bIsRadio                = channel.m_bIsRadio;
122   m_bIsHidden               = channel.m_bIsHidden;
123   m_bIsUserSetIcon          = channel.m_bIsUserSetIcon;
124   m_bIsLocked               = channel.m_bIsLocked;
125   m_strIconPath             = channel.m_strIconPath;
126   m_strChannelName          = channel.m_strChannelName;
127   m_bIsVirtual              = channel.m_bIsVirtual;
128   m_iLastWatched            = channel.m_iLastWatched;
129   m_bEPGEnabled             = channel.m_bEPGEnabled;
130   m_strEPGScraper           = channel.m_strEPGScraper;
131   m_iUniqueId               = channel.m_iUniqueId;
132   m_iClientId               = channel.m_iClientId;
133   m_iClientChannelNumber    = channel.m_iClientChannelNumber;
134   m_strClientChannelName    = channel.m_strClientChannelName;
135   m_strInputFormat          = channel.m_strInputFormat;
136   m_strStreamURL            = channel.m_strStreamURL;
137   m_strFileNameAndPath      = channel.m_strFileNameAndPath;
138   m_iClientEncryptionSystem = channel.m_iClientEncryptionSystem;
139   m_iCachedChannelNumber    = channel.m_iCachedChannelNumber;
140   m_iEpgId                  = channel.m_iEpgId;
141   m_bEPGCreated             = channel.m_bEPGCreated;
142   m_bChanged                = channel.m_bChanged;
143
144   UpdateEncryptionName();
145
146   return *this;
147 }
148
149 void CPVRChannel::Serialize(CVariant& value) const
150 {
151   value["channelid"] = m_iChannelId;
152   value["channeltype"] = m_bIsRadio ? "radio" : "tv";
153   value["hidden"] = m_bIsHidden;
154   value["locked"] = m_bIsLocked;
155   value["icon"] = m_strIconPath;
156   value["channel"]  = m_strChannelName;
157   CDateTime lastPlayed(m_iLastWatched);
158   value["lastplayed"] = lastPlayed.IsValid() ? lastPlayed.GetAsDBDate() : StringUtils::EmptyString;
159   value["channelnumber"] = m_iCachedChannelNumber;
160   
161   CEpgInfoTag epg;
162   if (GetEPGNow(epg))
163     epg.Serialize(value);
164 }
165
166 /********** XBMC related channel methods **********/
167
168 bool CPVRChannel::Delete(void)
169 {
170   bool bReturn = false;
171   CPVRDatabase *database = GetPVRDatabase();
172   if (!database)
173     return bReturn;
174
175   /* delete the EPG table */
176   CEpg *epg = GetEPG();
177   if (epg)
178   {
179     CPVRChannelPtr empty;
180     epg->SetChannel(empty);
181     g_EpgContainer.DeleteEpg(*epg, true);
182     CSingleLock lock(m_critSection);
183     m_bEPGCreated = false;
184   }
185
186   bReturn = database->Delete(*this);
187   return bReturn;
188 }
189
190 CEpg *CPVRChannel::GetEPG(void) const
191 {
192   int iEpgId(-1);
193   {
194     CSingleLock lock(m_critSection);
195     if (!m_bIsHidden && m_bEPGEnabled && m_iEpgId > 0)
196       iEpgId = m_iEpgId;
197   }
198
199   return iEpgId > 0 ? g_EpgContainer.GetById(iEpgId) : NULL;
200 }
201
202 bool CPVRChannel::UpdateFromClient(const CPVRChannel &channel)
203 {
204   SetClientID(channel.ClientID());
205   SetClientChannelNumber(channel.ClientChannelNumber());
206   SetInputFormat(channel.InputFormat());
207   SetStreamURL(channel.StreamURL());
208   SetEncryptionSystem(channel.EncryptionSystem());
209   SetClientChannelName(channel.ClientChannelName());
210
211   CSingleLock lock(m_critSection);
212   if (m_strChannelName.IsEmpty())
213     SetChannelName(channel.ClientChannelName());
214   if (m_strIconPath.IsEmpty()||(!m_strIconPath.Equals(channel.IconPath()) && !IsUserSetIcon()))
215     SetIconPath(channel.IconPath());
216
217   return m_bChanged;
218 }
219
220 bool CPVRChannel::Persist(bool bQueueWrite /* = false */)
221 {
222   {
223     // not changed
224     CSingleLock lock(m_critSection);
225     if (!m_bChanged && m_iChannelId > 0)
226       return true;
227   }
228
229   if (CPVRDatabase *database = GetPVRDatabase())
230   {
231     bool bReturn = database->Persist(*this, bQueueWrite);
232     CSingleLock lock(m_critSection);
233     m_bChanged = !bReturn;
234     return bReturn;
235   }
236
237   return false;
238 }
239
240 bool CPVRChannel::SetChannelID(int iChannelId)
241 {
242   CSingleLock lock(m_critSection);
243   if (m_iChannelId != iChannelId)
244   {
245     /* update the id */
246     m_iChannelId = iChannelId;
247     SetChanged();
248     m_bChanged = true;
249
250     return true;
251   }
252
253   return false;
254 }
255
256 int CPVRChannel::ChannelNumber(void) const
257 {
258   CSingleLock lock(m_critSection);
259   return m_iCachedChannelNumber;
260 }
261
262 bool CPVRChannel::SetHidden(bool bIsHidden)
263 {
264   CSingleLock lock(m_critSection);
265
266   if (m_bIsHidden != bIsHidden)
267   {
268     /* update the hidden flag */
269     m_bIsHidden = bIsHidden;
270         m_bEPGEnabled = !bIsHidden;
271     SetChanged();
272     m_bChanged = true;
273
274     return true;
275   }
276
277   return false;
278 }
279
280 bool CPVRChannel::SetLocked(bool bIsLocked)
281 {
282   CSingleLock lock(m_critSection);
283
284   if (m_bIsLocked != bIsLocked)
285   {
286     /* update the locked flag */
287     m_bIsLocked = bIsLocked;
288     SetChanged();
289     m_bChanged = true;
290
291     return true;
292   }
293
294   return false;
295 }
296
297 bool CPVRChannel::IsRecording(void) const
298 {
299   return g_PVRTimers->IsRecordingOnChannel(*this);
300 }
301
302 bool CPVRChannel::SetIconPath(const CStdString &strIconPath, bool bIsUserSetIcon /* = false */)
303 {
304   CSingleLock lock(m_critSection);
305
306   if (m_strIconPath != strIconPath)
307   {
308     /* update the path */
309     m_strIconPath.Format("%s", strIconPath);
310     SetChanged();
311     m_bChanged = true;
312
313     /* did the user change the icon? */
314     if (bIsUserSetIcon)
315       m_bIsUserSetIcon = !m_strIconPath.IsEmpty();
316           
317     return true;
318   }
319
320   return false;
321 }
322
323 bool CPVRChannel::SetChannelName(const CStdString &strChannelName)
324 {
325   CStdString strName(strChannelName);
326
327   if (strName.IsEmpty())
328     strName.Format(g_localizeStrings.Get(19085), ClientChannelNumber());
329
330   CSingleLock lock(m_critSection);
331   if (m_strChannelName != strName)
332   {
333     /* update the channel name */
334     m_strChannelName = strName;
335     SetChanged();
336     m_bChanged = true;
337
338     return true;
339   }
340
341   return false;
342 }
343
344 bool CPVRChannel::SetVirtual(bool bIsVirtual)
345 {
346   CSingleLock lock(m_critSection);
347
348   if (m_bIsVirtual != bIsVirtual)
349   {
350     /* update the virtual flag */
351     m_bIsVirtual = bIsVirtual;
352     SetChanged();
353     m_bChanged = true;
354
355     return true;
356   }
357
358   return false;
359 }
360
361 bool CPVRChannel::SetLastWatched(time_t iLastWatched)
362 {
363   CSingleLock lock(m_critSection);
364
365   if (m_iLastWatched != iLastWatched)
366   {
367     /* update last watched  */
368     m_iLastWatched = iLastWatched;
369     SetChanged();
370     m_bChanged = true;
371
372     return true;
373   }
374
375   return false;
376 }
377
378 bool CPVRChannel::IsEmpty() const
379 {
380   CSingleLock lock(m_critSection);
381   return (m_strFileNameAndPath.IsEmpty() ||
382           m_strStreamURL.IsEmpty());
383 }
384
385 /********** Client related channel methods **********/
386
387 bool CPVRChannel::SetUniqueID(int iUniqueId)
388 {
389   CSingleLock lock(m_critSection);
390
391   if (m_iUniqueId != iUniqueId)
392   {
393     /* update the unique ID */
394     m_iUniqueId = iUniqueId;
395     SetChanged();
396     m_bChanged = true;
397
398     return true;
399   }
400
401   return false;
402 }
403
404 bool CPVRChannel::SetClientID(int iClientId)
405 {
406   CSingleLock lock(m_critSection);
407
408   if (m_iClientId != iClientId)
409   {
410     /* update the client ID */
411     m_iClientId = iClientId;
412     SetChanged();
413     m_bChanged = true;
414
415     return true;
416   }
417
418   return false;
419 }
420
421 bool CPVRChannel::SetClientChannelNumber(int iClientChannelNumber)
422 {
423   CSingleLock lock(m_critSection);
424
425   if (m_iClientChannelNumber != iClientChannelNumber && iClientChannelNumber > 0)
426   {
427     /* update the client channel number */
428     m_iClientChannelNumber = iClientChannelNumber;
429     SetChanged();
430     m_bChanged = true;
431
432     return true;
433   }
434
435   return false;
436 }
437
438 bool CPVRChannel::SetClientChannelName(const CStdString &strClientChannelName)
439 {
440   CSingleLock lock(m_critSection);
441
442   if (m_strClientChannelName != strClientChannelName)
443   {
444     /* update the client channel name */
445     m_strClientChannelName.Format("%s", strClientChannelName);
446     SetChanged();
447     // this is not persisted, so don't update m_bChanged
448
449     return true;
450   }
451
452   return false;
453 }
454
455 bool CPVRChannel::SetInputFormat(const CStdString &strInputFormat)
456 {
457   CSingleLock lock(m_critSection);
458
459   if (m_strInputFormat != strInputFormat)
460   {
461     /* update the input format */
462     m_strInputFormat.Format("%s", strInputFormat);
463     SetChanged();
464     m_bChanged = true;
465
466     return true;
467   }
468
469   return false;
470 }
471
472 bool CPVRChannel::SetStreamURL(const CStdString &strStreamURL)
473 {
474   CSingleLock lock(m_critSection);
475
476   if (m_strStreamURL != strStreamURL)
477   {
478     /* update the stream url */
479     m_strStreamURL.Format("%s", strStreamURL);
480     SetChanged();
481     m_bChanged = true;
482
483     return true;
484   }
485
486   return false;
487 }
488
489 void CPVRChannel::UpdatePath(CPVRChannelGroupInternal* group, unsigned int iNewChannelGroupPosition)
490 {
491   if (!group) return;
492
493   CStdString strFileNameAndPath;
494   CSingleLock lock(m_critSection);
495   strFileNameAndPath.Format("pvr://channels/%s/%s/%i.pvr", (m_bIsRadio ? "radio" : "tv"), group->GroupName().c_str(), iNewChannelGroupPosition);
496   if (m_strFileNameAndPath != strFileNameAndPath)
497   {
498     m_strFileNameAndPath = strFileNameAndPath;
499     SetChanged();
500   }
501 }
502
503 bool CPVRChannel::SetEncryptionSystem(int iClientEncryptionSystem)
504 {
505   CSingleLock lock(m_critSection);
506
507   if (m_iClientEncryptionSystem != iClientEncryptionSystem)
508   {
509     /* update the client encryption system */
510     m_iClientEncryptionSystem = iClientEncryptionSystem;
511     UpdateEncryptionName();
512     SetChanged();
513     m_bChanged = true;
514
515     return true;
516   }
517
518   return false;
519 }
520
521 void CPVRChannel::UpdateEncryptionName(void)
522 {
523   // http://www.dvb.org/index.php?id=174
524   // http://en.wikipedia.org/wiki/Conditional_access_system
525   CStdString strName(g_localizeStrings.Get(13205)); /* Unknown */
526   CSingleLock lock(m_critSection);
527
528   if (     m_iClientEncryptionSystem == 0x0000)
529     strName = g_localizeStrings.Get(19013); /* Free To Air */
530   else if (m_iClientEncryptionSystem >= 0x0001 &&
531            m_iClientEncryptionSystem <= 0x009F)
532     strName = g_localizeStrings.Get(19014); /* Fixed */
533   else if (m_iClientEncryptionSystem >= 0x00A0 &&
534            m_iClientEncryptionSystem <= 0x00A1)
535     strName = g_localizeStrings.Get(338); /* Analog */
536   else if (m_iClientEncryptionSystem >= 0x00A2 &&
537            m_iClientEncryptionSystem <= 0x00FF)
538     strName = g_localizeStrings.Get(19014); /* Fixed */
539   else if (m_iClientEncryptionSystem >= 0x0100 &&
540            m_iClientEncryptionSystem <= 0x01FF)
541     strName = "SECA Mediaguard";
542   else if (m_iClientEncryptionSystem == 0x0464)
543     strName = "EuroDec";
544   else if (m_iClientEncryptionSystem >= 0x0500 &&
545            m_iClientEncryptionSystem <= 0x05FF)
546     strName = "Viaccess";
547   else if (m_iClientEncryptionSystem >= 0x0600 &&
548            m_iClientEncryptionSystem <= 0x06FF)
549     strName = "Irdeto";
550   else if (m_iClientEncryptionSystem >= 0x0900 &&
551            m_iClientEncryptionSystem <= 0x09FF)
552     strName = "NDS Videoguard";
553   else if (m_iClientEncryptionSystem >= 0x0B00 &&
554            m_iClientEncryptionSystem <= 0x0BFF)
555     strName = "Conax";
556   else if (m_iClientEncryptionSystem >= 0x0D00 &&
557            m_iClientEncryptionSystem <= 0x0DFF)
558     strName = "CryptoWorks";
559   else if (m_iClientEncryptionSystem >= 0x0E00 &&
560            m_iClientEncryptionSystem <= 0x0EFF)
561     strName = "PowerVu";
562   else if (m_iClientEncryptionSystem == 0x1000)
563     strName = "RAS";
564   else if (m_iClientEncryptionSystem >= 0x1200 &&
565            m_iClientEncryptionSystem <= 0x12FF)
566     strName = "NagraVision";
567   else if (m_iClientEncryptionSystem >= 0x1700 &&
568            m_iClientEncryptionSystem <= 0x17FF)
569     strName = "BetaCrypt";
570   else if (m_iClientEncryptionSystem >= 0x1800 &&
571            m_iClientEncryptionSystem <= 0x18FF)
572     strName = "NagraVision";
573   else if (m_iClientEncryptionSystem == 0x22F0)
574     strName = "Codicrypt";
575   else if (m_iClientEncryptionSystem == 0x2600)
576     strName = "BISS";
577   else if (m_iClientEncryptionSystem == 0x4347)
578     strName = "CryptOn";
579   else if (m_iClientEncryptionSystem == 0x4800)
580     strName = "Accessgate";
581   else if (m_iClientEncryptionSystem == 0x4900)
582     strName = "China Crypt";
583   else if (m_iClientEncryptionSystem == 0x4A10)
584     strName = "EasyCas";
585   else if (m_iClientEncryptionSystem == 0x4A20)
586     strName = "AlphaCrypt";
587   else if (m_iClientEncryptionSystem == 0x4A70)
588     strName = "DreamCrypt";
589   else if (m_iClientEncryptionSystem == 0x4A60)
590     strName = "SkyCrypt";
591   else if (m_iClientEncryptionSystem == 0x4A61)
592     strName = "Neotioncrypt";
593   else if (m_iClientEncryptionSystem == 0x4A62)
594     strName = "SkyCrypt";
595   else if (m_iClientEncryptionSystem == 0x4A63)
596     strName = "Neotion SHL";
597   else if (m_iClientEncryptionSystem >= 0x4A64 &&
598            m_iClientEncryptionSystem <= 0x4A6F)
599     strName = "SkyCrypt";
600   else if (m_iClientEncryptionSystem == 0x4A80)
601     strName = "ThalesCrypt";
602   else if (m_iClientEncryptionSystem == 0x4AA1)
603     strName = "KeyFly";
604   else if (m_iClientEncryptionSystem == 0x4ABF)
605     strName = "DG-Crypt";
606   else if (m_iClientEncryptionSystem >= 0x4AD0 &&
607            m_iClientEncryptionSystem <= 0x4AD1)
608     strName = "X-Crypt";
609   else if (m_iClientEncryptionSystem == 0x4AD4)
610     strName = "OmniCrypt";
611   else if (m_iClientEncryptionSystem == 0x4AE0)
612     strName = "RossCrypt";
613   else if (m_iClientEncryptionSystem == 0x5500)
614     strName = "Z-Crypt";
615   else if (m_iClientEncryptionSystem == 0x5501)
616     strName = "Griffin";
617
618   if (m_iClientEncryptionSystem >= 0)
619     strName.AppendFormat(" (%04X)", m_iClientEncryptionSystem);
620
621   m_strClientEncryptionName = strName;
622 }
623
624 /********** EPG methods **********/
625
626 int CPVRChannel::GetEPG(CFileItemList &results) const
627 {
628   CEpg *epg = GetEPG();
629   if (!epg)
630   {
631     CLog::Log(LOGDEBUG, "PVR - %s - cannot get EPG for channel '%s'",
632         __FUNCTION__, m_strChannelName.c_str());
633     return -1;
634   }
635
636   return epg->Get(results);
637 }
638
639 bool CPVRChannel::ClearEPG() const
640 {
641   CEpg *epg = GetEPG();
642   if (epg)
643     epg->Clear();
644
645   return true;
646 }
647
648 bool CPVRChannel::GetEPGNow(CEpgInfoTag &tag) const
649 {
650   CEpg *epg = GetEPG();
651   return epg ? epg->InfoTagNow(tag) : false;
652 }
653
654 bool CPVRChannel::GetEPGNext(CEpgInfoTag &tag) const
655 {
656   CEpg *epg = GetEPG();
657   return epg ? epg->InfoTagNext(tag) : false;
658 }
659
660 bool CPVRChannel::SetEPGEnabled(bool bEPGEnabled)
661 {
662   CSingleLock lock(m_critSection);
663
664   if (m_bEPGEnabled != bEPGEnabled)
665   {
666     /* update the EPG flag */
667     m_bEPGEnabled = bEPGEnabled;
668     SetChanged();
669     m_bChanged = true;
670
671     /* clear the previous EPG entries if needed */
672     if (!m_bEPGEnabled && m_bEPGCreated)
673       ClearEPG();
674
675     return true;
676   }
677
678   return false;
679 }
680
681 bool CPVRChannel::SetEPGScraper(const CStdString &strScraper)
682 {
683   CSingleLock lock(m_critSection);
684
685   if (m_strEPGScraper != strScraper)
686   {
687     bool bCleanEPG = !m_strEPGScraper.IsEmpty() || strScraper.IsEmpty();
688
689     /* update the scraper name */
690     m_strEPGScraper.Format("%s", strScraper);
691     SetChanged();
692     m_bChanged = true;
693
694     /* clear the previous EPG entries if needed */
695     if (bCleanEPG && m_bEPGEnabled && m_bEPGCreated)
696       ClearEPG();
697
698     return true;
699   }
700
701   return false;
702 }
703
704 void CPVRChannel::SetCachedChannelNumber(unsigned int iChannelNumber)
705 {
706   CSingleLock lock(m_critSection);
707   m_iCachedChannelNumber = iChannelNumber;
708 }
709
710 void CPVRChannel::ToSortable(SortItem& sortable, Field field) const
711 {
712   if (field == FieldChannelName)
713   {
714     CSingleLock lock(m_critSection);
715     sortable[FieldChannelName] = m_strChannelName;
716   }
717 }
718
719 int CPVRChannel::ChannelID(void) const
720 {
721   CSingleLock lock(m_critSection);
722   return m_iChannelId;
723 }
724
725 bool CPVRChannel::IsNew(void) const
726 {
727   CSingleLock lock(m_critSection);
728   return m_iChannelId <= 0;
729 }
730
731 bool CPVRChannel::IsHidden(void) const
732 {
733   CSingleLock lock(m_critSection);
734   return m_bIsHidden;
735 }
736
737 bool CPVRChannel::IsLocked(void) const
738 {
739   CSingleLock lock(m_critSection);
740   return m_bIsLocked;
741 }
742
743 CStdString CPVRChannel::IconPath(void) const
744 {
745   CSingleLock lock(m_critSection);
746   CStdString strReturn(m_strIconPath);
747   return strReturn;
748 }
749
750 bool CPVRChannel::IsUserSetIcon(void) const
751 {
752   CSingleLock lock(m_critSection);
753   return m_bIsUserSetIcon;
754 }
755
756 CStdString CPVRChannel::ChannelName(void) const
757 {
758   CSingleLock lock(m_critSection);
759   return m_strChannelName;
760 }
761
762 bool CPVRChannel::IsVirtual(void) const
763 {
764   CSingleLock lock(m_critSection);
765   return m_bIsVirtual;
766 }
767
768 time_t CPVRChannel::LastWatched(void) const
769 {
770   CSingleLock lock(m_critSection);
771   return m_iLastWatched;
772 }
773
774 bool CPVRChannel::IsChanged() const
775 {
776   CSingleLock lock(m_critSection);
777   return m_bChanged;
778 }
779
780 int CPVRChannel::UniqueID(void) const
781 {
782   CSingleLock lock(m_critSection);
783   return m_iUniqueId;
784 }
785
786 int CPVRChannel::ClientID(void) const
787 {
788   CSingleLock lock(m_critSection);
789   return m_iClientId;
790 }
791
792 int CPVRChannel::ClientChannelNumber(void) const
793 {
794   CSingleLock lock(m_critSection);
795   return m_iClientChannelNumber;
796 }
797
798 CStdString CPVRChannel::ClientChannelName(void) const
799 {
800   CSingleLock lock(m_critSection);
801   CStdString strReturn(m_strClientChannelName);
802   return strReturn;
803 }
804
805 CStdString CPVRChannel::InputFormat(void) const
806 {
807   CSingleLock lock(m_critSection);
808   CStdString strReturn(m_strInputFormat);
809   return strReturn;
810 }
811
812 CStdString CPVRChannel::StreamURL(void) const
813 {
814   CSingleLock lock(m_critSection);
815   CStdString strReturn(m_strStreamURL);
816   return strReturn;
817 }
818
819 CStdString CPVRChannel::Path(void) const
820 {
821   CSingleLock lock(m_critSection);
822   CStdString strReturn(m_strFileNameAndPath);
823   return strReturn;
824 }
825
826 bool CPVRChannel::IsEncrypted(void) const
827 {
828   CSingleLock lock(m_critSection);
829   return m_iClientEncryptionSystem > 0;
830 }
831
832 int CPVRChannel::EncryptionSystem(void) const
833 {
834   CSingleLock lock(m_critSection);
835   return m_iClientEncryptionSystem;
836 }
837
838 CStdString CPVRChannel::EncryptionName(void) const
839 {
840   CSingleLock lock(m_critSection);
841   CStdString strReturn(m_strClientEncryptionName);
842   return strReturn;
843 }
844
845 int CPVRChannel::EpgID(void) const
846 {
847   CSingleLock lock(m_critSection);
848   return m_iEpgId;
849 }
850
851 void CPVRChannel::SetEpgID(int iEpgId)
852 {
853   CSingleLock lock(m_critSection);
854   m_iEpgId = iEpgId;
855   SetChanged();
856 }
857
858 bool CPVRChannel::EPGEnabled(void) const
859 {
860   CSingleLock lock(m_critSection);
861   return m_bEPGEnabled;
862 }
863
864 CStdString CPVRChannel::EPGScraper(void) const
865 {
866   CSingleLock lock(m_critSection);
867   CStdString strReturn(m_strEPGScraper);
868   return strReturn;
869 }
870
871 bool CPVRChannel::CanRecord(void) const
872 {
873   return g_PVRClients->SupportsRecordings(m_iClientId);
874 }