...
3. Send /call/inject_stream/startup query to inject stream from a local file
4. Injected file contents is displayed in softphone video window
...
5. Send /call/inject_stream/terminate query to stop stream injection
Custom SIP messages listener implementation
In some cases, additional handling of incoming SIP messages is required. To do this, a custom Java class implementing ISipMessageListener
should be developed to catch incoming SIP messages and handle them as needed.
Look at the example to add port to Request URI of INVITE request if port is not set by callee. Here is the class source code:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
package com.customListener;
import com.flashphoner.sdk.sip.ISipMessageListener;
import com.flashphoner.server.client.IClient;
import gov.nist.javax.sip.address.Authority;
import gov.nist.javax.sip.address.SipUri;
import gov.nist.javax.sip.message.SIPMessage;
import gov.nist.javax.sip.message.SIPRequest;
import gov.nist.javax.sip.stack.MessageChannel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.sip.message.Request;
public class customSipMessageListener implements ISipMessageListener {
private static Logger log = LoggerFactory.getLogger("customSipMessageListener");
@Override
public void processMessage(SIPMessage sipMessage, IClient client, MessageChannel channel) {
if (sipMessage instanceof SIPRequest) {
SIPRequest request = (SIPRequest) sipMessage;
String method = request.getRequestLine().getMethod();
if (Request.INVITE.equals(method)) {
Authority authority = ((SipUri)request.getRequestURI()).getAuthority();
int port = authority.getPort();
if (port <= 0) {
if (log.isDebugEnabled()) {
log.debug("Inject port " + channel.getPort());
}
authority.setPort(channel.getPort());
}
}
}
}
} |
Make the folder structure in home directory on server
Code Block | ||||
---|---|---|---|---|
| ||||
mkdir -p com/customListener |
Copy the class source code to the folder created and compile it
Code Block | ||||
---|---|---|---|---|
| ||||
javac -cp "/usr/local/FlashphonerWebCallServer/lib/*" ./com/customListener/customSipMessageListener.java |
Pack the class compiled to the jar file
Code Block | ||||
---|---|---|---|---|
| ||||
jar cf customSipMessageListener.jar com/customListener/customSipMessageListener.class |
Copy jar file to server folder
Code Block | ||||
---|---|---|---|---|
| ||||
cp customSipMessageListener.jar /usr/local/FlashphonerWebCallServer/lib |
It is necessary to set the class developed to the following parameter in flashphoner.properties file
Code Block | ||||
---|---|---|---|---|
| ||||
sip_msg_listener=com.customListener.customSipMessageListener |
then restart server.
Incoming SIP call stream recording
Incoming SIP call streams can be recorded on server. Set the following parameter in flashphoner.properties file to record all the incoming SIP calls:
Code Block | ||
---|---|---|
| ||
sip_record_stream=true |
Use REST API query to record a certain SIP call stream.
Note that incoming SIP calls will not be recorded if the following setting is active
Code Block | ||
---|---|---|
| ||
sip_single_route_only=true |
Known issues
1. RTMP stream republished from incoming SIP call can be out of sync
Symptoms: SIP call stream is out of sync while playing it from RTMP server
Solution:
a) set the following parameter
Code Block | ||
---|---|---|
| ||
sip_force_rtcp_feedback=true |
b) minimize or exclude packet losses in channel between PBX and WCS