Skip to content

Commit

Permalink
This moves siscan from uning_dvb to using_backend in the .pro
Browse files Browse the repository at this point in the history
and adds the needed USING_DVB defines.

pcHDTV channel scanning uses siscan.cpp so this
is prep for adding that into SVN.



git-svn-id: http://svn.mythtv.org/svn/trunk@6860 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
daniel-kristjansson committed Jul 18, 2005
1 parent a79df3b commit 2963075
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 25 deletions.
6 changes: 2 additions & 4 deletions mythtv/libs/libmythtv/libmythtv.pro
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ using_backend {

# Channel scanner stuff
HEADERS += scanwizard.h scanwizardhelpers.h
HEADERS += frequencytables.h
HEADERS += siscan.h frequencytables.h
SOURCES += scanwizard.cpp scanwizardhelpers.cpp
SOURCES += frequencytables.cpp
SOURCES += siscan.cpp frequencytables.cpp

# TVRec & Recorder base classes
HEADERS += tv_rec.h
Expand Down Expand Up @@ -260,10 +260,8 @@ using_backend {
# Channel stuff
HEADERS += dvbchannel.h dvbsignalmonitor.h
HEADERS += dvbdiseqc.h dvbcam.h
HEADERS += siscan.h
SOURCES += dvbchannel.cpp dvbsignalmonitor.cpp
SOURCES += dvbdiseqc.cpp dvbcam.cpp
SOURCES += siscan.cpp

# DVB Recorder
HEADERS += dvbrecorder.h
Expand Down
81 changes: 66 additions & 15 deletions mythtv/libs/libmythtv/siscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
#include <stdio.h>
#include <qmutex.h>
#include "siscan.h"
#include "dvbchannel.h"
#include "siparser.h"
#include "dvbtypes.h"
#include "libmythtv/scheduledrecording.h"
#include "frequencies.h"
#include "mythdbcon.h"

#ifdef USING_DVB
#include "dvbchannel.h"
#include "siparser.h"
#include "dvbtypes.h"
#endif

#define CHECKNIT_TIMER 5000
#define DVBTSCAN_TIMEOUT 40000
//#define SISCAN_DEBUG

#ifdef USING_DVB
struct FrequencyTableOld
{
int frequencyStart; //The staring centre frequency
Expand Down Expand Up @@ -109,6 +112,7 @@ FrequencyTableOld frequenciesATSC_C[]=
{10000000,52000000,6000000,"QAM Channel T-%1",7,INVERSION_AUTO,BANDWIDTH_AUTO,FEC_AUTO,FEC_AUTO,QAM_AUTO,TRANSMISSION_MODE_AUTO,GUARD_INTERVAL_AUTO,HIERARCHY_AUTO,QAM_256,0,0},
{0,0,0,"",0,INVERSION_AUTO,BANDWIDTH_AUTO,FEC_AUTO,FEC_AUTO,QAM_AUTO,TRANSMISSION_MODE_AUTO,GUARD_INTERVAL_AUTO,HIERARCHY_AUTO,QAM_AUTO,0,0},
};
#endif // USING_DVB

SIScan::SIScan(DVBChannel* advbchannel, int _sourceID)
{
Expand All @@ -131,17 +135,19 @@ SIScan::SIScan(DVBChannel* advbchannel, int _sourceID)

pthread_mutex_init(&events_lock, NULL);

#ifdef USING_DVB
/* Signals to process tables and do database inserts */
connect(chan->siparser,SIGNAL(FindTransportsComplete()),this,SLOT(TransportTableComplete()));
connect(chan->siparser,SIGNAL(FindServicesComplete()),this,SLOT(ServiceTableComplete()));
connect(chan->siparser,SIGNAL(EventsReady(QMap_Events*)),this,SLOT(EventsReady(QMap_Events*)));
#endif // USING_DVB
}

SIScan::~SIScan()
{
while(scannerRunning)
usleep(50);
SIPARSER("SIScanner Stopped");
SISCAN("SIScanner Stopped");

pthread_mutex_destroy(&events_lock);
}
Expand All @@ -154,7 +160,11 @@ void SIScan::SetSourceID(int _SourceID)

bool SIScan::ScanTransports()
{
#ifdef USING_DVB
return chan->siparser->FindTransports();
#else
return false;
#endif // USING_DVB
}

bool SIScan::ScanServicesSourceID(int SourceID)
Expand Down Expand Up @@ -204,13 +214,21 @@ bool SIScan::ScanServices(int TransportID)
{
(void) TransportID;
// Requests the SDT table for the current transport from sections
#ifdef USING_DVB
return chan->siparser->FindServices();
#else
return false;
#endif // USING_DVB
}

int SIScan::CreateMultiplex(const fe_type_t cardType,
const TransportScanItem& a,
const DVBTuning& tuning)
{
(void) cardType;
(void) a;
(void) tuning;
#ifdef USING_DVB
MSqlQuery query(MSqlQuery::InitCon());
query.prepare("INSERT into dtv_multiplex (frequency, "
"sistandard, sourceid,inversion,bandwidth,hp_code_rate,lp_code_rate,constellation,transmission_mode,guard_interval,hierarchy,modulation) "
Expand Down Expand Up @@ -267,11 +285,14 @@ int SIScan::CreateMultiplex(const fe_type_t cardType,
transport = query.value(0).toInt();
}
return transport;
#else
return -1;
#endif // USING_DVB
}

void SIScan::StartScanner()
{
SIPARSER("Starting SIScanner");
SISCAN("Starting SIScanner");
scannerRunning = true;
threadExit = false;

Expand All @@ -291,6 +312,7 @@ void SIScan::StartScanner()

if (serviceListReady)
{
#ifdef USING_DVB
if (chan->siparser->GetServiceObject(SDT))
{
SISCAN("Updating Services");
Expand All @@ -299,6 +321,7 @@ void SIScan::StartScanner()
SISCAN("Service Update Complete");
emit ServiceScanUpdateText("Finished processing Transport");
}
#endif // USING_DVB
serviceListReady = false;
if (scanMode == TRANSPORT_LIST)
{
Expand All @@ -315,6 +338,7 @@ void SIScan::StartScanner()
}
if (transportListReady)
{
#ifdef USING_DVB
if (chan->siparser->GetTransportObject(NIT))
{
emit TransportScanUpdateText("Processing Transport List");
Expand All @@ -325,11 +349,13 @@ void SIScan::StartScanner()
emit TransportScanUpdateText("Finished processing Transport List");
}
transportListReady = false;
#endif // USING_DVB
emit TransportScanComplete();
}

if (scanMode == TRANSPORT_LIST)
{
#ifdef USING_DVB
if ((!sourceIDTransportTuned) || ((ScanTimeout > 0) && (timer.elapsed() > ScanTimeout)))
{
QValueList<TransportScanItem>::Iterator i;
Expand Down Expand Up @@ -377,7 +403,7 @@ void SIScan::StartScanner()
}
else
result = chan->SetTransportByInt((*i).mplexid);

if (!result)
{
int pct = ((transportsToScan-transportsCount)*100)/transportsToScan;
Expand Down Expand Up @@ -410,6 +436,7 @@ void SIScan::StartScanner()
}
}
}
#endif // USING_DVB
}
}
scannerRunning = false;
Expand All @@ -418,16 +445,19 @@ void SIScan::StartScanner()
void SIScan::StopScanner()
{
threadExit = true;
#ifdef USING_DVB
/* Force dvbchannel to exit */
chan->StopTuning();
SIPARSER("Stopping SIScanner");
SISCAN("Stopping SIScanner");
while (scannerRunning)
usleep(50);

#endif // USING_DVB
}

void SIScan::verifyTransport(TransportScanItem& t)
{
(void) t;
#ifdef USING_DVB
MSqlQuery query(MSqlQuery::InitCon());
/* See if mplexid is already in the database */
QString theQuery = QString("select mplexid from dtv_multiplex where "
Expand Down Expand Up @@ -485,6 +515,7 @@ void SIScan::verifyTransport(TransportScanItem& t)
}

t.mplexid = -1;
#endif // USING_DVB
}

bool SIScan::ATSCScanTransport(int SourceID, int FrequencyBand)
Expand Down Expand Up @@ -548,10 +579,11 @@ bool SIScan::ATSCScanTransport(int SourceID, int FrequencyBand)
#endif
}



bool SIScan::DVBTScanTransport(int SourceID,unsigned country)
bool SIScan::DVBTScanTransport(int SourceID, unsigned country)
{
(void) SourceID;
(void) country;
#ifdef USING_DVB
if (scanMode == TRANSPORT_LIST)
return false;

Expand Down Expand Up @@ -597,11 +629,14 @@ bool SIScan::DVBTScanTransport(int SourceID,unsigned country)
ScanTimeout = DVBTSCAN_TIMEOUT;
sourceIDTransportTuned = false;
scanMode = TRANSPORT_LIST;
#endif // USING_DVB
return true;
}

void SIScan::EventsReady(QMap_Events* EventList)
{
(void) EventList;
#ifdef USING_DVB
// Extra check since adding events to the DB is SLOW..
if (threadExit)
return;
Expand All @@ -613,6 +648,7 @@ void SIScan::EventsReady(QMap_Events* EventList)
eventsReady = true;
Events.append(events);
pthread_mutex_unlock(&events_lock);
#endif // USING_DVB
}

void SIScan::ServiceTableComplete()
Expand All @@ -627,6 +663,8 @@ void SIScan::TransportTableComplete()

void SIScan::UpdateServicesInDB(QMap_SDTObject SDT)
{
(void) SDT;
#ifdef USING_DVB
/* This will be fixed post .17 to be more elegant */
int localSourceID = -1;

Expand Down Expand Up @@ -879,10 +917,13 @@ void SIScan::UpdateServicesInDB(QMap_SDTObject SDT)
emit ServiceScanUpdateText(status);
}
}
#endif // USING_DVB
}

