MythTV  0.28pre
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
Private Types | Static Private Member Functions | Static Private Attributes | List of all members
ChannelUtil Class Reference

Collection of helper utilities for channel DB use. More...

#include <channelutil.h>

Private Types

enum  OrderBy { kChanOrderByChanNum, kChanOrderByName }
 
enum  GroupBy { kChanGroupByCallsign, kChanGroupByChanid }
 

Static Private Member Functions

static Q_DECLARE_TR_FUNCTIONS(ChannelUtil)
public uint 
CreateMultiplex (int sourceid, QString sistandard, uint64_t frequency, QString modulation, int transport_id, int network_id, int symbol_rate, signed char bandwidth, signed char polarity, signed char inversion, signed char trans_mode, QString inner_FEC, QString constellation, signed char hierarchy, QString hp_code_rate, QString lp_code_rate, QString guard_interval, QString mod_sys, QString rolloff)
 
static uint CreateMultiplex (uint sourceid, const DTVMultiplex &, int transport_id, int network_id)
 
static vector< uintCreateMultiplexes (int sourceid, const NetworkInformationTable *nit)
 
static uint GetMplexID (uint sourceid, const QString &channum)
 
static int GetMplexID (uint sourceid, uint64_t frequency)
 
static int GetMplexID (uint sourceid, uint64_t frequency, uint transport_id, uint network_id)
 
static int GetMplexID (uint sourceid, uint transport_id, uint network_id)
 
static uint GetMplexID (uint chanid)
 
static int GetBetterMplexID (int current_mplexid, int transport_id, int network_id)
 Returns best match multiplex ID, creating one if needed. More...
 
static bool GetTuningParams (uint mplexid, QString &modulation, uint64_t &frequency, uint &dvb_transportid, uint &dvb_networkid, QString &si_std)
 
static bool GetATSCChannel (uint sourceid, const QString &channum, uint &major, uint &minor)
 
static bool IsATSCChannel (uint sourceid, const QString &channum)
 
static int CreateChanID (uint sourceid, const QString &chan_num)
 Creates a unique channel ID for database use. More...
 
static bool CreateChannel (uint db_mplexid, uint db_sourceid, uint new_channel_id, const QString &callsign, const QString &service_name, const QString &chan_num, uint service_id, uint atsc_major_channel, uint atsc_minor_channel, bool use_on_air_guide, bool hidden, bool hidden_in_guide, const QString &freqid, QString icon=QString::null, QString format="Default", QString xmltvid=QString::null, QString default_authority=QString::null)
 
static bool UpdateChannel (uint db_mplexid, uint source_id, uint channel_id, const QString &callsign, const QString &service_name, const QString &chan_num, uint service_id, uint atsc_major_channel, uint atsc_minor_channel, bool use_on_air_guide, bool hidden, bool hidden_in_guide, QString freqid=QString::null, QString icon=QString::null, QString format=QString::null, QString xmltvid=QString::null, QString default_authority=QString::null)
 
static bool CreateIPTVTuningData (uint channel_id, const IPTVTuningData &tuning)
 
static bool UpdateIPTVTuningData (uint channel_id, const IPTVTuningData &tuning)
 
static void UpdateInsertInfoFromDB (ChannelInsertInfo &chan)
 
static bool DeleteChannel (uint channel_id)
 
static bool SetVisible (uint channel_id, bool hidden)
 
static bool SetServiceVersion (int mplexid, int version)
 
static int GetChanID (int db_mplexid, int service_transport_id, int major_channel, int minor_channel, int program_number)
 
static int GetServiceVersion (int mplexid)
 
static QString GetDefaultAuthority (uint chanid)
 Returns the DVB default authority for the chanid given. More...
 
static QString GetIcon (uint chanid)
 
static vector< uintGetCardIDs (uint chanid)
 
static QString GetUnknownCallsign (void)
 
static uint FindChannel (uint sourceid, const QString &freqid)
 
static int GetChanID (uint sourceid, const QString &channum)
 
