nx_server_plugin_sdk 1.0 Server Plugin SDK

media_encoder.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2
3 #ifndef RPI_MEDIA_ENCODER_H
4 #define RPI_MEDIA_ENCODER_H
5
6 #include <memory>
7
8 #include <camera/camera_plugin.h>
9
10 #include "ref_counter.h"
11 #include "stream_reader.h"
12
13 namespace rpi_cam
14 {
15 class RPiCamera;
16
18 class MediaEncoder : public DefaultRefCounter<nxcip::CameraMediaEncoder3>
19 {
20 public:
21 MediaEncoder(std::shared_ptr<RPiCamera> camera, unsigned encoderNumber);
22 virtual ~MediaEncoder();
23
24 // nxpl::PluginInterface
25
26 virtual void * queryInterface( const nxpl::NX_GUID& interfaceID ) override;
27
28 // nxcip::CameraMediaEncoder
29
30 virtual int getMediaUrl( char* urlBuf ) const override;
31 virtual int getResolutionList( nxcip::ResolutionInfo* infoList, int* infoListCount ) const override;
32 virtual int getMaxBitrate( int* maxBitrate ) const override;
33 virtual int setResolution( const nxcip::Resolution& resolution ) override;
34 virtual int setFps( const float&, float* selectedFps ) override;
35 virtual int setBitrate( int bitrateKbps, int* selectedBitrateKbps ) override;
36
37 // nxcip::CameraMediaEncoder2
38
39 virtual nxcip::StreamReader* getLiveStreamReader() override;
40 virtual int getAudioFormat( nxcip::AudioFormat* audioFormat ) const override;
41
42 // nxcip::CameraMediaEncoder3
43
44 virtual int getConfiguredLiveStreamReader(nxcip::LiveStreamConfig * config, nxcip::StreamReader ** reader) override;
45 virtual int getVideoFormat(nxcip::CompressionType * codec, nxcip::PixelFormat * pixelFormat) const override;
46
47 private:
48 std::weak_ptr<RPiCamera> m_camera;
49 unsigned m_encoderNumber;
50 unsigned m_bitrateKbps;
51 };
52 }
53
54 #endif
rpi_cam::MediaEncoder::getVideoFormat
virtual int getVideoFormat(nxcip::CompressionType *codec, nxcip::PixelFormat *pixelFormat) const override
Returns video format. Optional method.
Definition: media_encoder.cpp:101
rpi_cam::MediaEncoder::setFps
virtual int setFps(const float &, float *selectedFps) override
Definition: media_encoder.cpp:86
rpi_cam::MediaEncoder::getMaxBitrate
virtual int getMaxBitrate(int *maxBitrate) const override
Returns maximum bitrate in Kbps. 0 is interpreted as unlimited bitrate value.
Definition: media_encoder.cpp:75
rpi_cam::MediaEncoder::setBitrate
virtual int setBitrate(int bitrateKbps, int *selectedBitrateKbps) override
Definition: media_encoder.cpp:91
rpi_cam
Raspberry Pi camera unit and configuration.
Definition: camera_manager.cpp:21
nxcip::LiveStreamConfig
Definition: camera_plugin.h:441
nxcip::ResolutionInfo
Contains resolution and maximum fps, supported by camera for this resolution.
Definition: camera_plugin.h:282
rpi_cam::MediaEncoder::getAudioFormat
virtual int getAudioFormat(nxcip::AudioFormat *audioFormat) const override
Returns audio format, if audio is supported.
Definition: media_encoder.cpp:96
nxcip::AudioFormat
Definition: camera_plugin.h:362
nxcip::StreamReader
Used for reading media stream from camera.
Definition: camera_plugin.h:1168
nxpl::NX_GUID
GUID of plugin interface.
Definition: plugin_api.h:26
rpi_cam::MediaEncoder
Definition: media_encoder.h:18
nxcip::Resolution
Resolution of video stream picture.
Definition: camera_plugin.h:266
rpi_cam::MediaEncoder::getLiveStreamReader
virtual nxcip::StreamReader * getLiveStreamReader() override
Returns stream reader, providing live data stream.
Definition: media_encoder.cpp:106
rpi_cam::MediaEncoder::queryInterface
virtual void * queryInterface(const nxpl::NX_GUID &interfaceID) override
Cast to type, specified by interfaceID.
Definition: media_encoder.cpp:24
rpi_cam::MediaEncoder::getConfiguredLiveStreamReader
virtual int getConfiguredLiveStreamReader(nxcip::LiveStreamConfig *config, nxcip::StreamReader **reader) override
Returns configured stream reader, providing live data stream. Required method!
Definition: media_encoder.cpp:120
rpi_cam::DefaultRefCounter
Definition: ref_counter.h:11
rpi_cam::MediaEncoder::getResolutionList
virtual int getResolutionList(nxcip::ResolutionInfo *infoList, int *infoListCount) const override
Returns supported resolution list.
Definition: media_encoder.cpp:50
rpi_cam::MediaEncoder::getMediaUrl
virtual int getMediaUrl(char *urlBuf) const override
Returns url of media stream as NULL-terminated utf-8 string.
Definition: media_encoder.cpp:45
rpi_cam::MediaEncoder::setResolution
virtual int setResolution(const nxcip::Resolution &resolution) override
Change resolution on specified encoder.
Definition: media_encoder.cpp:81
nxcip::PixelFormat
PixelFormat
Definition: camera_plugin_types.h:39