[4797] in java-interest

home help back first fref pref prev next nref lref last post

Implementing a teleconference under Java (beta 2 release)

daemon@ATHENA.MIT.EDU (Mohamed Bazzi)
Mon Jan 15 16:35:16 1996

From: bazzi@rennes.enst-bretagne.fr (Mohamed Bazzi)
Date: Mon, 15 Jan 1996 15:42:51 +0100
To: java-interest@java.sun.com

Hello,

It's a long message. Thanks for your patience. 

My purpose is to implement a teleconference. 

I have two flows (two files on the server) : 

	1. The first is for the actions that i must perform.

The first flow is a sequence of paquets. Each paquet has a fix header to determine 
what kind of paquet i have : if a channel number is set to 2 it 's a "teleconference" 
paquet then i decode the remainder to know what action to perform. For example : action
would be loading an image file and draw it, move "hand" to a particular position (x,y)
in the image, draw line ...., loading the next image,...

	2. The second for data audio.
  
Another sequence of paquets. I decode the header. If channel is set to 1 it's an "audio 
teleconference paquet", then i must play the audio data which is in the remainder of 
the paquet. And the same thing for the next paquet. 
Unlike the first flow i havn't any audio file on disk. In teleconference, we don't know 
exactly what words we are going to use. 
And here i have the *problem*, since beta release support audio file on an URL and
not an array of audio data. 

The synchronization between images an audio is made by a timestamp associated with each
paquet so i can know exactly the moment when i must perform an action or to play audio.
May be they have the same timestamp so the action and the audio take at the same moment.

For audio i write on /dev/audio, it's UNIX solution and not portable. With this solution     
i have trouble to insure that the speaker would finish before an action of a first
flow paquet take place. The result is some kind like this : 
"In this picture we" action "going t" action "o see". It change to a "teledesaster" and
not a teleconference.

I tried several solutions : 

	1. Solution one : Implementing two threads one that have the applet itself as 
target to perform actions and other to play sound, the first thread sleeps until the 
timestamp. I had the same trouble.
	2. Solution two : Implementing a critical section ( even if i have not to share
data, there is two separate flows). With this solution i have not the above trouble,
but actions are much faster than the speaker. So we hear explanations of the previous
image.  
	3. Actual Solution : One thread that has the applet as target. In the run()
method i decode one action paquet and one audio paquet and regarding the timestamp i
execute either an action or play sound with sleeping the thred. See below. 

Here is the applet for the Actual Solution :  

import .....
private Thread thr;

public class TeleConf extends java.applet.Applet implements Runnable {
.....
public void init() {
str = getParameter("filein"); //the first flow : actions
straud = getParameter("fileaud"); //the second flow : audio
load_images(); /* like most client-server applications, i must first decode the flow of
		  actions in order to extract the names of images and load the image
		  files from the server and write them on /usr/tmp */ 
}
public void start() {
thr = new Thraed(this);
thr.start();
}
....
public void run() {	 
// here i decode the two flows and perform either an action or play audio, it depends
// on timestamp associated with each paquet. 

thr.setPriority(Thread.MIN_PRIORITY);
......
read_image(); // read an action paquet(first flow)
read_audio(); // read an audio paquet(second flow)

while(....) {

	if (time_stamp_image < time_stamp_audio) {
		repaint(); // I perform the action 
		try {
		     thr.sleep(periode); // sleep the periode between this timestamp and
					 // the leatest timestamp of action paquet. 
		} catch (InterruptedException e) {
		System.out.println(e);
		}
	read_image();
	}

	if (time_stamp_audio < time_stamp_image) {
		read_audio();
	}

	if (time_stamp_audio == time_stamp_image) {

		read_audio();
		repaint();
		try {
		     thr.sleep(periode); // sleep the periode between this timestamp and
					 // the leatest timestamp of action paquet. 
		} catch (InterruptedException e) {
		System.out.println(e);
		}
		read_image();
	}
}

public void read_image(){
........
}
public void read_audio(){
	// Here i decode the audio paquet and perform a loop while to read the data and
	// write on /dev/audio	
	......
	while (rest != 0) {
		s = datainputstream.read(buffaudio,0,rest);
		fileoutput.write(buffaudio,o,s); //*** here i write on /dev/audio
		rest -= s;
	}
	.........
}
....
....
}

I execute the applet with appletviewer(since i have to access files), on SunOS 5.4

In an ultimate solution i used sun.audio.* packages :

	AudioStream audiostream = new AudioStream(url.openStream());
	AudioPlayer.player.start(audiostream);

But i have the following message :

	audio device busy (attempt 1 out of 5)


Thanks for you to be patient and Thanks for reporting any solutions for this problem.

 
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post