use of org.jivesoftware.smackx.jingleold.listeners.JingleMediaListener in project Smack by igniterealtime.
the class MediaNegotiator method triggerMediaEstablished.
// Events
/**
* Trigger a session established event.
*
* @param bestPt
* payload type that has been agreed.
* @throws NotConnectedException
* @throws InterruptedException
*/
protected void triggerMediaEstablished(PayloadType bestPt) throws NotConnectedException, InterruptedException {
List<JingleListener> listeners = getListenersList();
for (JingleListener li : listeners) {
if (li instanceof JingleMediaListener) {
JingleMediaListener mli = (JingleMediaListener) li;
mli.mediaEstablished(bestPt);
}
}
}
use of org.jivesoftware.smackx.jingleold.listeners.JingleMediaListener in project Smack by igniterealtime.
the class MediaNegotiator method triggerMediaClosed.
/**
* Trigger a jmf closed event.
*
* @param currPt
* current payload type that is cancelled.
*/
protected void triggerMediaClosed(PayloadType currPt) {
List<JingleListener> listeners = getListenersList();
for (JingleListener li : listeners) {
if (li instanceof JingleMediaListener) {
JingleMediaListener mli = (JingleMediaListener) li;
mli.mediaClosed(currPt);
}
}
}
use of org.jivesoftware.smackx.jingleold.listeners.JingleMediaListener in project Smack by igniterealtime.
the class JingleSession method setupListeners.
/**
* Setup the listeners that act on events coming from the lower level negotiators.
*/
public void setupListeners() {
JingleMediaListener jingleMediaListener = new JingleMediaListener() {
@Override
public void mediaClosed(PayloadType cand) {
}
@Override
public void mediaEstablished(PayloadType pt) throws NotConnectedException, InterruptedException {
if (isFullyEstablished()) {
Jingle jout = new Jingle(JingleActionEnum.SESSION_ACCEPT);
// Build up a response packet from each media manager.
for (ContentNegotiator contentNegotiator : contentNegotiators) {
if (contentNegotiator.getNegotiatorState() == JingleNegotiatorState.SUCCEEDED)
jout.addContent(contentNegotiator.getJingleContent());
}
// Send the "accept" and wait for the ACK
addExpectedId(jout.getStanzaId());
sendStanza(jout);
//triggerSessionEstablished();
}
}
};
JingleTransportListener jingleTransportListener = new JingleTransportListener() {
@Override
public void transportEstablished(TransportCandidate local, TransportCandidate remote) throws NotConnectedException, InterruptedException {
if (isFullyEstablished()) {
// CHECKSTYLE:OFF
// Indicate that this session is active.
setSessionState(JingleSessionStateActive.getInstance());
for (ContentNegotiator contentNegotiator : contentNegotiators) {
// CHECKSTYLE:ON
if (contentNegotiator.getNegotiatorState() == JingleNegotiatorState.SUCCEEDED)
contentNegotiator.triggerContentEstablished();
}
if (getSessionState().equals(JingleSessionStatePending.getInstance())) {
Jingle jout = new Jingle(JingleActionEnum.SESSION_ACCEPT);
// Build up a response packet from each media manager.
for (ContentNegotiator contentNegotiator : contentNegotiators) {
if (contentNegotiator.getNegotiatorState() == JingleNegotiatorState.SUCCEEDED)
jout.addContent(contentNegotiator.getJingleContent());
}
// Send the "accept" and wait for the ACK
addExpectedId(jout.getStanzaId());
sendStanza(jout);
}
}
}
@Override
public void transportClosed(TransportCandidate cand) {
}
@Override
public void transportClosedOnError(XMPPException e) {
}
};
addMediaListener(jingleMediaListener);
addTransportListener(jingleTransportListener);
}
Aggregations