piratfm / eti-tools

ETI conversion software
Mozilla Public License 2.0
51 stars 18 forks source link

[idea] ni2http sorted services list #30

Open jpuigs opened 5 years ago

jpuigs commented 5 years ago

would it be possible , in ni2http --list option, to get the services list sorted by subchannel ID ?

wget http://192.168.0.16:8001/1:0:1:46:0:1:30300F:0:0:0: -q -O- | ts2na -p 1061 -s 12 | na2ni | ni2http --list
WARN:  Forward error correction (FEC) disabled (NOT COMPILED)
INFO:  Using pid: 0x0425 (1061)
INFO:  E1 Sync found at bit: 222, inverted: yes
DEBUG: seek: B:27, b:6
DEBUG: pre-readed output 15 frames (4 bytes left):
DEBUG: MULTIFRAME FILLING: 207
INFO:  ETI Sync found at pos: 0
INFO:  ETI Multiframe sync found at blockId: 20
.BBC National DAB (0xce15)
 0 : BBC Radio 4Extra (0xc22c) Pri subch=12 start=774 CUs= 58 PL=uep 3 bitrate=80
 1 : BBC Radio 1Xtra  (0xc22a) Pri subch=10 start=582 CUs= 96 PL=uep 3 bitrate=128
 2 : BBC AsianNetwork (0xc236) Pri subch= 7 start=486 CUs= 48 PL=uep 3 bitrate=64
 3 : BBC WorldService (0xc238) Pri subch= 9 start=534 CUs= 48 PL=uep 3 bitrate=64
 4 : BBC Radio 1      (0xc221) Pri subch= 1 start=  0 CUs= 96 PL=uep 3 bitrate=128
 5 : BBC Radio 2      (0xc222) Pri subch= 2 start= 96 CUs= 96 PL=uep 3 bitrate=128
 6 : BBC Radio 3      (0xc223) Pri subch= 3 start=192 CUs=140 PL=uep 3 bitrate=192
 7 : BBC Radio 4      (0xc224) Pri subch= 4 start=332 CUs= 96 PL=uep 3 bitrate=128
 8 : BBC Radio 5 Live (0xc225) Pri subch= 5 start=428 CUs= 58 PL=uep 3 bitrate=80
 9 : BBC Radio 6Music (0xc22b) Pri subch=11 start=678 CUs= 96 PL=uep 3 bitrate=128

in order to get this...

0 : BBC Radio 1      (0xc221) Pri subch= 1 start=  0 CUs= 96 PL=uep 3 bitrate=128
 1 : BBC Radio 2      (0xc222) Pri subch= 2 start= 96 CUs= 96 PL=uep 3 bitrate=128
 2 : BBC Radio 3      (0xc223) Pri subch= 3 start=192 CUs=140 PL=uep 3 bitrate=192
 3 : BBC Radio 4      (0xc224) Pri subch= 4 start=332 CUs= 96 PL=uep 3 bitrate=128
 4 : BBC Radio 5 Live (0xc225) Pri subch= 5 start=428 CUs= 58 PL=uep 3 bitrate=80
 5 : BBC AsianNetwork (0xc236) Pri subch= 7 start=486 CUs= 48 PL=uep 3 bitrate=64
 6 : BBC WorldService (0xc238) Pri subch= 9 start=534 CUs= 48 PL=uep 3 bitrate=64
 7 : BBC Radio 1Xtra  (0xc22a) Pri subch=10 start=582 CUs= 96 PL=uep 3 bitrate=128
 8 : BBC Radio 6Music (0xc22b) Pri subch=11 start=678 CUs= 96 PL=uep 3 bitrate=128
 9 : BBC Radio 4Extra (0xc22c) Pri subch=12 start=774 CUs= 58 PL=uep 3 bitrate=80
andimik commented 5 years ago

Better would be sorted by start CU.

jpuigs commented 5 years ago

.. or by name..... In order to suit everybody's wishes,: -- list -> current situation -- list i -> sorted by Subch ID -- list c -> sorted by start CU -- list n -> sorted by name -- list s -> sorted by service ID ....

andimik commented 5 years ago

The code is open source. You could basically do it yourself. Even I did it (and I am not a programmer, just a normal user)

Change https://github.com/piratfm/eti-tools/blob/master/wfficproc.c by separating the fields by a semicolon (which I hope it's not used for service labels) and remove unnecessary text and spaces and numbers, for instance start=%3d to ;%d; to have a number, not a text.

Then output the ni2http --list to a file by piping it with ni2http --list 2> file.txt (Remark: > does not work as this is the stderr output), delete the 1st row and then process it with awk and sort.

I can post the detailled solution later, but I will not change the code here.

And you can change line 186 in https://github.com/piratfm/eti-tools/blob/master/wfficproc.c#L186

from int i = 0; to int i = 1;

that the 1st service begins with 1, not with 0.

0 : BBC Radio 1 (0xc221) Pri subch= 1 start= 0 CUs= 96 PL=uep 3 bitrate=128

Of course you have to re-compile it by make in the eti-tools folder.

jpuigs commented 5 years ago

line 186 was the 1st thing I changed :-) I tried to sort inside wffic.c , but my knownledge of c++ is very very limited, and I didn't success. Each line has 3 elements, Label name, sid, and "rest". so it had to be sorted all of them. I had no problems with sid and "rest", but label name was problematic, and I don't know why. I used classic sort procedure , compare one element with next one, and if it's bigger the first one, then swap with second one. If you could post code, it'll be good.

andimik commented 5 years ago

output.txt

$ cat output.txt | sed 's/Pri subch=\|start=\|CUs=\|bitrate=\|PL=//g' > output_new.txt

sort by label: $ cat ./output_new.txt | sed '1d' | sort -t ";" -k2

sort by SId: $ cat ./output_new.txt | sed '1d' | sort -t ";" -k3

sort by subch (note, you have to specify it as number) $ cat ./output_new.txt | sed '1d' | sort -t ";" -nk4

sort by start CU (specified as number) $ cat ./output_new.txt | sed '1d' | sort -t ";" -nk5

sort by used CUs (specified as number) $ cat ./output_new.txt | sed '1d' | sort -t ";" -nk6

sort by protection level $ cat ./output_new.txt | sed '1d' | sort -t ";" -k7

sort by bitrate (as number) $ cat ./output_new.txt | sed '1d' | sort -t ";" -nk8

sort by DAB/DAB+ $ cat ./output_new.txt | sed '1d' | sort -t ";" -k9

wfficproc.zip

You could then save this as alias so that you don't need to re-type them.

jpuigs commented 5 years ago

Thank's. I'll try.