static bool GetChannelData (uint sourceid, uint &chanid, const QString &channum, QString &tvformat, QString &modulation, QString &freqtable, QString &freqid, int &finetune, uint64_t &frequency, QString &dtv_si_std, int &mpeg_prog_num, uint &atsc_major, uint &atsc_minor, uint &dvb_transportid, uint &dvb_networkid, uint &mplexid, bool &commfree)
 
static int GetProgramNumber (uint sourceid, const QString &channum)
 
static QString GetVideoFilters (uint sourceid, const QString &channum)
 
static IPTVTuningData GetIPTVTuningData (uint chanid)
 
static ChannelInfoList LoadChannels (uint startIndex, uint count, uint &totalAvailable, bool ignoreHidden=true, OrderBy orderBy=kChanOrderByChanNum, GroupBy groupBy=kChanGroupByChanid, uint sourceID=0, uint channelGroupID=0)
 Load channels from database into a list of ChannelInfo objects. More...
 
static ChannelInfoList GetChannels (uint sourceid, bool visible_only, const QString &group_by=QString(), uint channel_groupid=0)
 
static ChannelInfoList GetAllChannels (uint sourceid)
 Returns channels that are not connected to a capture card and channels that are not marked as visible. More...
 
static vector< uintGetChanIDs (int sourceid=-1, bool onlyVisible=false)
 
static uint GetChannelCount (int sourceid=-1)
 
static void SortChannels (ChannelInfoList &list, const QString &order, bool eliminate_duplicates=false)
 
static int GetNearestChannel (const ChannelInfoList &list, const QString &channum)
 
static uint GetNextChannel (const ChannelInfoList &sorted, uint old_chanid, uint mplexid_restriction, uint chanid_restriction, ChannelChangeDirection direction, bool skip_non_visible=true, bool skip_same_channum_and_callsign=false)
 
static QString GetChannelValueStr (const QString &channel_field, uint sourceid, const QString &channum)
 
static int GetChannelValueInt (const QString &channel_field, uint sourceid, const QString &channum)
 
static bool IsOnSameMultiplex (uint sourceid, const QString &new_channum, const QString &old_channum)
 
static QStringList GetValidRecorderList (uint chanid, const QString &channum)
 
static bool IsConflicting (const QString &channum, uint sourceid=0, uint excluded_chanid=0)
 
static vector< uintGetConflicting (const QString &channum, uint sourceid=0)
 
static QString GetChanNum (int chanid)
 Returns the channel-number string of the given channel. More...
 
static int GetTimeOffset (int chanid)
 Returns the listings time offset in minutes for given channel. More...
 
static int GetSourceID (int mplexid)
 
static uint GetSourceIDForChannel (uint chanid)
 
static QStringList GetCardTypes (uint chandid)
 
static bool GetCachedPids (uint chanid, pid_cache_t &pid_cache)
 Returns cached MPEG PIDs when given a Channel ID. More...
 
static bool SetChannelValue (const QString &field_name, QString value, uint sourceid, const QString &channum)
 
static bool SetChannelValue (const QString &field_name, QString value, int chanid)
 
static bool SaveCachedPids (uint chanid, const pid_cache_t &pid_cache, bool delete_all=false)
 Saves PIDs for PSIP tables to database. More...
 
static ChannelInfoList GetChannelsInternal (uint sourceid, bool visible_only, bool include_disconnected, const QString &group_by, uint channel_groupid)
 
static QString GetChannelStringField (int chanid, const QString &field)
 
static QString GetChannelValueStr (const QString &channel_field, uint cardid, const QString &input, const QString &channum)
 
static int GetChannelValueInt (const QString &channel_field, uint cardid, const QString &input, const QString &channum)
 

Static Private Attributes

static const QString kATSCSeparators = "(_|-|#|\\.)"
 

Detailed Description

Collection of helper utilities for channel DB use.

Definition at line 50 of file channelutil.h.

Member Enumeration Documentation

enum ChannelUtil::OrderBy
private
Enumerator
kChanOrderByChanNum 
kChanOrderByName 

Definition at line 192 of file channelutil.h.

enum ChannelUtil::GroupBy
private
Enumerator
kChanGroupByCallsign 
kChanGroupByChanid 