void SIScan::CheckNIT(NITObject& NIT)
{
(void) NIT;
#ifdef USING_DVB
dvb_channel_t chan_opts;
QValueList<TransportObject>::Iterator t;
for (t = NIT.Transport.begin() ; t != NIT.Transport.end() ; ++t )
Expand Down Expand Up @@ -950,10 +991,13 @@ void SIScan::CheckNIT(NITObject& NIT)
}
}
}
#endif // USING_DVB
}

void SIScan::UpdateTransportsInDB(NITObject NIT)
{
(void) NIT;
#ifdef USING_DVB
QValueList<NetworkObject>::Iterator n;
QValueList<TransportObject>::Iterator t;

Expand Down Expand Up @@ -1040,10 +1084,15 @@ void SIScan::UpdateTransportsInDB(NITObject NIT)
.arg((*t).NetworkID));
}
}
#endif // USING_DVB
}

int SIScan::GetDVBTID(uint16_t NetworkID,uint16_t TransportID,int CurrentMplexId)
int SIScan::GetDVBTID(uint16_t NetworkID, uint16_t TransportID, int CurrentMplexId)
{
(void) NetworkID;
(void) TransportID;
(void) CurrentMplexId;
#ifdef USING_DVB

#ifdef SISCAN_DEBUG
printf("Request for Networkid/Transportid %d %d\n",NetworkID,TransportID);
Expand Down Expand Up @@ -1173,12 +1222,13 @@ int SIScan::GetDVBTID(uint16_t NetworkID,uint16_t TransportID,int CurrentMplexId
int retval = query.value(0).toInt();

return retval;

#else // USING_DVB
return -1;
#endif // USING_DVB
}

int SIScan::GenerateNewChanID(int sourceID)
{

MSqlQuery query(MSqlQuery::InitCon());

QString theQuery =
Expand All @@ -1204,11 +1254,11 @@ int SIScan::GenerateNewChanID(int sourceID)
return sourceID * 1000;
else
return MaxChanID + 1;

}

void SIScan::AddEvents()
{
#ifdef USING_DVB
MSqlQuery query(MSqlQuery::InitCon());
MSqlQuery query2(MSqlQuery::InitCon());
QString theQuery;
Expand Down Expand Up @@ -1401,4 +1451,5 @@ void SIScan::AddEvents()
pthread_mutex_lock(&events_lock);
}
pthread_mutex_unlock(&events_lock);
#endif // USING_DVB
}
30 changes: 24 additions & 6 deletions mythtv/libs/libmythtv/siscan.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@

