Ignition Common

API Reference

3.5.0
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 IGNITION_COMMON_VIDEOENCODER_HH_
18 #define IGNITION_COMMON_VIDEOENCODER_HH_
19 
20 #include <chrono>
21 #include <string>
22 #include <memory>
23 
24 #include <ignition/common/av/Export.hh>
26 
27 // Default bitrate (0) indicates that a bitrate should be calculated when
28 // Start is called.
29 #define VIDEO_ENCODER_BITRATE_DEFAULT 0
30 #define VIDEO_ENCODER_WIDTH_DEFAULT 1280
31 #define VIDEO_ENCODER_HEIGHT_DEFAULT 720
32 #define VIDEO_ENCODER_FPS_DEFAULT 25
33 #define VIDEO_ENCODER_FORMAT_DEFAULT "mp4"
34 
35 namespace ignition
36 {
37  namespace common
38  {
39  // Forward declare private data class
40  class VideoEncoderPrivate;
41 
44  class IGNITION_COMMON_AV_VISIBLE VideoEncoder
45  {
47  public: VideoEncoder();
48 
50  public: virtual ~VideoEncoder();
51 
69  public: bool Start(
71  const std::string &_filename = "",
72  const unsigned int _width = VIDEO_ENCODER_WIDTH_DEFAULT,
73  const unsigned int _height = VIDEO_ENCODER_HEIGHT_DEFAULT,
74  const unsigned int _fps = VIDEO_ENCODER_FPS_DEFAULT,
75  const unsigned int _bitRate = VIDEO_ENCODER_BITRATE_DEFAULT);
76 
80  public: bool Stop();
81 
84  public: bool IsEncoding() const;
85 
91  public: bool AddFrame(const unsigned char *_frame,
92  const unsigned int _width,
93  const unsigned int _height);
94 
101  public: bool AddFrame(const unsigned char *_frame,
102  const unsigned int _width,
103  const unsigned int _height,
104  const std::chrono::steady_clock::time_point &_timestamp);
105 
109  public: bool SaveToFile(const std::string &_filename);
110 
113  public: std::string Format() const;
114 
117  public: unsigned int BitRate() const;
118 
121  public: void Reset();
122 
126  private: std::unique_ptr<VideoEncoderPrivate> dataPtr;
128  };
129  }
130 }
131 #endif
#define VIDEO_ENCODER_FPS_DEFAULT
Definition: VideoEncoder.hh:32
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: SuppressWarning.hh:67
STL class.
#define VIDEO_ENCODER_BITRATE_DEFAULT
Definition: VideoEncoder.hh:29
#define VIDEO_ENCODER_HEIGHT_DEFAULT
Definition: VideoEncoder.hh:31
The VideoEncoder class supports encoding a series of images to a video format, and then writing the v...
Definition: VideoEncoder.hh:44
#define VIDEO_ENCODER_WIDTH_DEFAULT
Definition: VideoEncoder.hh:30
Forward declarations for the common classes.
#define VIDEO_ENCODER_FORMAT_DEFAULT
Definition: VideoEncoder.hh:33
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: SuppressWarning.hh:64