Definition at line 198 of file channelutil.h.

Member Function Documentation

uint ChannelUtil::CreateMultiplex ( int  sourceid,
QString  sistandard,
uint64_t  frequency,
QString  modulation,
int  transport_id,
int  network_id,
int  symbol_rate,
signed char  bandwidth,
signed char  polarity,
signed char  inversion,
signed char  trans_mode,
QString  inner_FEC,
QString  constellation,
signed char  hierarchy,
QString  hp_code_rate,
QString  lp_code_rate,
QString  guard_interval,
QString  mod_sys,
QString  rolloff 
)
staticprivate
uint ChannelUtil::CreateMultiplex ( uint  sourceid,
const DTVMultiplex mux,
int  transport_id,
int  network_id 
)
staticprivate

Definition at line 415 of file channelutil.cpp.

vector< uint > ChannelUtil::CreateMultiplexes ( int  sourceid,
const NetworkInformationTable nit 
)
staticprivate

Definition at line 436 of file channelutil.cpp.

uint ChannelUtil::GetMplexID ( uint  sourceid,
const QString &  channum 
)
staticprivate
int ChannelUtil::GetMplexID ( uint  sourceid,
uint64_t  frequency 
)
staticprivate

Definition at line 482 of file channelutil.cpp.

int ChannelUtil::GetMplexID ( uint  sourceid,
uint64_t  frequency,
uint  transport_id,
uint  network_id 
)
staticprivate

Definition at line 507 of file channelutil.cpp.

int ChannelUtil::GetMplexID ( uint  sourceid,
uint  transport_id,
uint  network_id 
)
staticprivate

Definition at line 537 of file channelutil.cpp.

uint ChannelUtil::GetMplexID ( uint  chanid)
staticprivate

Definition at line 565 of file channelutil.cpp.

int ChannelUtil::GetBetterMplexID ( int  current_mplexid,
int  transport_id,
int  network_id 
)
staticprivate

Returns best match multiplex ID, creating one if needed.

First, see if you can get an exact match based on the current mplexid's sourceID and the NetworkID/TransportID.

Next, see if current one is NULL, if so update those values and return current mplexid.

Next, if values were set, see where you can find this NetworkID/TransportID. If we get an exact match just return it, since there is no question what mplexid this NetworkId/TransportId is for. If we get many matches, return CurrentMplexID.

Next, try to repeat query without currentmplexid as source id. If we get a singe match return it, if we get many matches we return the first one.

If none of these work return -1.

Returns
mplexid on success, -1 on failure.

Definition at line 608 of file channelutil.cpp.

Referenced by ChannelImporter::InsertChannels(), and ChannelImporter::UpdateChannels().

bool ChannelUtil::GetTuningParams ( uint  mplexid,
QString &  modulation,
uint64_t &  frequency,
uint dvb_transportid,
uint dvb_networkid,
QString &  si_std 
)
staticprivate

Definition at line 718 of file channelutil.cpp.

Referenced by handle_transport_desc().

bool ChannelUtil::GetATSCChannel ( uint  sourceid,
const QString &  channum,
uint major,
uint minor 
)
staticprivate

Definition at line 1863 of file channelutil.cpp.

Referenced by TVRec::TuningOnSameMultiplex().

static bool ChannelUtil::IsATSCChannel ( uint  sourceid,
const QString &  channum 
)
inlinestaticprivate

Definition at line 100 of file channelutil.h.

int ChannelUtil::CreateChanID ( uint  sourceid,
const QString &  chan_num 
)
staticprivate

Creates a unique channel ID for database use.

Returns
chanid if successful, -1 if not

Definition at line 1482 of file channelutil.cpp.

Referenced by ChannelScanSM::HandleAllGood(), ChannelData::handleChannels(), ChannelImporter::InsertChannels(), IPTVChannelFetcher::run(), and update_channel_basic().

