Commit c5a2def0 authored by ogg.k.ogg.k's avatar ogg.k.ogg.k
Browse files

fix takeHeader not returning >0 when ready to decode

fix start granpos not being actually set to anything else than 0
parent 55918242
......@@ -116,6 +116,14 @@ public class DurationScanner {
int ret;
Class c;
if (info.decoder != null) {
ret = info.decoder.takeHeader(packet);
if (ret > 0) {
info.ready = true;
}
return;
}
// try theora
try {
c = Class.forName("com.fluendo.plugin.TheoraDec");
......@@ -171,12 +179,15 @@ public class DurationScanner {
while (info.streamstate.packetout(op) == 1) {
int type = info.type;
if (type == NOTDETECTED) {
if (type == NOTDETECTED || !info.ready) {
determineType(op, info);
}
else if (type != NOTDETECTED && type != UNKNOWN && info.ready && info.startgranule < 0) {
info.startgranule = og.granulepos();
Debug.info("start granule for stream "+og.serialno()+": "+info.startgranule);
}
switch (type) {
if (info.ready) switch (type) {
case VORBIS:
{
com.fluendo.plugin.OggPayload pl = info.decoder;
......@@ -204,7 +215,7 @@ public class DurationScanner {
public float getDurationForURL(URL url, String user, String password) {
try {
int headbytes = 24 * 1024;
int headbytes = 64 * 1024;
int tailbytes = 128 * 1024;
float time = 0;
......@@ -247,9 +258,9 @@ public class DurationScanner {
private class StreamInfo {
public com.fluendo.plugin.OggPayload decoder;
public com.fluendo.plugin.OggPayload decoder = null;
public int type = NOTDETECTED;
public long startgranule;
public long startgranule = -1;
public StreamState streamstate;
public boolean ready = false;
}
......
......@@ -244,7 +244,7 @@ public class OggDemux extends Element
}
}
/* if we have all the headers we can stream */
if (haveHeaders) {
if (haveHeaders && !payload.isHeader(op)) {
/* discontinuous codecs do not need to wait for data to allow playback */
if (!complete && payload.isDiscontinuous()) {
complete = true;
......
......@@ -65,7 +65,7 @@ public class TheoraDec extends Element implements OggPayload
ts.decodeInit(ti);
haveDecoder = true;
}
return ret;
return haveDecoder?1:0;
}
public boolean isHeader (Packet op)
{
......
......@@ -46,7 +46,13 @@ public class VorbisDec extends Element implements OggPayload
}
public int takeHeader (Packet op)
{
return vi.synthesis_headerin(vc, op);
int ret = vi.synthesis_headerin(vc, op);
if (ret < 0)
return ret;
byte header = op.packet_base[op.packet];
if (header == 0x05)
return 1;
return 0;
}
public boolean isHeader (Packet op)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment