Skip to content

Commit 0bef566

Browse files
author
Robert McNamara
committed
Capture API: Add methods to query configured capture devices.
Also, disambiguate some capture API arguments (Id -> CardId and CardInputId) Adds the following APIs: ==GetCaptureCardList== * Returns a list of configured capture devices using the CaptureCardList data contract. * Takes optional arguments CardType and HostName to filter by those two criteria, otherwise return all capture devices. Usage: http://BackendServerIP:6544/Capture/GetCaptureCardList?CardType=HDHOMERUN&HostName=myhost Return: <CaptureCardList version="1.0" serializerVersion="1.1"> <CaptureCards> <CaptureCard> <CardId>3</CardId> <VideoDevice>12345678-0</VideoDevice> <AudioDevice/> <VBIDevice/> <CardType>HDHOMERUN</CardType> <DefaultInput>MPEG2TS</DefaultInput> <AudioRateLimit>0</AudioRateLimit> <HostName>myhost</HostName> <DVBSWFilter>0</DVBSWFilter> <DVBSatType>0</DVBSatType> <DVBWaitForSeqStart>true</DVBWaitForSeqStart> <SkipBTAudio>false</SkipBTAudio> <DVBOnDemand>false</DVBOnDemand> <DVBDiSEqCType>0</DVBDiSEqCType> <FirewireSpeed>0</FirewireSpeed> <FirewireModel/> <FirewireConnection>0</FirewireConnection> <SignalTimeout>1000</SignalTimeout> <ChannelTimeout>3000</ChannelTimeout> <DVBTuningDelay>0</DVBTuningDelay> <Contrast>0</Contrast> <Brightness>0</Brightness> <Colour>0</Colour> <Hue>0</Hue> <DiSEqCId>0</DiSEqCId> <DVBEITScan>true</DVBEITScan> </CaptureCard> </CaptureCards> </CaptureCardList> ==GetCaptureCard== * Returns a single Capture Device, by cardid, using the CaptureCard data contract. * Takes mandatory argument CardId. Usage: http://BackendServerIP:6544/Capture/GetCaptureCard?CardId=1 Return: <CaptureCard version="1.0" serializerVersion="1.1"> <CardId>1</CardId> <VideoDevice>/dev/dvb/adapter0/frontend0</VideoDevice> <AudioDevice/> <VBIDevice/> <CardType>DVB</CardType> <DefaultInput>DVBInput</DefaultInput> <AudioRateLimit>0</AudioRateLimit> <HostName>myhost</HostName> <DVBSWFilter>0</DVBSWFilter> <DVBSatType>0</DVBSatType> <DVBWaitForSeqStart>true</DVBWaitForSeqStart> <SkipBTAudio>false</SkipBTAudio> <DVBOnDemand>false</DVBOnDemand> <DVBDiSEqCType>0</DVBDiSEqCType> <FirewireSpeed>0</FirewireSpeed> <FirewireModel/> <FirewireConnection>0</FirewireConnection> <SignalTimeout>500</SignalTimeout> <ChannelTimeout>3000</ChannelTimeout> <DVBTuningDelay>0</DVBTuningDelay> <Contrast>0</Contrast> <Brightness>0</Brightness> <Colour>0</Colour> <Hue>0</Hue> <DiSEqCId>0</DiSEqCId> <DVBEITScan>true</DVBEITScan> </CaptureCard>
1 parent d0742ba commit 0bef566

File tree

5 files changed

+189
-26
lines changed

5 files changed

+189
-26
lines changed

mythtv/libs/libmythservicecontracts/datacontracts/captureCard.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ class SERVICE_PUBLIC CaptureCard : public QObject
3737
Q_OBJECT
3838
Q_CLASSINFO( "version" , "1.0" );
3939

