Skip to content

Commit

Permalink
jfDVR : fix buffering issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pquiring committed Mar 20, 2020
1 parent c8fcccb commit 03c7eb3
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions projects/jfdvr/src/CameraWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,9 @@ private static class Packets {
public Packets(int log) {
this.log = log;
data = new byte[maxPacketsSize];
frag_data = new byte[maxPacketsSize];
nextFrame.data = new byte[maxPacketsSize];
}
public byte[] data;
private byte[] frag_data;
private Packet nextFrame = new Packet();
public int[] offset = new int[maxPackets];
public int[] length = new int[maxPackets];
Expand Down Expand Up @@ -239,7 +238,6 @@ public void cleanPackets(boolean mark) {
}
}
public boolean haveCompleteFrame() {
next_frame_fragmented = false;
for(int pos=tail;pos!=head;) {
switch (type[pos]) {
case 1: return true;
Expand All @@ -248,7 +246,6 @@ public boolean haveCompleteFrame() {
pos++;
if (pos == maxPackets) {
pos = 0;
next_frame_fragmented = true;
}
}
return false;
Expand All @@ -270,21 +267,9 @@ public Packet getNextFrame() {
JFLog.log(log, "Error : getNextFrame() called but don't have one ???");
return null;
}
if (next_frame_fragmented) {
JFLog.log(log, "Warning:frame is fragmented");
nextFrame.data = frag_data;
nextFrame.offset = 0;
} else {
nextFrame.data = data;
nextFrame.offset = offset[tail];
}
nextFrame.length = 0;
int frag_pos = 0;
for(int pos=tail;pos!=head;) {
if (next_frame_fragmented) {
System.arraycopy(data, offset[pos], frag_data, frag_pos, length[pos]);
frag_pos += length[pos];
}
System.arraycopy(data, offset[pos], nextFrame.data, nextFrame.length, length[pos]);
nextFrame.length += length[pos];
next_frame_packets++;
int this_type = type[pos];
Expand All @@ -304,7 +289,6 @@ public void removeNextFrame() {
next_frame_packets--;
}
}
public boolean next_frame_fragmented;
public int next_frame_packets;
public String toString() {
return "Packets:tail=" + tail + ":head=" + head;
Expand Down

0 comments on commit 03c7eb3

Please sign in to comment.