Skip to content

Commit

Permalink
KVP DVBString refactoring2
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBerendsen committed Sep 14, 2024
1 parent 698731c commit f139407
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -584,22 +584,21 @@ private static Descriptor getINTDescriptor(final byte[] data, final TableSection

switch (toUnsignedInt(data[0])) {
case 0x0C:
return new IPMACPlatformNameDescriptor(data, 0, tableSection);
return new IPMACPlatformNameDescriptor(data, tableSection);
case 0x0D:
return new IPMACPlatformProviderNameDescriptor(data, 0, tableSection);
return new IPMACPlatformProviderNameDescriptor(data, tableSection);
case 0x0F:
return new TargetIPSlashDescriptor(data, 0, tableSection);
return new TargetIPSlashDescriptor(data, tableSection);
case 0x13:
return new IPMACStreamLocationDescriptor(data, 0, tableSection);
return new IPMACStreamLocationDescriptor(data, tableSection);
default:
Descriptor d = new INTDescriptor(data, 0, tableSection);
Descriptor d = new INTDescriptor(data, tableSection);
logger.info("Not implemented IntDescriptor:" + toUnsignedInt(data[0]) + " ("
+ INTDescriptor.getDescriptorname(toUnsignedInt(data[0]), tableSection)
+ ")in section " + TableSection.getTableType(tableSection.getTableId()) + " (" + tableSection
+ ",) data=" + d.getRawDataString());
+ INTDescriptor.getDescriptorname(toUnsignedInt(data[0]), tableSection) + ")in section "
+ TableSection.getTableType(tableSection.getTableId()) + " (" + tableSection + ",) data=" + d.getRawDataString());
return d;
}

}

