Gazebo Common
API Reference
6.0.0
insert_drive_file
Tutorials
library_books
Classes
toc
Namespaces
insert_drive_file
Files
launch
Gazebo Website
Index
List
Hierarchy
Members: All
Members: Functions
Members: Variables
Members: Typedefs
Members: Enumerations
Members: Enumerator
List
Members
Functions
Typedefs
Variables
Enumerations
Enumerator
src
gz-common
av
include
gz
common
VideoEncoder.hh
Go to the documentation of this file.
1
/*
2
* Copyright 2016 Open Source Robotics Foundation
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*
16
*/
17
#ifndef GZ_COMMON_VIDEOENCODER_HH_
18
#define GZ_COMMON_VIDEOENCODER_HH_
19
20
#include <chrono>
21
#include <string>
22
#include <optional>
23
24
#include <
gz/common/FlagSet.hh
>
25
#include <gz/common/av/Export.hh>
26
#include <
gz/common/HWVideo.hh
>
27
#include <gz/utils/ImplPtr.hh>
28
29
// Default bitrate (0) indicates that a bitrate should be calculated when
30
// Start is called.
31
#define VIDEO_ENCODER_BITRATE_DEFAULT 0
32
#define VIDEO_ENCODER_WIDTH_DEFAULT 1280
33
#define VIDEO_ENCODER_HEIGHT_DEFAULT 720
34
#define VIDEO_ENCODER_FPS_DEFAULT 25
35
#define VIDEO_ENCODER_FORMAT_DEFAULT "mp4"
36
37
namespace
gz
38
{
39
namespace
common
40
{
43
class
GZ_COMMON_AV_VISIBLE
VideoEncoder
44
{
46
public
:
VideoEncoder
();
47
49
public
:
virtual
~VideoEncoder
();
50
92
public
:
bool
Start
(
93
const
std::string
&_format =
VIDEO_ENCODER_FORMAT_DEFAULT
,
94
const
std::string
&_filename =
""
,
95
const
unsigned
int
_width =
VIDEO_ENCODER_WIDTH_DEFAULT
,
96
const
unsigned
int
_height =
VIDEO_ENCODER_HEIGHT_DEFAULT
,
97
const
unsigned
int
_fps =
VIDEO_ENCODER_FPS_DEFAULT
,
98
const
unsigned
int
_bitRate =
VIDEO_ENCODER_BITRATE_DEFAULT
);
99
126
public
:
bool
Start
(
127
const
std::string
&_format,
128
const
std::string
&_filename,
129
const
unsigned
int
_width,
130
const
unsigned
int
_height,
131
const
unsigned
int
_fps,
132
const
unsigned
int
_bitRate,
133
const
bool
_allowHwAccel);
134
163
public
:
bool
Start
(
164
const
std::string
&_format,
165
const
std::string
&_filename,
166
unsigned
int
_width,
167
unsigned
int
_height,
168
unsigned
int
_fps,
169
unsigned
int
_bitRate,
170
const
FlagSet<HWEncoderType>
& _allowedHwAccel,
171
const
std::string
& _hwAccelDevice =
""
,
172
std::optional<bool> _useHwSurface = {});
173
177
public
:
bool
Stop
();
178
181
public
:
bool
IsEncoding
()
const
;
182
188
public
:
bool
AddFrame
(
const
unsigned
char
*_frame,
189
const
unsigned
int
_width,
190
const
unsigned
int
_height);
191
198
public
:
bool
AddFrame
(
const
unsigned
char
*_frame,
199
const
unsigned
int
_width,
200
const
unsigned
int
_height,
201
const
std::chrono::steady_clock::time_point &_timestamp);
202
206
public
:
bool
SaveToFile
(
const
std::string
&_filename);
207
210
public
:
std::string
Format
()
const
;
211
214
public
:
unsigned
int
BitRate
()
const
;
215
218
public
:
void
Reset
();
219
221
GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
222
};
223
}
224
}
225
#endif