mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-13 11:09:39 +02:00
Jingle Media Manager for Multiple Media Managers.
JIngle Media Manager Refactoring. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7361 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
18c14f70d4
commit
945561242a
8 changed files with 180 additions and 242 deletions
|
@ -74,6 +74,7 @@ import java.net.DatagramPacket;
|
|||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Test the Jingle extension using the high level API
|
||||
|
@ -706,33 +707,7 @@ public class JingleManagerTest extends SmackTestCase {
|
|||
// JingleManager jm1 = new JingleSessionManager(
|
||||
// x1, new ICEResolver());
|
||||
|
||||
JingleMediaManager jingleMediaManager = new JingleMediaManager() {
|
||||
// Media Session Implementation
|
||||
public JingleMediaSession createMediaSession(final PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local) {
|
||||
return new JingleMediaSession(payloadType, remote, local) {
|
||||
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
public void startTrasmit() {
|
||||
}
|
||||
|
||||
public void startReceive() {
|
||||
}
|
||||
|
||||
public void setTrasmit(boolean active) {
|
||||
}
|
||||
|
||||
public void stopTrasmit() {
|
||||
}
|
||||
|
||||
public void stopReceive() {
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
jingleMediaManager.addPayloadType(new PayloadType.Audio(3, "GSM", 1, 16000));
|
||||
JingleMediaManager jingleMediaManager = new JmfMediaManager();
|
||||
|
||||
jm0.setMediaManager(jingleMediaManager);
|
||||
jm1.setMediaManager(jingleMediaManager);
|
||||
|
@ -746,32 +721,27 @@ public class JingleManagerTest extends SmackTestCase {
|
|||
session.addListener(new JingleSessionListener() {
|
||||
|
||||
public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
incCounter();
|
||||
System.out.println("Establish In");
|
||||
}
|
||||
|
||||
public void sessionDeclined(String reason, JingleSession jingleSession) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public void sessionRedirected(String redirection, JingleSession jingleSession) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public void sessionClosed(String reason, JingleSession jingleSession) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public void sessionClosedOnError(XMPPException e, JingleSession jingleSession) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
});
|
||||
|
||||
session.start();
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -874,9 +844,17 @@ public class JingleManagerTest extends SmackTestCase {
|
|||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
jingleMediaManager.addPayloadType(new PayloadType.Audio(3, "GSM", 1, 16000));
|
||||
public List<PayloadType> getPayloads() {
|
||||
return new ArrayList();
|
||||
}
|
||||
|
||||
public PayloadType getPreferredPayloadType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
jm0.setMediaManager(jingleMediaManager);
|
||||
jm1.setMediaManager(jingleMediaManager);
|
||||
|
@ -891,7 +869,7 @@ public class JingleManagerTest extends SmackTestCase {
|
|||
session.start(request);
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,106 +65,6 @@ public class BridgedResolverTest extends SmackTestCase {
|
|||
assertTrue(valCounter() == 3);
|
||||
}
|
||||
|
||||
public void testFullBridge() {
|
||||
resetCounter();
|
||||
|
||||
try {
|
||||
|
||||
//XMPPConnection.DEBUG_ENABLED = true;
|
||||
|
||||
XMPPConnection x0 = new XMPPConnection("thiago");
|
||||
XMPPConnection x1 = new XMPPConnection("thiago");
|
||||
|
||||
x0.connect();
|
||||
x0.login("barata7", "barata7");
|
||||
x1.connect();
|
||||
x1.login("barata6", "barata6");
|
||||
|
||||
final JingleManager jm0 = new JingleManager(
|
||||
x0, new BridgedResolver(x0));
|
||||
final JingleManager jm1 = new JingleManager(
|
||||
x1, new BridgedResolver(x1));
|
||||
|
||||
JingleMediaManager jingleMediaManager = new JingleMediaManager() {
|
||||
// Media Session Implementation
|
||||
public JingleMediaSession createMediaSession(final PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local) {
|
||||
return new JingleMediaSession(payloadType, remote, local) {
|
||||
|
||||
public void initialize() {
|
||||
|
||||
}
|
||||
|
||||
public void startTrasmit() {
|
||||
incCounter();
|
||||
|
||||
System.out.print("IPs:");
|
||||
System.out.println(local.getSymmetric().getIp());
|
||||
System.out.println(local.getIp());
|
||||
|
||||
System.out.println("Transmit");
|
||||
}
|
||||
|
||||
public void startReceive() {
|
||||
incCounter();
|
||||
System.out.println("Receive");
|
||||
}
|
||||
|
||||
public void setTrasmit(boolean active) {
|
||||
}
|
||||
|
||||
public void stopTrasmit() {
|
||||
incCounter();
|
||||
System.out.println("Stop Transmit");
|
||||
}
|
||||
|
||||
public void stopReceive() {
|
||||
incCounter();
|
||||
System.out.println("Stop Receive");
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
jingleMediaManager.addPayloadType(new PayloadType.Audio(3, "GSM", 1, 16000));
|
||||
|
||||
jm0.setMediaManager(jingleMediaManager);
|
||||
jm1.setMediaManager(jingleMediaManager);
|
||||
|
||||
jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
|
||||
public void sessionRequested(final JingleSessionRequest request) {
|
||||
|
||||
try {
|
||||
|
||||
IncomingJingleSession session = request.accept(jm1.getMediaManager().getPayloads());
|
||||
|
||||
session.start(request);
|
||||
} catch (XMPPException e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
OutgoingJingleSession js0 = jm0.createOutgoingJingleSession("barata6@thiago/Smack");
|
||||
|
||||
js0.start();
|
||||
|
||||
Thread.sleep(10000);
|
||||
js0.terminate();
|
||||
|
||||
Thread.sleep(3000);
|
||||
|
||||
System.out.println(valCounter());
|
||||
|
||||
assertTrue(valCounter() == 8);
|
||||
//Thread.sleep(15000);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected int getMaxConnections() {
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue