nx_server_plugin_sdk 1.0 Server Plugin SDK

Public Member Functions | List of all members
rpi_cam::MediaEncoder Class Reference
Inheritance diagram for rpi_cam::MediaEncoder:

## Public Member Functions
| MediaEncoder (std::shared_ptr< RPiCamera > camera, unsigned encoderNumber)
virtual void * | queryInterface (const nxpl::NX_GUID &interfaceID) override
| Cast to type, specified by interfaceID. More...
virtual int | getMediaUrl (char *urlBuf) const override
| Returns url of media stream as NULL-terminated utf-8 string. More...
virtual int | getResolutionList (nxcip::ResolutionInfo *infoList, int *infoListCount) const override
| Returns supported resolution list. More...
virtual int | getMaxBitrate (int *maxBitrate) const override
| Returns maximum bitrate in Kbps. 0 is interpreted as unlimited bitrate value. More...
virtual int | setResolution (const nxcip::Resolution &resolution) override
| Change resolution on specified encoder. More...
virtual int | setFps (const float &, float *selectedFps) override
virtual int | setBitrate (int bitrateKbps, int *selectedBitrateKbps) override
virtual nxcip::StreamReader * | getLiveStreamReader () override
| Returns stream reader, providing live data stream. More...
virtual int | getAudioFormat (nxcip::AudioFormat *audioFormat) const override
| Returns audio format, if audio is supported.
virtual int | getConfiguredLiveStreamReader (nxcip::LiveStreamConfig *config, nxcip::StreamReader **reader) override
| Returns configured stream reader, providing live data stream. Required method! More...
virtual int | getVideoFormat (nxcip::CompressionType *codec, nxcip::PixelFormat *pixelFormat) const override
| Returns video format. Optional method. More...
Public Member Functions inherited from rpi_cam::DefaultRefCounter< nxcip::CameraMediaEncoder3 >
virtual int | addRef () const override
virtual int | releaseRef () const override

## Additional Inherited Members
Protected Member Functions inherited from rpi_cam::DefaultRefCounter< nxcip::CameraMediaEncoder3 >
| DefaultRefCounter (nxpt::CommonRefManager *refManager)
Protected Attributes inherited from rpi_cam::DefaultRefCounter< nxcip::CameraMediaEncoder3 >
nxpt::CommonRefManager | m_refManager

## Member Function Documentation

## ◆ getConfiguredLiveStreamReader()

int MediaEncoder::getConfiguredLiveStreamReader | ( | nxcip::LiveStreamConfig * | config,
|  | nxcip::StreamReader ** | reader
| ) |  |
| override virtual

Returns configured stream reader, providing live data stream. Required method!

BaseCameraManager::nativeMediaStreamCapability should be present.

Parameters

  [in] | config |
  [out] | reader |

Returns
  nxcip::NX_NO_ERROR on success, otherwise - error code

Note
  It's possible to return both NULL as a reader and nxcip::NX_NO_ERROR as error code.
  - CameraMediaEncoder::getMediaUrl() will be used in this case.
  Using with this call setResolution(), setFps() and setBitrate() may return nxcip::NX_NOT_IMPLEMENTED

Implements nxcip::CameraMediaEncoder3.

## ◆ getLiveStreamReader()

nxcip::StreamReader * MediaEncoder::getLiveStreamReader | ( |  | ) |
| override virtual

Returns stream reader, providing live data stream.

This method is only used if BaseCameraManager::nativeMediaStreamCapability is present, otherwise CameraMediaEncoder::getMediaUrl is used

Can be used if camera uses some proprietary media stream control protocol or wants to provide motion information

Implements nxcip::CameraMediaEncoder2.

## ◆ getMaxBitrate()

int MediaEncoder::getMaxBitrate | ( | int * | maxBitrate | ) | const
| override virtual

Returns maximum bitrate in Kbps. 0 is interpreted as unlimited bitrate value.

Parameters

  [out] | maxBitrate | Returned value of max bitrate

Returns
  0 on success, otherwise - error code

Implements nxcip::CameraMediaEncoder.

## ◆ getMediaUrl()

int MediaEncoder::getMediaUrl | ( | char * | urlBuf | ) | const
| override virtual

Returns url of media stream as NULL-terminated utf-8 string.

Returned url MUST consider stream parameters set with setResolution, setFps, etc... Supported protocols:

- rtsp. RTP with h.264 and motion jpeg supported
- http. Motion jpeg only supported
  Parameters

    [out] | urlBuf | Buffer of size MAX_TEXT_LEN. MUST be NULL-terminated after return

  Returns
    0 on success, otherwise - error code

Implements nxcip::CameraMediaEncoder.

## ◆ getResolutionList()

int MediaEncoder::getResolutionList | ( | nxcip::ResolutionInfo * | infoList,
|  | int * | infoListCount
| ) |  | const
| override virtual

Returns supported resolution list.

Parameters

  [out] | infoList | Array of size MAX_RESOLUTION_LIST_SIZE
  [out] | infoListCount | Returned number of supported resolutions

Returns
  0 on success, otherwise - error code

Note
  Plugin is can return empty resolution list

Implements nxcip::CameraMediaEncoder.

## ◆ getVideoFormat()

int MediaEncoder::getVideoFormat | ( | nxcip::CompressionType * | codec,
|  | nxcip::PixelFormat * | pixelFormat
| ) |  | const
| override virtual

Returns video format. Optional method.

Parameters

  [out] | codec |
  [out] | pixelFormat | NOTE: Uncompressed video from a camera is not supported by the Server, thus the values AV_PIX_FMT_RGB24, AV_PIX_FMT_BGRA and AV_PIX_FMT_RGBA cannot be used.

Returns
  nxcip::NX_NO_ERROR on success, otherwise - error code

See also
  nxcip::CompressionType
  nxcip::PixelFormat

Implements nxcip::CameraMediaEncoder3.

## ◆ queryInterface()

void * MediaEncoder::queryInterface | ( | const nxpl::NX_GUID & | interfaceID | ) |
| override virtual

Cast to type, specified by interfaceID.

If pointer cannot be cast, NULL MUST be returned

Returns
  If not NULL, returned pointer can be safely cast to type, defined by interfaceID

Note
  This method increments reference counter

Implements nxpl::PluginInterface.

## ◆ setBitrate()

int MediaEncoder::setBitrate | ( | int | bitrateKbps,
|  | int * | selectedBitrateKbps
| ) |  |
| override virtual

Camera is allowed to select bitrate different from requested, but it should try to choose bitrate nearest to requested

Parameters

  [in] | bitrateKbps | Requested bitrate in kbps
  [out] | selectedBitrateKbps | *selectedBitrateKbps MUST be set to actual bitrate implied

Returns
  0 on success, otherwise - error code

Implements nxcip::CameraMediaEncoder.

## ◆ setFps()

int MediaEncoder::setFps | ( | const float & | fps,
|  | float * | selectedFps
| ) |  |
| override virtual

Camera is allowed to select fps different from requested, but it should try to choose fps nearest to requested

Parameters

  [in] | fps | Requested fps
  [out] | selectedFps | *selectedFps MUST be set to actual fps implied

Returns
  0 on success, otherwise - error code

Implements nxcip::CameraMediaEncoder.

## ◆ setResolution()

int MediaEncoder::setResolution | ( | const nxcip::Resolution & | resolution | ) |
| override virtual

Change resolution on specified encoder.

Parameters

  [in] | resolution |

Returns
  0 on success, otherwise - error code

Implements nxcip::CameraMediaEncoder.

The documentation for this class was generated from the following files:

- samples/device/rpi_camera_plugin/src/media_encoder.h
- samples/device/rpi_camera_plugin/src/media_encoder.cpp