Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge some identical channel loading code in the guide and channel

services.

Also:
* Start exposing correct visibility information for channels returned by
  GetProgramGuide. This would be necessary for any third parties
  wishing only to display the channels the user actually wants to use
  (which may be dozens out of hundreds for Satellite/Cable).

* Change some argument types from int to uint for consistency, and
  because these cannot legitimately be less than zero so it forces
  users of the services API to provide sane values
  • Loading branch information...
commit 2b680bd68ee5bb45ae64fae797ed9201e986518a 1 parent 7c6cd81
@stuartm stuartm authored
View
2  mythtv/libs/libmythbase/mythversion.h
@@ -12,7 +12,7 @@
/// Update this whenever the plug-in ABI changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods in exported headers.
-#define MYTH_BINARY_VERSION "0.28.20131018-2"
+#define MYTH_BINARY_VERSION "0.28.20131018-3"
/** \brief Increment this whenever the MythTV network protocol changes.
*
View
20 mythtv/libs/libmythservicecontracts/services/channelServices.h
@@ -41,7 +41,7 @@
class SERVICE_PUBLIC ChannelServices : public Service
{
Q_OBJECT
- Q_CLASSINFO( "version" , "1.2" );
+ Q_CLASSINFO( "version" , "1.3" );
Q_CLASSINFO( "AddDBChannel_Method", "POST" )
Q_CLASSINFO( "UpdateDBChannel_Method", "POST" )
Q_CLASSINFO( "RemoveDBChannel_Method", "POST" )
@@ -69,11 +69,11 @@ class SERVICE_PUBLIC ChannelServices : public Service
/* Channel Methods */
- virtual DTC::ChannelInfoList* GetChannelInfoList ( int SourceID,
- int StartIndex,
- int Count ) = 0;
+ virtual DTC::ChannelInfoList* GetChannelInfoList ( uint SourceID,
+ uint StartIndex,
+ uint Count ) = 0;
- virtual DTC::ChannelInfo* GetChannelInfo ( int ChanID ) = 0;
+ virtual DTC::ChannelInfo* GetChannelInfo ( uint ChanID ) = 0;
virtual bool UpdateDBChannel ( uint MplexID,
uint SourceID,
@@ -150,13 +150,13 @@ class SERVICE_PUBLIC ChannelServices : public Service
/* Multiplex Methods */
- virtual DTC::VideoMultiplexList* GetVideoMultiplexList ( int SourceID,
- int StartIndex,
- int Count ) = 0;
+ virtual DTC::VideoMultiplexList* GetVideoMultiplexList ( uint SourceID,
+ uint StartIndex,
+ uint Count ) = 0;
- virtual DTC::VideoMultiplex* GetVideoMultiplex ( int MplexID ) = 0;
+ virtual DTC::VideoMultiplex* GetVideoMultiplex ( uint MplexID ) = 0;
- virtual QStringList GetXMLTVIdList ( int SourceID ) = 0;
+ virtual QStringList GetXMLTVIdList ( uint SourceID ) = 0;
};
#endif
View
133 mythtv/programs/mythbackend/services/channel.cpp
@@ -38,7 +38,6 @@
#include "channelutil.h"
#include "sourceutil.h"
#include "cardutil.h"
-#include "channelinfo.h"
#include "datadirect.h"
#include "mythdate.h"
@@ -48,9 +47,9 @@
//
/////////////////////////////////////////////////////////////////////////////
-DTC::ChannelInfoList* Channel::GetChannelInfoList( int nSourceID,
- int nStartIndex,
- int nCount )
+DTC::ChannelInfoList* Channel::GetChannelInfoList( uint nSourceID,
+ uint nStartIndex,
+ uint nCount )
{
vector<uint> chanList;
@@ -62,70 +61,18 @@ DTC::ChannelInfoList* Channel::GetChannelInfoList( int nSourceID,
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() );
+ nStartIndex = min( nStartIndex, (uint)chanList.size() );
+ nCount = (nCount > 0) ? min( nCount, (uint)chanList.size() ) : chanList.size();
+ int nEndIndex = min((nStartIndex + nCount), (uint)chanList.size() );
for( int n = nStartIndex; n < nEndIndex; n++)
{
DTC::ChannelInfo *pChannelInfo = pChannelInfos->AddNewChannelInfo();
uint chanid = chanList.at(n);
- QString channum, format, modulation, freqtable, freqid, dtv_si_std,
- xmltvid, default_authority, icon;
- int finetune, program_number;
- uint64_t frequency;
- uint atscmajor, atscminor, transportid, networkid, mplexid, sourceid;
- bool commfree = false;
- bool eit = false;
- bool visible = true;
-
- ChannelInfo channel;
- if (channel.Load(chanid))
- {
- // TODO update DTC::ChannelInfo to match functionality of ChannelInfo,
- // ultimately replacing it's progenitor?
- pChannelInfo->setChanId(channel.chanid);
- pChannelInfo->setChanNum(channel.channum);
- pChannelInfo->setCallSign(channel.callsign);
- if (!channel.icon.isEmpty())
- {
- QString sIconURL = QString( "/Guide/GetChannelIcon?ChanId=%3")
- .arg( chanid );
- pChannelInfo->setIconURL( sIconURL );
- }
- pChannelInfo->setChannelName(channel.name);
- pChannelInfo->setMplexId(channel.mplexid);
- pChannelInfo->setServiceId(channel.serviceid);
- pChannelInfo->setATSCMajorChan(channel.atsc_major_chan);
- pChannelInfo->setATSCMinorChan(channel.atsc_minor_chan);
- pChannelInfo->setFormat(channel.tvformat);
- pChannelInfo->setFineTune(channel.finetune);
- pChannelInfo->setFrequencyId(channel.freqid);
- pChannelInfo->setChanFilters(channel.videofilters);
- pChannelInfo->setSourceId(channel.sourceid);
- pChannelInfo->setCommFree(channel.commmethod == -2);
- pChannelInfo->setUseEIT(channel.useonairguide);
- pChannelInfo->setVisible(channel.visible);
- pChannelInfo->setXMLTVID(channel.xmltvid);
- pChannelInfo->setDefaultAuth(channel.default_authority);
-
- // Extended data - This doesn't come from the channel table but the
- // dtv_multiplex table
- QString format, modulation, freqtable, freqid, dtv_si_std;
- uint64_t frequency = 0;
- uint transportid = 0;
- uint networkid = 0;
- ChannelUtil::GetTuningParams(channel.mplexid, modulation, frequency,
- transportid, networkid, dtv_si_std);
-
- pChannelInfo->setModulation(modulation);
- pChannelInfo->setFrequencyTable(freqtable);
- pChannelInfo->setFrequency((long)frequency);
- pChannelInfo->setSIStandard(dtv_si_std);
- pChannelInfo->setTransportId(transportid);
- pChannelInfo->setNetworkId(networkid);
- }
+
+ if (!FillChannelInfo(pChannelInfo, chanid, true))
+ throw( QString("Channel ID appears invalid."));
}
int curPage = 0, totalPages = 0;
@@ -157,60 +104,14 @@ DTC::ChannelInfoList* Channel::GetChannelInfoList( int nSourceID,
//
/////////////////////////////////////////////////////////////////////////////
-DTC::ChannelInfo* Channel::GetChannelInfo( int nChanID )
+DTC::ChannelInfo* Channel::GetChannelInfo( uint nChanID )
{
if (nChanID <= 0)
throw( QString("Channel ID appears invalid."));
DTC::ChannelInfo *pChannelInfo = new DTC::ChannelInfo();
- ChannelInfo channel;
- if (channel.Load(nChanID))
- {
- // TODO update DTC::ChannelInfo to match functionality of ChannelInfo,
- // ultimately replacing it's progenitor?
- pChannelInfo->setChanId(channel.chanid);
- pChannelInfo->setChanNum(channel.channum);
- pChannelInfo->setCallSign(channel.callsign);
- if (!channel.icon.isEmpty())
- {
- QString sIconURL = QString( "/Guide/GetChannelIcon?ChanId=%3")
- .arg( nChanID );
- pChannelInfo->setIconURL( sIconURL );
- }
- pChannelInfo->setChannelName(channel.name);
- pChannelInfo->setMplexId(channel.mplexid);
- pChannelInfo->setServiceId(channel.serviceid);
- pChannelInfo->setATSCMajorChan(channel.atsc_major_chan);
- pChannelInfo->setATSCMinorChan(channel.atsc_minor_chan);
- pChannelInfo->setFormat(channel.tvformat);
- pChannelInfo->setFineTune(channel.finetune);
- pChannelInfo->setFrequencyId(channel.freqid);
- pChannelInfo->setChanFilters(channel.videofilters);
- pChannelInfo->setSourceId(channel.sourceid);
- pChannelInfo->setCommFree(channel.commmethod == -2);
- pChannelInfo->setUseEIT(channel.useonairguide);
- pChannelInfo->setVisible(channel.visible);
- pChannelInfo->setXMLTVID(channel.xmltvid);
- pChannelInfo->setDefaultAuth(channel.default_authority);
-
- // Extended data - This doesn't come from the channel table but the
- // dtv_multiplex table
- QString format, modulation, freqtable, freqid, dtv_si_std;
- uint64_t frequency = 0;
- uint transportid = 0;
- uint networkid = 0;
- ChannelUtil::GetTuningParams(channel.mplexid, modulation, frequency,
- transportid, networkid, dtv_si_std);
-
- pChannelInfo->setModulation(modulation);
- pChannelInfo->setFrequencyTable(freqtable);
- pChannelInfo->setFrequency((long)frequency);
- pChannelInfo->setSIStandard(dtv_si_std);
- pChannelInfo->setTransportId(transportid);
- pChannelInfo->setNetworkId(networkid);
- }
- else
+ if (!FillChannelInfo(pChannelInfo, nChanID, true))
throw( QString("Channel ID appears invalid."));
return pChannelInfo;
@@ -515,9 +416,9 @@ int Channel::FetchChannelsFromSource( const uint nSourceId,
//
/////////////////////////////////////////////////////////////////////////////
-DTC::VideoMultiplexList* Channel::GetVideoMultiplexList( int nSourceID,
- int nStartIndex,
- int nCount )
+DTC::VideoMultiplexList* Channel::GetVideoMultiplexList( uint nSourceID,
+ uint nStartIndex,
+ uint nCount )
{
MSqlQuery query(MSqlQuery::InitCon());
@@ -541,7 +442,7 @@ DTC::VideoMultiplexList* Channel::GetVideoMultiplexList( int nSourceID,
throw( QString( "Database Error executing query." ));
}
- int muxCount = query.size();
+ uint muxCount = (uint)query.size();
// ----------------------------------------------------------------------
// Build Response
@@ -612,7 +513,7 @@ DTC::VideoMultiplexList* Channel::GetVideoMultiplexList( int nSourceID,
return pVideoMultiplexes;
}
-DTC::VideoMultiplex* Channel::GetVideoMultiplex( int nMplexID )
+DTC::VideoMultiplex* Channel::GetVideoMultiplex( uint nMplexID )
{
MSqlQuery query(MSqlQuery::InitCon());
@@ -674,7 +575,7 @@ DTC::VideoMultiplex* Channel::GetVideoMultiplex( int nMplexID )
//
/////////////////////////////////////////////////////////////////////////////
-QStringList Channel::GetXMLTVIdList( int SourceID )
+QStringList Channel::GetXMLTVIdList( uint SourceID )
{
MSqlQuery query(MSqlQuery::InitCon());
View
18 mythtv/programs/mythbackend/services/channel.h
@@ -42,11 +42,11 @@ class Channel : public ChannelServices
/* Channel Methods */
- DTC::ChannelInfoList* GetChannelInfoList ( int SourceID,
- int StartIndex,
- int Count );
+ DTC::ChannelInfoList* GetChannelInfoList ( uint SourceID,
+ uint StartIndex,
+ uint Count );
- DTC::ChannelInfo* GetChannelInfo ( int ChanID );
+ DTC::ChannelInfo* GetChannelInfo ( uint ChanID );
bool UpdateDBChannel ( uint MplexID,
uint SourceID,
@@ -123,13 +123,13 @@ class Channel : public ChannelServices
/* Multiplex Methods */
- DTC::VideoMultiplexList* GetVideoMultiplexList ( int SourceID,
- int StartIndex,
- int Count );
+ DTC::VideoMultiplexList* GetVideoMultiplexList ( uint SourceID,
+ uint StartIndex,
+ uint Count );
- DTC::VideoMultiplex* GetVideoMultiplex ( int MplexID );
+ DTC::VideoMultiplex* GetVideoMultiplex ( uint MplexID );
- QStringList GetXMLTVIdList ( int SourceID );
+ QStringList GetXMLTVIdList ( uint SourceID );
};
View
2  mythtv/programs/mythbackend/services/guide.cpp
@@ -136,7 +136,7 @@ DTC::ProgramGuide *Guide::GetProgramGuide( const QDateTime &rawStartTime ,
pChannel = pGuide->AddNewChannel();
- FillChannelInfo( pChannel, pInfo, bDetails );
+ FillChannelInfo( pChannel, pInfo->GetChanID(), bDetails );
}
View
64 mythtv/programs/mythbackend/services/serviceUtil.cpp
@@ -31,6 +31,7 @@
#include "recordinginfo.h"
#include "recordingtypes.h"
#include "channelutil.h"
+#include "channelinfo.h"
#include "videoutils.h"
#include "metadataimagehelper.h"
@@ -85,7 +86,7 @@ void FillProgramInfo( DTC::Program *pProgram,
{
// Build Channel Child Element
- FillChannelInfo( pProgram->Channel(), pInfo, bDetails );
+ FillChannelInfo( pProgram->Channel(), pInfo->GetChanID(), bDetails );
}
// Build Recording Child Element
@@ -132,35 +133,66 @@ void FillProgramInfo( DTC::Program *pProgram,
//
/////////////////////////////////////////////////////////////////////////////
-void FillChannelInfo( DTC::ChannelInfo *pChannel,
- ProgramInfo *pInfo,
+bool FillChannelInfo( DTC::ChannelInfo *pChannel,
+ uint nChanID,
bool bDetails /* = true */ )
{
- if (pInfo)
+ ChannelInfo channel;
+ if (channel.Load(nChanID))
{
- if (!ChannelUtil::GetIcon(pInfo->GetChanID()).isEmpty())
+ // TODO update DTC::ChannelInfo to match functionality of ChannelInfo,
+ // ultimately replacing it's progenitor?
+ pChannel->setChanId(channel.chanid);
+ pChannel->setChanNum(channel.channum);
+ pChannel->setCallSign(channel.callsign);
+ if (!channel.icon.isEmpty())
{
QString sIconURL = QString( "/Guide/GetChannelIcon?ChanId=%3")
- .arg( pInfo->GetChanID() );
- pChannel->setIconURL ( sIconURL );
+ .arg( nChanID );
+ pChannel->setIconURL( sIconURL );
}
-
- pChannel->setChanId ( pInfo->GetChanID() );
- pChannel->setChanNum ( pInfo->GetChanNum() );
- pChannel->setCallSign ( pInfo->GetChannelSchedulingID() );
- pChannel->setChannelName( pInfo->GetChannelName() );
+ pChannel->setChannelName(channel.name);
+ pChannel->setVisible(channel.visible);
pChannel->setSerializeDetails( bDetails );
if (bDetails)
{
- pChannel->setChanFilters( pInfo->GetChannelPlaybackFilters() );
- pChannel->setSourceId ( pInfo->GetSourceID() );
- pChannel->setInputId ( pInfo->GetInputID() );
- pChannel->setCommFree ( (pInfo->IsCommercialFree()) ? 1 : 0);
+ pChannel->setMplexId(channel.mplexid);
+ pChannel->setServiceId(channel.serviceid);
+ pChannel->setATSCMajorChan(channel.atsc_major_chan);
+ pChannel->setATSCMinorChan(channel.atsc_minor_chan);
+ pChannel->setFormat(channel.tvformat);
+ pChannel->setFineTune(channel.finetune);
+ pChannel->setFrequencyId(channel.freqid);
+ pChannel->setChanFilters(channel.videofilters);
+ pChannel->setSourceId(channel.sourceid);
+ pChannel->setCommFree(channel.commmethod == -2);
+ pChannel->setUseEIT(channel.useonairguide);
+ pChannel->setXMLTVID(channel.xmltvid);
+ pChannel->setDefaultAuth(channel.default_authority);
+
+ // Extended data - This doesn't come from the channel table but the
+ // dtv_multiplex table
+ QString format, modulation, freqtable, freqid, dtv_si_std;
+ uint64_t frequency = 0;
+ uint transportid = 0;
+ uint networkid = 0;
+ ChannelUtil::GetTuningParams(channel.mplexid, modulation, frequency,
+ transportid, networkid, dtv_si_std);
+
+ pChannel->setModulation(modulation);
+ pChannel->setFrequencyTable(freqtable);
+ pChannel->setFrequency((long)frequency);
+ pChannel->setSIStandard(dtv_si_std);
+ pChannel->setTransportId(transportid);
+ pChannel->setNetworkId(networkid);
}
+
+ return true;
}
+ return false;
}
/////////////////////////////////////////////////////////////////////////////
View
4 mythtv/programs/mythbackend/services/serviceUtil.h
@@ -40,8 +40,8 @@ void FillProgramInfo( DTC::Program *pProgram,
bool bIncChannel = true,
bool bDetails = true );
-void FillChannelInfo( DTC::ChannelInfo *pChannel,
- ProgramInfo *pInfo,
+bool FillChannelInfo( DTC::ChannelInfo *pChannel,
+ uint nChanID,
bool bDetails = true );
void FillRecRuleInfo( DTC::RecRule *pRecRule,
Please sign in to comment.
Something went wrong with that request. Please try again.