private static Descriptor getUNTDescriptor(final byte[] data, final TableSection tableSection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,18 @@

package nl.digitalekabeltelevisie.data.mpeg.descriptors.dsmcc;

import static nl.digitalekabeltelevisie.util.Utils.MASK_16BITS;
import static nl.digitalekabeltelevisie.util.Utils.getInt;
import static nl.digitalekabeltelevisie.util.Utils.*;

import java.util.Arrays;
import java.util.Base64;
import java.util.Base64.Decoder;

import javax.swing.tree.DefaultMutableTreeNode;

import nl.digitalekabeltelevisie.controller.DVBString;
import nl.digitalekabeltelevisie.controller.KVP;
import nl.digitalekabeltelevisie.controller.TreeNode;
import nl.digitalekabeltelevisie.data.mpeg.PsiSectionData;
import nl.digitalekabeltelevisie.data.mpeg.psi.SCTE35;
import nl.digitalekabeltelevisie.data.mpeg.psi.SpliceInfoSection;

import static nl.digitalekabeltelevisie.util.Utils.*;


/**
*
Expand All @@ -62,7 +56,6 @@ public class DSMCCStreamEventPayloadBinary implements TreeNode {
private int private_data_length;
private long private_data_specifier;
private byte[] private_data_byte;
private int carousel_object_name_length;
private DVBString carousel_object_name;

SpliceInfoSection scte35_section;
Expand Down Expand Up @@ -98,9 +91,8 @@ public DSMCCStreamEventPayloadBinary(byte[] privateDataByte) {
}

if (event_type == 1) {
carousel_object_name_length = getInt(binary, offset++, 1, MASK_8BITS);
carousel_object_name = new DVBString(binary, offset, carousel_object_name_length);
offset += carousel_object_name_length;
carousel_object_name = new DVBString(binary, offset);
offset += 1 + carousel_object_name.getLength();

}

Expand All @@ -115,31 +107,30 @@ public DSMCCStreamEventPayloadBinary(byte[] privateDataByte) {
}

@Override
public DefaultMutableTreeNode getJTreeNode(int modus) {
final DefaultMutableTreeNode t = new DefaultMutableTreeNode(new KVP("DSM-CC_stream_event_payload_binary"));
t.add(new DefaultMutableTreeNode(new KVP("binary", binary, null)));
public KVP getJTreeNode(int modus) {
final KVP t = new KVP("DSM-CC_stream_event_payload_binary");
t.add(new KVP("binary", binary));
if (binary.length > 0) {
t.add(new DefaultMutableTreeNode(new KVP("DVB_data_length", dvb_data_length, null)));
t.add(new DefaultMutableTreeNode(new KVP("reserved_zero_future_use", reserved_zero_future_use, null)));
t.add(new DefaultMutableTreeNode(new KVP("event_type", event_type, null)));
t.add(new DefaultMutableTreeNode(new KVP("timeline_type", timeline_type, null)));
t.add(new KVP("DVB_data_length", dvb_data_length));
t.add(new KVP("reserved_zero_future_use", reserved_zero_future_use));
t.add(new KVP("event_type", event_type));
t.add(new KVP("timeline_type", timeline_type));

if (timeline_type == 0x2) {
t.add(new DefaultMutableTreeNode(new KVP("temi_component_tag", temi_component_tag, null)));
t.add(new DefaultMutableTreeNode(new KVP("temi_timeline_id", temi_timeline_id, null)));
t.add(new KVP("temi_component_tag", temi_component_tag));
t.add(new KVP("temi_timeline_id", temi_timeline_id));
}
if(reserved_zero_future_use2 != null) {
t.add(new DefaultMutableTreeNode(new KVP("reserved_zero_future_use", reserved_zero_future_use2, null)));
t.add(new KVP("reserved_zero_future_use", reserved_zero_future_use2));
}
t.add(new DefaultMutableTreeNode(new KVP("private_data_length", private_data_length, null)));
t.add(new KVP("private_data_length", private_data_length));

if (private_data_length > 0) {
t.add(new DefaultMutableTreeNode(new KVP("private_data_specifier", private_data_specifier, getPrivateDataSpecString(private_data_specifier))));
t.add(new DefaultMutableTreeNode(new KVP("private_data_byte", private_data_byte, null)));
t.add(new KVP("private_data_specifier", private_data_specifier).setDescription(getPrivateDataSpecString(private_data_specifier)));
t.add(new KVP("private_data_byte", private_data_byte));
}
if (event_type == 1) {
t.add(new DefaultMutableTreeNode(new KVP("carousel_object_name_length", carousel_object_name_length, null)));
t.add(new DefaultMutableTreeNode(new KVP("carousel_object_name", carousel_object_name, null)));
t.add(new KVP("carousel_object_name", carousel_object_name));
}
if (event_type == 0) {
t.add(scte35_section.getJTreeNode(2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

package nl.digitalekabeltelevisie.data.mpeg.descriptors.intable;

import nl.digitalekabeltelevisie.controller.KVP;
import nl.digitalekabeltelevisie.data.mpeg.descriptors.Descriptor;
import nl.digitalekabeltelevisie.data.mpeg.psi.TableSection;

Expand All @@ -47,16 +48,22 @@ public class INTDescriptor extends Descriptor {
* @param offset
* @param parent
*/
public INTDescriptor(final byte[] b, final int offset, final TableSection parent) {
super(b, offset, parent);
public INTDescriptor(byte[] b, TableSection parent) {
super(b, parent);
}

@Override
public String getDescriptorname(){
return INTDescriptor.getDescriptorname(descriptorTag, parentTableSection);
}

public static String getDescriptorname(final int tag, final TableSection tableSection){
@Override
public KVP getJTreeNode(int modus){
return (KVP)super.getJTreeNode(modus);
}


public static String getDescriptorname(int tag, TableSection tableSection){



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

import static nl.digitalekabeltelevisie.util.Utils.getISO8859_1String;

import javax.swing.tree.DefaultMutableTreeNode;

import nl.digitalekabeltelevisie.controller.DVBString;
import nl.digitalekabeltelevisie.controller.KVP;
import nl.digitalekabeltelevisie.data.mpeg.psi.TableSection;
Expand All @@ -49,18 +47,18 @@ public class IPMACPlatformNameDescriptor extends INTDescriptor {
* @param offset
* @param parent
*/
public IPMACPlatformNameDescriptor(final byte[] b, final int offset, final TableSection parent) {
super(b, offset, parent);
iso639LanguageCode = getISO8859_1String(b, offset + 2, 3);
text = new DVBString(b, offset + 5, descriptorLength - 3);
public IPMACPlatformNameDescriptor(byte[] b, TableSection parent) {
super(b, parent);
iso639LanguageCode = getISO8859_1String(b, 2, 3);
text = new DVBString(b, 5, descriptorLength - 3);

}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

import static nl.digitalekabeltelevisie.util.Utils.getISO8859_1String;

import javax.swing.tree.DefaultMutableTreeNode;

import nl.digitalekabeltelevisie.controller.DVBString;
import nl.digitalekabeltelevisie.controller.KVP;
import nl.digitalekabeltelevisie.data.mpeg.psi.TableSection;
Expand All @@ -49,20 +47,19 @@ public class IPMACPlatformProviderNameDescriptor extends INTDescriptor {
* @param offset
* @param parent
*/
public IPMACPlatformProviderNameDescriptor(final byte[] b, final int offset, final TableSection parent) {
super(b, offset, parent);
iso639LanguageCode = getISO8859_1String(b, offset + 2, 3);
text = new DVBString(b, offset + 5, descriptorLength - 3);
public IPMACPlatformProviderNameDescriptor(byte[] b, TableSection parent) {
super(b, parent);
iso639LanguageCode = getISO8859_1String(b, 2, 3);
text = new DVBString(b, 5, descriptorLength - 3);

}

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


}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import static nl.digitalekabeltelevisie.util.Utils.MASK_8BITS;
import static nl.digitalekabeltelevisie.util.Utils.getInt;

import javax.swing.tree.DefaultMutableTreeNode;

import nl.digitalekabeltelevisie.controller.KVP;
import nl.digitalekabeltelevisie.data.mpeg.psi.TableSection;
import nl.digitalekabeltelevisie.util.Utils;
Expand All @@ -49,13 +47,13 @@ public class IPMACStreamLocationDescriptor extends INTDescriptor {



public IPMACStreamLocationDescriptor(final byte[] b, final int offset, final TableSection parent) {
super(b, offset,parent);
networkId = getInt(b,offset+2,2,MASK_16BITS);
originalNetworkId = getInt(b,offset+4,2,MASK_16BITS);
transportStreamId = getInt(b,offset+6,2,MASK_16BITS);
serviceId = getInt(b,offset+8,2,MASK_16BITS);
componentTag = getInt(b,offset+10,1,MASK_8BITS);
public IPMACStreamLocationDescriptor(byte[] b, TableSection parent) {
super(b, parent);
networkId = getInt(b, 2, 2, MASK_16BITS);
originalNetworkId = getInt(b, 4, 2, MASK_16BITS);
transportStreamId = getInt(b, 6, 2, MASK_16BITS);
serviceId = getInt(b, 8, 2, MASK_16BITS);
componentTag = getInt(b, 10, 1, MASK_8BITS);
}

@Override
Expand All @@ -64,36 +62,23 @@ public String toString() {
}

@Override
public DefaultMutableTreeNode getJTreeNode(final int modus){
final var treeNode = super.getJTreeNode(modus);
public KVP getJTreeNode(int modus){
final KVP treeNode = super.getJTreeNode(modus);
final var psi = parentTableSection.getParentPID().getParentTransportStream().getPsi();
treeNode.add(new DefaultMutableTreeNode(new KVP("network_id",networkId ,psi.getNit().getNetworkName(networkId))));
treeNode.add(new DefaultMutableTreeNode(new KVP("original_network_id",originalNetworkId ,Utils.getOriginalNetworkIDString(originalNetworkId))));
treeNode.add(new DefaultMutableTreeNode(new KVP("transport_stream_id",transportStreamId ,null)));
treeNode.add(new DefaultMutableTreeNode(new KVP("service_id",serviceId ,psi.getSdt().getServiceName(originalNetworkId, transportStreamId, serviceId))));
treeNode.add(new DefaultMutableTreeNode(new KVP("component_tag",componentTag ,null)));
treeNode.add(new KVP("network_id",networkId ,psi.getNit().getNetworkName(networkId)));
treeNode.add(new KVP("original_network_id",originalNetworkId ,Utils.getOriginalNetworkIDString(originalNetworkId)));
treeNode.add(new KVP("transport_stream_id",transportStreamId));
treeNode.add(new KVP("service_id",serviceId ,psi.getSdt().getServiceName(originalNetworkId, transportStreamId, serviceId)));
treeNode.add(new KVP("component_tag",componentTag));
return treeNode;
}

public int getOriginalNetworkId() {
return originalNetworkId;
}


public void setOriginalNetworkId(final int caPID) {
this.originalNetworkId = caPID;
}

public int getTransportStreamId() {
return transportStreamId;
}

public void setTransportStreamId(final int caSystemID) {
this.transportStreamId = caSystemID;
}





}
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,16 @@
*/
public class TargetIPSlashDescriptor extends INTDescriptor {

private List<IPAdress> ipList = new ArrayList<IPAdress>();
private List<IPAdress> ipList = new ArrayList<>();

public static record IPAdress(byte[] IPv4_addr, int IPv4_slash_mask) implements TreeNode {

public static class IPAdress implements TreeNode{

private final byte[]IPv4_addr;
private final int IPv4_slash_mask;

public IPAdress(final byte[] pv4_addr, final int pv4_slash_mask) {
super();
IPv4_addr = pv4_addr;
IPv4_slash_mask = pv4_slash_mask;
}

public DefaultMutableTreeNode getJTreeNode(final int modus){
final DefaultMutableTreeNode s=new DefaultMutableTreeNode(new KVP("ip-adress(es) "+Utils.formatIPNumber(IPv4_addr)+"/"+IPv4_slash_mask));
s.add(new DefaultMutableTreeNode(new KVP("IPv4_addr",IPv4_addr,Utils.formatIPNumber(IPv4_addr))));
s.add(new DefaultMutableTreeNode(new KVP("IPv4_slash_mask",IPv4_slash_mask,null)));
@Override
public DefaultMutableTreeNode getJTreeNode(int modus) {
final DefaultMutableTreeNode s = new DefaultMutableTreeNode(
new KVP("ip-adress(es) " + Utils.formatIPNumber(IPv4_addr) + "/" + IPv4_slash_mask));
s.add(new DefaultMutableTreeNode(new KVP("IPv4_addr", IPv4_addr, Utils.formatIPNumber(IPv4_addr))));
s.add(new DefaultMutableTreeNode(new KVP("IPv4_slash_mask", IPv4_slash_mask, null)));
return s;
}

Expand All @@ -71,22 +63,22 @@ public DefaultMutableTreeNode getJTreeNode(final int modus){
* @param offset
* @param parent
*/
public TargetIPSlashDescriptor(final byte[] b, final int offset, final TableSection parent) {
super(b, offset, parent);
public TargetIPSlashDescriptor(byte[] b, TableSection parent) {
super(b, parent);
int t = 0;
while (t<descriptorLength) {
final byte[] adress = Utils.getBytes(b, offset+2+t, 4);
final int mask = Utils.getInt(b, offset+6+t, 1, 0xFF);
final byte[] adress = Utils.getBytes(b, 2+t, 4);
final int mask = Utils.getInt(b, 6+t, 1, 0xFF);
final IPAdress a = new IPAdress(adress,mask);
ipList.add(a);
t+=5;
}
}

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

final DefaultMutableTreeNode t = super.getJTreeNode(modus);
final KVP t = super.getJTreeNode(modus);
Utils.addListJTree(t,ipList,modus,"ip_list");
return t;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,15 @@ public class CosTimezoneDescriptor extends Descriptor {

private List<TimezoneName> timezoneNames = new ArrayList<>();

public record TimezoneName(String country_code, int country_region_id, int reserved, DVBString region_name) implements TreeNode{
public record TimezoneName(String country_code, int country_region_id, int reserved, DVBString region_name) implements TreeNode {

@Override
public DefaultMutableTreeNode getJTreeNode(final int modus){
final DefaultMutableTreeNode s=new DefaultMutableTreeNode(new KVP("TimezoneName"));
s.add(new DefaultMutableTreeNode(new KVP("country_code",country_code,null)));
s.add(new DefaultMutableTreeNode(new KVP("country_region_id",country_region_id,null)));
s.add(new DefaultMutableTreeNode(new KVP("reserved",reserved,null)));
s.add(new DefaultMutableTreeNode(new KVP("region_name_length",region_name.getLength(),null)));
s.add(new DefaultMutableTreeNode(new KVP("region_name",region_name,null)));
public KVP getJTreeNode(final int modus) {
final KVP s = new KVP("TimezoneName");
s.add(new KVP("country_code", country_code));
s.add(new KVP("country_region_id", country_region_id));
s.add(new KVP("reserved", reserved, null));
s.add(new KVP("region_name", region_name));
return s;
}
}
Expand Down

0 comments on commit f139407

Please sign in to comment.