@@ -25,6 +25,36 @@ class AVFilterGraph;
25
25
BEGIN_FFMPEG_NAMESPACE_V
26
26
27
27
class FFMPEG_API_DLL Recorder {
28
+ private:
29
+ class Impl {
30
+ public:
31
+ AVFormatContext* m_formatContext = nullptr ;
32
+ const AVCodec* m_codec = nullptr ;
33
+ AVStream* m_videoStream = nullptr ;
34
+ AVCodecContext* m_codecContext = nullptr ;
35
+ AVBufferRef* m_hwDevice = nullptr ;
36
+ AVFrame* m_frame = nullptr ;
37
+ AVFrame* m_convertedFrame = nullptr ;
38
+ AVFrame* m_filteredFrame = nullptr ;
39
+ AVPacket* m_packet = nullptr ;
40
+ SwsContext* m_swsCtx = nullptr ;
41
+ AVFilterGraph* m_filterGraph = nullptr ;
42
+ AVFilterContext* m_buffersrcCtx = nullptr ;
43
+ AVFilterContext* m_buffersinkCtx = nullptr ;
44
+ AVFilterContext* m_colorspaceCtx = nullptr ;
45
+ AVFilterContext* m_vflipCtx = nullptr ;
46
+
47
+ size_t m_frameCount = 0 ;
48
+ bool m_init = false ;
49
+
50
+ geode::Result<> init (const RenderSettings& settings);
51
+ void stop ();
52
+ geode::Result<> writeFrame (const std::vector<uint8_t >& frameData);
53
+ geode::Result<> filterFrame (AVFrame* inputFrame, AVFrame* outputFrame);
54
+ };
55
+
56
+ std::unique_ptr<Impl> m_impl = nullptr ;
57
+
28
58
public:
29
59
/* *
30
60
* @brief Initializes the Recorder with the specified rendering settings.
@@ -37,15 +67,18 @@ class FFMPEG_API_DLL Recorder {
37
67
*
38
68
* @return true if initialization is successful, false otherwise.
39
69
*/
40
- geode::Result<> init (const RenderSettings& settings);
70
+ geode::Result<> init (const RenderSettings& settings) {
71
+ m_impl = std::make_unique<Impl>();
72
+ return m_impl->init (settings);
73
+ }
41
74
42
75
/* *
43
76
* @brief Stops the recording process and finalizes the output file.
44
77
*
45
78
* This function ensures that all buffered frames are written to the output file,
46
79
* releases allocated resources, and properly closes the output file.
47
80
*/
48
- void stop ();
81
+ void stop () const { m_impl-> stop (); }
49
82
50
83
/* *
51
84
* @brief Writes a single video frame to the output.
@@ -60,7 +93,9 @@ class FFMPEG_API_DLL Recorder {
60
93
*
61
94
* @warning Ensure that the frameData size matches the expected dimensions of the frame.
62
95
*/
63
- geode::Result<> writeFrame (const std::vector<uint8_t >& frameData);
96
+ geode::Result<> writeFrame (const std::vector<uint8_t >& frameData) const {
97
+ return m_impl->writeFrame (frameData);
98
+ }
64
99
65
100
/* *
66
101
* @brief Retrieves a list of available codecs for video encoding.
@@ -73,32 +108,9 @@ class FFMPEG_API_DLL Recorder {
73
108
static std::vector<std::string> getAvailableCodecs ();
74
109
75
110
private:
76
- geode::Result<> filterFrame (AVFrame* inputFrame, AVFrame* outputFrame);
77
-
78
- private:
79
- class Impl {
80
- public:
81
- AVFormatContext* m_formatContext = nullptr ;
82
- const AVCodec* m_codec = nullptr ;
83
- AVStream* m_videoStream = nullptr ;
84
- AVCodecContext* m_codecContext = nullptr ;
85
- AVBufferRef* m_hwDevice = nullptr ;
86
- AVFrame* m_frame = nullptr ;
87
- AVFrame* m_convertedFrame = nullptr ;
88
- AVFrame* m_filteredFrame = nullptr ;
89
- AVPacket* m_packet = nullptr ;
90
- SwsContext* m_swsCtx = nullptr ;
91
- AVFilterGraph* m_filterGraph = nullptr ;
92
- AVFilterContext* m_buffersrcCtx = nullptr ;
93
- AVFilterContext* m_buffersinkCtx = nullptr ;
94
- AVFilterContext* m_colorspaceCtx = nullptr ;
95
- AVFilterContext* m_vflipCtx = nullptr ;
96
-
97
- size_t m_frameCount = 0 ;
98
- bool m_init = false ;
99
- };
100
-
101
- std::unique_ptr<Impl> m_impl = nullptr ;
111
+ geode::Result<> filterFrame (AVFrame* inputFrame, AVFrame* outputFrame) const {
112
+ return m_impl->filterFrame (inputFrame, outputFrame);
113
+ }
102
114
};
103
115
104
116
END_FFMPEG_NAMESPACE_V
0 commit comments