Problem to get video stream from XProtectMobile

Hello,

I am developing an API to forward video from a Milestone server. Currently, I am using XProtectMobile to gather the necessary information. I have successfully obtained a valid ConnectionId by sending the appropriate XML request. Now, I am attempting to request a video stream and retrieve the video data.

Here is the XML I am sending to /XProtectMobile/Communication:

<?xml version="1.0" encoding="utf-8"?>

${token2}

<Type>Request</Type>

<Name>RequestStream</Name>

<InputParams>

  <Param Name="Fps" Value="30"/>

  <Param Name="DestHeight" Value="1920"/>

  <Param Name="StreamType" Value="Transcoded"/>

  <Param Name="KeyFramesOnly" Value="No"/>

  <Param Name="DestWidth" Value="1080"/>

  <Param Name="MethodType" Value="Push"/>

  <Param Name="ItemId" Value="${cameraUid}"/>

  <Param Name="SignalType" Value="Live"/>

  <Param Name="ComprLevel" Value="70"/>

  <Param Name="Time" Value="${timestamp}"/>

  <Param Name="TimeRangeBegin" Value="${timestamp}"/>

  <Param Name="TimeRangeEnd" Value="${timestamp+30}"/>

  <Param Name="ExportAvi" Value="Yes"/>

  <Param Name="ExportDatabase" Value="Yes"/>

  <Param Name="ExportJpeg" Value="Yes"/>

</InputParams>

<OutputParams/>

In response, I receive the StreamId and VideoId, for example:

<?xml version="1.0" encoding="utf-8"?>

11afaaae-cfdd-48dd-8405-f651559b6025

<Type>Response</Type>

<Name>RequestStream</Name>

<InputParams />

<OutputParams>

  <Param Name="Live" Value="Yes" />

  <Param Name="Playback" Value="Yes" />

  <Param Name="PTZ" Value="No" />

  <Param Name="Preset" Value="No" />

  <Param Name="ExportAvi" Value="Yes" />

  <Param Name="ExportDatabase" Value="Yes" />

  <Param Name="ExportJpeg" Value="Yes" />

  <Param Name="BookmarkAdd" Value="Yes" />

  <Param Name="BookmarkEdit" Value="Yes" />

  <Param Name="BookmarkView" Value="Yes" />

  <Param Name="BookmarkDelete" Value="Yes" />

  <Param Name="Sequences" Value="Yes" />

  <Param Name="VideoId" Value="75c2f983-54e8-49f7-9394-87cbea6698e2" />

  <Param Name="StreamId" Value="75c2f983-54e8-49f7-9394-87cbea6698e2" />

  <Param Name="ByteOrder" Value="LittleEndian" />

  <Param Name="StreamType" Value="Transcoded" />

  <Param Name="SrcWidth" Value="1920" />

  <Param Name="SrcHeight" Value="1080" />

</OutputParams>

<Items />

<Result>OK</Result>

At this point, I am trying to retrieve the stream and send it to my frontend application. I have attempted to fetch the stream using Axios and directly in Postman at /XProtectMobile/Video/, but I am not receiving any data. This issue is blocking my progress.

Additionally, I have a few questions:

Once I obtain the stream, do I need to use the command to manage the stream, such as changing the speed or retrieving a different time of the video, or do I need to make another stream request?

If I want to implement multi-camera playback, is it better to try to manage this with the Milestone stream or to create two separate streams?

Have a nice day,

Thanks for your help

Hello!

To be able to help you we need more information about which mobile sdk you use - mipsdk-mobile-iOS, mipsdk-mobile-Android, mipsdkmobile-web? What frontend application you are developing?

Thanks!

Have a nice day!

Hello,

Thank you for your message. I am using mipsdkmobile-web for my project. On the frontend, I am developing with Next.js, and I have set up an API using Fastify to handle and forward information provided by the mobile SDK. My implementation is based on the guidelines and protocols outlined in the documentation available at Milestone Systems Developer Documentation. https://doc.developer.milestonesys.com/mipsdkmobile/index.html?base=reference/protocols/mobile_appendix.html&tree=tree_1.html

Looking forward to your assistance.

Best regards,

Hi Thibault,

Thanks for reaching out! Have you checked documentation for mipsdkmobile-web javascript library? You can see it here: https://doc.developer.milestonesys.com/mipsdkmobile/reference/WebSDKdoc/index.html

I think the section for VideoConnection could be helpful for you: https://doc.developer.milestonesys.com/mipsdkmobile/reference/WebSDKdoc/VideoConnection.html

You can also check the usage of it in mipsdkmobile-web samples here: https://github.com/milestonesys/mipsdkmobile-web/blob/main/Samples/lib/js/application.js

Let me know if that helps. Have a great day!

Best regards,

Cagri Kayalar

Hi,

I’m currently having trouble using the jDataView library to decode a video frame. It seems the code I’m working with might be outdated, as the method calls mentioned in the documentation no longer seem to exist. Specifically, I’m referring to the protocol details found in the Milestone Systems documentation: https://doc.developer.milestonesys.com/mipsdkmobile/index.html?base=reference/protocols/mobile_appendix.html&tree=tree_1.html.

image.png

From what I understand, jDataView is a library mentioned in their documentation for manipulating and reading binary data, which is essential for decoding video frames according to their protocol. However, while searching for additional examples and information online, I noticed your not using

jDataView in the examples I found, including the one you provided, this is not matching what is described in the official documentation.

This discrepancy is making it difficult to proceed with correctly decoding the frame. Do you have any suggestions or updated examples on how to properly decode the frame using jDataView ? Any guidance or resources you could point me to would be greatly appreciated.

Thank you!

Best regards,

Have a nice day !

Hi Thibault,

You are right that some of the documentation seems to be outdated. As far as I can see, you don’t need to use jDataView. As I suggested in my previous post, you can use mipsdkmobile-web library. If you add videoConnectionObserver after getting videoConnection, then you should be able to get the frames through videoConnectionReceivedFrame event.

Here is a small sample:

    var videoConnectionObserver = {
      videoConnectionReceivedFrame: videoConnectionReceivedFrame,
    };
 
    var streamRequest = XPMobileSDK.RequestStream(
      RequestStreamParams(Id, "Live"),
      requestStreamCallback,
      function (error) {},
    );
 
    function requestStreamCallback(videoConnection) {
      videoController = videoConnection;
      videoConnection.addObserver(videoConnectionObserver);
      videoConnection.open();
    }
 
    function videoConnectionReceivedFrame(frame) {
      //draw frame
    }

You can see the full code sample here: https://github.com/milestonesys/mipsdkmobile-web/blob/main/Samples/lib/js/application.js

Let me know if you have any questions.

Have a great day!

Best regards.

/Cagri