Commit 3bc7b455 authored by Thomas Krex's avatar Thomas Krex

-Rectangle und FreehandAnnotations hinzugefügt

-annotations werden über updatview in handleMessage() geupdated
--strokedshape als hilfklasse erzeugt
parent ffc94b88
eclipse.preferences.version=1
encoding//src/tttclient/connections/TTTConnection.java=UTF-8
encoding//src/tttclient/messages/HighlightAnnotation.java=UTF-8
encoding//src/tttclient/messages/annotations/HighlightAnnotation.java=UTF-8
encoding//src/tttclient/ttt/Constants.java=ISO-8859-1
......@@ -52,7 +52,7 @@ public final class R {
public static final class layout {
public static final int activity_main=0x7f030000;
public static final int activity_player_extended=0x7f030001;
public static final int activity_player_fullscreen=0x7f030002;
public static final int activity_player_fullscreen_overlay=0x7f030002;
public static final int activity_player_main=0x7f030003;
public static final int dialog_connect=0x7f030004;
public static final int dialog_feeds=0x7f030005;
......
......@@ -25,6 +25,7 @@ import android.widget.MediaController.MediaPlayerControl;
import android.widget.ScrollView;
import android.widget.SearchView;
import android.widget.SearchView.OnQueryTextListener;
import android.widget.SeekBar;
import android.widget.ViewSwitcher;
import com.example.test.R;
......@@ -39,6 +40,7 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
private Recording recording;
private MediaPlayer audioPlayer;
private MediaController audioController;
private SeekBar seekbar;
private int imgVHeight;
private int imgVWidth;
private SearchView searchView;
......@@ -70,7 +72,12 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
final int screenHeight = display.getHeight(); // deprecated
audioController = new MediaController(this);
final int topContainerId1 = getResources().getIdentifier(
"mediacontroller_progress", "id", "android");
seekbar = (SeekBar) audioController.findViewById(topContainerId1);
audioController.setMediaPlayer(this);
audioController.setHorizontalScrollBarEnabled(false);
// final ProgressDialog dialog = new ProgressDialog(
// getApplicationContext());
// dialog.setMessage("Reading File");
......@@ -119,11 +126,6 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
});
t.start();
// init SearchView in ActionBar
// erst ab API 11
// create audio player & control
}
public void search(String word) {
......@@ -131,6 +133,11 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
recording.getIndex().search(word);
recording.highlightSearchResults(recording.graphicsContext()
.getCanvas());
// update display if recording is not playing
// if (!recording.isPlaying())
recording.graphicsContext().updateCanvas();
}
@Override
......@@ -187,7 +194,8 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
@Override
public void seekTo(int pos) {
recording.sliderStateChanged(pos);
if (!audioController.isPressed())
recording.sliderStateChanged(pos);
}
......@@ -273,6 +281,7 @@ public class PlayerActivity extends Activity implements MediaPlayerControl {
if (index == 0) {
imgV = (ImageView) findViewById(R.id.playerView_fullscreen);
recording.graphicsContext().setImageView(imgV);
recording.focusCurrentIndexEntry(recording.getLastIndexFired() - 1);
switcher.setDisplayedChild(0);
}
......
package tttclient.connections;
/*
* MODIFIED VERSION OF
*
* @(#)AVReceive2.java 1.3 01/03/13
*
* Copyright (c) 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
*
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
* modify and redistribute this software in source and binary code form,
* provided that i) this copyright notice and license appear on all copies of
* the software; and ii) Licensee does not utilize the software in a manner
* which is disparaging to Sun.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* This software is not designed or intended for use in on-line control of
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
* the design, construction, operation or maintenance of any nuclear
* facility. Licensee represents and warrants that it will not use or
* redistribute the Software for such purposes.
*/
/**
* AVReceive2 to receive RTP transmission using the new RTP API.
*/
public class AVReceiveSimple {
// String sessions = null;
// RTPManager mgrs = null;
// Vector playerWindows = null;
// Player player = null;
//
// boolean dataReceived = false;
// Object dataSync = new Object();
// Window rootFrame;
//
// public AVReceiveSimple(String sessions) {
// this.sessions = sessions;
// }
//
// protected boolean initialize() {
//
// try {
// InetAddress ipAddr;
// SessionAddress localAddr = new SessionAddress();
// SessionAddress destAddr;
//
// playerWindows = new Vector();
//
// SessionLabel session;
//
// // Parse the session addresses.
// try {
// session = new SessionLabel(sessions);
// } catch (IllegalArgumentException e) {
// System.err
// .println("Failed to parse the session address given: "
// + sessions);
// return false;
// }
//
// System.err.println(" - Open RTP session for: addr: "
// + session.addr + " port: " + session.port + " ttl: "
// + session.ttl);
//
// mgrs = (RTPManager) RTPManager.newInstance();
// mgrs.addSessionListener(this);
// mgrs.addReceiveStreamListener(this);
//
// ipAddr = InetAddress.getByName(session.addr);
//
// if (ipAddr.isMulticastAddress()) {
// // local and remote address pairs are identical:
// localAddr = new SessionAddress(ipAddr, session.port,
// session.ttl);
// destAddr = new SessionAddress(ipAddr, session.port, session.ttl);
// } else {
// localAddr = new SessionAddress(InetAddress.getLocalHost(),
// session.port);
// destAddr = new SessionAddress(ipAddr, session.port);
// }
//
// mgrs.initialize(localAddr);
//
// // You can try out some other buffer size to see
// // if you can get better smoothness.
// BufferControl bc = (BufferControl) mgrs
// .getControl("javax.media.control.BufferControl");
// if (bc != null)
// bc.setBufferLength(350);
//
// mgrs.addTarget(destAddr);
//
// } catch (Exception e) {
// System.err.println("Cannot create the RTP Session: "
// + e.getMessage());
// return false;
// }
//
// // Wait for data to arrive before moving on.
//
// long then = System.currentTimeMillis();
// long waitingPeriod = 10000; // wait for a maximum of 10 secs.
//
// try {
// synchronized (dataSync) {
// while (!dataReceived
// && System.currentTimeMillis() - then < waitingPeriod) {
// if (!dataReceived)
// System.err
// .println(" - Waiting for RTP data to arrive...");
// dataSync.wait(1000);
// }
// }
// } catch (Exception e) {
// }
//
// if (!dataReceived) {
// System.err.println("No RTP data was received.");
// close();
// return false;
// }
//
// return true;
// }
//
// public boolean isDone() {
// return playerWindows.size() == 0;
// }
//
// /**
// * Close the players and the session managers.
// */
protected void close() {
try {
// player.close();
} catch (Exception e) {
}
// close the RTP session.
// for (int i = 0; i < mgrs.length; i++) {
// if (mgrs != null) {
// mgrs.removeTargets("Closing session from AVReceive");
// mgrs.dispose();
// mgrs = null;
// }
// }
}
//
// /**
// * SessionListener.
// */
// public synchronized void update(SessionEvent evt) {
// }
//
// /**
// * ReceiveStreamListener
// */
// public synchronized void update(ReceiveStreamEvent evt) {
//
// ReceiveStream stream = evt.getReceiveStream(); // could be null.
//
// if (evt instanceof RemotePayloadChangeEvent) {
//
// System.err.println(" - Received an RTP PayloadChangeEvent.");
// System.err.println("Sorry, cannot handle payload change.");
// System.exit(0);
//
// } else if (evt instanceof NewReceiveStreamEvent) {
//
// try {
// stream = ((NewReceiveStreamEvent) evt).getReceiveStream();
// DataSource ds = stream.getDataSource();
//
// // Find out the formats.
// RTPControl ctl = (RTPControl) ds
// .getControl("javax.media.rtp.RTPControl");
// if (ctl != null) {
// System.err.println(" - Recevied new RTP stream: "
// + ctl.getFormat());
// } else
// System.err.println(" - Recevied new RTP stream");
//
// // create a player by passing datasource to the Media Manager
// player = javax.media.Manager.createPlayer(ds);
// if (player == null)
// return;
//
// player.addControllerListener(this);
// player.realize();
//
// // Notify intialize() that a new stream had arrived.
// synchronized (dataSync) {
// dataReceived = true;
// dataSync.notifyAll();
// }
//
// } catch (Exception e) {
// System.err.println("NewReceiveStreamEvent exception "
// + e.getMessage());
// return;
// }
//
// }
// }
//
// /**
// * ControllerListener for the Players.
// */
// public synchronized void controllerUpdate(ControllerEvent ce) {
// }
//
// /**
// * A utility class to parse the session addresses.
// */
// class SessionLabel {
//
// public String addr = null;
// public int port;
// public int ttl = 1;
//
// SessionLabel(String session) throws IllegalArgumentException {
//
// int off;
// String portStr = null, ttlStr = null;
//
// if (session != null && session.length() > 0) {
// while (session.length() > 1 && session.charAt(0) == '/')
// session = session.substring(1);
//
// // Now see if there's a addr specified.
// off = session.indexOf('/');
// if (off == -1) {
// if (!session.equals(""))
// addr = session;
// } else {
// addr = session.substring(0, off);
// session = session.substring(off + 1);
// // Now see if there's a port specified
// off = session.indexOf('/');
// if (off == -1) {
// if (!session.equals(""))
// portStr = session;
// } else {
// portStr = session.substring(0, off);
// session = session.substring(off + 1);
// // Now see if there's a ttl specified
// off = session.indexOf('/');
// if (off == -1) {
// if (!session.equals(""))
// ttlStr = session;
// } else {
// ttlStr = session.substring(0, off);
// }
// }
// }
// }
//
// if (addr == null)
// throw new IllegalArgumentException();
//
// if (portStr != null) {
// try {
// Integer integer = Integer.valueOf(portStr);
// if (integer != null)
// port = integer.intValue();
// } catch (Throwable t) {
// throw new IllegalArgumentException();
// }
// } else
// throw new IllegalArgumentException();
//
// if (ttlStr != null) {
// try {
// Integer integer = Integer.valueOf(ttlStr);
// if (integer != null)
// ttl = integer.intValue();
// } catch (Throwable t) {
// throw new IllegalArgumentException();
// }
// }
// }
// }
//
public static AVReceiveSimple createPlayer(String sessionAddress) {
// AVReceiveSimple avReceive = new AVReceiveSimple(sessionAddress);
// if (!avReceive.initialize()) {
// System.err.println("Failed to initialize the sessions.");
// avReceive = null;
// }
// return avReceive;
return null;
}
}
// TeleTeachingTool - Presentation Recording With Automated Indexing
//
// Copyright (C) 2003-2008 Peter Ziewer - Technische Universit?t M?nchen
//
// This file is part of TeleTeachingTool.
//
// TeleTeachingTool is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// TeleTeachingTool is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with TeleTeachingTool. If not, see <http://www.gnu.org/licenses/>.
package tttclient.connections;
/**
* @author Peter Ziewer (University of Trier,Germany)
* sending alive messages to server periodically
*/
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Timer;
import java.util.TimerTask;
public class AliveDaemon extends TimerTask {
DatagramSocket socket;
DatagramPacket packet;
byte[] msg = { (byte) 42 };
Timer timer;
AliveDaemon(InetAddress address, int port) {
System.out.println("AliveDaemon: " + address + ":" + port);
try {
socket = new DatagramSocket();
packet = new DatagramPacket(msg, 0, address, port);
socket.send(packet);
timer = new Timer(true);
timer.scheduleAtFixedRate(this, 30000, 60000);
} catch (Exception e) {
System.err.println("Couldn't start AliveDaemon: " + e);
}
}
void terminate() throws IOException {
timer.cancel();
// send terminate message
packet.setLength(1);
socket.send(packet);
}
@Override
public void run() {
try {
socket.send(packet);
} catch (Exception e) {
System.err.println(e);
// javax.swing.JOptionPane.showMessageDialog(null,
// "Server is done. Exiting.");
}
}
}
This diff is collapsed.
// TeleTeachingTool - Presentation Recording With Automated Indexing
//
// Copyright (C) 2003-2008 Peter Ziewer - Technische Universit�t M�nchen
//
// This file is part of TeleTeachingTool.
//
// TeleTeachingTool is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// TeleTeachingTool is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with TeleTeachingTool. If not, see <http://www.gnu.org/licenses/>.
/*
* Created on 01.12.2005
*
* Author: Peter Ziewer, TU Munich, Germany - ziewer@in.tum.de
*/
package tttclient.connections;
import java.io.BufferedInputStream;
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketException;
import java.util.ArrayList;
import tttclient.messages.Message;
import tttclient.messages.MessageConsumer;
import tttclient.messages.MessageProducer;
import tttclient.ttt.Connection;
import tttclient.ttt.Constants;
import tttclient.ttt.ProtocolPreferences;
public class TTTConnection implements Connection, MessageProducer, Runnable,
Closeable {
// I/O
private Socket socket;
private ReconnectingInputStream userInputStream;
private int accessMode = Constants.Unicast;
private AVReceiveSimple[] players;
private AVReceiveSimple audioPlayer; // , videoPlayer;
private AliveDaemon aliveDaemon;
// initialization pereferences
private final ProtocolPreferences prefs;
public TTTConnection(InetAddress host, int port, int accessMode) {
prefs = new ProtocolPreferences();
prefs.host = host;
prefs.port = port;
this.accessMode = accessMode;
}
// returns component which displays video
// public Component getVideoComponent() {
// // search video component
// if (players != null)
// for (AVReceiveSimple player : players) {
// Component component = player.player.getVisualComponent();
// if (component != null)
// return component;
// }
// return null;
// }
// TODO: add switching to another host
// TODO: catch errors, like host not found
// connect to given vnc server
@Override
public synchronized byte connect() throws IOException {
// cleanup (if needed)
close();
// init
// TODO: maybe NoInputStream and NoOutputsStream is needed to avoid
// NullPointerExceptions
// I/O stream used during initialisation
DataInputStream initializationDataInputStream = null;
OutputStream initializationOutputstream = null;
InputStream initializationInputStream = null;
// connect
while (socket == null) {
System.out.println(" Connect to " + prefs.host + " : "
+ prefs.port);
// open socket and I/O streams
// TODO: timeout handling
try {
socket = new Socket(prefs.host, prefs.port);
} catch (IOException e) {