// -*- Mode: c++ -*-
#include <qobject.h>
#include <qstring.h>
#include <qmap.h>
#include <qvaluelist.h>
#include <qdatetime.h>

#include "frequencytables.h"

#ifdef USING_DVB
#include "dvbchannel.h"
#include "sitypes.h"
#include "dvbtypes.h"
#include "frequencytables.h"

typedef QValueList<Event> QList_Events;
typedef QValueList<QList_Events*> QListList_Events;
#define SISCAN(args...) \
VERBOSE(VB_SIPARSER, QString("SIScan(%1): ").arg(chan->GetDevice()) << args);
#else
typedef unsigned short uint16_t;
typedef QMap<uint16_t, void*> QMap_Events;
typedef QMap<uint16_t, void*> QMap_SDTObject;
typedef QValueList<void*> QList_Events;
typedef QValueList<QList_Events> QListList_Events;
typedef void* DVBChannel;
typedef void* DVBTuning;
typedef int fe_type_t;
typedef void* NITObject;
typedef void* NIT;
#define SISCAN(args...) \
VERBOSE(VB_SIPARSER, QString("SIScan: ") << args);
#endif // USING_DVB

typedef enum { IDLE, TRANSPORT_LIST, EIT_CRAWL } SCANMODE;

Expand Down Expand Up @@ -95,6 +116,3 @@ public slots:
SCANMODE scanMode;
pthread_mutex_t events_lock;
};

#define SISCAN(args...) \
VERBOSE(VB_SIPARSER, QString("SIScan#%1: ").arg(chan->GetCardNum()) << args);

0 comments on commit 2963075

Please sign in to comment.