📄 scan.java
字号:
return;
}
public void loadPVA(byte[] check, int a) throws IOException
{
Hashtable table = new Hashtable();
ScanObject scanobject;
String str;
int jump, id;
while ( a < 550000)
{
jump = (0xFF & check[a+6])<<8 | (0xFF & check[a+7]);
if (a + 8 + ((1 & check[a+5]>>>4) * 4) + jump > 700000)
break;
id = 0xFF & check[a+2];
str = String.valueOf(id);
if (!table.containsKey(str))
table.put(str, new ScanObject(id));
scanobject = (ScanObject)table.get(str);
switch (id)
{
case 1:
scanobject.write(check, a + 8 + ((1 & check[a+5]>>>4) * 4), jump );
break;
default:
scanobject.write(check, a + 8, jump );
}
a += 8 + jump;
}
video = msg_1;
audio = msg_2;
for (Enumeration n = table.keys(); n.hasMoreElements() ; )
{
str = n.nextElement().toString();
scanobject = (ScanObject)table.get(str);
if (str.equals("1"))
{
try
{
checkVid(scanobject.getData());
}
catch ( Exception e)
{
//video = msg_8;
video_streams.add(msg_8);
}
}
else
{
try
{
checkPES(scanobject.getData());
}
catch ( Exception e)
{
//audio = msg_8;
audio_streams.add(msg_8);
}
}
}
table.clear();
return;
}
public void checkPES(byte[] check)
{
checkPES(check, 0);
}
public void checkPES(byte[] check, int a)
{
int end = a + 8000;
rawcheck:
for (; a < end; a++)
{
if ( check[a] != 0 || check[a+1] != 0 || check[a+2] != 1 )
continue rawcheck;
if ( (0xE0 & check[a+3]) == 0xC0 || check[a+3] == (byte)0xBD )
{
int next = a + 6 + ( (0xFF & check[a+4])<<8 | (0xFF & check[a+5]) );
if ( check[next] != 0 || check[next+1] != 0 || check[next+2] != 1 )
continue rawcheck;
if ( (0xE0 & check[a+3]) == 0xC0 && (0xE0 & check[a+3]) == (0xE0 & check[next+3]) )
{
MPEGAudio(loadPES(check,a));
return;
}
else if ( check[a+3] == (byte)0xBD && check[a+3] == check[next+3] )
{
byte buffer[] = loadPES(check, a); //DM19122003 081.6 int07 changed
if (AC3Audio(buffer) < 1)
DTSAudio(buffer);
return;
}
}
}
}
public void checkVid(byte[] check)
{
ByteArrayOutputStream bytecheck = new ByteArrayOutputStream();
video = msg_7;
mpvcheck:
for (int a=0; a<check.length-630; a++)
{
if ( check[a]!=0 || check[a+1]!=0 || check[a+2]!=1 || check[a+3]!=(byte)0xb3 )
continue mpvcheck;
for (int b=7; b < 600; b++)
{
if ( check[a+b]==0 && check[a+b+1]==0 && check[a+b+2]==1 && check[a+b+3]==(byte)0xb8 )
{
hasVideo=true;
System.arraycopy(check,a,vbasic,0,12);
bytecheck.write(check,a,20);
video_streams.add(Video.videoformatByte(bytecheck.toByteArray()));
return;
}
}
}
return;
}
public void PMTcheck(byte[] check, int a)
{
ByteArrayOutputStream bytecheck = new ByteArrayOutputStream();
video = msg_5;
audio = msg_5;
text = msg_5; //DM10032004 081.6 int18 add
pics = msg_5; //DM28042004 081.7 int02 add
pidlist.clear();
tscheck:
for ( ; a < check.length - 1000; a++)
{
if ( check[a]!=0x47 || check[a+188]!=0x47 || check[a+376]!=0x47 )
continue tscheck;
if ( (0x30&check[a+3])!=0x10 || check[a+4]!=0 || check[a+5]!=2 || (0xf0&check[a+6])!=0xb0 )
{
a+=187;
continue tscheck;
}
bytecheck.write(check,a+4,184);
int pmtpid = (0x1F & check[a+1])<<8 | (0xFF & check[a+2]);
if ( bytecheck.size() < 188 )
{
a += 188;
addpack:
for ( ; a<check.length-500; a++)
{
if ( check[a]!=0x47 || check[a+188]!=0x47 || check[a+376]!=0x47 )
continue addpack;
if ( ((0x1F & check[a+1])<<8 | (0xFF & check[a+2]))!=pmtpid || (0x40&check[a+1])!=0 || (0x30&check[a+3])!=0x10 )
{
a += 187;
continue addpack;
}
bytecheck.write(check,a+4,184);
if ( bytecheck.size() > 188 )
break addpack;
}
}
byte[] pmt = bytecheck.toByteArray();
if (pmt.length > 5)
{
int sid = (0xFF & pmt[4])<<8 | (0xFF & pmt[5]);
pidlist.add("" + sid);
pidlist.add("" + pmtpid);
addInfo += " (SID 0x" + Integer.toHexString(sid).toUpperCase() + " ,PMT 0x" + Integer.toHexString(pmtpid).toUpperCase() + ")";
}
video = "";
audio = "";
text = "";
pics = "";
int pmt_len = (0xF&pmt[2])<<8 | (0xFF&pmt[3]); //DM30122003 081.6 int10 add
//DM30122003 081.6 int10 changed
//DM10032004 081.6 int18 changed , 0xF & pmt[a+3]<<4 | 0xFF & pmt[a+4]
pidsearch:
for (int b=8, r=8; b < pmt_len-4 && b < pmt.length-6; b++)
{
r = b;
if ( (0xe0 & pmt[b+1]) != 0xe0 )
continue pidsearch;
int pid = (0x1F & pmt[b+1])<<8 | (0xFF & pmt[b+2]);
switch(0xFF & pmt[b])
{
case 1 : //DM10032004 081.6 int18 add
case 2 :
getDescriptor(pmt, b+5, (b += 4+ (0xFF & pmt[b+4])), pid, 2);
pidlist.add("" + pid);
break;
case 3 :
case 4 :
getDescriptor(pmt, b+5, (b += 4+ (0xFF & pmt[b+4])), pid, 4);
pidlist.add("" + pid);
break;
case 0x80:
case 0x81: //private data of AC3 in ATSC
case 0x82:
case 0x83:
case 6 :
getDescriptor(pmt, b+5, (b += 4+ (0xFF & pmt[b+4])), pid, 6);
pidlist.add("" + pid);
break;
default:
b += 4+ (0xFF & pmt[b+4]);
}
if (b < 0)
b = r;
}
return;
}
return;
}
//DM10032004 081.6 int18 new
//DM04052004 081.7 int02 fix
private void getDescriptor(byte check[], int off, int end, int pid, int type)
{
String str = "";
int chunk_end = 0;
try
{
loop:
for (; off < end && off < check.length; off++)
{
switch(0xFF & check[off])
{
//DM28042004 081.7 int02 add
case 0x59: //dvb subtitle descriptor
type = 0x59;
chunk_end = off + 2 + (0xFF & check[off+1]);
str += "(";
for (int a=off+2; a<chunk_end; a+=8)
{
for (int b=a; b<a+3; b++) //language
str += (char)(0xFF & check[b]);
int page_type = 0xFF & check[a+3];
int comp_page_id = (0xFF & check[a+4])<<16 | (0xFF & check[a+5]);
int anci_page_id = (0xFF & check[a+6])<<16 | (0xFF & check[a+7]);
str += "_0x" + Integer.toHexString(page_type).toUpperCase();
str += "_p" + comp_page_id;
str += "_a" + anci_page_id + " ";
}
str += ")";
break loop;
case 0x56: //teletext descriptor incl. index page + subtitle pages
type = 0x56;
chunk_end = off + 2 + (0xFF & check[off+1]);
str += "(";
for (int a=off+2; a<chunk_end; a+=5)
{
for (int b=a; b<a+3; b++) //language
str += (char)(0xFF & check[b]);
int page_type = (0xF8 & check[a+3])>>>3;
int page_number = 0xFF & check[a+4];
str += "_";
switch (page_type)
{
case 1:
str += "i";
break;
case 2:
str += "s";
break;
case 3:
str += "ai";
break;
case 4:
str += "ps";
break;
case 5:
str += "s.hip";
break;
default:
str += "res";
}
str += Integer.toHexString((7 & check[a+3]) == 0 ? 8 : (7 & check[a+3])).toUpperCase();
str += (page_number < 0x10 ? "0" : "") + Integer.toHexString(page_number).toUpperCase() + " ";
}
str += ")";
//break loop;
off++;
off += (0xFF & check[off]);
break;
case 0xA: //ISO 639 language descriptor
str += "(";
for (int a=off+2; a<off+5; a++)
str += (char)(0xFF & check[a]);
str += ")";
off++;
off += (0xFF & check[off]);
break;
case 0x6A: //ac3 descriptor
str += "(AC-3)";
off++;
off += (0xFF & check[off]);
break;
case 0xC3: //VBI descriptor
off++;
switch (0xFF & check[off + 1])
{
case 4:
str += "(VPS)";
type = 0xC3;
break;
case 5:
str += "(WSS)";
break;
case 6:
str += "(CC)";
break;
case 1:
str += "(EBU-TTX)";
break;
case 7:
str += "(VBI)";
break;
}
off += (0xFF & check[off]);
break;
case 0x52: //ID of service
chunk_end = off + 2 + (0xFF & check[off+1]);
str += "(#" + (0xFF & check[off + 2]) + ")";
off++;
off += (0xFF & check[off]);
break;
case 0x5: //registration descriptor
chunk_end = off + 2 + (0xFF & check[off+1]);
str += "(";
for (int a=off+2; a<chunk_end; a++)
str += (char)(0xFF & check[a]);
str += ")";
default:
off++;
off += (0xFF & check[off]);
}
}
String out = "PID: 0x" + Integer.toHexString(pid).toUpperCase();
switch (type)
{
case 0x59:
pic_streams.add(out + str);
break;
case 0x56:
ttx_streams.add(out + str);
break;
case 2:
case 0xC3:
video_streams.add(out + str);
break;
case 4:
audio_streams.add(out + str);
break;
default:
audio_streams.add(out + str + "_PD");
}
}
catch (ArrayIndexOutOfBoundsException ae)
{
playtime += msg_6;
}
}
public int[] getPIDs()
{
int[] b = new int[pidlist.size()];
for (int a=0; a<pidlist.size();a++)
b[a] = Integer.parseInt(pidlist.get(a).toString());
return b;
}
public String getAudioTime(long len)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -