Hi @Dulce Polinar,
Here is a sample code on Java for Video Push in application that uses MIP SDK Mobile. The steps that should be followed are:
1. Connect to Milestone Mobile Server.
2. Login to the server.
3. Request a video push channel.
4. Push all the frames that you want with an incremented frame number.
5. Call stopVideoStream command from the MIP SDK Mobile to close the opened channel.
And the code is:
private static String videoChannelID = “”;
private void requestNewPushChannel(){
xpMobileSDK.requestVideoStream(null, null, null, null, CommunicationCommand.PARAM_SIGNAL_UPLOAD, CommunicationCommand.PARAM_METHOD_PULL, null, new SuccessCallback() {
@Override
public void onSuccess(CommunicationCommand response) {
_videoChannelID_ \= response.getOutputParam().get("VideoId");
//After the received video push channel ID, you could start sending frames to the Mobile server.
}
}, new ErrorCallback() {
@Override
public void onErrorOccurred(CommunicationCommand cmd) {
//Error occurred when requestVideoStream was called.
}
});
}
/**
* Pushes frames to the Mobile server. Before sending your frames to the Mobile server, you should request a new video channel id. Then you can send all the frames by calling pushFrame method. When you want to stop sending frames, you should stop calling pushFrame method and call stopVideoStream command from the Mobile SDK.
* @param frameAsByteArray - the frame that will be pushed to the Mobile Server. It should be in JPEG format.
* @param frameNumber - number of the frame. Every next should be incremented with 1
*/
private void pushFrame(final byte[] frameAsByteArray,int frameNumber) {
if (videoChannelID != null && !videoChannelID.equals(“”)) {
String videoAlias = new StringBuilder("/").append(_communicationAlias_).append("/Video/").append(_videoChannelID_).append('/').toString();
try {
HTTPConnection conn = new HTTPConnection(address, port, videoAlias);
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
byte\[\] hBuffer = new byte\[36\];
bOut.write(hBuffer);
bOut.write(frameAsByteArray);
VideoCommand vcmd = new VideoCommand(_videoChannelID_);
byte\[\] frameBuffer = bOut.toByteArray();
vcmd.refactorMainHeader(frameBuffer, frameNumber, System._currentTimeMillis_());
conn.sendByteArrayRequest(frameBuffer);
} catch (IOException e) {
//Handle the IOException ...
}
}
}