-
Notifications
You must be signed in to change notification settings - Fork 341
/
channel.cpp
673 lines (560 loc) · 27 KB
/
channel.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
//////////////////////////////////////////////////////////////////////////////
// Program Name: channel.cpp
// Created : Apr. 8, 2011
//
// Copyright (c) 2011 Robert McNamara <rmcnamara@mythtv.org>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or at your option any later version of the LGPL.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library. If not, see <http://www.gnu.org/licenses/>.
//
//////////////////////////////////////////////////////////////////////////////
#include <QList>
#include <math.h>
#include "channel.h"
#include "compat.h"
#include "mythdbcon.h"
#include "mythdirs.h"
#include "mythversion.h"
#include "mythcorecontext.h"
#include "channelutil.h"
#include "sourceutil.h"
#include "datadirect.h"
#include "serviceUtil.h"
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
DTC::ChannelInfoList* Channel::GetChannelInfoList( int nSourceID,
int nStartIndex,
int nCount )
{
vector<uint> chanList;
chanList = ChannelUtil::GetChanIDs(nSourceID);
// ----------------------------------------------------------------------
// Build Response
// ----------------------------------------------------------------------
DTC::ChannelInfoList *pChannelInfos = new DTC::ChannelInfoList();
nStartIndex = min( nStartIndex, (int)chanList.size() );
nCount = (nCount > 0) ? min( nCount, (int)chanList.size() ) : chanList.size();
int nEndIndex = min((nStartIndex + nCount), (int)chanList.size() );
for( int n = nStartIndex; n < nEndIndex; n++)
{
DTC::ChannelInfo *pChannelInfo = pChannelInfos->AddNewChannelInfo();
int chanid = chanList.at(n);
QString channum = ChannelUtil::GetChanNum(chanid);
QString format, modulation, freqtable, freqid, dtv_si_std,
xmltvid, default_authority, icon;
int finetune, program_number;
uint64_t frequency;
uint atscmajor, atscminor, transportid, networkid, mplexid;
bool commfree = false;
bool eit = false;
bool visible = true;
if (ChannelUtil::GetExtendedChannelData( nSourceID, channum, format, modulation,
freqtable, freqid, finetune, frequency,
dtv_si_std, program_number, atscmajor,
atscminor, transportid, networkid, mplexid,
commfree, eit, visible, xmltvid, default_authority, icon ))
{
pChannelInfo->setChanId(chanid);
pChannelInfo->setChanNum(channum);
pChannelInfo->setCallSign(ChannelUtil::GetCallsign(chanid));
pChannelInfo->setIconURL(icon);
pChannelInfo->setChannelName(ChannelUtil::GetServiceName(chanid));
pChannelInfo->setMplexId(mplexid);
pChannelInfo->setServiceId(program_number);
pChannelInfo->setATSCMajorChan(atscmajor);
pChannelInfo->setATSCMinorChan(atscminor);
pChannelInfo->setFormat(format);
pChannelInfo->setModulation(modulation);
pChannelInfo->setFrequencyTable(freqtable);
pChannelInfo->setFineTune(finetune);
pChannelInfo->setFrequency((long)frequency);
pChannelInfo->setFrequencyId(freqid);
pChannelInfo->setSIStandard(dtv_si_std);
pChannelInfo->setTransportId(transportid);
pChannelInfo->setNetworkId(networkid);
pChannelInfo->setChanFilters(ChannelUtil::GetVideoFilters(nSourceID, channum));
pChannelInfo->setSourceId(nSourceID);
pChannelInfo->setCommFree(commfree);
pChannelInfo->setUseEIT(eit);
pChannelInfo->setVisible(visible);
pChannelInfo->setXMLTVID(xmltvid);
pChannelInfo->setDefaultAuth(default_authority);
}
}
int curPage = 0, totalPages = 0;
if (nCount == 0)
totalPages = 1;
else
totalPages = (int)ceil((float)chanList.size() / nCount);
if (totalPages == 1)
curPage = 1;
else
{
curPage = (int)ceil((float)nStartIndex / nCount) + 1;
}
pChannelInfos->setStartIndex ( nStartIndex );
pChannelInfos->setCount ( nCount );
pChannelInfos->setCurrentPage ( curPage );
pChannelInfos->setTotalPages ( totalPages );
pChannelInfos->setTotalAvailable( chanList.size() );
pChannelInfos->setAsOf ( QDateTime::currentDateTime() );
pChannelInfos->setVersion ( MYTH_BINARY_VERSION );
pChannelInfos->setProtoVer ( MYTH_PROTO_VERSION );
return pChannelInfos;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
DTC::ChannelInfo* Channel::GetChannelInfo( int nChanID )
{
if (nChanID == 0)
throw( QString("Channel ID appears invalid."));
DTC::ChannelInfo *pChannelInfo = new DTC::ChannelInfo();
QString channum = ChannelUtil::GetChanNum(nChanID);
uint sourceid = ChannelUtil::GetSourceIDForChannel(nChanID);
QString format, modulation, freqtable, freqid, dtv_si_std,
xmltvid, default_authority, icon;
int finetune, program_number;
uint64_t frequency;
uint atscmajor, atscminor, transportid, networkid, mplexid;
bool commfree = false;
bool eit = false;
bool visible = true;
if (ChannelUtil::GetExtendedChannelData( sourceid, channum, format, modulation,
freqtable, freqid, finetune, frequency,
dtv_si_std, program_number, atscmajor,
atscminor, transportid, networkid, mplexid,
commfree, eit, visible, xmltvid, default_authority, icon ))
{
pChannelInfo->setChanId(nChanID);
pChannelInfo->setChanNum(channum);
pChannelInfo->setCallSign(ChannelUtil::GetCallsign(nChanID));
pChannelInfo->setIconURL(icon);
pChannelInfo->setChannelName(ChannelUtil::GetServiceName(nChanID));
pChannelInfo->setMplexId(mplexid);
pChannelInfo->setServiceId(program_number);
pChannelInfo->setATSCMajorChan(atscmajor);
pChannelInfo->setATSCMinorChan(atscminor);
pChannelInfo->setFormat(format);
pChannelInfo->setModulation(modulation);
pChannelInfo->setFrequencyTable(freqtable);
pChannelInfo->setFineTune(finetune);
pChannelInfo->setFrequency((long)frequency);
pChannelInfo->setFrequencyId(freqid);
pChannelInfo->setSIStandard(dtv_si_std);
pChannelInfo->setTransportId(transportid);
pChannelInfo->setNetworkId(networkid);
pChannelInfo->setChanFilters(ChannelUtil::GetVideoFilters(sourceid, channum));
pChannelInfo->setSourceId(sourceid);
pChannelInfo->setCommFree(commfree);
pChannelInfo->setUseEIT(eit);
pChannelInfo->setVisible(visible);
pChannelInfo->setXMLTVID(xmltvid);
pChannelInfo->setDefaultAuth(default_authority);
}
else
throw( QString("Channel ID appears invalid."));
return pChannelInfo;
}
bool Channel::UpdateDBChannel( uint MplexID,
uint SourceID,
uint ChannelID,
const QString &CallSign,
const QString &ChannelName,
const QString &ChannelNumber,
uint ServiceID,
uint ATSCMajorChannel,
uint ATSCMinorChannel,
bool UseEIT,
bool visible,
const QString &FrequencyID,
const QString &Icon,
const QString &Format,
const QString &XMLTVID,
const QString &DefaultAuthority )
{
bool bResult = false;
bResult = ChannelUtil::UpdateChannel( MplexID, SourceID, ChannelID,
CallSign, ChannelName, ChannelNumber,
ServiceID, ATSCMajorChannel, ATSCMinorChannel,
UseEIT, !visible, false, FrequencyID,
Icon, Format, XMLTVID, DefaultAuthority );
return bResult;
}
bool Channel::CreateDBChannel( uint MplexID,
uint SourceID,
uint ChannelID,
const QString &CallSign,
const QString &ChannelName,
const QString &ChannelNumber,
uint ServiceID,
uint ATSCMajorChannel,
uint ATSCMinorChannel,
bool UseEIT,
bool visible,
const QString &FrequencyID,
const QString &Icon,
const QString &Format,
const QString &XMLTVID,
const QString &DefaultAuthority )
{
bool bResult = false;
bResult = ChannelUtil::CreateChannel( MplexID, SourceID, ChannelID,
CallSign, ChannelName, ChannelNumber,
ServiceID, ATSCMajorChannel, ATSCMinorChannel,
UseEIT, !visible, false, FrequencyID,
Icon, Format, XMLTVID, DefaultAuthority );
return bResult;
}
bool Channel::DeleteDBChannel( uint nChannelID )
{
bool bResult = false;
bResult = ChannelUtil::DeleteChannel( nChannelID );
return bResult;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
DTC::VideoSourceList* Channel::GetVideoSourceList()
{
MSqlQuery query(MSqlQuery::InitCon());
if (!query.isConnected())
throw( QString("Database not open while trying to list "
"Video Sources."));
query.prepare("SELECT sourceid, name, xmltvgrabber, userid, "
"freqtable, lineupid, password, useeit, configpath, "
"dvb_nit_id FROM videosource "
"ORDER BY sourceid" );
if (!query.exec())
{
MythDB::DBError("MythAPI::GetVideoSourceList()", query);
throw( QString( "Database Error executing query." ));
}
// ----------------------------------------------------------------------
// return the results of the query
// ----------------------------------------------------------------------
DTC::VideoSourceList* pList = new DTC::VideoSourceList();
while (query.next())
{
DTC::VideoSource *pVideoSource = pList->AddNewVideoSource();
pVideoSource->setId ( query.value(0).toInt() );
pVideoSource->setSourceName ( query.value(1).toString() );
pVideoSource->setGrabber ( query.value(2).toString() );
pVideoSource->setUserId ( query.value(3).toString() );
pVideoSource->setFreqTable ( query.value(4).toString() );
pVideoSource->setLineupId ( query.value(5).toString() );
pVideoSource->setPassword ( query.value(6).toString() );
pVideoSource->setUseEIT ( query.value(7).toBool() );
pVideoSource->setConfigPath ( query.value(8).toString() );
pVideoSource->setNITId ( query.value(9).toInt() );
}
pList->setAsOf ( QDateTime::currentDateTime() );
pList->setVersion ( MYTH_BINARY_VERSION );
pList->setProtoVer ( MYTH_PROTO_VERSION );
return pList;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
DTC::VideoSource* Channel::GetVideoSource( uint nSourceID )
{
MSqlQuery query(MSqlQuery::InitCon());
if (!query.isConnected())
throw( QString("Database not open while trying to list "
"Video Sources."));
query.prepare("SELECT name, xmltvgrabber, userid, "
"freqtable, lineupid, password, useeit, configpath, "
"dvb_nit_id FROM videosource WHERE sourceid = :SOURCEID "
"ORDER BY sourceid" );
query.bindValue(":SOURCEID", nSourceID);
if (!query.exec())
{
MythDB::DBError("MythAPI::GetVideoSource()", query);
throw( QString( "Database Error executing query." ));
}
// ----------------------------------------------------------------------
// return the results of the query
// ----------------------------------------------------------------------
DTC::VideoSource *pVideoSource = new DTC::VideoSource();
if (query.next())
{
pVideoSource->setId ( nSourceID );
pVideoSource->setSourceName ( query.value(0).toString() );
pVideoSource->setGrabber ( query.value(1).toString() );
pVideoSource->setUserId ( query.value(2).toString() );
pVideoSource->setFreqTable ( query.value(3).toString() );
pVideoSource->setLineupId ( query.value(4).toString() );
pVideoSource->setPassword ( query.value(5).toString() );
pVideoSource->setUseEIT ( query.value(6).toBool() );
pVideoSource->setConfigPath ( query.value(7).toString() );
pVideoSource->setNITId ( query.value(8).toInt() );
}
return pVideoSource;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
bool Channel::UpdateVideoSource( uint nSourceId,
const QString &sSourceName,
const QString &sGrabber,
const QString &sUserId,
const QString &sFreqTable,
const QString &sLineupId,
const QString &sPassword,
bool bUseEIT,
const QString &sConfigPath,
int nNITId )
{
bool bResult = false;
bResult = SourceUtil::UpdateSource(nSourceId, sSourceName, sGrabber, sUserId, sFreqTable,
sLineupId, sPassword, bUseEIT, sConfigPath,
nNITId);
return bResult;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
bool Channel::CreateVideoSource( const QString &sSourceName,
const QString &sGrabber,
const QString &sUserId,
const QString &sFreqTable,
const QString &sLineupId,
const QString &sPassword,
bool bUseEIT,
const QString &sConfigPath,
int nNITId )
{
bool bResult = false;
bResult = SourceUtil::CreateSource(sSourceName, sGrabber, sUserId, sFreqTable,
sLineupId, sPassword, bUseEIT, sConfigPath,
nNITId);
return bResult;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
bool Channel::DeleteVideoSource( uint nSourceID )
{
bool bResult = false;
bResult = SourceUtil::DeleteSource( nSourceID );
return bResult;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
DTC::LineupList* Channel::GetDDLineups( const QString &sSource,
const QString &sUserId,
const QString &sPassword )
{
int source = 0;
DTC::LineupList *pLineups = new DTC::LineupList();
if (sSource.toLower() == "schedulesdirect1" ||
sSource.toLower() == "schedulesdirect" ||
sSource.isEmpty())
{
source = 1;
DataDirectProcessor ddp(source, sUserId, sPassword);
if (!ddp.GrabLineupsOnly())
{
throw( QString("Unable to grab lineups. Check info."));
}
const DDLineupList lineups = ddp.GetLineups();
DDLineupList::const_iterator it;
for (it = lineups.begin(); it != lineups.end(); ++it)
{
DTC::Lineup *pLineup = pLineups->AddNewLineup();
pLineup->setLineupId((*it).lineupid);
pLineup->setName((*it).name);
pLineup->setDisplayName((*it).displayname);
pLineup->setType((*it).type);
pLineup->setPostal((*it).postal);
pLineup->setDevice((*it).device);
}
}
return pLineups;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
DTC::VideoMultiplexList* Channel::GetVideoMultiplexList( int nSourceID,
int nStartIndex,
int nCount )
{
MSqlQuery query(MSqlQuery::InitCon());
if (!query.isConnected())
throw( QString("Database not open while trying to list "
"Video Sources."));
query.prepare("SELECT mplexid, sourceid, transportid, networkid, "
"frequency, inversion, symbolrate, fec, polarity, "
"modulation, bandwidth, lp_code_rate, transmission_mode, "
"guard_interval, visible, constellation, hierarchy, hp_code_rate, "
"mod_sys, rolloff, sistandard, serviceversion, updatetimestamp, "
"default_authority FROM dtv_multiplex WHERE sourceid = :SOURCEID "
"ORDER BY mplexid" );
query.bindValue(":SOURCEID", nSourceID);
if (!query.exec())
{
MythDB::DBError("MythAPI::GetVideoMultiplexList()", query);
throw( QString( "Database Error executing query." ));
}
int muxCount = query.size();
// ----------------------------------------------------------------------
// Build Response
// ----------------------------------------------------------------------
DTC::VideoMultiplexList *pVideoMultiplexes = new DTC::VideoMultiplexList();
nStartIndex = min( nStartIndex, muxCount );
nCount = (nCount > 0) ? min( nCount, muxCount ) : muxCount;
int nEndIndex = min((nStartIndex + nCount), muxCount );
for( int n = nStartIndex; n < nEndIndex; n++)
{
if (query.seek(n))
{
DTC::VideoMultiplex *pVideoMultiplex = pVideoMultiplexes->AddNewVideoMultiplex();
pVideoMultiplex->setMplexId( query.value(0).toInt() );
pVideoMultiplex->setSourceId( query.value(1).toInt() );
pVideoMultiplex->setTransportId( query.value(2).toInt() );
pVideoMultiplex->setNetworkId( query.value(3).toInt() );
pVideoMultiplex->setFrequency( query.value(4).toLongLong() );
pVideoMultiplex->setInversion( query.value(5).toString() );
pVideoMultiplex->setSymbolRate( query.value(6).toLongLong() );
pVideoMultiplex->setFEC( query.value(7).toString() );
pVideoMultiplex->setPolarity( query.value(8).toString() );
pVideoMultiplex->setModulation( query.value(9).toString() );
pVideoMultiplex->setBandwidth( query.value(10).toString() );
pVideoMultiplex->setLPCodeRate( query.value(11).toString() );
pVideoMultiplex->setTransmissionMode( query.value(12).toString() );
pVideoMultiplex->setGuardInterval( query.value(13).toString() );
pVideoMultiplex->setVisible( query.value(14).toBool() );
pVideoMultiplex->setConstellation( query.value(15).toString() );
pVideoMultiplex->setHierarchy( query.value(16).toString() );
pVideoMultiplex->setHPCodeRate( query.value(17).toString() );
pVideoMultiplex->setModulationSystem( query.value(18).toString() );
pVideoMultiplex->setRollOff( query.value(19).toString() );
pVideoMultiplex->setSIStandard( query.value(20).toString() );
pVideoMultiplex->setServiceVersion( query.value(21).toInt() );
pVideoMultiplex->setUpdateTimeStamp( query.value(22).toDateTime() );
pVideoMultiplex->setDefaultAuthority( query.value(23).toString() );
}
}
int curPage = 0, totalPages = 0;
if (nCount == 0)
totalPages = 1;
else
totalPages = (int)ceil((float)muxCount / nCount);
if (totalPages == 1)
curPage = 1;
else
{
curPage = (int)ceil((float)nStartIndex / nCount) + 1;
}
pVideoMultiplexes->setStartIndex ( nStartIndex );
pVideoMultiplexes->setCount ( nCount );
pVideoMultiplexes->setCurrentPage ( curPage );
pVideoMultiplexes->setTotalPages ( totalPages );
pVideoMultiplexes->setTotalAvailable( muxCount );
pVideoMultiplexes->setAsOf ( QDateTime::currentDateTime() );
pVideoMultiplexes->setVersion ( MYTH_BINARY_VERSION );
pVideoMultiplexes->setProtoVer ( MYTH_PROTO_VERSION );
return pVideoMultiplexes;
}
DTC::VideoMultiplex* Channel::GetVideoMultiplex( int nMplexID )
{
MSqlQuery query(MSqlQuery::InitCon());
if (!query.isConnected())
throw( QString("Database not open while trying to list "
"Video Multiplex."));
query.prepare("SELECT sourceid, transportid, networkid, "
"frequency, inversion, symbolrate, fec, polarity, "
"modulation, bandwidth, lp_code_rate, transmission_mode, "
"guard_interval, visible, constellation, hierarchy, hp_code_rate, "
"mod_sys, rolloff, sistandard, serviceversion, updatetimestamp, "
"default_authority FROM dtv_multiplex WHERE mplexid = :MPLEXID "
"ORDER BY mplexid" );
query.bindValue(":MPLEXID", nMplexID);
if (!query.exec())
{
MythDB::DBError("MythAPI::GetVideoMultiplex()", query);
throw( QString( "Database Error executing query." ));
}
DTC::VideoMultiplex *pVideoMultiplex = new DTC::VideoMultiplex();
if (query.next())
{
pVideoMultiplex->setMplexId( nMplexID );
pVideoMultiplex->setSourceId( query.value(0).toInt() );
pVideoMultiplex->setTransportId( query.value(1).toInt() );
pVideoMultiplex->setNetworkId( query.value(2).toInt() );
pVideoMultiplex->setFrequency( query.value(3).toLongLong() );
pVideoMultiplex->setInversion( query.value(4).toString() );
pVideoMultiplex->setSymbolRate( query.value(5).toLongLong() );
pVideoMultiplex->setFEC( query.value(6).toString() );
pVideoMultiplex->setPolarity( query.value(7).toString() );
pVideoMultiplex->setModulation( query.value(8).toString() );
pVideoMultiplex->setBandwidth( query.value(9).toString() );
pVideoMultiplex->setLPCodeRate( query.value(10).toString() );
pVideoMultiplex->setTransmissionMode( query.value(11).toString() );
pVideoMultiplex->setGuardInterval( query.value(12).toString() );
pVideoMultiplex->setVisible( query.value(13).toBool() );
pVideoMultiplex->setConstellation( query.value(14).toString() );
pVideoMultiplex->setHierarchy( query.value(15).toString() );
pVideoMultiplex->setHPCodeRate( query.value(16).toString() );
pVideoMultiplex->setModulationSystem( query.value(17).toString() );
pVideoMultiplex->setRollOff( query.value(18).toString() );
pVideoMultiplex->setSIStandard( query.value(19).toString() );
pVideoMultiplex->setServiceVersion( query.value(20).toInt() );
pVideoMultiplex->setUpdateTimeStamp( query.value(21).toDateTime() );
pVideoMultiplex->setDefaultAuthority( query.value(22).toString() );
}
return pVideoMultiplex;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
QStringList Channel::GetXMLTVIds( int SourceID )
{
MSqlQuery query(MSqlQuery::InitCon());
if (!query.isConnected())
throw( QString("Database not open while trying to get source name."));
query.prepare("SELECT name FROM videosource WHERE sourceid = :SOURCEID ");
query.bindValue(":SOURCEID", SourceID);
if (!query.exec())
{
MythDB::DBError("MythAPI::GetXMLTVIds()", query);
throw( QString( "Database Error executing query." ));
}
QStringList idList;
if (query.next())
{
QString sourceName = query.value(0).toString();
QString xmltvFile = GetConfDir() + '/' + sourceName + ".xmltv";
if (QFile::exists(xmltvFile))
{
QFile file(xmltvFile);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return idList;
while (!file.atEnd())
{
QByteArray line = file.readLine();
if (line.startsWith("channel="))
{
QString id = line.mid(8, -1).trimmed();
idList.append(id);
}
}
idList.sort();
}
}
else
throw(QString("SourceID (%1) not found").arg(SourceID));
return idList;
}