OSDN Git Service

lots of bug fixes.
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sat, 14 Nov 2009 14:14:45 +0000 (14:14 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Sat, 14 Nov 2009 14:14:45 +0000 (14:14 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@224 4e526526-5e11-4fc0-8910-f8fd03428081

12 files changed:
jTsSplitter/trunk/src/jtssplitter/Mpeg2TSPacket.java
jTsSplitter/trunk/src/jtssplitter/Tsfile.java
jTsSplitter/trunk/src/jtssplitter/calc.java [new file with mode: 0644]
jTsSplitter/trunk/src/jtssplitter/data/Audio_stream_descriptor.java [new file with mode: 0644]
jTsSplitter/trunk/src/jtssplitter/data/Descriptor.java [new file with mode: 0644]
jTsSplitter/trunk/src/jtssplitter/data/DescriptorData.java [new file with mode: 0644]
jTsSplitter/trunk/src/jtssplitter/data/PIDs.java
jTsSplitter/trunk/src/jtssplitter/data/PMTData.java
jTsSplitter/trunk/src/jtssplitter/data/Video_stream_descriptor.java [new file with mode: 0644]
jTsSplitter/trunk/src/jtssplitter/data/descriptor/ARIB_Audio_Component_Descriptor.java [new file with mode: 0644]
jTsSplitter/trunk/src/jtssplitter/data/descriptor/ARIB_Video_Compornent_Descriptor.java [new file with mode: 0644]
jTsSplitter/trunk/src/jtssplitter/data/descriptor/abstract_Descriptor.java [new file with mode: 0644]

index ad51975..39e79e0 100644 (file)
@@ -1,9 +1,12 @@
 package jtssplitter;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.zip.CRC32;
 import jtssplitter.data.PATData;
 import jtssplitter.data.PMTData;
+import jtssplitter.data.Descriptor;
+import jtssplitter.data.Video_stream_descriptor;
 /*
  * To change this template, choose Tools | Templates
  * and open the template in the editor.
@@ -136,6 +139,7 @@ public class Mpeg2TSPacket {
         ArrayList<PMTData> pmt_t = new ArrayList<PMTData>();
         int tableid = TSString2Int(payload_temp, 0, 8);
         int section_length = TSString2Int(payload_temp, 12, 12);
+        int pcr_pid = TSString2Int(payload_temp, 67, 13);
         int program_info_length = TSString2Int(payload_temp, 84, 12);
         boolean end = false;
         int cur_point = 96 + program_info_length * 8;
@@ -149,11 +153,23 @@ public class Mpeg2TSPacket {
                 int elementary_PID = TSString2Int(payload_temp, cur_point + 11, 13);
                 //System.out.println(Integer.toString(cur_point)+" :  "+Integer.toString(section_length*8));
                 int es_length = TSString2Int(payload_temp, cur_point + 28, 12);
+                if (pmt_stream_type==0x02){
+                    Descriptor des=new Descriptor();
+                    Object a=des.getDescriptors(payload_temp.substring(cur_point + 40,cur_point + 40+es_length*8));
+                }else if(pmt_stream_type==0x0f){
+                    Descriptor des=new Descriptor();
+                    Object a=des.getDescriptors(payload_temp.substring(cur_point + 40,cur_point + 40+es_length*8));
+                }
+
+                
                 PMTData pmtd=new PMTData();
-                pmtd.Stream_Type=pmt_stream_type;
-                pmtd.Program_Table=PAT_TABLE;
-                pmtd.Elementary_PID=elementary_PID;
-                pmt_t.add(pmtd);
+                if ((pmt_stream_type==0x02)||(pmt_stream_type==0x0f)){
+                    pmtd.Stream_Type=pmt_stream_type;
+                    pmtd.Program_Table=PAT_TABLE;
+                    pmtd.Elementary_PID=elementary_PID;
+                    pmtd.PCR_PID=pcr_pid;
+                    pmt_t.add(pmtd);
+                }
                 cur_point = cur_point + 40 + es_length * 8;
                 //System.out.println(Integer.toString(cur_point)+" :  "+Integer.toString(section_length));
                 if (cur_point > section_length * 8 - 1) {
@@ -179,22 +195,15 @@ public class Mpeg2TSPacket {
          */
         int matchnum=0;
         byte[] tbb=new byte[ts.length-4];
-        for (int i=0;i<ts.length-4;i++){
-            tbb[i]=ts[4+i];
-            if (bPAT_payload!=null){
-                if (ts[4+i]==bPAT_payload[i]){
-                    matchnum++;
-                }
+        System.arraycopy(ts,4,tbb,0,tbb.length);
+        if (bPAT_payload!=null){
+            if (Arrays.equals(tbb, bPAT_payload)){
+                byte[] retb=new byte[188];
+                System.arraycopy(ts,0,retb,0,4);
+                System.arraycopy(bPAT_payload,0,retb,4,184);
+                return retb;
             }
         }
-        if (matchnum==ts.length-4){
-            byte[] retb=new byte[188];
-            System.arraycopy(ts,0,retb,0,4);
-            System.arraycopy(bPAT_payload,0,retb,4,184);
-            return retb;
-        }else{
-            bPAT_payload=tbb;
-        }
         String tsbyte = byte2String2(ts);
         String tsheader = "";
         header = tsbyte.substring(0, 31);
@@ -224,6 +233,8 @@ public class Mpeg2TSPacket {
         if (PID == 0) {
             //showPAT(tsbyte);
             payload = makePAT(tsheader,payload, p_table);
+            byte[] retb=String2Byte(payload);
+            bPAT_payload=retb;
         }
         String rets = tsheader + payload;
         return String2Byte(rets);
@@ -467,7 +478,7 @@ public class Mpeg2TSPacket {
         return ret;
     }
 
-    public ArrayList getPAT() {
+    public ArrayList<PATData> getPAT() {
         return pat_list_all;
     }
 
@@ -476,7 +487,7 @@ public class Mpeg2TSPacket {
         pat_list_all = pat;
     }
 
-    public ArrayList getPMT() {
+    public ArrayList<PMTData> getPMT() {
         return pmt_list;
     }
 
@@ -487,7 +498,37 @@ public class Mpeg2TSPacket {
     public int getPID() {
         return PID;
     }
-
+    public String getPayload(byte[] ts){
+        /**
+         * 188バイトのtsから読み出したbyteを与える
+         */
+        String tsbyte = byte2String2(ts);
+        //header = tsbyte.substring(0, 31);
+        String ret_payload="";
+        //starter = TSString2Int(tsbyte, 0, 8);
+        //transporterror = TSString2Int(tsbyte, 8, 1);
+        //payloadstart = TSString2Int(tsbyte, 9, 1);
+        //transport_priority = TSString2Int(tsbyte, 10, 1);
+        int pid = TSString2Int(tsbyte, 11, 13);
+        int af = TSString2Int(tsbyte, 26, 2);
+        //continuity_counter = TSString2Int(tsbyte, 28, 4);
+        if (pid != 8191) {
+            if (af == 1) {
+                ret_payload = tsbyte.substring(40);
+            } else if (af == 3) {
+                int al = TSString2Int(tsbyte, 32, 8);
+                if ((al < 184)&((tsbyte.length()-al*8)>48)) {
+                    al = al * 8;
+                }
+                ret_payload = tsbyte.substring(48 + al);
+            }
+        }
+        return ret_payload;
+    }
+    public ArrayList<PMTData> readPMT(byte[] ts,int TABLE_NUM){
+        String payload=getPayload(ts);
+        return readPMT(payload, TABLE_NUM);
+    }
     public void showPAT(String ts) {
         System.out.println("先頭:" + ts.substring(0, 8));
         System.out.println("" + ts.substring(8, 11));
index 2c5b307..b4e463c 100644 (file)
@@ -8,6 +8,7 @@ import java.util.ArrayList;
 import java.io.*;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import java.util.Arrays;
 import jtssplitter.data.PATData;
 import jtssplitter.data.PIDs;
 import jtssplitter.data.PMTData;
@@ -71,6 +72,7 @@ public class Tsfile {
         PIDs pidss=getTablePID(origpath,p_table);
         p_table=pidss.Program_Table;
         pids=pidss.PIDs;
+        int pmt_pid=pidss.PMT_PID;
         byte[] tb=new byte[188];
         try {
             FileInputStream in = new FileInputStream(origpath);
@@ -100,8 +102,23 @@ public class Tsfile {
                         if ((ii==0)&&(readti>187)){
                             //Mpeg2TSPacket m2tp2=new Mpeg2TSPacket();
                             wbyte=m2tpp.splitPAT(tb,p_table);
+                        }else if ((ii==pmt_pid)&&(readti>187)){
+                            wbyte=tb;
+                            ArrayList<PMTData> pmtss=m2tpp.readPMT(tb, pmt_pid);
+                            int[] new_pids=new int[pmtss.size()+3];
+                            new_pids[pmtss.size()]=0;
+                            new_pids[pmtss.size()+1]=pmt_pid;
+                            new_pids[pmtss.size()+2]=pmtss.get(0).PCR_PID;
+                            for (int i=0;i<pmtss.size();i++){
+                                new_pids[i]=pmtss.get(i).Elementary_PID;
+                            }
+                            if (!Arrays.equals(pids, new_pids)){
+                                pids=new_pids;
+                            }
+
                         }else if (readti>187){
                             wbyte=tb;
+
                         }else {
                             readend=true;
                         }
@@ -112,10 +129,6 @@ public class Tsfile {
             if (alreadyreaded==false){
                 bis.skip(188);
             }
-            int bbb=bis.available();
-            //if (bis.available()<188){
-            //    readend=true;
-            //}
                 if (wbyte!=null){
                     bos.write(wbyte);
                 }
@@ -212,13 +225,17 @@ public class Tsfile {
             }
             ret.add(0);
             ret.add(patd_det.PID);
+            ret.add(pmt.get(0).Elementary_PID);
             for (int i=0;i<pmt.size();i++){
                 if (patd_det.Program_TABLE==pmt.get(i).Program_Table){
                     if (!(ret.contains(pmt.get(i).Elementary_PID))){
-                        ret.add(pmt.get(i).Elementary_PID);
+                        if ((pmt.get(i).Stream_Type==0x02)||(pmt.get(i).Stream_Type==0x0f)){
+                            ret.add(pmt.get(i).Elementary_PID);
+                        }
                     }
                 }
             }
+            pids.PMT_PID=patd_det.PID;
             pids.Program_Table=patd_det.Program_TABLE;
             pids.PIDs=new int[ret.size()];
             for (int i=0;i<ret.size();i++){
diff --git a/jTsSplitter/trunk/src/jtssplitter/calc.java b/jTsSplitter/trunk/src/jtssplitter/calc.java
new file mode 100644 (file)
index 0000000..17f7b76
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package jtssplitter;
+
+/**
+ *
+ * @author yukikaze
+ */
+public class calc {
+   public String Int2String(int num, int length) {
+        String ret = Integer.toBinaryString(num);
+        if (ret.length() < length) {
+            int it = length - ret.length();
+            for (int i = 0; i < it; i++) {
+                ret = "0" + ret;
+            }
+        }
+        return ret;
+    }
+   public String Long2String(long num, int length) {
+        String ret = Long.toBinaryString(num);
+        if (ret.length() < length) {
+            int it = length - ret.length();
+            for (int i = 0; i < it; i++) {
+                ret = "0" + ret;
+            }
+        }
+        return ret;
+    }
+
+    public byte[] String2Byte(String ts) {
+        //StringBuffer sb=new StringBuffer(ts);
+        int len = ts.length() - ts.length() % 8;
+        len = len / 8;
+        byte[] ret = new byte[len];
+        for (int i = 0; i < len; i++) {
+            String tet = ts.substring(i * 8, i * 8 + 8);
+            int itt = TSString2Int(tet, 0, 8);
+            ret[i] = (byte) itt;
+        }
+        return ret;
+    }
+    public String byte2String(byte[] b) {
+        StringBuffer sb=new StringBuffer(8*b.length);
+        for (int i = 0; i < b.length; i++) {
+            StringBuffer sb2=new StringBuffer(8);
+            sb2.append(Integer.toBinaryString(b[i] & 0xFF));
+            if ((sb2.length() < 8) & (sb2.length() > 0)) {
+                sb2.insert(0,addzero(8-sb2.length()));
+            }
+            sb.append(sb2);
+        }
+        return sb.toString();
+    }
+    public String byte2String2(byte[] b){
+        int bl=b.length;
+        bl=bl-bl%8;
+        bl=bl/8;
+        StringBuffer sb=new StringBuffer();
+        for (int i=0;i<bl;i++){
+            long retl=0;
+            for (int j=0;j<8;j++){
+                retl=retl<<8;
+                int ri=b[i*8+j]&0xFF;
+                retl=retl+ri;
+            }
+            sb.append(Long2String(retl,64));
+        }
+        int bl2=b.length%8;
+        bl2=(bl2-bl2%4)/4;
+        for (int i=0;i<bl2;i++){
+            int reti=0;
+            for (int j=0;j<4;j++){
+                reti=reti<<8;
+                reti=reti+(b[bl*8+4*i+j]&0xFF);
+            }
+            sb.append(Int2String(reti,32));
+        }
+        for (int i=0;i<(b.length%8)%4;i++){
+            sb.append(Int2String(b[bl*8+bl2*4+i]&0xFF,8));
+        }
+        return sb.toString();
+    }
+
+    public String byte2HexString(byte[] b) {
+        String ret = "";
+        for (int i = 0; i < b.length; i++) {
+            ret = ret + Integer.toHexString(b[i] & 0xFF);
+        }
+        return ret;
+    }
+    public String addzero(int num){
+        switch (num){
+            case 0:
+                return "";
+            case 1:
+                return "0";
+            case 2:
+                return "00";
+            case 3:
+                return "000";
+            case 4:
+                return "0000";
+            case 5:
+                return "00000";
+            case 6:
+                return "000000";
+            case 7:
+                return "0000000";
+            case 8:
+                return "00000000";
+            default:
+                StringBuffer sb=new StringBuffer();
+                for (int i=0;i<num;i++){
+                    sb.append("0");
+                }
+                return sb.toString();
+        }
+    }
+    public int TSString2Int(String s, int begin, int length) {
+        String st = s.substring(begin, begin + length);
+        int i = Integer.parseInt(st, 2);
+        return i;
+    }
+}
diff --git a/jTsSplitter/trunk/src/jtssplitter/data/Audio_stream_descriptor.java b/jTsSplitter/trunk/src/jtssplitter/data/Audio_stream_descriptor.java
new file mode 100644 (file)
index 0000000..337bd03
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package jtssplitter.data;
+
+/**
+ *
+ * @author yukikaze
+ */
+public class Audio_stream_descriptor {
+    private int descriptor_tag;//0-7
+    private int descriptor_length;//8-15
+    private boolean multiple_frame_rate_flag;//16
+    private String frame_rate_code;//17-20
+    /**
+     * frame rate
+     * 0001 : 24000/1001
+     * 0010 : 24
+     * 0011 : 25
+     * 0100 : 30000/1001
+     * 0101 : 30
+     * 0110 : 50
+     * 0111 : 60000/1001
+     * 1000 : 60
+     *
+     **/
+    private jtssplitter.calc cal=new jtssplitter.calc();
+    public void analyze(String s){
+        multiple_frame_rate_flag=cal.TSString2Int(s,16,1)==1;
+        frame_rate_code=cal.Int2String(cal.TSString2Int(s, 17, 4),4);
+        s="";
+        //descriptor_tag=
+    }
+}
diff --git a/jTsSplitter/trunk/src/jtssplitter/data/Descriptor.java b/jTsSplitter/trunk/src/jtssplitter/data/Descriptor.java
new file mode 100644 (file)
index 0000000..a0c6440
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package jtssplitter.data;
+
+import java.util.ArrayList;
+import jtssplitter.calc;
+import jtssplitter.data.descriptor.ARIB_Audio_Component_Descriptor;
+import jtssplitter.data.descriptor.ARIB_Video_Compornent_Descriptor;
+
+/**
+ *
+ * @author yukikaze
+ */
+public class Descriptor {
+
+    private calc cal = new calc();
+
+    public String analyze(String s) {
+        StringBuffer sb=new StringBuffer();
+        int curp = 0;
+        while (s.length() > curp + 16) {
+            String adds = "";
+            int tag = cal.TSString2Int(s, curp + 0, 8);
+            int len = cal.TSString2Int(s, curp + 8, 8) * 8;
+            String des_s = s.substring(curp + 16, curp + 16 + len);
+            curp = curp + len + 16;
+            switch (tag) {
+                case 0xc8://ビデオコントロール記述子
+                    switch (cal.TSString2Int(des_s, 3, 4)) {
+                        case 0:
+                            adds = "Video:1080p";
+                            break;
+                        case 1:
+                            adds = "Video:1080i";
+                            break;
+                        case 2:
+                            adds = "Video:720p";
+                            break;
+                        case 3:
+                            adds = "Video:480p";
+                            break;
+                        case 4:
+                            adds = "Video:480i";
+                            break;
+                        case 5:
+                            adds = "Video:240p";
+                            break;
+                        case 6:
+                            adds = "Video:120p";
+                            break;
+                        case 7:
+                            adds = "Video:2160p";
+                            break;
+                    }
+                    break;
+                case 0xc4://音声コンポーネント記述子
+                    switch (cal.TSString2Int(des_s, 8, 8)) {
+                        case 0x01:
+                            adds = "Video:120p";
+                            break;
+
+                    }
+                    break;
+            }
+            if (adds.length() > 0) {
+                sb.append(adds);
+            }
+        }
+        return sb.toString();
+    }
+    public ArrayList<jtssplitter.data.descriptor.abstract_Descriptor> getDescriptors(String s){
+        jtssplitter.calc cal=new calc();
+        return getDescriptors(cal.String2Byte(s));
+    }
+    public ArrayList<jtssplitter.data.descriptor.abstract_Descriptor> getDescriptors(byte[] b){
+        int curp = 0;
+        ArrayList<jtssplitter.data.descriptor.abstract_Descriptor> ad=new ArrayList<jtssplitter.data.descriptor.abstract_Descriptor>();
+        while (b.length > curp + 2) {
+            int tag = b[curp]&0xFF;
+            int len = b[curp+1]&0xFF;
+            byte[] btag=new byte[len];
+            System.arraycopy(b,curp+2,btag,0,len);
+            curp = curp + len + 2;
+            switch (tag) {
+                case 0xc8://ビデオコントロール記述子
+                    jtssplitter.data.descriptor.ARIB_Video_Compornent_Descriptor avcd=new jtssplitter.data.descriptor.ARIB_Video_Compornent_Descriptor();
+                    avcd.analyzeDescriptor(0xc8, btag);
+                    ad.add(avcd);
+                    break;
+                case 0xc4://音声コンポーネント記述子
+                    ARIB_Audio_Component_Descriptor aacd=new ARIB_Audio_Component_Descriptor();
+                    aacd.analyzeDescriptor(0xC4, btag);
+                    ad.add(aacd);
+                    break;
+            }
+        }
+        return ad;
+    }
+}
diff --git a/jTsSplitter/trunk/src/jtssplitter/data/DescriptorData.java b/jTsSplitter/trunk/src/jtssplitter/data/DescriptorData.java
new file mode 100644 (file)
index 0000000..d0d8cce
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package jtssplitter.data;
+
+/**
+ * 記述子の内容を保持
+ * @author yukikaze
+ */
+public class DescriptorData{
+    public DescriptorData(){
+
+    }
+    public DescriptorData(int descriptor_tag,int value){
+        Descriptor_tag=descriptor_tag;
+        Value=value;
+    }
+    /**
+     * 記述子タグ
+     * 0x08:動画タグ::
+     * -value::
+     * -0:1080p
+     * -1:1080i
+     * -2:720p
+     * -3:480p
+     * -4:480i
+     * -5:240p
+     * -6:120p
+     * -7:2160p
+     * 0xC4:音声タグ::
+     * -value::
+     * -1:1/0(シングルモノラル)
+     * -2:1/0+1/0(デュアルモノラル)
+     * -3:2/0
+     * -4:2/1
+     * -7:3/1
+     * -8:3/2
+     * -9:3/2+LFE (5.1chサラウンド)
+     *
+     */
+    public int Descriptor_tag;
+    public int Value;
+}
index 7b7729f..c684609 100644 (file)
@@ -12,4 +12,6 @@ package jtssplitter.data;
 public class PIDs {
     public int Program_Table;
     public int[] PIDs;
+    public int PMT_PID;
+    public int PCR_PID;
 }
index 498f023..725e7d3 100644 (file)
@@ -19,5 +19,6 @@ public class PMTData {
      * Streamのタイプを決定する
      */
     public int Stream_Type;
+    public int PCR_PID;
     public int Elementary_PID;
 }
diff --git a/jTsSplitter/trunk/src/jtssplitter/data/Video_stream_descriptor.java b/jTsSplitter/trunk/src/jtssplitter/data/Video_stream_descriptor.java
new file mode 100644 (file)
index 0000000..de67a80
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package jtssplitter.data;
+import jtssplitter.calc;
+/**
+ * ビデオ記述子
+ * 定義はISO/IEC 13818-1:2000(E) Table 2-40による
+ * @author yukikaze
+ */
+
+public class Video_stream_descriptor {
+    private int descriptor_tag;//0-7
+    private int descriptor_length;//8-15
+    private boolean multiple_frame_rate_flag;//16
+    private String frame_rate_code;//17-20
+    /**
+     * frame rate
+     * 0001 : 24000/1001
+     * 0010 : 24
+     * 0011 : 25
+     * 0100 : 30000/1001
+     * 0101 : 30
+     * 0110 : 50
+     * 0111 : 60000/1001
+     * 1000 : 60
+     *
+     **/
+    private jtssplitter.calc cal=new jtssplitter.calc();
+    public void analyze(String s){
+        descriptor_tag=cal.TSString2Int(s,0,8);
+        multiple_frame_rate_flag=cal.TSString2Int(s,16,1)==1;
+        frame_rate_code=cal.Int2String(cal.TSString2Int(s, 17, 4),4);
+        s="";
+        //descriptor_tag=
+    }
+
+}
diff --git a/jTsSplitter/trunk/src/jtssplitter/data/descriptor/ARIB_Audio_Component_Descriptor.java b/jTsSplitter/trunk/src/jtssplitter/data/descriptor/ARIB_Audio_Component_Descriptor.java
new file mode 100644 (file)
index 0000000..16e24b5
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package jtssplitter.data.descriptor;
+
+import java.io.UnsupportedEncodingException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author yukikaze
+ */
+public class ARIB_Audio_Component_Descriptor extends jtssplitter.data.descriptor.abstract_Descriptor{
+    private int Descriptor;
+    private int compornent_type;
+    private int compornent_tag;
+    private int stream_type;
+    private boolean ES_multi_lingual_flag;
+    private boolean main_component_flag;
+    private int quality_indicator;
+    private int sampling_rate;
+    private int ISO_639_language_code;
+    private int ISO_639_language_code_2;
+    private String text;
+    @Override
+    public int getDescriptorTag() {
+        return Descriptor;
+    }
+
+    @Override
+    public void analyzeDescriptor(byte[] descriptor) {
+        Descriptor=descriptor[0]&0xFF;
+        compornent_type=descriptor[3]&0xFF;
+        compornent_tag=descriptor[4]&0xFF;
+        stream_type=descriptor[5]&0xFF;
+        ES_multi_lingual_flag=(((descriptor[7]&0x80)>>7)==1);
+        main_component_flag=(((descriptor[7]&0x40)>>6)==1);
+        quality_indicator=(descriptor[7]&0x30>>4);
+        sampling_rate=(descriptor[7]&0xE>>1);
+        ISO_639_language_code=(((descriptor[8]&0xFF)<<16)+((descriptor[9]&0xFF)<<8)+(descriptor[10]&0xFF));
+        if (ES_multi_lingual_flag){
+            ISO_639_language_code_2=(((descriptor[11]&0xFF)<<16)+((descriptor[12]&0xFF)<<8)+(descriptor[13]&0xFF));
+            try {
+                text = new String(descriptor, 14, descriptor.length - 14, "EUC-JP");
+            } catch (UnsupportedEncodingException ex) {
+                Logger.getLogger(ARIB_Audio_Component_Descriptor.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }else{
+            try {
+                text = new String(descriptor, 11, descriptor.length - 11, "EUC-JP");
+            } catch (UnsupportedEncodingException ex) {
+                Logger.getLogger(ARIB_Audio_Component_Descriptor.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+
+    }
+
+    @Override
+    public void analyzeDescriptor(int DescriptorTag, byte[] descriptor) {
+
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    /**
+     * 音声のコンポーネント種別を示す。
+     * @return the compornent_type
+     * -1:1/0(シングルモノラル)
+     * -2:1/0+1/0(デュアルモノラル)
+     * -3:2/0
+     * -4:2/1
+     * -7:3/1
+     * -8:3/2
+     * -9:3/2+LFE (5.1chサラウンド)
+     */
+    public int getCompornent_type() {
+        return compornent_type;
+    }
+
+    /**
+     * @return the compornent_tag
+     */
+    public int getCompornent_tag() {
+        return compornent_tag;
+    }
+
+    /**
+     * @return the stream_type
+     */
+    public int getStream_type() {
+        return stream_type;
+    }
+
+    /**
+     * @return the ES_multi_lingual_flag
+     */
+    public boolean isES_multi_lingual_flag() {
+        return ES_multi_lingual_flag;
+    }
+
+    /**
+     * @return the main_component_flag
+     */
+    public boolean isMain_component_flag() {
+        return main_component_flag;
+    }
+
+    /**
+     * @return the quality_indicator
+     */
+    public int getQuality_indicator() {
+        return quality_indicator;
+    }
+
+    /**
+     * サンプリング周波数を示す。
+     * @return the sampling_rate
+     * 1-16kHz
+     * 2-22.05kHz
+     * 3-24kHz
+     * 5-32kHz
+     * 6-44.1kHz
+     * 7-48kHz
+     */
+    public int getSampling_rate() {
+        return sampling_rate;
+    }
+
+    /**
+     * @return the ISO_639_language_code
+     */
+    public int getISO_639_language_code() {
+        return ISO_639_language_code;
+    }
+
+    /**
+     * @return the ISO_639_language_code_2
+     */
+    public int getISO_639_language_code_2() {
+        return ISO_639_language_code_2;
+    }
+
+    /**
+     * @return the text
+     */
+    public String getText() {
+        return text;
+    }
+    
+
+}
diff --git a/jTsSplitter/trunk/src/jtssplitter/data/descriptor/ARIB_Video_Compornent_Descriptor.java b/jTsSplitter/trunk/src/jtssplitter/data/descriptor/ARIB_Video_Compornent_Descriptor.java
new file mode 100644 (file)
index 0000000..112c0d4
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package jtssplitter.data.descriptor;
+
+import jtssplitter.data.descriptor.abstract_Descriptor;
+/**
+ *
+ * @author yukikaze
+ */
+public class ARIB_Video_Compornent_Descriptor extends jtssplitter.data.descriptor.abstract_Descriptor{
+    private int Descriptor;
+    private boolean still_picture_flag;
+    private boolean sequence_end_code_flag;
+    private int video_encode_format;
+
+    /**
+     * @return the still_picture_flag
+     */
+    public boolean isStill_picture_flag() {
+        return still_picture_flag;
+    }
+
+    /**
+     * 動画フォーマットが直後から変更されるかどうか
+     * @return the sequence_end_code_flag
+     */
+    public boolean isSequence_end_code_flag() {
+        return sequence_end_code_flag;
+    }
+
+    /**
+     * 動画のフォーマットを示す。
+     * @return the video_encode_format
+     * 0-1080p
+     * 1-1080i
+     * 2-720p
+     * 3-480p
+     * 4-480i
+     * 5-240p
+     * 6-120p
+     * 7-2160p
+     */
+    public int getVideo_encode_format() {
+        return video_encode_format;
+    }
+
+    @Override
+    public void analyzeDescriptor(int DescriptorTag, byte[] descriptor) {
+        Descriptor=DescriptorTag;
+        still_picture_flag=((descriptor[0]&0x80)>>7==1);
+        sequence_end_code_flag=((descriptor[0]&0x40)>>6==1);
+        video_encode_format=(descriptor[0]&0x3C)>>2;
+    }
+
+    @Override
+    public int getDescriptorTag() {
+        return Descriptor;
+    }
+
+    @Override
+    public void analyzeDescriptor(byte[] descriptor) {
+        Descriptor=descriptor[0]&0xFF;
+        still_picture_flag=((descriptor[2]&0x80)>>7==1);
+        sequence_end_code_flag=((descriptor[2]&0x40)>>6==1);
+        video_encode_format=(descriptor[2]&0x3C)>>2;
+    }
+
+}
diff --git a/jTsSplitter/trunk/src/jtssplitter/data/descriptor/abstract_Descriptor.java b/jTsSplitter/trunk/src/jtssplitter/data/descriptor/abstract_Descriptor.java
new file mode 100644 (file)
index 0000000..5a7eb5c
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package jtssplitter.data.descriptor;
+
+/**
+ * 記述子記述のための抽象メソッド
+ * @author yukikaze
+ */
+abstract public class abstract_Descriptor {
+    /**
+     *記述子タグを得る。
+     * @return
+     */
+    abstract public int getDescriptorTag();
+    /**
+     * 記述子を記述したbyte列を与え、解析する。
+     * @param descriptor
+     * 記述子本体
+     */
+    abstract public void analyzeDescriptor(byte[] descriptor);
+    /**
+     * 記述子の一部を指定した状態で解析させる。
+     * @param DescriptorTag
+     * 記述子のタグを指定する。
+     * @param TagLength
+     * タグの長さ
+     * @param descriptor
+     * 記述子本体
+     */
+    abstract public void analyzeDescriptor(int DescriptorTag,byte[] descriptor);
+}