Commit fdeb17ec authored by Thomas Krex's avatar Thomas Krex

-funktionstüchtige wiedergabe, audio spur snychronisiert messages.

-noch weiße flecken im bild und etwas ruckelig
parent dc196368
......@@ -92,6 +92,8 @@ public class HextileMessage extends FramebufferUpdateMessage {
handleHextileRect(graphicsContext, is, null, x, y, width, height,
updateFlag);
graphicsContext.handleUpdatedPixels(x, y, width, height);
} catch (IOException e) {
e.printStackTrace();
}
......@@ -140,7 +142,6 @@ public class HextileMessage extends FramebufferUpdateMessage {
// Finished, now let's show it.
graphicsContext.handleUpdatedPixels(x, y, w, h);
// graphicsContext.refresh(x, y, w, h);
}
......@@ -241,8 +242,6 @@ public class HextileMessage extends FramebufferUpdateMessage {
DataInputStream is, DataOutputStream os, int x, int y, int w, int h)
throws IOException {
Log.d("HextileMessage", "handle RawRect at " + x + " , " + y + " , "
+ w + " , " + h);
switch (graphicsContext.getPrefs().bytesPerPixel) {
// case 1:
// for (int dy = y; dy < y + h; dy++) {
......@@ -315,16 +314,6 @@ public class HextileMessage extends FramebufferUpdateMessage {
int color = graphicsContext.decodeColor(colorField);
// Log.d("color", "color = " + color);
// Paint paint = new Paint(color);
// if (y > 100) {
// Log.d("HextileMessage", " fill Rec : " + x + " , " + y + " , " + w
// + " , " + h);
// }
// graphicsContext.canvas.drawRect(x, y, x + w, y + h, paint);
// graphicsContext.canvas.dr
// graphicsContext.updateView();
for (int i = y; i < y + h; i++) {
int offset = i * graphicsContext.getPrefs().framebufferWidth + x;
for (int j = 0; j < w; j++) {
......@@ -332,7 +321,7 @@ public class HextileMessage extends FramebufferUpdateMessage {
graphicsContext.getPixels()[offset + j] = color;
}
}
graphicsContext.handleUpdatedPixels(x, y, w, h);
// graphicsContext.handleUpdatedPixels(x, y, w, h);
}
......
......@@ -32,6 +32,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
......@@ -51,6 +52,8 @@ public class Recording extends MessageProducerAdapter implements Runnable {
private File tttFile;
private final MediaPlayer audioPlayer;
private HashMap<Integer, ArrayList<Message>> sortedMessages;
public Messages getMessages() {
return messages;
}
......@@ -74,9 +77,11 @@ public class Recording extends MessageProducerAdapter implements Runnable {
public Recording(File file, MediaPlayer audioPlayer) throws IOException {
// read
messages = new Messages(this);
prefs = new ProtocolPreferences();
this.audioPlayer = audioPlayer;
read(file);
// sortMessages();
// Note: keyframes are computed dynamically during random access
// TODO: add keyframes if dynamic computation is too slow - e.g. if
......@@ -121,6 +126,21 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// }
}
public void sortMessages() {
for (int i = 0; i < messages.getMessages().size(); i++) {
Message m = messages.get(i);
if (sortedMessages.containsKey(m.timestamp)) {
sortedMessages.get(m.timestamp).add(m);
} else {
ArrayList<Message> mlist = new ArrayList<Message>();
mlist.add(m);
sortedMessages.put(m.timestamp, mlist);
}
}
}
public String getFileName() throws IOException {
return tttFile.getCanonicalPath();
}
......@@ -467,40 +487,40 @@ public class Recording extends MessageProducerAdapter implements Runnable {
//
// // next message
//
// // synchronize message and audio/video player
// // delay if too early
// int time = audioVideoPlayer.getTime();
// if (messages.get(next_message).timestamp <= time) {
// message = messages.get(next_message);
//
// int delay = sync(message.getTimestamp()) - time;
// System.out.println(next_message + " delay: "
// + Constants.getStringFromTime(delay) + "\t");
// if (delay > 0)
// wait(delay);
// closing
// if (!running)
// break;
//
// // state changed - active message may be outdated -
// // abort
// if (interrupted || adjusting) {
// interrupted = false;
// continue;
// }
// display message
// System.out.println(next_message + ".\t" + message);
deliverMessage(message);
// update index viewer
// index.updateRunningIndex(message.getTimestamp());
// increase message counter
next_message++;
// synchronize message and audio/video player
// delay if too early
int time = audioPlayer.getCurrentPosition();
if (messages.get(next_message).timestamp <= time) {
message = messages.get(next_message);
// int delay = sync(message.getTimestamp()) - time;
// System.out.println(next_message + " delay: "
// + Constants.getStringFromTime(delay) + "\t");
// if (delay > 0)
// wait(delay);
// closing
if (!running)
break;
//
// // state changed - active message may be outdated -
// // abort
if (interrupted || adjusting) {
interrupted = false;
continue;
}
// display message
// System.out.println(next_message + ".\t" + message);
deliverMessage(message);
// update index viewer
// index.updateRunningIndex(message.getTimestamp());
// increase message counter
next_message++;
}
}
} catch (Exception e) {
// TODO:
// wait until audio finished and stop
......
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