40-
Q_PROPERTY( QString CardId READ CardId WRITE setCardId )
40+
Q_PROPERTY( uint CardId READ CardId WRITE setCardId )
4141
Q_PROPERTY( QString VideoDevice READ VideoDevice WRITE setVideoDevice )
4242
Q_PROPERTY( QString AudioDevice READ AudioDevice WRITE setAudioDevice )
43+
Q_PROPERTY( QString VBIDevice READ VBIDevice WRITE setVBIDevice )
4344
Q_PROPERTY( QString CardType READ CardType WRITE setCardType )
4445
Q_PROPERTY( QString DefaultInput READ DefaultInput WRITE setDefaultInput )
4546
Q_PROPERTY( uint AudioRateLimit READ AudioRateLimit WRITE setAudioRateLimit )
@@ -63,9 +64,10 @@ class SERVICE_PUBLIC CaptureCard : public QObject
6364
Q_PROPERTY( uint DiSEqCId READ DiSEqCId WRITE setDiSEqCId )
6465
Q_PROPERTY( bool DVBEITScan READ DVBEITScan WRITE setDVBEITScan )
6566

66-
PROPERTYIMP( QString , CardId )
67+
PROPERTYIMP( uint , CardId )
6768
PROPERTYIMP( QString , VideoDevice )
6869
PROPERTYIMP( QString , AudioDevice )
70+
PROPERTYIMP( QString , VBIDevice )
6971
PROPERTYIMP( QString , CardType )
7072
PROPERTYIMP( QString , DefaultInput )
7173
PROPERTYIMP( uint , AudioRateLimit )
@@ -100,7 +102,7 @@ class SERVICE_PUBLIC CaptureCard : public QObject
100102
public:
101103

102104
CaptureCard(QObject *parent = 0)
103-
: QObject ( parent ),
105+
: QObject ( parent ), m_CardId(0),
104106
m_AudioRateLimit(0), m_DVBSWFilter(0),
105107
m_DVBSatType(0), m_DVBWaitForSeqStart(false),
106108
m_SkipBTAudio(false), m_DVBOnDemand(false),

