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.
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/>.
package tttclient.connections;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.util.ArrayList;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import tttclient.messages.Message;
import tttclient.ttt.ProtocolPreferences;
// TODO: rework this class - it's just a copy and paste and hack version from old TTT
/**
* @author Peter Ziewer (University of Trier,Germany)
*
* receives UDP packets and creates InputStream
*/
public class UDPInputStream {
DatagramSocket socket;
InputStream in;
InetAddress serverAddress;
int serverPort;
ProtocolPreferences prefs;
/**
* Constructor for UDPInputStream.
*/
public UDPInputStream(InetAddress localAddress, String host, int port,
String serverAddress, int serverPort, ProtocolPreferences prefs)
throws IOException {
// System.out.println(host+":"+port+" from "+serverAddress+":"+serverPort);
this.prefs = prefs;
this.serverAddress = InetAddress.getByName(serverAddress);
this.serverPort = serverPort;
InetAddress address = InetAddress.getByName(host);
if (address.isMulticastAddress()) {
socket = new MulticastSocket(port);
((MulticastSocket) socket).joinGroup(address);
} else {
try {
// try to open port on dedicated local address (supporting
// multiple network adapters)
System.out.println("try to open " + localAddress);
socket = new DatagramSocket(port, localAddress);
} catch (Exception e) {
// default local address
System.out.println("Failed to open port " + port + " on "
+ localAddress
+ " - Trying default network adapter instead");
socket = new DatagramSocket(port);
}
}
// TODO: availabe test, unicast reconnect if needed
// socket.setSoTimeout(35000);
socket.setSoTimeout(1000);
socket.setReceiveBufferSize(1024 * 64);
System.out.println("UDP Socket ReceiveBufferSize: "
+ socket.getReceiveBufferSize());
}
boolean terminate;
public void close() throws IOException {
socket.close();
terminate = true;
}
// /**
// * @see java.io.InputStream#read()
// */
// public int read() throws IOException {
// try {
// int b = in.read();
// if (b >= 0)
// return b;
// // input is empty, receive new packet
// getDatagram();
// // read again
// return read();
// } catch (Exception e) {
// getDatagram();
// return read();
// }
// }
//
// public void drop() {
// in = new ByteArrayInputStream(new byte[0]);
// }
// bytes 0-3 contain message size
byte[] buffer = new byte[1024 * 64 + 1];
byte[] unpack = new byte[1024 * 70];
DatagramPacket packet = new DatagramPacket(buffer, 0, buffer.length);
Inflater inflater = new Inflater();
byte count_expected = -1;
int timeoutCount = 0;
// receive udp packet
ArrayList<Message> getMessages() throws IOException {
// receive next packet
// accept only packets from server
do {
// set packet length to maximum
packet.setLength(buffer.length);
while (!terminate)
try {
// wait for packet
socket.receive(packet);
break;
} catch (InterruptedIOException e) {
// timeout
timeoutCount++;
if (timeoutCount > 15) {
// too many timeouts
System.out
.println("Too many timeouts. Reachability Test not implemented yet.");
// try {
// // test if server is alive
//
// String host;
// int port;
// if (TTT.getInstance().connection instanceof
// UDPConnectionTCPInit) {
// UDPConnectionTCPInit connection =
// (UDPConnectionTCPInit)
// (TTT.getInstance().connection);
// host = connection.host;
// port = connection.port;
// } else {
// throw new IOException("No output stream available.");
// }
// Socket socket = new Socket(host, port);
// socket.getOutputStream().write("reachability".getBytes());
// socket.close();
//
// // server is alive
// Object[] options = { "Continue waiting", "Reconnect",
// "Disconnect" };
// int answer =
// JOptionPane.showOptionDialog(TTT.getInstance().viewerFrame.getViewer(),
// "Time Out ! Server is running.", "Time Out",
// JOptionPane.YES_NO_CANCEL_OPTION,
// JOptionPane.ERROR_MESSAGE, null, options,
// options[1]);
//
// if (answer == JOptionPane.YES_OPTION)
// timeoutCount = 0;
// if (answer == JOptionPane.NO_OPTION)
// TTT.getInstance().reconnect();
// if (answer == JOptionPane.CANCEL_OPTION)
// TTT.getInstance().disconnect();
//
// } catch (IOException ioe) {
// // server unreachable
// Object[] options = { "Continue waiting", "Disconnect"
// };
// int answer = JOptionPane
// .showOptionDialog(
// TTT.getInstance().viewerFrame.getViewer(),
// TTT.getInstance().connection instanceof
// UDPConnectionTCPInit ? "Time Out ! Server
// unreachable."
// : "Time Out !", "Time Out",
// JOptionPane.YES_NO_OPTION,
// JOptionPane.ERROR_MESSAGE, null, options,
// options[1]);
//
// if (answer == JOptionPane.YES_OPTION)
// timeoutCount = 0;
// if (answer == JOptionPane.NO_OPTION)
// TTT.getInstance().disconnect();
// }
}
}
// System.out.println("packet from "+packet.getAddress().getHostName()+" port "+packet.getPort()+"
// size
// "+packet.getLength());
} while ((packet.getPort() != serverPort || !packet.getAddress()
.equals(serverAddress)) && !terminate);
// done - return empty list
if (terminate)
return new ArrayList<Message>();
// reset timeout counter
timeoutCount = 0;