Black Hole
May contain traces of nut
For background, please refer to the associated topic: http://hummy.tv/forum/threads/copying-tuning-from-one-hd-hdr-fox-to-another.5975/. Note that this discussion does not require custom firmware installed on the HD/HDR-FOX. Note also that I have no experience with databases, so whatever I describe below anyone could do (well, almost).
I decided I would have a crack at adding the new services Classic FM and Magic to the tuning database manually, using data from primary sources only (ie not copied from another 'FOX). The first thing to do (I thought) was to dissect the channel.db file, so I downloaded the portable version of DB Browser for SQLite from sqlitebrowser.org and used it to open the channel.db file extracted from my recently-tuned HD-FOX using the hidden menu "Copy DB to USB" option. Then, for good measure, I exported the TBL_SVC table as CSV and opened that as a spreadsheet (saved to .xls and available for inspection as a zipped attachment to this post - different service types are identified by highlighting applied afterwards). Bear in mind that the tuning set has already been edited down in the 'FOX by deleting the services I am not interested in. Warning: DB Browser for SQLite does not have a "save as" option. Committing alterations to the database file over-writes the original file.
I must say - I am a little bemused as to what advantage a database brings to this as opposed to a straightforward data table (saving the overhead of running SQLite). Maybe it pays dividends when it comes to the reservation database rsv.db, and if SQLite is running for one, they might as well use it for the other.
Some of the fields are constant and therefore of little interest (although they might not have been constant if I had not deleted shopping/IPTV/gay/sex/chat.., and they might respond to some user settings - eg subtitles, I will edit in subsequent new information):
Thus, in my slightly naive analysis, I reckon it should be possible to add records to this table by duplicating an existing record and then inserting appropriate values for the fields which are not constant. The problem is: what are the appropriate values. Bear in mind the following are hypotheses based on observations from the attached file only.
svcIdx
usLcn
szSvcName
usSvcId
eSvcType
eVideoType
ucVideoCodec
ucAudioCodec
usPmtPid
usVideoPid
usAudioPid
usPcrPid
tsIdx
hSvc
usTsId
eOrgSvcType
aucDefaultAuthority
ulFTAContentMgr
So, in my naive expectations, adding records for new services (presuming they are on muxes currently included in TBL_TS) is a case of finding suitable values for usSvcId, usPmtPid, usVideoPid, usAudioPid, and usPcrPid. The other fields can then be patched according to the patterns observed, or left blank maybe (eg aucDefaultAuthority).
I decided I would have a crack at adding the new services Classic FM and Magic to the tuning database manually, using data from primary sources only (ie not copied from another 'FOX). The first thing to do (I thought) was to dissect the channel.db file, so I downloaded the portable version of DB Browser for SQLite from sqlitebrowser.org and used it to open the channel.db file extracted from my recently-tuned HD-FOX using the hidden menu "Copy DB to USB" option. Then, for good measure, I exported the TBL_SVC table as CSV and opened that as a spreadsheet (saved to .xls and available for inspection as a zipped attachment to this post - different service types are identified by highlighting applied afterwards). Bear in mind that the tuning set has already been edited down in the 'FOX by deleting the services I am not interested in. Warning: DB Browser for SQLite does not have a "save as" option. Committing alterations to the database file over-writes the original file.
I must say - I am a little bemused as to what advantage a database brings to this as opposed to a straightforward data table (saving the overhead of running SQLite). Maybe it pays dividends when it comes to the reservation database rsv.db, and if SQLite is running for one, they might as well use it for the other.
Well, SQLite is not running as such, it's just being used as a library for reading the data file off disk. A ready-made parser making it easy to read, update, sort etc. It also allows the use of SQL to construct queries across the various tables as necessary and they can use triggers to handle cascading deletes...
Some of the fields are constant and therefore of little interest (although they might not have been constant if I had not deleted shopping/IPTV/gay/sex/chat.., and they might respond to some user settings - eg subtitles, I will edit in subsequent new information):
eCasType - always "1"
usTtxPid - always "8192"
prvIdx - always "1"
ucSearchFlag - always "0"
eOrgDeliType - always "2"
ucAudUserSetFlag - always "0"
ucSubttlUserFlag - always "0"
ucSubttlIdx - always "255"
ucLocked - always "0"
usAudioAuxPid - always "8192"
ucSatType - always "0"
ucSoundMode - always "0"
ucAudioAuxCodec - always "0"
usDolbyPid - always "8192"
ucChListPriority - always "0"
ucAntIdx - always "0"
usOnId - always "9018"
ucModifiedName - always "0"
ucDolbyFlag - always "0"
ucLcnFlag - always "1"
ucVisibleSvcFlag - always "1"
ucDolbyCodec - always "0"
ulRatingPassedEventId - always "4294967295"
eSection - always "16"
eSvcOpType - always "1"
eUserFlag1 - always "2"
usOrgLcn - always "0"
ucGuidanceType - always "255"
ucGuidanceMode - always "0"
szGuidanceStr - always ""
stRegionInfo - some kind of binary string, apparently constant even though from West and Wales.
usTtxPid - always "8192"
prvIdx - always "1"
ucSearchFlag - always "0"
eOrgDeliType - always "2"
ucAudUserSetFlag - always "0"
ucSubttlUserFlag - always "0"
ucSubttlIdx - always "255"
ucLocked - always "0"
usAudioAuxPid - always "8192"
ucSatType - always "0"
ucSoundMode - always "0"
ucAudioAuxCodec - always "0"
usDolbyPid - always "8192"
ucChListPriority - always "0"
ucAntIdx - always "0"
usOnId - always "9018"
ucModifiedName - always "0"
ucDolbyFlag - always "0"
ucLcnFlag - always "1"
ucVisibleSvcFlag - always "1"
ucDolbyCodec - always "0"
ulRatingPassedEventId - always "4294967295"
eSection - always "16"
eSvcOpType - always "1"
eUserFlag1 - always "2"
usOrgLcn - always "0"
ucGuidanceType - always "255"
ucGuidanceMode - always "0"
szGuidanceStr - always ""
stRegionInfo - some kind of binary string, apparently constant even though from West and Wales.
Thus, in my slightly naive analysis, I reckon it should be possible to add records to this table by duplicating an existing record and then inserting appropriate values for the fields which are not constant. The problem is: what are the appropriate values. Bear in mind the following are hypotheses based on observations from the attached file only.
svcIdx
This is a number unique for each record in the table, presumably used to reference that record in database queries. Is this number arbitrary, and allocated on a first-come-first-served basis? If I had retuned from factory reset and not deleted any services, would this field be an incrementing count?
usLcn
This number corresponds with the LCN for the service.
szSvcName
Text string corresponding with the display name of the service at that LCN.
usSvcId
Different for each record, presumed to be the unique identifier for the service on the broadcast network. This is constant across the network for non-regional services, but (for example) BBC ONE has a different ID in the South region compared to the West. See post 2.
eSvcType
"2" for radio, "1" for everything else (including the BBC Red Button data service, LCN 200).
eVideoType
"0" for radio, "2" for HiDef, "1" for everything else (including data).
ucVideoCodec
"0" for radio and data, "2" for HiDef, but then it gets complicated. StDef TV services are mostly "1" with the following exceptions: Film4+1 (transmitted on a HiDef mux) is "2"; BBC THREE, BBC FOUR, ITV3+1, ITV4+1, truTV+1 are "0".
I wonder if this has something to do with the difficulty somebody is having with BBC THREE and FOUR (StDef)? Flagging them "0" seems to imply no video codec. I wonder what would happen if they were changed to "1"?
I wonder if this has something to do with the difficulty somebody is having with BBC THREE and FOUR (StDef)? Flagging them "0" seems to imply no video codec. I wonder what would happen if they were changed to "1"?
ucAudioCodec
"0" for data, "7" for HiDef, "1" for radio, "1" for StDef TV services with the following exceptions: Film4+1 (transmitted on a HiDef mux) is "7"; BBC THREE, BBC FOUR, ITV3+1, ITV4+1, truTV+1 are "0".
Flagging the exceptions "0" seems to imply no audio codec. I wonder what would happen if they were changed to "1"?
Flagging the exceptions "0" seems to imply no audio codec. I wonder what would happen if they were changed to "1"?
usPmtPid
usVideoPid
usAudioPid
usPcrPid
These tend to have unique values for each record, with a few exceptions as noted below. My guess is that these are something to do with identifying specific data streams within the service TS.
usPmtPid shows some duplication between radio and TV services. usVideoPid is "8192" for radio, data, and BBC THREE, BBC FOUR, ITV3+1, ITV4+1, truTV+1, 5*. usAudioPid is "8192" for data and BBC THREE, BBC FOUR, ITV3+1, ITV4+1, truTV+1, 5*. usPcrPid is "8191" for data and BBC THREE, BBC FOUR, ITV3+1, ITV4+1, truTV+1, 5*.
If these parameters are necessary for extracting the relevant data from the TS stream, why can some services get away with defaulting to 8192? See post 4.
usPmtPid shows some duplication between radio and TV services. usVideoPid is "8192" for radio, data, and BBC THREE, BBC FOUR, ITV3+1, ITV4+1, truTV+1, 5*. usAudioPid is "8192" for data and BBC THREE, BBC FOUR, ITV3+1, ITV4+1, truTV+1, 5*. usPcrPid is "8191" for data and BBC THREE, BBC FOUR, ITV3+1, ITV4+1, truTV+1, 5*.
If these parameters are necessary for extracting the relevant data from the TS stream, why can some services get away with defaulting to 8192? See post 4.
tsIdx
This number corresponds with the index number for the particular mux in the TBL_TS section of the database, so will be used to look up the tuning parameters (channel frequency etc) for this particular service and send them to the tuner front-end.
In my data, indexes 7-10 are missing because I have deleted any services from those channels - however, in the TBL_TS, 7-9 are missing. That there are only 9 records in TBL_TS is not a mystery: I only (manually) tuned 9 channels (and then deleted the contents of one of them, as a means to push BBC ONE Wales onto LCN 801). What is more of a mystery is why these 9 channels are not allocated IDs 1-9 instead of 1-12 (maybe a hang-over from an auto-tune without a factory reset in between?).
In my data, indexes 7-10 are missing because I have deleted any services from those channels - however, in the TBL_TS, 7-9 are missing. That there are only 9 records in TBL_TS is not a mystery: I only (manually) tuned 9 channels (and then deleted the contents of one of them, as a means to push BBC ONE Wales onto LCN 801). What is more of a mystery is why these 9 channels are not allocated IDs 1-9 instead of 1-12 (maybe a hang-over from an auto-tune without a factory reset in between?).
hSvc
This value corresponds with svcIdx + tsIdx * 2^16.
hSvc = 65536 * tsIdx + svcIdx
so 131094 decodes to tsIdx=2, svcIdx=22
usTsId
This value is unique to each mux, presumably some kind of identification on the broadcast network. Difficult to see why it is in this table at all - it could be referenced from TBL_TS.
eOrgSvcType
"2" for radio, "1" for everything else (including data).
aucDefaultAuthority
A URL-like string identifying the broadcaster responsible for that service.
ulFTAContentMgr
"50332417" for HiDef, "0" for everything else.
So, in my naive expectations, adding records for new services (presuming they are on muxes currently included in TBL_TS) is a case of finding suitable values for usSvcId, usPmtPid, usVideoPid, usAudioPid, and usPcrPid. The other fields can then be patched according to the patterns observed, or left blank maybe (eg aucDefaultAuthority).
Attachments
Last edited: