WS '/api/http_audio' API endpoint

Answered

Comments

29 comments

  • Avatar
    Andrey Terentyev

    Hello Denis Rozhkov ,

    how to use this endpoint?
    what are prerequisites?

    Here is a quotation from the built-in API documentation.

    Please pay your attention, it should be a websocket connection, not plain HTTP/HTTS connection.

    I'd need more details for more specific assistance. What is your scenario? What is the final result, you'd like to achieve?
    Could you please share a code example of how you are trying to connect?
    Just place files (or an archive) on the Google drive or similar and post a link to it here.

    0
    Comment actions Permalink
  • Avatar
    Denis Rozhkov

    hi Andrey,

    i need to stream audio back from nx meta (mic) to the camera

    https://1drv.ms/u/s!Aox6-d_KSzT7g4cOxDm9OHB9_mLhLQ?e=Yzap2z

     

    0
    Comment actions Permalink
  • Avatar
    Denis Rozhkov

    hey,
    any comments? should i provide any additional info?

     

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hello Denis,

    Sorry for not responding.

    I got your code the same day. I'm working on it.
    At the moment, I try to create the simplest example of how to use that API.
    Please allow me some time.

    I'll update here as soon as I finish it.

    0
    Comment actions Permalink
  • Avatar
    Denis Rozhkov

    hi Andrey,
    thank you!

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hello Denis,

    Here is what I've found, so far.

    In the wavewsclient.cpp the code

    m_wsConnection = m_wsClient.get_connection(m_wsUri, ec);

    leads to an error having this string in the ec.message()

    endpoint not secure

    In fact, the get_connection() method does not pass this check (see the client_endpoint.hpp file)

    connection_ptr get_connection(uri_ptr location, lib::error_code & ec) {
    if (location->get_secure() && !transport_type::is_secure()) {
    ec = error::make_error_code(error::endpoint_not_secure);
    return connection_ptr();
    }
    ...

    I guess, transport_type has to be set to the secure type in the config of the m_wsClient, since wss (secured websocket) is supposed to be used.

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Just found one more thing.

    You define your client like this:

     typedef websocketpp::client<websocketpp::config::asio_client> t_wsClient;

    but the asio_client is TLS disabled type. See the  asio_no_tls_client.hpp for details.

    0
    Comment actions Permalink
  • Avatar
    Denis Rozhkov

    hi Andrey,
    thanks, so actually it's a WSS endpoint (not WS as stated in the documentation)?
    ok, i'll check it...

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    I suppose, you should use the asio_tls_client type for TLS support.

    typedef websocketpp::client<websocketpp::config::asio_tls_client> t_wsClient;
    0
    Comment actions Permalink
  • Avatar
    Denis Rozhkov

    Andrey,
    still doesn't work, and still HTTP 404:

    GET https://as-gm04:7001/api/http_audio?camera_id=a118a339-82ac-b8fa-d4bf-c2d7529534a2&format=s16be&sample_rate=22050&channels=1&auth=YWRtaW46NWNkNGZjYmUxNDFhODozMGY0NDk5YzM1ZTk2NjJlZWRiZDI2ZDM0YTQ4MTA5Zg== HTTP/1.1
    Host: as-gm04:7001
    Connection: Upgrade
    Upgrade: websocket
    Sec-WebSocket-Version: 13
    Sec-WebSocket-Key: M0lIo8NAvUCJO6affEauSg==

     

    HTTP/1.1 404 Not Found
    Date: Fri, 01 Oct 2021 22:50:37 +0300
    Server: Nx Meta/4.2.0.32836 (Network Optix) Apache/2.4.16 (MSWin)
    Connection: Keep-Alive
    Keep-Alive: timeout=5
    Content-Length: 0
    Access-Control-Allow-Origin: *

     

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hi Denis,

    Ok, I see a HTTPS connection has been established. That's progress.

    Could you please update the code by the link above to the current version?

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Denis,

    thanks, so actually it's a WSS endpoint (not WS as stated in the documentation)?

    Yes, starting with a certain build, HTTP has been disabled for all the communication types with the Server. All request are redirected to the HTTPS. Web API functions should be invoked using HTTPS.

    One more thing. We've recently rolled out a new early preview version (Meta 5.0 R3), which has a completely new REST API -- you can try it out. Although not all the API functions has been transferred there, it should be much more convenient to use: https://meta.nxvms.com/downloads/patches

    0
    Comment actions Permalink
  • Avatar
    Denis Rozhkov

    hi Andrey,

    the code is updated

     

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hello Denis,

    Try the  boost::asio::ssl::context::method::sslv23_client in the WsClient constructor.

    WsClient( const Uri & url )
    : m_url( url ),
    m_ctx( boost::asio::ssl::context::method::sslv23_client ),
    m_stream( m_io, m_ctx )
    {
    }

    It works for me.

    0
    Comment actions Permalink
  • Avatar
    Denis Rozhkov

    hi Andrey,

    finally i found the reason of 404 error - unstable RTSP connection.

    but now there is another problem - no data, just ping frames...

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hi Denis,

    There should not be any data. It's a websocket for sending audio stream TO a camera, not for retrieving audio from a camera.

    Could you give more details about your scenario? What's the finale objective, the expected final result?

    0
    Comment actions Permalink
  • Avatar
    Denis Rozhkov

    hi Andrey,

    just a reminder:

    i need to stream audio back from nx meta (mic) to the camera

     

    i am pressing mic icon (in nx meta/wave vms client), speaking (so i see input level meter) and... nothing

     

    0
    Comment actions Permalink
  • Avatar
    Denis Rozhkov

    anyway, can you just answer these questions:

    how to use this endpoint?
    what are prerequisites?

     

    what i found yet:

    - camera must advertise audio output capability (is there any method to do this other than implementing ONVIF services?)

    - RTSP stream must be alive

     

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hello Denis,

    how to use this endpoint?

    You just send an audio file of the PCM stream to the opened websocket.

    what are prerequisites?

    The device (a camera or an I/O module) has to support 2-way audio. The "Enable Audio" flag has to be set in the GUI.

    (is there any method to do this other than implementing ONVIF services?)

    If a camera does not support ONVIF, you can develop your own camera driver (a plugin) with Video source SDK.

     

    0
    Comment actions Permalink
  • Avatar
    Denis Rozhkov

    hi Andrey,

    You just send an audio file of the PCM stream to the opened websocket.

    and audio will be sent via RTSP backchannel to the camera?

     

    if i understand all right - Wisenet's support doesn't understand how system works. They were asked how it's possible to send audio from the (WAVE VMS) client app to the camera (except RTSP backchannel) and they suggested to use:
    1. Video Source SDK
    2. WS endpoint

    and both options are not suitable for the task...

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Denis,

    and audio will be sent via RTSP backchannel to the camera?

    Yes, it will. You can get the audio from the camera via https://localhost:7001/media/<cameraId>.<format> API by passing the audio_only parameter.

    0
    Comment actions Permalink
  • Avatar
    Denis Rozhkov

    Audio _from_ the camera is not a problem, the problem is how to send audio stream form WAVE VMS client _to_ the camera (without RTSP backchannel)...

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Denis,

    They were asked how it's possible to send audio from the (WAVE VMS) client app

    That's something more about your scenario. And that's something different from what we are discussing here.

    Tell me more about the scenario, user case, business case, please.

    For instance. Are you developing your own external web service (or GUI application) because business needs call operators to... ? Do you need this application/service be accessible via VMS GUI application? etc.

    You see, I don't stop asking you about that just because we have code examples and those could suite you right away without the long discussion and debugging code specifics.

     

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Denis,

    and audio will be sent via RTSP backchannel to the camera?

    Audio _from_ the camera is not a problem, the problem is how to send audio stream form WAVE VMS client _to_ the camera (without RTSP backchannel)...

    I'm sorry. I did not understand you.

    The answer is NO. When send audio to a camera (in fact to the Server) via a websokcket there is only a websocket. No RTSP.

    1. You send audio to the Server via a websocket.

    2. The Server sends audio to a camera.

    0
    Comment actions Permalink
  • Avatar
    Denis Rozhkov

    Tell me more about the scenario, user case, business case, please.


    hmm...

    i need to stream audio back from nx meta (mic) to the camera

    so basically i need to press mic icon in the WAVE VMS client, say something and receive this mic input on the camera side. that's all. and again - without RTSP backchannel.

     

    and we were informed by Hanwha/Wisenet that this can be achieved with Video Source SDK or WS API. but it's just not true.

     

    0
    Comment actions Permalink
  • Avatar
    Denis Rozhkov

    2. The Server sends audio to a camera.

    oh, and what transport is used?

     

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    oh, and what transport is used?

    To send audio from the Server to a camera, RTSP backchannel is used.

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Denis,

    so basically i need to press mic icon in the WAVE VMS client, say something and receive this mic input on the camera side. that's all. and again - without RTSP backchannel.

    Could you please share with us where, why and what for did the requirement "without RTSP backchannel" come from? What are the specifics of your case?

    0
    Comment actions Permalink
  • Avatar
    Denis Rozhkov

    Where, why and what for did this requirement "without RTSP backchannel" come from?

    that doesn't matter. in general we wanted to implement some lightweight transport, we can do this (with Video Source SDK) for input streams, so we were interesting if it's possible for audio output. and as it's revealed now we were misinformed that it's possible.

    anyway, thanks for clarification.

     

    0
    Comment actions Permalink

Please sign in to leave a comment.