Commit 031e923c authored by Thomas Krex's avatar Thomas Krex

index und indexEntry impementiert

indexEntry extends ImageButton

-getScreenshot implementiert --> gibt Bitmap zurück
	-recording.setTime() wird dafür benutzt
	-hat nun auch boolean, ob display aktualisiert wird oder nicht
computeIndex implmentiert

index.readExtensions implementiert---> thumbnails werden noch selber
berrechnet
BufferedImage muss noch in Android implementiert werden
parent 8d28a695
......@@ -24,25 +24,29 @@ public final class R {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int action_settings=0x7f08000b;
public static final int add=0x7f08000a;
public static final int button_save=0x7f080006;
public static final int feedDetailsLv=0x7f080008;
public static final int feed_list=0x7f080007;
public static final int action_settings=0x7f08000e;
public static final int add=0x7f08000d;
public static final int button_save=0x7f080009;
public static final int feedDetailsLv=0x7f08000b;
public static final int feed_list=0x7f08000a;
public static final int feedback_button=0x7f080002;
public static final int indexScrollView=0x7f080004;
public static final int playerView=0x7f080003;
public static final int progressBar=0x7f080009;
public static final int playerView_extended=0x7f080005;
public static final int progressBar=0x7f08000c;
public static final int scrollView1=0x7f080006;
public static final int test_button=0x7f080000;
public static final int tx_name=0x7f080005;
public static final int tx_url=0x7f080004;
public static final int tx_name=0x7f080008;
public static final int tx_url=0x7f080007;
public static final int watch_button=0x7f080001;
}
public static final class layout {
public static final int activity_main=0x7f030000;
public static final int activity_player=0x7f030001;
public static final int dialog_feeds=0x7f030002;
public static final int feed_activity=0x7f030003;
public static final int feed_details_activity=0x7f030004;
public static final int activity_player_extended=0x7f030002;
public static final int dialog_feeds=0x7f030003;
public static final int feed_activity=0x7f030004;
public static final int feed_details_activity=0x7f030005;
}
public static final class menu {
public static final int feed_menu=0x7f070000;
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<ScrollView
android:id="@+id/indexScrollView"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_weight="3" >
</ScrollView>
<ImageView
android:id="@+id/playerView_extended"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@+id/scrollView1"
android:layout_weight="5"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
</LinearLayout>
\ No newline at end of file
......@@ -6,6 +6,7 @@ import java.io.IOException;
import tttclient.services.DownloadService;
import tttclient.ttt.Recording;
import android.app.Activity;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
......@@ -13,8 +14,10 @@ import android.util.Log;
import android.view.Display;
import android.view.MotionEvent;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.MediaController;
import android.widget.MediaController.MediaPlayerControl;
import android.widget.ScrollView;
import com.example.test.R;
......@@ -23,15 +26,20 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
public String fileName;
public String filePath;
public ImageView imgV;
private ScrollView scrollView;
private Recording recording;
private MediaPlayer audioPlayer;
private MediaController audioController;
private int imgVHeight;
private int imgVWidth;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
imgV = (ImageView) findViewById(R.id.playerView);
setContentView(R.layout.activity_player_extended);
imgV = (ImageView) findViewById(R.id.playerView_extended);
scrollView = (ScrollView) findViewById(R.id.indexScrollView);
fileName = getIntent().getStringExtra(DownloadService.FILE_NAME);
filePath = getIntent().getStringExtra(DownloadService.FILE_PATH);
......@@ -40,11 +48,13 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
audioPlayer = MediaPlayer.create(this, Uri.fromFile(audioFile));
try {
Log.d("Player", " width: " + imgVWidth + " , height: " + imgVHeight);
Display display = getWindowManager().getDefaultDisplay();
int screenWidth = display.getWidth(); // deprecated
int screenHeight = display.getHeight(); // deprecated
recording = new Recording(tttFile, audioPlayer, imgV, screenWidth,
screenWidth);
recording = new Recording(getApplicationContext(), tttFile,
audioPlayer, imgV, screenWidth, screenHeight);
} catch (IOException e) {
// TODO Auto-generated catch block
......@@ -84,7 +94,12 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
//
// }
// });
LinearLayout layout = new LinearLayout(getApplicationContext());
layout.setBackgroundColor(Color.MAGENTA);
//
Log.d("Index", " length " + recording.getIndex().size());
layout.addView(recording.getIndex().get(0));
scrollView.addView(layout);
}
@Override
......
......@@ -92,7 +92,8 @@ public class Messages {
while (true) {
// TODO: show progress
Message message = Message.readMessage(in, recording.prefs());
Message message = Message.readMessage(in,
recording.getProtocolPreferences());
if (message == null)
continue;
......@@ -228,15 +229,15 @@ public class Messages {
synchronized public void setTime_full_frame_check(int time) {
// long t = System.currentTimeMillis();
boolean[][] covered = new boolean[recording.prefs().framebufferWidth][recording
.prefs().framebufferHeight];
boolean[][] covered = new boolean[recording.getProtocolPreferences().framebufferWidth][recording
.getProtocolPreferences().framebufferHeight];
int coveredCounter = 0;
// if not set newly, this causes a call of stop() in run() beacuse end
// of recording reached
int newNext = messages.size();
int full = recording.prefs().framebufferWidth
* recording.prefs().framebufferHeight;
int full = recording.getProtocolPreferences().framebufferWidth
* recording.getProtocolPreferences().framebufferHeight;
int totalCounter = 0;
......
......@@ -53,6 +53,7 @@ public class GraphicsContext implements MessageConsumer {
// compute scale factor
this.screenWidth = width;
this.screenHeight = height;
scaleFactorX = width / prefs.framebufferWidth;
scaleFactorY = height / prefs.framebufferHeight;
......@@ -65,8 +66,8 @@ public class GraphicsContext implements MessageConsumer {
Log.d("Bitmap", "size: " + bitmapContainer.getBimap().getHeight()
+ bitmapContainer.getBimap().getWidth());
Log.d("ImageView", " ScaleX " + imgView.getScaleX() + " , ScaleY "
+ imgView.getScaleY());
// Log.d("ImageView", " ScaleX " + imgView.getScaleX() + " , ScaleY "
// + imgView.getScaleY());
// updateView(bitmapContainer.getBimap());
......@@ -221,6 +222,8 @@ public class GraphicsContext implements MessageConsumer {
public void handleUpdatedPixels(int x, int y, int w, int h) {
// TODO
// if recording is adjusting, messages are not painted one by one but
// only the final image
if (!recording.adjusting) {
bitmapContainer.getBimap().setPixels(pixels,
x + y * prefs.framebufferWidth, prefs.framebufferWidth, x,
......@@ -338,4 +341,25 @@ public class GraphicsContext implements MessageConsumer {
// refresh(temporaryAnnotationBounds);
// temporaryAnnotationBounds = null;
}
public Bitmap getScreenshotWithoutAnnotations() {
Bitmap screenshot;
// Create a buffered image using the default color model
screenshot = Bitmap.createBitmap(pixels, prefs.framebufferWidth,
prefs.framebufferHeight, Config.ARGB_8888);
// show blank page if whiteboard activated
// if (isWhiteboardEnabled()) {
// g.setColor(Color.white);
// g.fillRect(0, 0, prefs.framebufferWidth, prefs.framebufferHeight);
// // g.setColor(Color.black);
// // g.setFont(g.getFont().deriveFont(100f));
// // g.drawString("WHITEBOARD", 200, 200);
// g.dispose();
// }
// show desktop
return screenshot;
}
}
\ No newline at end of file
This diff is collapsed.
package tttclient.ttt;
import java.util.ArrayList;
import tttclient.messages.Annotation;
import android.content.Context;
import android.graphics.Bitmap;
import android.widget.ImageButton;
public class IndexEntry extends ImageButton {
private final int timestamp;
private final Index index;
private Bitmap thumbnail;
private String title = "";
private final String searchbase_of_page;
private ArrayList<Annotation> annotations;
// private ArrayList<SearchBaseEntry> words;
// private Index index;
public IndexEntry(Context context, Index index, String title,
int timestamp, String searchableText, Bitmap thumbnail) {
super(context);
this.index = index;
this.timestamp = timestamp;
this.title = title;
this.searchbase_of_page = searchableText;
this.thumbnail = thumbnail;
}
public IndexEntry(Context context, Index index) {
this(context, index, "", 0, null, null);
}
public IndexEntry(Context context, Index index, int timestamp) {
this(context, index, "", timestamp, null, null);
}
public int getTimestamp() {
return timestamp;
}
public Bitmap getThumbnail() {
return thumbnail;
}
public String getTitle() {
return title;
}
public String getSearchbase_of_page() {
return searchbase_of_page;
}
public void setThumbnail(Bitmap thumbnail) {
this.thumbnail = thumbnail;
// set src of ImageButton
this.setImageBitmap(thumbnail);
}
public void setAnnotations(ArrayList<Annotation> annotations) {
this.annotations = new ArrayList<Annotation>(annotations);
}
}
......@@ -25,6 +25,7 @@
package tttclient.ttt;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
......@@ -38,6 +39,7 @@ import java.util.zip.InflaterInputStream;
import tttclient.messages.Message;
import tttclient.messages.MessageProducerAdapter;
import tttclient.messages.Messages;
import android.content.Context;
import android.media.MediaPlayer;
import android.util.Log;
import android.widget.ImageView;
......@@ -48,6 +50,8 @@ public class Recording extends MessageProducerAdapter implements Runnable {
private final GraphicsContext graphicsContext;
private final Messages messages;
private final Index index;
private final Context context;
private File tttFile;
private final MediaPlayer audioPlayer;
......@@ -56,8 +60,8 @@ public class Recording extends MessageProducerAdapter implements Runnable {
return messages;
}
public ProtocolPreferences prefs() {
return this.prefs;
public Index getIndex() {
return this.index;
}
public GraphicsContext graphicsContext() {
......@@ -72,25 +76,28 @@ public class Recording extends MessageProducerAdapter implements Runnable {
messages.setmessages(list);
}
public Recording(File file, MediaPlayer audioPlayer, ImageView imgV,
int screenWidth, int screenHeight) throws IOException {
public Recording(Context context, File file, MediaPlayer audioPlayer,
ImageView imgV, int screenWidth, int screenHeight)
throws IOException {
// read
this.context = context;
messages = new Messages(this);
prefs = new ProtocolPreferences();
this.audioPlayer = audioPlayer;
index = new Index(this, context);
read(file);
graphicsContext = new GraphicsContext(imgV, this, screenWidth,
screenHeight);
// TODO readExtensions to get index
// Note: keyframes are computed dynamically during random access
// TODO: add keyframes if dynamic computation is too slow - e.g. if
// border stays unchanged over long periods
// if (!true) {
// index.computeKeyframes(Index.COLLECT_MESSAGES);
// // indexExtension.computeKeyframes(Index.RAW_IN_ARRAY);
// // indexExtension.computeKeyframes(Index.RAW_IN_OFFSCREEN_IMAGE);
// // indexExtension.computeKeyframes(Index.PAINT_TO_OFFSCREEN_IMAGE);
// }
if (!index.isValid())
index.computeIndex();
boolean indexComputed = index.createScreenshots();
Log.d("Recording", "index computed: " + indexComputed + " ,length "
+ index.size());
//
// gather (future) annotations for thumbnail and script generator
index.extractAnnotations();
// // TODO: fixDuration();
if (audioPlayer != null) {
......@@ -115,38 +122,6 @@ 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 getAudioFilename() throws IOException {
// if (audioVideoPlayer != null)
// return audioVideoPlayer.getAudioFilename();
// else
// return Constants.getExistingFile(getFileName(),
// Constants.AUDIO_FILE).getCanonicalPath();
// }
// public String getVideoFilename() throws IOException {
// if (audioVideoPlayer != null)
// return audioVideoPlayer.getVideoFilename();
// else
// return Constants.getExistingFile(getFileName(),
// Constants.VIDEO_FILE).getCanonicalPath();
//
// }
void read(File file) throws IOException {
DataInputStream in = new DataInputStream(new BufferedInputStream(
......@@ -173,12 +148,8 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// read body of recording
messages.readMessages(in);
// // ensure index is read from extension or computed
// ensure index is read from extension or computed
// if (!index.isValid())
// index.computeIndex();
//
// // gather (future) annotations for thumbnail and script generator
// index.extractAnnotations();
// read search bases
// TODO: upercase ending??
......@@ -324,53 +295,59 @@ public class Recording extends MessageProducerAdapter implements Runnable {
extensions.add(extension);
}
// parseExtensions();
parseExtensions();
// no original, but modified recording
if (extensions.size() > 0)
original = false;
}
// public Index index = new Index(this);
// private void parseExtensions() throws IOException {
// for (int i = 0; i < extensions.size(); i++) {
// byte[] extension = extensions.get(i);
// DataInputStream ext_in = new DataInputStream(
// new ByteArrayInputStream(extension));
// int tag = ext_in.readByte();
// switch (tag) {
// case
// try {
// index.readIndexExtension(ext_in);
// } catch (Exception e) {
//
//
// }
// break;
//
// case Constants.EXTENSION_SEARCHBASE_TABLE_WITH_COORDINATES:
//
// try {
// SearchbaseExtension.readSearchbaseExtension(ext_in, index);
// // extensions.remove(i);
// } catch (Exception e) {
// System.out
// .println("READING OF SEARCHBASE EXTENSION FAILED: "
// + e);
// if (TTT.debug)
// e.printStackTrace();
// }
// break;
//
// default:
// System.out
// .println("\n-----------------------------------------------\nUNKNOWN EXTENSION (["
// + tag + "] " + extension.length + " bytes)\n");
// break;
// }
// }
// }
private void parseExtensions() throws IOException {
for (int i = 0; i < extensions.size(); i++) {
byte[] extension = extensions.get(i);
DataInputStream ext_in = new DataInputStream(
new ByteArrayInputStream(extension));
int tag = ext_in.readByte();
switch (tag) {
case Constants.EXTENSION_INDEX_TABLE:
// if (TTT.verbose)
// System.out
// .println("\n-----------------------------------------------\nReading Index Table\n");
try {
index.readIndexExtension(ext_in);
} catch (Exception e) {
System.out
.println("READING OF INDEX TABLE EXTENSION FAILED: "
+ e);
// if (TTT.debug)
// e.printStackTrace();
}
break;
// case Constants.EXTENSION_SEARCHBASE_TABLE_WITH_COORDINATES:
// if (TTT.verbose)
// System.out
// .println("\n-----------------------------------------------\nReading Searchbase Extension\n");
// try {
// SearchbaseExtension.readSearchbaseExtension(ext_in, index);
// // extensions.remove(i);
// } catch (Exception e) {
// System.out
// .println("READING OF SEARCHBASE EXTENSION FAILED: "
// + e);
// if (TTT.debug)
// e.printStackTrace();
// }
// break;
default:
System.out
.println("\n-----------------------------------------------\nUNKNOWN EXTENSION (["
+ tag + "] " + extension.length + " bytes)\n");
break;
}
}
}
/*******************************************************************************************************************
* playback
......@@ -538,7 +515,9 @@ public class Recording extends MessageProducerAdapter implements Runnable {
*
* @param time
*/
public void setTime(int time) {
public void setTime(int time, boolean refresh) {
// refresh determine if display is updated or not
setAdjusting(true);
time = sync(time);
......@@ -551,8 +530,9 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// paint offscreen
messages.setTime_full_frame_check(time);
setAudioPlayerTime(time);
graphicsContext.refresh();
if (refresh) {
graphicsContext.refresh();
}
setAdjusting(false);
//
// index.setCorrespondingIndex(time);
......@@ -653,20 +633,9 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// also sets audio/video player if not adjusting
public void sliderStateChanged(int pos) {
// // adjusting = ((MyChangeEvent) event).adjusting;
// // if (adjusting) {
// // visible scrolling
// setAudioPlayerTime(pos);
setTime(pos);
// adjusting = false;
// // } else {
// // // synchronize audio/video
// // // NOTE: the slider fires one last event with adjusting==false
// // // but same timestamp than before,
// // // therefore setTime has allready been called for this time
// // // value
// setAudioPlayerTime(pos);
// // }
// bitmap is set and display is updated
setTime(pos, true);
setAudioPlayerTime(pos);
}
......@@ -849,9 +818,10 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// return index.thumbnailsAvailable();
// }
//
// public boolean createThumbnails() throws IOException {
// return createScript(ScriptCreator.THUMBNAILS);
// }
// 4 = Thumbnails
public boolean createThumbnails() throws IOException {
return index.createScreenshots();
}
//
// public boolean createScript() throws IOException {
// return createScript(ScriptCreator.HTML_SCRIPT
......@@ -861,14 +831,7 @@ public class Recording extends MessageProducerAdapter implements Runnable {
// // mode can be a & combination of HTML_SCRIPT, OCR_OPTIMIZED, THUMBNAILS
// (of
// // class ScriptCreator)
// public boolean createScript(final int mode) throws IOException {
// return index.computeScreenshots(mode, false, true);
// }
//
// public boolean createScript(final int mode, boolean batch)
// throws IOException {
// return index.computeScreenshots(mode, batch, true);
// }
//
// public boolean createScript(final int mode, boolean batch, String
// ocrPath)
......
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