Argus Camera Sample Argus Camera Sample

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VideoPipeline.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of NVIDIA CORPORATION nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef VIDEO_PIPELINE_H
30 #define VIDEO_PIPELINE_H
31
32 #include <EGL/egl.h>
33 #include <EGL/eglext.h>
34
35 #ifdef GST_SUPPORTED
36 #include <gst/gst.h>
37 #endif
38
39 namespace ArgusSamples
40 {
41
42 /**
43 * Record a video from a EGL stream
44 */
45 class VideoPipeline
46 {
47 public:
48 VideoPipeline();
49 ~VideoPipeline();
50
51 /**
52 * Supported video formats
53 */
54 typedef enum
55 {
56 VIDEO_FORMAT_H264,
57 VIDEO_FORMAT_H265,
58 VIDEO_FORMAT_VP8,
59 VIDEO_FORMAT_VP9
60 } VideoFormat;
61
62 /**
63 * Video BitRate presets
64 */
65 typedef enum
66 {
67 VIDEO_BITRATE_4M = 4000000,
68 VIDEO_BITRATE_8M = 8000000,
69 VIDEO_BITRATE_14M = 14000000,
70 VIDEO_BITRATE_20M = 20000000,
71 VIDEO_BITRATE_MAX = 240000000
72 } VideoBitRate;
73
74 /**
75 * Supported video file types
76 */
77 typedef enum
78 {
79 VIDEO_FILE_TYPE_MP4,
80 VIDEO_FILE_TYPE_3GP,
81 VIDEO_FILE_TYPE_AVI,
82 VIDEO_FILE_TYPE_MKV,
83 VIDEO_FILE_TYPE_H265
84 } VideoFileType;
85
86 /**
87 * Video AVC profile types, each profile indicates support for various
88 * performance bounds and different annexes.
89 */
90 typedef enum {
91 VIDEO_AVC_PROFILE_BASELINE = 0x01,
92 VIDEO_AVC_PROFILE_MAIN = 0x02,
93 VIDEO_AVC_PROFILE_EXTENDED = 0x04,
94 VIDEO_AVC_PROFILE_HIGH = 0x08,
95 VIDEO_AVC_PROFILE_HIGH10 = 0x10,
96 VIDEO_AVC_PROFILE_MAX = 0x7FFFFFFF
97 } VideoAvcProfileType;
98
99 /**
100 * Destroy the video pipeline
101 */
102 bool destroy();
103
104 /**
105 * Setup the video pipeline for recording
106 *
107 * @param[in] videoStream EGL stream to record from
108 * @param[in] width Width of the recorded video
109 * @param[in] height Height of the recorded video
110 * @param[in] frameRate Frame rate
111 * @param[in] fileName File name
112 * @param[in] videoFormat Video format
113 * @param[in] videoFileType Video file type
114 * @param[in] bitRate Bitrate, if 0 the bitrate will be selected depending on the
115 * resolution
116 */
117 bool setupForRecording(EGLStreamKHR videoStream, uint32_t width, uint32_t height,
118 float frameRate, const char *fileName,
119 VideoFormat videoFormat = VIDEO_FORMAT_H265,
120 VideoFileType videoFileType = VIDEO_FILE_TYPE_MKV, uint32_t bitRate = 0);
121
122 /**
123 * Setup the video pipeline for playback
124 *
125 * @param[out] videoStream EGL stream
126 * @param[in] fileName File name
127 */
128 bool setupForPlayback(EGLStreamKHR *videoStream, const char *fileName);
129
130 /**
131 * Start recording/playback
132 */
133 bool start();
134
135 /**
136 * Pause recording/playback
137 */
138 bool pause();
139
140 /**
141 * Toggle recording/playback
142 */
143 bool toggle();
144
145 /**
146 * Rewind (playback only)
147 */
148 bool rewind();
149
150 /**
151 * Stop recording/playback
152 */
153 bool stop();
154
155 /**
156 * Get the file extension for a video file type.
157 */
158 static const char* getFileExtension(VideoFileType fileType);
159
160 /**
161 * Get the aspect ratio of the video. The video has to be in paused or playing state.
162 *
163 * @param aspectRatio [out]
164 */
165 bool getAspectRatio(float *aspectRatio) const;
166
167 /**
168 * Get indicator of video recording being supported
169 */
170 static bool isSupported();
171
172 private:
173 #ifdef GST_SUPPORTED
174 GstState m_state;
175
176 GstElement *m_pipeline;
177 #endif
178 };
179
180 }; // namespace ArgusSamples
181
182 #endif // VIDEO_PIPELINE_H