Jetson Inference
DNN Vision Library
gstDecoder Class Reference

Hardware-accelerated video decoder for Jetson using GStreamer. More...

#include <gstDecoder.h>

Inheritance diagram for gstDecoder:
videoSource

Public Member Functions

 ~gstDecoder ()
 Destructor. More...
 
virtual bool Capture (void **image, imageFormat format, uint64_t timeout=DEFAULT_TIMEOUT, int *status=NULL)
 Capture the next decoded frame. More...
 
virtual bool Open ()
 Open the stream. More...
 
virtual void Close ()
 Close the stream. More...
 
bool IsEOS () const
 Return true if End Of Stream (EOS) has been reached. More...
 
virtual uint32_t GetType () const
 Return the interface type (gstDecoder::Type) More...
 
- Public Member Functions inherited from videoSource
virtual ~videoSource ()
 Destroy interface and release all resources. More...
 
template<typename T >
bool Capture (T **image, int *status)
 Capture the next image from the video stream, using the default timeout of 1000ms. More...
 
template<typename T >
bool Capture (T **image, uint64_t timeout=DEFAULT_TIMEOUT, int *status=NULL)
 Capture the next image from the video stream. More...
 
bool IsStreaming () const
 Check if the device is actively streaming or not. More...
 
uint32_t GetWidth () const
 Return the width of the stream, in pixels. More...
 
uint32_t GetHeight () const
 Return the height of the stream, in pixels. More...
 
uint32_t GetFrameRate () const
 Return the framerate, in Hz or FPS. More...
 
uint64_t GetFrameCount () const
 Return the number of frames captured. More...
 
uint64_t GetLastTimestamp () const
 Get timestamp of the last captured frame, in nanoseconds. More...
 
imageFormat GetRawFormat () const
 Get raw image format. More...
 
const URIGetResource () const
 Return the resource URI of the stream. More...
 
const videoOptionsGetOptions () const
 Return the videoOptions of the stream. More...
 
bool IsType (uint32_t type) const
 Check if this stream is of a particular type. More...
 
template<typename T >
bool IsType () const
 Check if a this stream is of a particular type. More...
 
const char * TypeToStr () const
 Convert this stream's class type to string. More...
 

Static Public Member Functions

static gstDecoderCreate (const videoOptions &options)
 Create a decoder from the provided video options. More...
 
static gstDecoderCreate (const URI &resource, videoOptions::Codec codec)
 Create a decoder instance from resource URI and codec. More...
 
static bool IsSupportedExtension (const char *ext)
 Return true if the extension is in the list of SupportedExtensions. More...
 
- Static Public Member Functions inherited from videoSource
static videoSourceCreate (const videoOptions &options)
 Create videoSource interface from a videoOptions struct that's already been filled out. More...
 
static videoSourceCreate (const char *URI, const videoOptions &options=videoOptions())
 Create videoSource interface from a resource URI string and optional videoOptions. More...
 
static videoSourceCreate (const char *URI, const commandLine &cmdLine)
 Create videoSource interface from a resource URI string and parsing command line arguments. More...
 
static videoSourceCreate (const char *URI, const int argc, char **argv)
 Create videoSource interface from a resource URI string and parsing command line arguments. More...
 
static videoSourceCreate (const int argc, char **argv, int positionArg=-1)
 Create videoSource interface by parsing command line arguments, including the resource URI. More...
 
static videoSourceCreate (const commandLine &cmdLine, int positionArg=-1)
 Create videoSource interface by parsing command line arguments, including the resource URI. More...
 
static const char * Usage ()
 Usage string for command line arguments to Create() More...
 
static const char * TypeToStr (uint32_t type)
 Convert a class type to a string. More...
 

Static Public Attributes

static const uint32_t Type = (1 << 1)
 Unique type identifier of gstDecoder class. More...
 
static const char * SupportedExtensions []
 String array of supported video file extensions, terminated with a NULL sentinel value. More...
 
- Static Public Attributes inherited from videoSource
static const uint64_t DEFAULT_TIMEOUT =1000
 The default Capture timeout (1000ms) More...
 

Protected Member Functions

 gstDecoder (const videoOptions &options)
 
void checkMsgBus ()
 
void checkBuffer ()
 
bool buildLaunchStr ()
 
bool discover ()
 
bool init ()
 
bool initPipeline ()
 
void destroyPipeline ()
 
bool isLooping () const
 
- Protected Member Functions inherited from videoSource
 videoSource (const videoOptions &options)
 

Static Protected Member Functions

static void onEOS (_GstAppSink *sink, void *user_data)
 
static GstFlowReturn onPreroll (_GstAppSink *sink, void *user_data)
 
static GstFlowReturn onBuffer (_GstAppSink *sink, void *user_data)
 
static void onWebsocketMessage (WebRTCPeer *peer, const char *message, size_t message_size, void *user_data)
 

Protected Attributes

GstBus * mBus
 
GstElement * mPipeline
 
_GstAppSink * mAppSink
 
Event mWaitEvent
 
std::string mLaunchStr
 
bool mCustomSize
 
bool mCustomRate
 
bool mEOS
 
size_t mLoopCount
 
gstBufferManagermBufferManager
 
WebRTCServermWebRTCServer
 
bool mWebRTCConnected
 
- Protected Attributes inherited from videoSource
bool mStreaming
 
videoOptions mOptions
 
uint64_t mLastTimestamp
 
