Get video from 3rd party NVR using video source SDK




  • Avatar
    Andrey Terentyev

    Hello Doug,

    Now my question is , can the Nx plugin allow reading video playback from this 3rd party DVR and play it directly on Nx client  ?

    Yes, it allows reading video recordings from 3rd party DVR, however video won't be played directly to NX client. First it will go to the Server and only afterward to Nx Client.

    If the answer is yes , can you share some sample code for how to support the playback function ? any NVR/DVR brand sample code  would be good ... we just need to have more clarity on how this could be implemented

    There is no sample code which would cover NVR/DVE specifics. Nevertheless, here is what I would recommend you.

    See the image_library_plugin code of the Video Source SDK. It's a good, relevant example.

    Here are some notes covering specifics while working with NVR/DVR.

    VMS Camera Integration Plugin API (c++)
    Contains structures and abstract classes to be implemented in real plugin.
    The following interfaces can be implemented by a plugin:

    • nxcip::CameraDiscoveryManager. Mandatory. Used to discover camera and instantiate nxcip::BaseCameraManager

    There are several extension classes available for the CameraDiscoverManager, i.e. CameraDiscoverManager2, CameraDiscoverManager3, depending on your needs. The instance should not be destroyed until the plugin binary is unloaded (i.e. Server stops). Must implement the createCameraManager() method, returning a pointer to the BaseCameraManager class instance. There are several extension classes available for the BaseCameraManager, i.e.BaseCameraManager2, BaseCameraManager3, depending on your need. In your case, you need to create an instance of the BaseCameraManager2.

    • nxcip::BaseCameraManager. Mandatory. Is used to get camera properties and get pointers to other interfaces

    The instance of this class should not be destroyed until the plugin binary is unloaded (i.e. Server stops). As it's mentioned above, it must be an instance of the BaseCameraManager2 class. The class instance must implement the getCameraCapabilities() method, returning in your case the dtsArchiveCapability flag set.

    The instance must implement the createDtsArchiveReader( DtsArchiveReader** dtsArchiveReader ) method, creating and returning to the second output parameter a pointer to a DtsArchiveReader class instance.

    The DtsArchiveReader class implies that you implement the setQuality() method. See the camera_plugin.h file.

    The BaseCameraManager2 instance must implement the getEncoder(int encoderIndex, CameraMediaEncoder** encoderPtr) method returning to the second output parameter in your case a pointer to a CameraMediaEncoder2 class instance. 

    • nxcip::CameraMediaEncoder. Optional. Is ised to get media stream from camera

    In your case, it should be a CameraMediaEncoder2 class instance

    • nxcip::CameraRelayIOManager. Optional. Is used to receive relay input port change state events and change relay output port state
    • nxcip::CameraPtzManager. Optional. Is used for pan-tilt-zoom control.
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    DtsArchiveReader::startTime() must be implemented to return a timestamp (usec (microseconds) since 1970-01-01, UTC) of oldest data, present in the archive on an NVR.

    DtsArchiveReader::endTime() must be implemented a timestamp (usec (microseconds) since 1970-01-01, UTC) of newest data, present in the archive on an NVR.

    The methods are called by the Server.

    If by invoking the DtsArchiveReader::seek(unsigned int cSeq, UsecUTCTimestamp timestamp, bool findKeyFrame, UsecUTCTimestamp *selectedPosition) method, the Server passes the position parameter.

    You return NX_NO_DATA if a timestamp is greater than timestamp of the last frame of the archive (in case of if forward play) and

    if a timestamp is less than timestamp of the first frame of the archive (in case of reverse play)

    In other words, if position < startTime() and position > endTime() .

    You should return NX_NO_ERROR on success, and return to the selectedPosition the nearest timestamp found to the requested in the timestamp.


    Several notes regarding cSeq.

    The Server passes command sequence number  cSeq (command sequence counter) to the several methods.

    Methods DtsArchiveReader::seek, DtsArchiveReader::setReverseMode, DtsArchiveReader::playRange accept cSeq value which they MUST use in every media packet generated in response to this command

    When the Server calls any of these methods, it passes cSeq, which should be saved inside the plugin. The getNexData() method MUST return the data packet corresponding to the last cSeq received and saved. It means cSeq in the data packet MUST be the last cSeq has been passed.

    Comment actions Permalink

Please sign in to leave a comment.