bool ChannelUtil::CreateChannel ( uint  db_mplexid,
uint  db_sourceid,
uint  new_channel_id,
const QString &  callsign,
const QString &  service_name,
const QString &  chan_num,
uint  service_id,
uint  atsc_major_channel,
uint  atsc_minor_channel,
bool  use_on_air_guide,
bool  hidden,
bool  hidden_in_guide,
const QString &  freqid,
QString  icon = QString::null,
QString  format = "Default",
QString  xmltvid = QString::null,
QString  default_authority = QString::null 
)
staticprivate
bool ChannelUtil::UpdateChannel ( uint  db_mplexid,
uint  source_id,
uint  channel_id,
const QString &  callsign,
const QString &  service_name,
const QString &  chan_num,
uint  service_id,
uint  atsc_major_channel,
uint  atsc_minor_channel,
bool  use_on_air_guide,
bool  hidden,
bool  hidden_in_guide,
QString  freqid = QString::null,
QString  icon = QString::null,
QString  format = QString::null,
QString  xmltvid = QString::null,
QString  default_authority = QString::null 
)
staticprivate
static bool ChannelUtil::CreateIPTVTuningData ( uint  channel_id,
const IPTVTuningData tuning 
)
inlinestaticprivate

Definition at line 142 of file channelutil.h.

Referenced by ChannelImporter::InsertChannels(), and IPTVChannelFetcher::run().

bool ChannelUtil::UpdateIPTVTuningData ( uint  channel_id,
const IPTVTuningData tuning 
)
staticprivate

Definition at line 1717 of file channelutil.cpp.

Referenced by IPTVChannelFetcher::run().

void ChannelUtil::UpdateInsertInfoFromDB ( ChannelInsertInfo chan)
staticprivate

Definition at line 1685 of file channelutil.cpp.

Referenced by ChannelImporter::UpdateChannels().

bool ChannelUtil::DeleteChannel ( uint  channel_id)
staticprivate
bool ChannelUtil::SetVisible ( uint  channel_id,
bool  hidden 
)
staticprivate

Definition at line 1803 of file channelutil.cpp.

Referenced by ChannelImporter::DeleteChannels().

bool ChannelUtil::SetServiceVersion ( int  mplexid,
int  version 
)
staticprivate

Definition at line 1822 of file channelutil.cpp.

int ChannelUtil::GetChanID ( int  db_mplexid,
int  service_transport_id,
int  major_channel,
int  minor_channel,
int  program_number 
)
staticprivate
int ChannelUtil::GetServiceVersion ( int  mplexid)
staticprivate

Definition at line 1841 of file channelutil.cpp.

QString ChannelUtil::GetDefaultAuthority ( uint  chanid)
staticprivate

Returns the DVB default authority for the chanid given.

Definition at line 1211 of file channelutil.cpp.

Referenced by EITFixUp::AddDVBEITAuthority().

QString ChannelUtil::GetIcon ( uint  chanid)
staticprivate
static vector<uint> ChannelUtil::GetCardIDs ( uint  chanid)
staticprivate
QString ChannelUtil::GetUnknownCallsign ( void  )
staticprivate
uint ChannelUtil::FindChannel ( uint  sourceid,
const QString &  freqid 
)
staticprivate

Definition at line 1420 of file channelutil.cpp.

Referenced by ChannelScanSM::HandleAllGood().

static int ChannelUtil::GetChanID ( uint  sourceid,
const QString &  channum 
)
inlinestaticprivate

Definition at line 171 of file channelutil.h.

bool ChannelUtil::GetChannelData ( uint  sourceid,
uint chanid,
const QString &  channum,
QString &  tvformat,
QString &  modulation,
QString &  freqtable,
QString &  freqid,
int finetune,
uint64_t &  frequency,
QString &  dtv_si_std,
int mpeg_prog_num,
uint atsc_major,
uint atsc_minor,
uint dvb_transportid,
uint dvb_networkid,
uint mplexid,
bool commfree 
)
staticprivate

Definition at line 1890 of file channelutil.cpp.

Referenced by ChannelBase::IsTunable(), and DTVChannel::SetChannelByString().

static int ChannelUtil::GetProgramNumber ( uint  sourceid,
const QString &  channum 
)
inlinestaticprivate

Definition at line 183 of file channelutil.h.

