docs/html/videoOutput_8h_source.html
| | Jetson Inference
DNN Vision Library |
videoOutput.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23 #ifndef __VIDEO_OUTPUT_H_
24 #define __VIDEO_OUTPUT_H_
25
26
27 #include "videoOptions.h"
28 #include "imageFormat.h"
29 #include "commandLine.h"
30
31 #include <vector>
32
33
38 #define VIDEO_OUTPUT_USAGE_STRING "videoOutput arguments: \n" \
39 " output resource URI of the output stream, for example:\n" \
40 " * file://my_image.jpg (image file)\n" \
41 " * file://my_video.mp4 (video file)\n" \
42 " * file://my_directory/ (directory of images)\n" \
43 " * rtp://<remote-ip>:1234 (RTP stream)\n" \
44 " * rtsp://@:8554/my_stream (RTSP stream)\n" \
45 " * webrtc://@:1234/my_stream (WebRTC stream)\n" \
46 " * display://0 (OpenGL window)\n" \
47 " --output-codec=CODEC desired codec for compressed output streams:\n" \
48 " * h264 (default), h265\n" \
49 " * vp8, vp9\n" \
50 " * mpeg2, mpeg4\n" \
51 " * mjpeg\n" \
52 " --output-encoder=TYPE the encoder engine to use, one of these:\n" \
53 " * cpu\n" \
54 " * omx (aarch64/JetPack4 only)\n" \
55 " * v4l2 (aarch64/JetPack5 only)\n" \
56 " --output-save=FILE path to a video file for saving the compressed stream\n" \
57 " to disk, in addition to the primary output above\n" \
58 " --bitrate=BITRATE desired target VBR bitrate for compressed streams,\n" \
59 " in bits per second. The default is 4000000 (4 Mbps)\n" \
60 " --headless don't create a default OpenGL GUI window\n\n"
61
62
104 class videoOutput
105 {
106 public:
111static videoOutput* Create( const videoOptions& options );
112
117static videoOutput* Create( const char* URI, const videoOptions& options=videoOptions() );
118
124static videoOutput* Create( const char* URI, const commandLine& cmdLine );
125
131static videoOutput* Create( const char* URI, const int argc, char** argv );
132
141static videoOutput* Create( const int argc, char** argv, int positionArg=-1 );
142
151static videoOutput* Create( const commandLine& cmdLine, int positionArg=-1 );
152
157static videoOutput* CreateNullOutput();
158
162virtual ~videoOutput();
163
167static inline const char* Usage() { return VIDEO_OUTPUT_USAGE_STRING; }
168
186template<typename T> bool Render( T* image, uint32_t width, uint32_t height ) { return Render((void**)image, width, height, imageFormatFromType<T>()); }
187
200virtual bool Render( void* image, uint32_t width, uint32_t height, imageFormat format );
201
212virtual bool Open();
213
221virtual void Close();
222
229inline bool IsStreaming() const { return mStreaming; }
230
234inline uint32_t GetWidth() const { return mOptions.width; }
235
239inline uint32_t GetHeight() const { return mOptions.height; }
240
244inline float GetFrameRate() const { return mOptions.frameRate; }
245
249inline uint64_t GetFrameCount() const { return mOptions.frameCount; }
250
254inline const URI& GetResource() const { return mOptions.resource; }
255
259inline const videoOptions& GetOptions() const { return mOptions; }
260
265inline void AddOutput( videoOutput* output ) { if(output != NULL) mOutputs.push_back(output); }
266
270inline uint32_t GetNumOutputs() const { return mOutputs.size(); }
271
275inline videoOutput* GetOutput( uint32_t index ) const { return mOutputs[index]; }
276
281virtual void SetStatus( const char* str );
282
291virtual inline uint32_t GetType() const { return 0; }
292
297inline bool IsType( uint32_t type ) const { return (type == GetType()); }
298
306template<typename T> bool IsType() const { return IsType(T::Type); }
307
311inline const char* TypeToStr() const { return TypeToStr(GetType()); }
312
316static const char* TypeToStr( uint32_t type );
317
318 protected:
319videoOutput( const videoOptions& options );
320
321boolmStreaming;
323
324 std::vector<videoOutput*> mOutputs;
325 };
326
327 #endif
virtual void SetStatus(const char *str)
Set a status string (i.e.
#define VIDEO_OUTPUT_USAGE_STRING
Standard command-line options able to be passed to videoOutput::Create()
Definition: videoOutput.h:38
void AddOutput(videoOutput *output)
Add an output sub-stream.
Definition: videoOutput.h:265
videoOutput * GetOutput(uint32_t index) const
Return a sub-stream.
Definition: videoOutput.h:275
uint64_t GetFrameCount() const
Return the number of frames output.
Definition: videoOutput.h:249
virtual bool Open()
Begin streaming the device.
bool IsType() const
Check if a this stream is of a particular type.
Definition: videoOutput.h:306
virtual ~videoOutput()
Destroy interface and release all resources.
uint32_t GetHeight() const
Return the height of the stream, in pixels.
Definition: videoOutput.h:239
bool Render(T *image, uint32_t width, uint32_t height)
Render and output the next frame to the stream.
Definition: videoOutput.h:186
bool mStreaming
Definition: videoOutput.h:321
const URI & GetResource() const
Return the resource URI of the stream.
Definition: videoOutput.h:254
videoOptions mOptions
Definition: videoOutput.h:322
virtual void Close()
Stop streaming the device.
URI resource
The resource URI of the device, IP stream, or file/directory.
Definition: videoOptions.h:49
videoOutput(const videoOptions &options)
uint32_t GetNumOutputs() const
Return the number of sub-streams.
Definition: videoOutput.h:270
bool IsType(uint32_t type) const
Check if this stream is of a particular type.
Definition: videoOutput.h:297
Resource URI of a video device, IP stream, or file/directory.
Definition: URI.h:101
static videoOutput * Create(const videoOptions &options)
Create videoOutput interface from a videoOptions struct that's already been filled out.
static videoOutput * CreateNullOutput()
Create videoOutput interface that acts as a NULL output and does nothing with incoming frames.
const char * TypeToStr() const
Convert this stream's class type to string.
Definition: videoOutput.h:311
uint32_t GetWidth() const
Return the width of the stream, in pixels.
Definition: videoOutput.h:234
static const char * Usage()
Usage string for command line arguments to Create()
Definition: videoOutput.h:167
The videoOutput API is for rendering and transmitting frames to video input devices such as display w...
Definition: videoOutput.h:104
bool IsStreaming() const
Check if the device is actively streaming or not.
Definition: videoOutput.h:229
float GetFrameRate() const
Return the framerate, in Hz or FPS.
Definition: videoOutput.h:244
The videoOptions struct contains common settings that are used to configure and query videoSource and...
Definition: videoOptions.h:37
Command line parser for extracting flags, values, and strings.
Definition: commandLine.h:35
uint32_t width
The width of the stream (in pixels).
Definition: videoOptions.h:64
std::vector< videoOutput * > mOutputs
Definition: videoOutput.h:324
const videoOptions & GetOptions() const
Return the videoOptions of the stream.
Definition: videoOutput.h:259
uint64_t frameCount
The number of frames that have been captured or output on this interface.
Definition: videoOptions.h:83
float frameRate
The framerate of the stream (the default is 30Hz).
Definition: videoOptions.h:78
imageFormat
The imageFormat enum is used to identify the pixel format and colorspace of an image.
Definition: imageFormat.h:49
uint32_t height
The height of the stream (in pixels).
Definition: videoOptions.h:71
virtual uint32_t GetType() const
Return the interface type of the stream.
Definition: videoOutput.h:291