FireBirdLib - Topfield TMS PVR TAP Programming Library
FlashServiceFindNum.c
Go to the documentation of this file.
1#include "FBLib_flash.h"
2
3bool FlashServiceFindNum(byte SatIndex, word NetworkID, word TSID, word ServiceID, TYPE_ServiceType *SvcType, int *SvcNum)
4{
6
7 word TpIdx, SvcIdx;
8 bool ret;
9 static byte LastSatIndex = 0;
10 static word LastNetworkID = 0, LastTSID = 0, LastServiceID = 0;
11 static TYPE_ServiceType LastSvcType = 0;
12 static int LastSvcNum = 0;
13 int TrCount;
14 tFlashTransponderTable Transponder;
15
16 if((SatIndex == LastSatIndex) && (NetworkID == LastNetworkID) && (TSID == LastTSID) && (ServiceID == LastServiceID))
17 {
18 if(SvcType) *SvcType = LastSvcType;
19 if(SvcNum) *SvcNum = LastSvcNum;
20
21 TRACEEXIT();
22 return TRUE;
23 }
24
25 ret = FALSE;
26
27 TrCount = FlashTransponderTablesGetTotal(SatIndex);
28 for(TpIdx = 0; TpIdx < TrCount; TpIdx++)
29 {
30 if(FlashTransponderTablesGetInfo(SatIndex, TpIdx, &Transponder))
31 {
32 if((Transponder.OriginalNetworkID == NetworkID) && (Transponder.TSID == TSID))
33 {
34 SvcIdx = ApplSvc_GetSvcIdx(SVC_TYPE_Tv, SatIndex, TpIdx, ServiceID, 0, 0xffff);
35 if(SvcIdx != 0xffff)
36 {
37 if(SvcType) *SvcType = SVC_TYPE_Tv;
38 if(SvcNum) *SvcNum = SvcIdx;
39
40 LastSatIndex = SatIndex;
41 LastNetworkID = NetworkID;
42 LastTSID = TSID;
43 LastServiceID = ServiceID;
44 LastSvcType = SVC_TYPE_Tv;
45 LastSvcNum = SvcIdx;
46
47 ret = TRUE;
48 break;
49 }
50 else
51 {
52 SvcIdx = ApplSvc_GetSvcIdx(SVC_TYPE_Radio, SatIndex, TpIdx, ServiceID, 0, 0xffff);
53 if(SvcIdx != 0xffff)
54 {
55 if(SvcType) *SvcType = SVC_TYPE_Radio;
56 if(SvcNum) *SvcNum = SvcIdx;
57
58 LastSatIndex = SatIndex;
59 LastNetworkID = NetworkID;
60 LastTSID = TSID;
61 LastServiceID = ServiceID;
62 LastSvcType = SVC_TYPE_Radio;
63 LastSvcNum = SvcIdx;
64
65 ret = TRUE;
66 break;
67 }
68 }
69 }
70 }
71 }
72
73 TRACEEXIT();
74 return ret;
75}
word ApplSvc_GetSvcIdx(byte TYPE_ServiceType, byte SatIndex, word TPIndex, word ServiceID, word Start, word NrOfServicesToSearch)
bool FlashServiceFindNum(byte SatIndex, word NetworkID, word TSID, word ServiceID, TYPE_ServiceType *SvcType, int *SvcNum)
bool FlashTransponderTablesGetInfo(int SatNum, int TransponderNum, tFlashTransponderTable *TransponderTable)
int FlashTransponderTablesGetTotal(int SatNum)
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243