Referenced by TVRec::TuningOnSameMultiplex().

static QString ChannelUtil::GetVideoFilters ( uint  sourceid,
const QString &  channum 
)
inlinestaticprivate

Definition at line 185 of file channelutil.h.

Referenced by TVRec::SetVideoFiltersForChannel().

IPTVTuningData ChannelUtil::GetIPTVTuningData ( uint  chanid)
staticprivate

Definition at line 1955 of file channelutil.cpp.

Referenced by DTVChannel::SetChannelByString().

ChannelInfoList ChannelUtil::LoadChannels ( uint  startIndex,
uint  count,
uint totalAvailable,
bool  ignoreHidden = true,
ChannelUtil::OrderBy  orderBy = kChanOrderByChanNum,
ChannelUtil::GroupBy  groupBy = kChanGroupByChanid,
uint  sourceID = 0,
uint  channelGroupID = 0 
)
staticprivate

Load channels from database into a list of ChannelInfo objects.

Note
This replaces all previous methods e.g. GetChannels() and GetAllChannels() in channelutil.h
There is no grouping option by design and here's why. Grouping with a ChannelInfo object is largely self-defeating, 99% of the information in the remaining result won't apply to the other 'grouped' channels. Therefore GroupBy should be used when you only care about Name, Number and Callsign. Loading a complete ChannelInfo object, including card/input info is therefore an actual waste of processor cycles and memory, so we may yet introduce a parent class for ChannelInfo called BasicChannelInfo or similar with it's own Load function

Definition at line 2390 of file channelutil.cpp.

Referenced by Channel::GetChannelInfoList(), and Guide::GetProgramGuide().

static ChannelInfoList ChannelUtil::GetChannels ( uint  sourceid,
bool  visible_only,
const QString &  group_by = QString(),
uint  channel_groupid = 0 
)
inlinestaticprivate
static ChannelInfoList ChannelUtil::GetAllChannels ( uint  sourceid)
inlinestaticprivate

Returns channels that are not connected to a capture card and channels that are not marked as visible.

Deprecated:

Definition at line 243 of file channelutil.h.

Referenced by StartingChannel::SetSourceID().

vector< uint > ChannelUtil::GetChanIDs ( int  sourceid = -1,
bool  onlyVisible = false 
)
staticprivate

Definition at line 2119 of file channelutil.cpp.

Referenced by ProgramData::ClearDataBySource().

uint ChannelUtil::GetChannelCount ( int  sourceid = -1)
staticprivate

Definition at line 2245 of file channelutil.cpp.

Referenced by ChannelImporter::Process().

void ChannelUtil::SortChannels ( ChannelInfoList list,
const QString &  order,
bool  eliminate_duplicates = false 
)
staticprivate
int ChannelUtil::GetNearestChannel ( const ChannelInfoList list,
const QString &  channum 
)
staticprivate

Definition at line 2297 of file channelutil.cpp.

Referenced by GuideGrid::FindChannel().

uint ChannelUtil::GetNextChannel ( const ChannelInfoList sorted,
uint  old_chanid,
uint  mplexid_restriction,
uint  chanid_restriction,
ChannelChangeDirection  direction,
bool  skip_non_visible = true,
bool  skip_same_channum_and_callsign = false 
)
staticprivate
QString ChannelUtil::GetChannelValueStr ( const QString &  channel_field,
uint  sourceid,
const QString &  channum 
)
staticprivate

Definition at line 976 of file channelutil.cpp.

int ChannelUtil::GetChannelValueInt ( const QString &  channel_field,
uint  sourceid,
const QString &  channum 
)
staticprivate
bool ChannelUtil::IsOnSameMultiplex ( uint  sourceid,
const QString &  new_channum,
const QString &  old_channum 
)
staticprivate

Definition at line 1030 of file channelutil.cpp.

Referenced by TVRec::TuningOnSameMultiplex().

QStringList ChannelUtil::GetValidRecorderList ( uint  chanid,
const QString &  channum 
)
staticprivate

Definition at line 1130 of file channelutil.cpp.