mythtv/libs/libmythservicecontracts/services/captureServices.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
class SERVICE_PUBLIC CaptureServices : public Service
5252
{
5353
Q_OBJECT
54-
Q_CLASSINFO( "version" , "1.1" );
54+
Q_CLASSINFO( "version" , "1.2" );
5555
Q_CLASSINFO( "RemoveCaptureCard_Method", "POST" )
5656
Q_CLASSINFO( "AddCaptureCard_Method", "POST" )
5757
Q_CLASSINFO( "UpdateCaptureCard_Method", "POST" )
@@ -72,7 +72,12 @@ class SERVICE_PUBLIC CaptureServices : public Service
7272

7373
public slots:
7474

75-
virtual bool RemoveCaptureCard ( int Id ) = 0;
75+
virtual DTC::CaptureCardList* GetCaptureCardList ( const QString &HostName,
76+
const QString &CardType ) = 0;
77+
78+
virtual DTC::CaptureCard* GetCaptureCard ( int CardId ) = 0;
79+
80+
virtual bool RemoveCaptureCard ( int CardId ) = 0;
7681

7782
virtual int AddCaptureCard ( const QString &VideoDevice,
7883
const QString &AudioDevice,
@@ -100,13 +105,13 @@ class SERVICE_PUBLIC CaptureServices : public Service
100105
const uint DiSEqCId,
101106
bool DVBEITScan) = 0;
102107

103-
virtual bool UpdateCaptureCard ( int Id,
108+
virtual bool UpdateCaptureCard ( int CardId,
104109
const QString &Setting,
105110
const QString &Value ) = 0;
106111

107112
// Card Inputs
108113

109-
virtual bool RemoveCardInput ( int Id ) = 0;
114+
virtual bool RemoveCardInput ( int CardInputId) = 0;
110115

111116
virtual int AddCardInput ( const uint CardId,
112117
const uint SourceId,
@@ -122,7 +127,7 @@ class SERVICE_PUBLIC CaptureServices : public Service
122127
const uint RecPriority,
123128
const uint Quicktune) = 0;
124129

125-
virtual bool UpdateCardInput ( int Id,
130+
virtual bool UpdateCardInput ( int CardInputId,
126131
const QString &Setting,
127132
const QString &Value ) = 0;
128133
};

mythtv/programs/mythbackend/services/capture.cpp

Lines changed: 165 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,165 @@
3737
//
3838
/////////////////////////////////////////////////////////////////////////////
3939

40-
bool Capture::RemoveCaptureCard( int nId )
40+
DTC::CaptureCardList* Capture::GetCaptureCardList( const QString &sHostName,
41+
const QString &sCardType )
4142
{
42-
if ( nId < 1 )
43+
MSqlQuery query(MSqlQuery::InitCon());
44+
45+
if (!query.isConnected())
46+
throw( QString("Database not open while trying to list "
47+
"Capture Cards."));
48+
49+
QString str = "SELECT cardid, videodevice, audiodevice, vbidevice, "
50+
"cardtype, defaultinput, audioratelimit, hostname, "
51+
"dvb_swfilter, dvb_sat_type, dvb_wait_for_seqstart, "
52+
"skipbtaudio, dvb_on_demand, dvb_diseqc_type, "
53+
"firewire_speed, firewire_model, firewire_connection, "
54+
"signal_timeout, channel_timeout, dvb_tuning_delay, "
55+
"contrast, brightness, colour, hue, diseqcid, dvb_eitscan "
56+
"from capturecard";
57+
58+
if (!sHostName.isEmpty())
59+
str += " WHERE hostname = :HOSTNAME";
60+
else if (!sCardType.isEmpty())
61+
str += " WHERE cardtype = :CARDTYPE";
62+
63+
if (!sHostName.isEmpty() && !sCardType.isEmpty())
64+
str += " AND cardtype = :CARDTYPE";
65+
66+
query.prepare(str);
67+
68+
if (!sHostName.isEmpty())
69+
query.bindValue(":HOSTNAME", sHostName);
70+
if (!sCardType.isEmpty())
71+
query.bindValue(":CARDTYPE", sCardType);
72+
73+
if (!query.exec())
74+
{
75+
MythDB::DBError("MythAPI::GetCaptureCardList()", query);
76+
throw( QString( "Database Error executing query." ));
77+
}
78+
79+
// ----------------------------------------------------------------------
80+
// return the results of the query
81+
// ----------------------------------------------------------------------
82+
83+
DTC::CaptureCardList* pList = new DTC::CaptureCardList();
84+
85+
while (query.next())
86+
{
87+
88+
DTC::CaptureCard *pCaptureCard = pList->AddNewCaptureCard();
89+
90+
pCaptureCard->setCardId ( query.value(0).toInt() );
91+
pCaptureCard->setVideoDevice ( query.value(1).toString() );
92+
pCaptureCard->setAudioDevice ( query.value(2).toString() );
93+
pCaptureCard->setVBIDevice ( query.value(3).toString() );
94+
pCaptureCard->setCardType ( query.value(4).toString() );
95+
pCaptureCard->setDefaultInput ( query.value(5).toString() );
96+
pCaptureCard->setAudioRateLimit ( query.value(6).toUInt() );
97+
pCaptureCard->setHostName ( query.value(7).toString() );
98+
pCaptureCard->setDVBSWFilter ( query.value(8).toUInt() );
99+
pCaptureCard->setDVBSatType ( query.value(9).toUInt() );
100+
pCaptureCard->setDVBWaitForSeqStart( query.value(10).toBool() );
101+
pCaptureCard->setSkipBTAudio ( query.value(11).toBool() );
102+
pCaptureCard->setDVBOnDemand ( query.value(12).toBool() );
103+
pCaptureCard->setDVBDiSEqCType ( query.value(13).toUInt() );
104+
pCaptureCard->setFirewireSpeed ( query.value(14).toUInt() );
105+
pCaptureCard->setFirewireModel ( query.value(15).toString() );
106+
pCaptureCard->setFirewireConnection( query.value(16).toUInt() );
107+
pCaptureCard->setSignalTimeout ( query.value(17).toUInt() );
108+
pCaptureCard->setChannelTimeout ( query.value(18).toUInt() );
109+
pCaptureCard->setDVBTuningDelay ( query.value(19).toUInt() );
110+
pCaptureCard->setContrast ( query.value(20).toUInt() );
111+
pCaptureCard->setBrightness ( query.value(21).toUInt() );
112+
pCaptureCard->setColour ( query.value(22).toUInt() );
113+
pCaptureCard->setHue ( query.value(23).toUInt() );
114+
pCaptureCard->setDiSEqCId ( query.value(24).toUInt() );
115+
pCaptureCard->setDVBEITScan ( query.value(25).toBool() );
116+
}
117+
118+
return pList;
119+
}
120+
121+
/////////////////////////////////////////////////////////////////////////////
122+
//
123+
/////////////////////////////////////////////////////////////////////////////
124+
125+
DTC::CaptureCard* Capture::GetCaptureCard( int nCardId )
126+
{
127+
if ( nCardId < 1 )
128+
throw( QString( "The Card ID is invalid."));
129+
130+
MSqlQuery query(MSqlQuery::InitCon());
131+
132+
if (!query.isConnected())
133+
throw( QString("Database not open while trying to list "
134+
"Capture Cards."));
135+
136+
QString str = "SELECT cardid, videodevice, audiodevice, vbidevice, "
137+
"cardtype, defaultinput, audioratelimit, hostname, "
138+
"dvb_swfilter, dvb_sat_type, dvb_wait_for_seqstart, "
139+
"skipbtaudio, dvb_on_demand, dvb_diseqc_type, "
140+
"firewire_speed, firewire_model, firewire_connection, "
141+
"signal_timeout, channel_timeout, dvb_tuning_delay, "
142+
"contrast, brightness, colour, hue, diseqcid, dvb_eitscan "
143+
"from capturecard WHERE cardid = :CARDID";
144+
145+
query.prepare(str);
146+
query.bindValue(":CARDID", nCardId);
147+
148+
if (!query.exec())
149+
{
150+
MythDB::DBError("MythAPI::GetCaptureCard()", query);
151+
throw( QString( "Database Error executing query." ));
152+
}
153+
154+
DTC::CaptureCard* pCaptureCard = new DTC::CaptureCard();
155+
156+
if (query.next())
157+
{
158+
pCaptureCard->setCardId ( query.value(0).toInt() );
159+
pCaptureCard->setVideoDevice ( query.value(1).toString() );
160+
pCaptureCard->setAudioDevice ( query.value(2).toString() );
161+
pCaptureCard->setVBIDevice ( query.value(3).toString() );
162+
pCaptureCard->setCardType ( query.value(4).toString() );
163+
pCaptureCard->setDefaultInput ( query.value(5).toString() );
164+
pCaptureCard->setAudioRateLimit ( query.value(6).toUInt() );
165+
pCaptureCard->setHostName ( query.value(7).toString() );
166+
pCaptureCard->setDVBSWFilter ( query.value(8).toUInt() );
167+
pCaptureCard->setDVBSatType ( query.value(9).toUInt() );
168+
pCaptureCard->setDVBWaitForSeqStart( query.value(10).toBool() );
169+
pCaptureCard->setSkipBTAudio ( query.value(11).toBool() );
170+
pCaptureCard->setDVBOnDemand ( query.value(12).toBool() );
171+
pCaptureCard->setDVBDiSEqCType ( query.value(13).toUInt() );
172+
pCaptureCard->setFirewireSpeed ( query.value(14).toUInt() );
173+
pCaptureCard->setFirewireModel ( query.value(15).toString() );
174+
pCaptureCard->setFirewireConnection( query.value(16).toUInt() );
175+
pCaptureCard->setSignalTimeout ( query.value(17).toUInt() );
176+
pCaptureCard->setChannelTimeout ( query.value(18).toUInt() );
177+
pCaptureCard->setDVBTuningDelay ( query.value(19).toUInt() );
178+
pCaptureCard->setContrast ( query.value(20).toUInt() );
179+
pCaptureCard->setBrightness ( query.value(21).toUInt() );
180+
pCaptureCard->setColour ( query.value(22).toUInt() );
181+
pCaptureCard->setHue ( query.value(23).toUInt() );
182+
pCaptureCard->setDiSEqCId ( query.value(24).toUInt() );
183+
pCaptureCard->setDVBEITScan ( query.value(25).toBool() );
184+
}
185+
186+
return pCaptureCard;
187+
}
188+
189+
/////////////////////////////////////////////////////////////////////////////
190+
//
191+
/////////////////////////////////////////////////////////////////////////////
192+
193+
bool Capture::RemoveCaptureCard( int nCardId )
194+
{
195+
if ( nCardId < 1 )
43196
throw( QString( "The Card ID is invalid."));
44197

45-
bool bResult = CardUtil::DeleteCard(nId);
198+
bool bResult = CardUtil::DeleteCard(nCardId);
46199

47200
return bResult;
48201
}
@@ -96,24 +249,24 @@ int Capture::AddCaptureCard ( const QString &sVideoDevice,
96249
return nResult;
97250
}
98251

99-
bool Capture::UpdateCaptureCard ( int nId,
252+
bool Capture::UpdateCaptureCard ( int nCardId,
100253
const QString &sSetting,
101254
const QString &sValue )
102255
{
103-
if ( nId < 1 || sSetting.isEmpty() || sValue.isEmpty() )
256+
if ( nCardId < 1 || sSetting.isEmpty() || sValue.isEmpty() )
104257
throw( QString( "Card ID, Setting Name, and Value are required." ));
105258

106-
return set_on_source(sSetting, nId, 0, sValue);
259+
return set_on_source(sSetting, nCardId, 0, sValue);
107260
}
108261

109262
// Card Inputs
110263

111-
bool Capture::RemoveCardInput( int nId )
264+
bool Capture::RemoveCardInput( int nCardInputId )
112265
{
113-
if ( nId < 1 )
266+
if ( nCardInputId < 1 )
114267
throw( QString( "The Input ID is invalid."));
115268

116-
bool bResult = CardUtil::DeleteInput(nId);
269+
bool bResult = CardUtil::DeleteInput(nCardInputId);
117270

118271
return bResult;
119272
}
@@ -144,13 +297,13 @@ int Capture::AddCardInput ( const uint nCardId,
144297
return nResult;
145298
}
146299

147-
bool Capture::UpdateCardInput ( int nId,
300+
bool Capture::UpdateCardInput ( int nCardInputId,
148301
const QString &sSetting,
149302
const QString &sValue )
150303
{
151-
if ( nId < 1 || sSetting.isEmpty() || sValue.isEmpty() )
304+
if ( nCardInputId < 1 || sSetting.isEmpty() || sValue.isEmpty() )
152305
throw( QString( "Input ID, Setting Name, and Value are required." ));
153306

154-
return set_on_input(sSetting, nId, sValue);
307+
return set_on_input(sSetting, nCardInputId, sValue);
155308
}
156309

mythtv/programs/mythbackend/services/capture.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ class Capture : public CaptureServices
3737

3838
public:
3939

40-
bool RemoveCaptureCard ( int Id );
40+
DTC::CaptureCardList* GetCaptureCardList ( const QString &HostName,
41+
const QString &CardType );
42+
43+
DTC::CaptureCard* GetCaptureCard ( int CardId );
44+
45+
bool RemoveCaptureCard ( int CardId );
4146

4247
int AddCaptureCard ( const QString &VideoDevice,
4348
const QString &AudioDevice,
@@ -65,13 +70,13 @@ class Capture : public CaptureServices
6570
const uint DiSEqCId,
6671
bool DVBEITScan);
6772

68-
bool UpdateCaptureCard ( int Id,
73+
bool UpdateCaptureCard ( int CardId,
6974
const QString &Setting,
7075
const QString &Value );
7176

7277
// Card Inputs
7378

74-
bool RemoveCardInput ( int Id );
79+
bool RemoveCardInput ( int CardInputId);
7580

7681
int AddCardInput ( const uint CardId,
7782
const uint SourceId,
@@ -87,7 +92,7 @@ class Capture : public CaptureServices
8792
const uint RecPriority,
8893
const uint Quicktune);
8994

90-
bool UpdateCardInput ( int Id,
95+
bool UpdateCardInput ( int CardInputId,
9196
const QString &Setting,
9297
const QString &Value );
9398

mythtv/programs/mythbackend/services/channel.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,6 @@ int Channel::FetchChannelsFromSource( const uint nSourceId,
472472

473473
int nResult = 0;
474474

475-
uint num_channels_before = SourceUtil::GetChannelCount(nSourceId);
476-
477475
QString cardtype = CardUtil::GetRawCardType(nCardId);
478476

479477
if (!CardUtil::IsUnscanable(cardtype) &&

0 commit comments

Comments
 (0)