imageFormat mRawFormat
 

Additional Inherited Members

- Public Types inherited from videoSource
enum  Status { ERROR = -2, EOS = -1, TIMEOUT = 0, OK = 1 }
 Stream status codes that are optionally returned from Capture() More...
 

Detailed Description

Hardware-accelerated video decoder for Jetson using GStreamer.

gstDecoder supports loading video files from disk (MKV, MP4, AVI, FLV) and RTP/RTSP network streams over UDP/IP. The supported decoder codecs are H.264, H.265, VP8, VP9, MPEG-2, MPEG-4, and MJPEG.

Note
gstDecoder implements the videoSource interface and is intended to be used through that as opposed to directly. videoSource implements additional command-line parsing of videoOptions to construct instances.
See also
videoSource

Constructor & Destructor Documentation

◆ ~gstDecoder()

gstDecoder::~gstDecoder ( )

Destructor.

◆ gstDecoder()

gstDecoder::gstDecoder ( const videoOptions options)
protected

Member Function Documentation

◆ buildLaunchStr()

bool gstDecoder::buildLaunchStr ( )
protected

◆ Capture()

virtual bool gstDecoder::Capture ( void **  image,
imageFormat  format,
uint64_t  timeout = DEFAULT_TIMEOUT,
int *  status = NULL 
)
virtual

Capture the next decoded frame.

See also
videoSource::Capture()

Implements videoSource.

◆ checkBuffer()

void gstDecoder::checkBuffer ( )
protected

◆ checkMsgBus()

void gstDecoder::checkMsgBus ( )
protected

◆ Close()

virtual void gstDecoder::Close ( )
virtual

Close the stream.

See also
videoSource::Close()

Reimplemented from videoSource.

◆ Create() [1/2]

static gstDecoder* gstDecoder::Create ( const URI resource,
videoOptions::Codec  codec 
)
static

Create a decoder instance from resource URI and codec.

◆ Create() [2/2]

static gstDecoder* gstDecoder::Create ( const videoOptions options)
static

Create a decoder from the provided video options.

◆ destroyPipeline()

void gstDecoder::destroyPipeline ( )
protected

◆ discover()

bool gstDecoder::discover ( )
protected

◆ GetType()

virtual uint32_t gstDecoder::GetType ( ) const
inlinevirtual

Return the interface type (gstDecoder::Type)

Reimplemented from videoSource.

◆ init()

bool gstDecoder::init ( )
protected

◆ initPipeline()

bool gstDecoder::initPipeline ( )
protected

◆ IsEOS()

bool gstDecoder::IsEOS ( ) const
inline

Return true if End Of Stream (EOS) has been reached.

In the context of gstDecoder, EOS means that playback has reached the end of the file, and looping is either disabled or all loops have already been run. In the case of RTP/RTSP, it means that the stream has terminated.

◆ isLooping()

bool gstDecoder::isLooping ( ) const
inlineprotected

◆ IsSupportedExtension()

static bool gstDecoder::IsSupportedExtension ( const char *  ext)
static

Return true if the extension is in the list of SupportedExtensions.

Parameters
extstring containing the extension to be checked (should not contain leading dot)
See also
SupportedExtensions for the list of supported Video Streaming file extensions.

◆ onBuffer()

static GstFlowReturn gstDecoder::onBuffer ( _GstAppSink *  sink,
void *  user_data 
)
staticprotected

◆ onEOS()

static void gstDecoder::onEOS ( _GstAppSink *  sink,
void *  user_data 
)
staticprotected

◆ onPreroll()

static GstFlowReturn gstDecoder::onPreroll ( _GstAppSink *  sink,
void *  user_data 
)
staticprotected

◆ onWebsocketMessage()

static void gstDecoder::onWebsocketMessage ( WebRTCPeer peer,
const char *  message,
size_t  message_size,
void *  user_data 
)
staticprotected

◆ Open()

virtual bool gstDecoder::Open ( )
virtual

Open the stream.

See also
videoSource::Open()

Reimplemented from videoSource.

Member Data Documentation

◆ mAppSink

_GstAppSink* gstDecoder::mAppSink
protected

◆ mBufferManager

gstBufferManager* gstDecoder::mBufferManager
protected

◆ mBus

GstBus* gstDecoder::mBus
protected

◆ mCustomRate

bool gstDecoder::mCustomRate
protected

◆ mCustomSize

bool gstDecoder::mCustomSize
protected

◆ mEOS

bool gstDecoder::mEOS
protected

◆ mLaunchStr

std::string gstDecoder::mLaunchStr
protected

◆ mLoopCount

size_t gstDecoder::mLoopCount
protected

◆ mPipeline

GstElement* gstDecoder::mPipeline
protected

◆ mWaitEvent

Event gstDecoder::mWaitEvent
protected

◆ mWebRTCConnected

bool gstDecoder::mWebRTCConnected
protected

◆ mWebRTCServer

WebRTCServer* gstDecoder::mWebRTCServer
protected

◆ SupportedExtensions

const char* gstDecoder::SupportedExtensions[]
static

String array of supported video file extensions, terminated with a NULL sentinel value.

The supported extension are:

  • MKV
  • MP4 / QT
  • AVI
  • FLV
See also
IsSupportedExtension() to check a string against this list.

◆ Type

const uint32_t gstDecoder::Type = (1 << 1)
static

Unique type identifier of gstDecoder class.


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