Referenced by TV::ChangeChannel(), TV::HandleStateChange(), and TV::SwitchCards().

static bool ChannelUtil::IsConflicting ( const QString &  channum,
uint  sourceid = 0,
uint  excluded_chanid = 0 
)
inlinestaticprivate
vector< uint > ChannelUtil::GetConflicting ( const QString &  channum,
uint  sourceid = 0 
)
staticprivate

Definition at line 1141 of file channelutil.cpp.

QString ChannelUtil::GetChanNum ( int  chanid)
staticprivate

Returns the channel-number string of the given channel.

Parameters
chanidprimary key for channel record

Definition at line 774 of file channelutil.cpp.

Referenced by TV::ChangeChannel(), ChannelImporter::DeleteChannels(), TV::SwitchCards(), and TVRec::TuningGetChanNum().

int ChannelUtil::GetTimeOffset ( int  chanid)
staticprivate

Returns the listings time offset in minutes for given channel.

Parameters
chanidprimary key for channel record

Definition at line 779 of file channelutil.cpp.

Referenced by ProgramData::ClearDataByChannel().

int ChannelUtil::GetSourceID ( int  mplexid)
staticprivate

Definition at line 784 of file channelutil.cpp.

uint ChannelUtil::GetSourceIDForChannel ( uint  chanid)
staticprivate
QStringList ChannelUtil::GetCardTypes ( uint  chandid)
staticprivate

Definition at line 822 of file channelutil.cpp.

Referenced by ChannelWizard::ChannelWizard().

bool ChannelUtil::GetCachedPids ( uint  chanid,
pid_cache_t pid_cache 
)
staticprivate

Returns cached MPEG PIDs when given a Channel ID.

Parameters
chanidChannel ID to fetch cached pids for.
pid_cacheList of PIDs with their TableID types is returned in pid_cache.

Definition at line 855 of file channelutil.cpp.

Referenced by DTVChannel::GetCachedPids(), ChannelOptionsRawTS::Load(), and DTVChannel::SetChannelByString().

bool ChannelUtil::SetChannelValue ( const QString &  field_name,
QString  value,
uint  sourceid,
const QString &  channum 
)
staticprivate
bool ChannelUtil::SetChannelValue ( const QString &  field_name,
QString  value,
int  chanid 
)
staticprivate

Definition at line 1194 of file channelutil.cpp.

bool ChannelUtil::SaveCachedPids ( uint  chanid,
const pid_cache_t _pid_cache,
bool  delete_all = false 
)
staticprivate

Saves PIDs for PSIP tables to database.

Parameters
chanidChannel ID to fetch cached pids for.
pid_cacheList of PIDs with their TableID types to be saved.
delete_allIf true delete both permanent and transient pids first.

Definition at line 887 of file channelutil.cpp.

Referenced by ChannelOptionsRawTS::Save(), and DTVChannel::SaveCachedPids().

ChannelInfoList ChannelUtil::GetChannelsInternal ( uint  sourceid,
bool  vis_only,
bool  include_disconnected,
const QString &  grp,
uint  changrpid 
)
staticprivate
Deprecated:
Use LoadChannels instead
Deprecated:
Use ChannelInfo::LoadChannels() instead

Definition at line 2029 of file channelutil.cpp.

QString ChannelUtil::GetChannelStringField ( int  chanid,
const QString &  field 
)
staticprivate

Definition at line 753 of file channelutil.cpp.

QString ChannelUtil::GetChannelValueStr ( const QString &  channel_field,
uint  cardid,
const QString &  input,
const QString &  channum 
)
staticprivate

Definition at line 945 of file channelutil.cpp.

int ChannelUtil::GetChannelValueInt ( const QString &  channel_field,
uint  cardid,
const QString &  input,
const QString &  channum 
)
staticprivate

Definition at line 1003 of file channelutil.cpp.

Member Data Documentation

const QString ChannelUtil::kATSCSeparators = "(_|-|#|\\.)"
staticprivate

Definition at line 320 of file channelutil.h.

Referenced by GuideGrid::FindChannel(), and lt_smart().


The documentation for this class was generated from the following files: