Skip to content

Commit

Permalink
KVP DVBString add htmlSource, fix all callers
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBerendsen committed Sep 16, 2024
1 parent f139407 commit 51d52f7
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 163 deletions.
14 changes: 7 additions & 7 deletions src/main/java/nl/digitalekabeltelevisie/controller/KVP.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public KVP(String label, byte[] byteArray) {
this.byteStart = 0;
this.byteLen = byteArray.length;
this.fieldType = FIELD_TYPE.BYTES;
detailViews.add(new DetailView((HTMLSource) () -> getHTMLHexview(byteValue, byteStart, byteLen), "Hex View"));
addHTMLSource(() -> getHTMLHexview(byteValue, byteStart, byteLen), "Hex View");
}

public KVP(String label, byte[] byteArray, String description) {
Expand All @@ -194,7 +194,7 @@ public KVP(String label, byte[] byteArray, int offset, int len) {
this.byteStart = offset;
this.byteLen = len;
this.fieldType = FIELD_TYPE.BYTES;
detailViews.add(new DetailView((HTMLSource) () -> getHTMLHexview(byteValue, byteStart, byteLen), "Hex View"));
addHTMLSource(() -> getHTMLHexview(byteValue, byteStart, byteLen), "Hex View");
}

public KVP(String label, byte[] byteArray, int offset, int len, String description) {
Expand All @@ -208,11 +208,11 @@ public KVP(String label, DVBString dvbStringValue) {
this.fieldType = FIELD_TYPE.DVBSTRING;
this.add(new KVP("encoding", dvbStringValue.getEncodingString()));
this.add(new KVP("length", dvbStringValue.getLength()));
}

public KVP(String label, DVBString dvbStringValue, String description) {
this(label,dvbStringValue);
setDescription(description);
this.addHTMLSource(
() ->"<b>Encoding:</b> " + dvbStringValue.getEncodingString()
+ "<br><br><b>Data:</b><br>" + getHTMLHexview(dvbStringValue.getData(), dvbStringValue.getOffset() + 1, dvbStringValue.getLength())
+ "<br><b>Formatted:</b><br>" + dvbStringValue.toEscapedHTML(),
"DVB String");
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private static Descriptor getPrivateDVBSIDescriptor(final byte[] data, final Tab
case 0x83:
return new NordigLogicalChannelDescriptorV1(data, 0, tableSection, descriptorContext);
case 0x87:
return new NordigLogicalChannelDescriptorV2(data, 0, tableSection, descriptorContext);
return new NordigLogicalChannelDescriptorV2(data, tableSection, descriptorContext);
}


Expand All @@ -272,7 +272,7 @@ private static Descriptor getPrivateDVBSIDescriptor(final byte[] data, final Tab
} else if (private_data_specifier == 0xa4) { // Canal + International
switch (descriptor_tag) {
case 0x80:
return new CosBatSelectionDescriptor (data, 0, tableSection);
return new CosBatSelectionDescriptor (data, tableSection);
case 0x81:
return new CosInformationParametersDescriptor(data, 0, tableSection);
case 0x83:
Expand All @@ -287,7 +287,7 @@ private static Descriptor getPrivateDVBSIDescriptor(final byte[] data, final Tab
case 0x86:
return new ServiceAttributeDescriptor(data, 0, tableSection);
case 0x89:
return new GuidanceDescriptor(data, 0, tableSection);
return new GuidanceDescriptor(data, tableSection);
}
} else if (private_data_specifier >= 0x00003200 && private_data_specifier <= 0x0000320F ) { // FREE TV AUSTRALIA OPERATIONAL PRACTICE OP-40
switch (descriptor_tag) {
Expand Down Expand Up @@ -610,7 +610,7 @@ private static Descriptor getUNTDescriptor(final byte[] data, final TableSection
case 0x03:
return new SSULocationDescriptor(data, 0, tableSection);
case 0x04:
return new MessageDescriptor(data, 0, tableSection);
return new MessageDescriptor(data, tableSection);
case 0x05:
return new SSUEventNameDescriptor(data, 0, tableSection);
case 0x06:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,18 @@ public class CosBatSelectionDescriptor extends Descriptor {

/**
* @param b
* @param offset
* @param parent
*/
public CosBatSelectionDescriptor(byte[] b, int offset, TableSection parent) {
super(b, offset, parent);
bouquet_id = getInt(b, offset+2,2,MASK_16BITS);
selector_type = getInt(b, offset+4,1,MASK_8BITS);
if (selector_type == 0x01) {
usage_id = getInt(b, offset+5,1,MASK_8BITS);
}else if (selector_type == 0x02) {
region_name = new DVBString (b,offset+5);
}else if (selector_type != 0x03) {
databyte = getBytes(b, offset+5, descriptorLength -3);
public CosBatSelectionDescriptor(byte[] b, TableSection parent) {
super(b, parent);
bouquet_id = getInt(b, 2, 2, MASK_16BITS);
selector_type = getInt(b, 4, 1, MASK_8BITS);
if (selector_type == 0x01) {
usage_id = getInt(b, 5, 1, MASK_8BITS);
} else if (selector_type == 0x02) {
region_name = new DVBString(b, 5);
} else if (selector_type != 0x03) {
databyte = getBytes(b, 5, descriptorLength - 3);
}
}

Expand All @@ -68,22 +67,20 @@ public String getDescriptorname(){
}

@Override
public DefaultMutableTreeNode getJTreeNode(final int modus){

final DefaultMutableTreeNode t = super.getJTreeNode(modus);
t.add(new DefaultMutableTreeNode(new KVP("bouquet_id",bouquet_id,null)));
t.add(new DefaultMutableTreeNode(new KVP("selector_type",selector_type,getSelectorTypeString(selector_type))));
if (selector_type == 0x01) {
t.add(new DefaultMutableTreeNode(new KVP("usage_id",usage_id,null)));
}else if (selector_type == 0x02) {
t.add(new DefaultMutableTreeNode(new KVP("region_name_length",region_name.getLength(),null)));
t.add(new DefaultMutableTreeNode(new KVP("region_name",region_name,null)));
}else if (selector_type != 0x03) {
t.add(new DefaultMutableTreeNode(new KVP("databyte",databyte,null)));
public DefaultMutableTreeNode getJTreeNode(int modus) {

DefaultMutableTreeNode t = super.getJTreeNode(modus);
t.add(new KVP("bouquet_id", bouquet_id));
t.add(new KVP("selector_type", selector_type).setDescription(getSelectorTypeString(selector_type)));
if (selector_type == 0x01) {
t.add(new KVP("usage_id", usage_id));
} else if (selector_type == 0x02) {
t.add(new KVP("region_name", region_name));
} else if (selector_type != 0x03) {
t.add(new KVP("databyte", databyte));

}


return t;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,40 +50,41 @@ public class GuidanceDescriptor extends Descriptor {
byte[] reserved_for_future_use;


public GuidanceDescriptor(final byte[] b, final int offset, final TableSection parent) {
super(b, offset,parent);
reserved = getInt(b, offset+2, 1, 0xFC)>>2;
guidance_type = getInt(b, offset+2, 1, MASK_2BITS);
public GuidanceDescriptor( byte[] b, TableSection parent) {
super(b, parent);
reserved = getInt(b, 2, 1, 0xFC)>>2;
guidance_type = getInt(b, 2, 1, MASK_2BITS);
if(guidance_type==0){
iso_639_language_code=getISO8859_1String(b, offset+3, 3);
guidance_char = new DVBString(b, offset+6, descriptorLength-4);
iso_639_language_code=getISO8859_1String(b, 3, 3);
guidance_char = new DVBString(b, 6, descriptorLength-4);
}else if(guidance_type==1){
reserved2 = getInt(b, offset+3, 1, 0xFE)>>1;
guidance_mode = getInt(b, offset+3, 1, MASK_1BIT);
iso_639_language_code=getISO8859_1String(b, offset+4, 3);
guidance_char = new DVBString(b, offset+7, descriptorLength-5);
reserved2 = getInt(b, 3, 1, 0xFE)>>1;
guidance_mode = getInt(b, 3, 1, MASK_1BIT);
iso_639_language_code=getISO8859_1String(b, 4, 3);
guidance_char = new DVBString(b, 7, descriptorLength-5);
}else{
reserved_for_future_use = getBytes(b, offset+3, descriptorLength-3);
reserved_for_future_use = getBytes(b, 3, descriptorLength-3);
}

}

@Override
public DefaultMutableTreeNode getJTreeNode(final int modus){
public DefaultMutableTreeNode getJTreeNode(int modus) {

final DefaultMutableTreeNode t = super.getJTreeNode(modus);
t.add(new DefaultMutableTreeNode(new KVP("reserved",reserved,null)));
t.add(new DefaultMutableTreeNode(new KVP("guidance_type",guidance_type,null)));
if(guidance_type==0){
t.add(new DefaultMutableTreeNode(new KVP("ISO_639_language_code",iso_639_language_code,null)));
t.add(new DefaultMutableTreeNode(new KVP("guidance_char",guidance_char,null)));
}else if(guidance_type==1){
t.add(new DefaultMutableTreeNode(new KVP("reserved",reserved2,null)));
t.add(new DefaultMutableTreeNode(new KVP("guidance_mode",guidance_mode,(guidance_mode==1)?"guidance for content unsuitable for broadcast until after the watershed is appropriate.":null)));
t.add(new DefaultMutableTreeNode(new KVP("ISO_639_language_code",iso_639_language_code,null)));
t.add(new DefaultMutableTreeNode(new KVP("guidance_char",guidance_char,null)));
}else{
t.add(new DefaultMutableTreeNode(new KVP("reserved_for_future_use",reserved_for_future_use,null)));
DefaultMutableTreeNode t = super.getJTreeNode(modus);
t.add(new KVP("reserved", reserved));
t.add(new KVP("guidance_type", guidance_type));
if (guidance_type == 0) {
t.add(new KVP("ISO_639_language_code", iso_639_language_code));
t.add(new KVP("guidance_char", guidance_char));
} else if (guidance_type == 1) {
t.add(new KVP("reserved", reserved2));
t.add(new KVP("guidance_mode", guidance_mode)
.setDescription((guidance_mode == 1) ? "guidance for content unsuitable for broadcast until after the watershed is appropriate." : null));
t.add(new KVP("ISO_639_language_code", iso_639_language_code));
t.add(new KVP("guidance_char", guidance_char));
} else {
t.add(new KVP("reserved_for_future_use", reserved_for_future_use));
}

return t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public class M7OperatorNameDescriptor extends M7Descriptor {

public M7OperatorNameDescriptor(byte[] b, int offset, TableSection parent) {
super(b, offset, parent);
operatorName = new DVBString(b,offset+1);
operatorName = new DVBString(b,1);
}

@Override
public DefaultMutableTreeNode getJTreeNode(final int modus){
final DefaultMutableTreeNode t = super.getJTreeNode(modus);
t.add(new DefaultMutableTreeNode(new KVP("operator_name",operatorName ,null)));
t.add(new KVP("operator_name",operatorName));
return t;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public class M7OperatorSublistNameDescriptor extends M7Descriptor {

public M7OperatorSublistNameDescriptor(byte[] b, int offset, TableSection parent) {
super(b, offset, parent);
operatorSublistName = new DVBString(b,offset+1);
operatorSublistName = new DVBString(b,1);
}

@Override
public DefaultMutableTreeNode getJTreeNode(final int modus){
public DefaultMutableTreeNode getJTreeNode(final int modus) {
final DefaultMutableTreeNode t = super.getJTreeNode(modus);
t.add(new DefaultMutableTreeNode(new KVP("operator_sublist_name",operatorSublistName ,null)));
t.add(new KVP("operator_sublist_name", operatorSublistName));
return t;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,41 +49,18 @@
//based on NorDig Unified ver 2.3 12.2.9.3 NorDig private; Logical Channel Descriptor (version 2)
public class NordigLogicalChannelDescriptorV2 extends AbstractLogicalChannelDescriptor {



private List<ChannelList> channelLists = new ArrayList<>();
public static class ChannelList implements TreeNode{
/**
* @param channel_list_id
* @param channel_list_name
* @param service_loop_length
* @param logicalChannelList
*/
private ChannelList(int channel_list_id, DVBString channel_list_name,String country_code,
int service_loop_length, List<LogicalChannel> logicalChannelList) {
super();
this.channel_list_id = channel_list_id;
this.channel_list_name = channel_list_name;
this.country_code = country_code;
this.service_loop_length = service_loop_length;
this.logicalChannelList = logicalChannelList;
}


private int channel_list_id;
private DVBString channel_list_name;
private final String country_code;
private int service_loop_length;
private List<LogicalChannel> logicalChannelList = new ArrayList<>();

public static record ChannelList(int channel_list_id, DVBString channel_list_name, String country_code, int service_loop_length,
List<LogicalChannel> logicalChannelList) implements TreeNode {

public DefaultMutableTreeNode getJTreeNode(final int modus){
final DefaultMutableTreeNode s=new DefaultMutableTreeNode(new KVP("Channel List ("+channel_list_name+")"));
s.add(new DefaultMutableTreeNode(new KVP("channel_list_id",channel_list_id,null)));
s.add(new DefaultMutableTreeNode(new KVP("channel_list_name_length",channel_list_name.getLength(),null)));
s.add(new DefaultMutableTreeNode(new KVP("channel_list_name",channel_list_name,null)));
s.add(new DefaultMutableTreeNode(new KVP("country_code",country_code,null)));
s.add(new DefaultMutableTreeNode(new KVP("service_loop_length",service_loop_length,null)));
@Override
public KVP getJTreeNode(int modus) {
KVP s = new KVP("Channel List (" + channel_list_name + ")");
s.add(new KVP("channel_list_id", channel_list_id));
s.add(new KVP("channel_list_name", channel_list_name));
s.add(new KVP("country_code", country_code));
s.add(new KVP("service_loop_length", service_loop_length));

addListJTree(s, logicalChannelList, modus, "Logical Channels");
return s;
Expand All @@ -93,50 +70,46 @@ public DefaultMutableTreeNode getJTreeNode(final int modus){

public class LogicalChannel extends AbstractLogicalChannel{


public LogicalChannel(final int service_id, final int visible_service, final int reserved, final int logical_channel_number){
public LogicalChannel(int service_id, int visible_service, int reserved, int logical_channel_number){
super(service_id, visible_service, reserved, logical_channel_number);
}



}

public NordigLogicalChannelDescriptorV2(final byte[] b, final int offset, final TableSection parent, DescriptorContext descriptorContext) {
super(b, offset,parent, descriptorContext);
int t=0;
while (t<descriptorLength) {
final int channel_list_id=getInt(b, offset+2+t,1,MASK_8BITS);
DVBString channel_list_name = new DVBString(b,offset+t+3);
t+=2+channel_list_name.getLength();
String country_code = getISO8859_1String(b, offset+t+2, 3);
t+=3;
int service_loop_length=getInt(b, offset+2+t,1,MASK_8BITS);
t+=1;
public NordigLogicalChannelDescriptorV2(byte[] b, TableSection parent, DescriptorContext descriptorContext) {
super(b, 0 , parent, descriptorContext);
int t = 0;
while (t < descriptorLength) {
final int channel_list_id = getInt(b, 2 + t, 1, MASK_8BITS);
DVBString channel_list_name = new DVBString(b, t + 3);
t += 2 + channel_list_name.getLength();
String country_code = getISO8859_1String(b, t + 2, 3);
t += 3;
int service_loop_length = getInt(b, 2 + t, 1, MASK_8BITS);
t += 1;
List<LogicalChannel> channelList = new ArrayList<>();
int s=0;
while (s<service_loop_length) {
final int serviceId=getInt(b, offset+2+t+s,2,MASK_16BITS);
final int visible = getInt(b,offset+t+4+s,1,0x80) >>7;
final int reserved = getInt(b,offset+t+4+s,1,0x7C) >>2; // 5 bits
int s = 0;
while (s < service_loop_length) {
final int serviceId = getInt(b, 2 + t + s, 2, MASK_16BITS);
final int visible = getInt(b, t + 4 + s, 1, 0x80) >> 7;
final int reserved = getInt(b, t + 4 + s, 1, 0x7C) >> 2; // 5 bits
// chNumber is 10 bits in Nordig specs V2
final int chNumber=getInt(b, offset+t+4+s,2,MASK_10BITS);
final int chNumber = getInt(b, t + 4 + s, 2, MASK_10BITS);
final LogicalChannel lc = new LogicalChannel(serviceId, visible, reserved, chNumber);
channelList.add(lc);
s+=4;
s += 4;
}
t+=s;
ChannelList chList = new ChannelList(channel_list_id, channel_list_name,country_code,service_loop_length,channelList);
t += s;
ChannelList chList = new ChannelList(channel_list_id, channel_list_name, country_code, service_loop_length, channelList);
channelLists.add(chList);
}
}



@Override
public DefaultMutableTreeNode getJTreeNode(final int modus){
public DefaultMutableTreeNode getJTreeNode(int modus){

final DefaultMutableTreeNode t = super.getJTreeNode(modus);
DefaultMutableTreeNode t = super.getJTreeNode(modus);
addListJTree(t,channelLists,modus,"Channel Lists");
return t;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,25 @@ public class MessageDescriptor extends UNTDescriptor {

/**
* @param b
* @param offset
* @param parent
*/
public MessageDescriptor(final byte[] b, final int offset, final TableSection parent) {
super(b, offset, parent);
public MessageDescriptor(byte[] b, TableSection parent) {
super(b, 0, parent);

descriptorNumber = Utils.getInt(b, offset + 2, 1, 0xF0)>>4;
lastDescriptorNumber = Utils.getInt(b, offset + 2, 1, Utils.MASK_4BITS);
iso639LanguageCode = getISO8859_1String(b, offset + 3, 3);
text = new DVBString(b, offset + 6, descriptorLength - 4);
descriptorNumber = Utils.getInt(b, 2, 1, 0xF0)>>4;
lastDescriptorNumber = Utils.getInt(b,2, 1, Utils.MASK_4BITS);
iso639LanguageCode = getISO8859_1String(b, 3, 3);
text = new DVBString(b, 6, descriptorLength - 4);

}

@Override
public DefaultMutableTreeNode getJTreeNode(final int modus) {
final DefaultMutableTreeNode t = super.getJTreeNode(modus);
t.add(new DefaultMutableTreeNode(new KVP("descriptor_number", descriptorNumber, null)));
t.add(new DefaultMutableTreeNode(new KVP("last_descriptor_number", lastDescriptorNumber, null)));
t.add(new DefaultMutableTreeNode(new KVP("ISO_639_language_code", iso639LanguageCode, null)));
t.add(new DefaultMutableTreeNode(new KVP("platform name", text, null)));
public DefaultMutableTreeNode getJTreeNode(int modus) {
DefaultMutableTreeNode t = super.getJTreeNode(modus);
t.add(new KVP("descriptor_number", descriptorNumber));
t.add(new KVP("last_descriptor_number", lastDescriptorNumber));
t.add(new KVP("ISO_639_language_code", iso639LanguageCode));
t.add(new KVP("platform name", text));
return t;
}

Expand Down
Loading

0 comments on commit 51d52f7

Please sign in to comment.