How about centralized client-server system by using JMF and RTP ?
I have a question about using jmf.
First, i want to make a conferans system just for audio. Before i met jmf i try to do it by using udp.
By using UDP, i had been able to send packets, which i just captured from mic, to server and on server side
i could send to clients.
The sound format was PCM, 8000, 8, mono. I decided to change it to G.723.1. When i was googling for it, i saw that jmf already doing it.
I had read about jmf, and its protocols on suns tutorials. They are using RTP. So i decided to use jmf. I looked the source code of AVReceive2 and AVTransmit2.
They are try to create a session to communicate. But i have a centralized client-server system. For example, on the client side,
i want to take one of the clients sound packet and on the server side, send that packet all other clients.
How can i do this with jmf? Am i be able to reach the packets? OR to do this, should i create sessions between clients?
I read an article about jmf. It says that with jmf by using RTP, we arent be able to write sockets. Is that my answer?
I hope i could explain my problem in spite of my english.
Im waiting for any help.
# 1
Doesnt anybody have any ideas? or are my questions soo stupid, so nobody answer me?
Also i change my question. As i told before, i wanna make a centralized client server system.
Is the algorithym wrong ?
Sample adresses :
Server IP= a.a.a.a
Client1 IP = x.x.x.x
Client2 IP = y.y.y.y
Client3 IP = z.z.z.z
(They are all public)
The situation is :
Both Client1 and Client2 have got a mic, Client3 hasnt got. All of them are in the same room and wanna make
an audio conversation. Also, they connected to server (whose IP is a.a.a.a).
We have 3 clients. Two of them sending packets to server and all of them recieving these packets from server.
Algorithym (I assume that they had already connected to the server):
- Client1 is sending his packet which was just captured from his mic by using his session.
- At that time, Client2 is doing the same thing, sending his packet.
- Server has received a packet from Client1 and then Client2. Server puts them its message queue.
- By the way, server is going on sending packets from queue. Server is getting a packet from his queue and
sending them to all clients.
Also in the samples of Sun, there are AVTransmit2 and AVRecieve2.
AVTransmit2 is trying to open a session with given args.
Also i can give some args to connect my server. ( like "dsound:// a.a.a.a 22222 44444" )
And for server i can make some changes to AVRecieve2. AVReceive2 takes packets and create a Player and then play it.
Have i a changes to say server "Dont play them. U are a server, u must send them to clients." ?
I guess it is been able to do. But its more important " HOW ? ".
It must be here somewhere.
(These codes are from one of the Suns sample, AVTransmit2.java)
public synchronized void update(ReceiveStreamEvent evt) {
RTPManager mgr = (RTPManager) evt.getSource();
Participant participant = evt.getParticipant(); // could be null.
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");
if (participant == null)
System.err
.println(" The sender of this stream had yet to be identified.");
else {
System.err.println(" The stream comes from: "
+ participant.getCNAME());
}
// create a player by passing datasource to the Media Manager
Player p = javax.media.Manager.createPlayer(ds);
if (p == null)
return;
p.addControllerListener(this);
p.realize();
PlayerWindow pw = new PlayerWindow(p, stream);
playerWindows.addElement(pw);
// 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;
}
}
else if (evt instanceof StreamMappedEvent) {
if (stream != null && stream.getDataSource() != null) {
DataSource ds = stream.getDataSource();
// Find out the formats.
RTPControl ctl = (RTPControl) ds
.getControl("javax.media.rtp.RTPControl");
System.err.println(" - The previously unidentified stream ");
if (ctl != null)
System.err.println(" " + ctl.getFormat());
System.err.println(" had now been identified as sent by: "
+ participant.getCNAME());
}
}
else if (evt instanceof ByeEvent) {
System.err
.println(" - Got \"bye\" from: " + participant.getCNAME());
PlayerWindow pw = find(stream);
if (pw != null) {
pw.close();
playerWindows.removeElement(pw);
}
}
}
Also to solve my problem, should i send the (ReceiveStreamEvent) "evt" to all clients
"if (evt instanceof NewReceiveStreamEvent)" ?
Waiting for help...
Navigator