-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseVideoRecorder.h
More file actions
130 lines (110 loc) · 4.65 KB
/
BaseVideoRecorder.h
File metadata and controls
130 lines (110 loc) · 4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
Copyright (c) 2015-2021 hkrn All rights reserved
This file is part of emapp component and it's licensed under Mozilla Public License. see LICENSE.md for more details.
*/
#ifndef NANOEM_EMAPP_MACOS_BASEVIDEORECORDER_H_
#define NANOEM_EMAPP_MACOS_BASEVIDEORECORDER_H_
#import "emapp/IVideoRecorder.h"
#import <CoreMedia/CoreMedia.h>
#import <CoreVideo/CoreVideo.h>
#import <IOSurface/IOSurface.h>
#include "emapp/Project.h"
@class AVAssetWriter;
@class AVAssetWriterInput;
@class AVAssetWriterInputPixelBufferAdaptor;
namespace nanoem {
class Accessory;
class Model;
class Project;
namespace internal {
class BlitPass;
}
namespace macos {
class BaseVideoRecorder : public IVideoRecorder, private NonCopyable {
public:
BaseVideoRecorder(Project *projectPtr);
~BaseVideoRecorder() noexcept;
bool isStarted() const noexcept override;
bool start(Error &error) override;
bool finish(Error &error) override;
void setAudioCodec(const String &value) override;
void setVideoCodec(const String &value) override;
void setVideoProfile(const String &value) override;
void setVideoPixelFormat(sg_pixel_format value) override;
void setViewportAspectRatioEnabled(bool value) override;
void getAllAvailableAudioCodecs(StringPairList &value) const override;
void getAllAvailableVideoCodecs(StringPairList &value) const override;
void getAllAvailableVideoProfiles(StringPairList &value) const override;
void getAllAvailableVideoPixelFormats(FormatPairList &value) const override;
void getAllAvailableExtensions(StringList &value) const override;
bool isCancelled() const noexcept override;
void cancel() override;
bool isConfigured() const noexcept override;
void makeConfigured() override;
void setFileURI(const URI &value) override;
void setSize(const Vector2UI16 &value) override;
sg_pixel_format pixelFormat() const noexcept override;
nanoem_frame_index_t duration() const noexcept override;
protected:
OSType internalPixelFormat() const noexcept;
Project *project();
internal::BlitPass *blitter();
void acquirePixelBuffer(CVPixelBufferRef *pixelBufferPtr, IOSurfaceRef *surfacePtr);
bool appendPixelBuffer(nanoem_frame_index_t frameIndex, CVPixelBufferRef pixelBuffer);
bool appendAudioSampleBuffer(nanoem_frame_index_t frameIndex);
void blitPass(sg::PassBlock::IDrawQueue *drawQueue, sg_pass value);
void updateAllMSAAImages(int width, int height);
void enableOpenGLCompatibility();
void enableMetalCompatibility();
sg_image_desc m_description;
sg_pass m_videoFramePass = { SG_INVALID_ID };
sg_image m_colorImage = { SG_INVALID_ID };
sg_image m_depthImage = { SG_INVALID_ID };
private:
void setupAudioInput(Error &error);
void setupVideoInput(int width, int height, Error &error);
void destroyBlitter(internal::BlitPass *&value);
AVAssetWriter *m_writer = nil;
AVAssetWriterInput *m_audioWriterInput = nil;
AVAssetWriterInput *m_videoWriterInput = nil;
Project *m_project = nullptr;
internal::BlitPass *m_blitter = nullptr;
URI m_fileURI;
Vector2UI16 m_lastViewportImageSize;
Vector2UI16 m_outputSize;
NSNumber *m_audioBits = nil;
AudioFormatID m_audioCodec = 0;
NSNumber *m_audioChannels = nil;
NSNumber *m_audioDuration = nil;
NSNumber *m_audioFrequency = nil;
NSNumber *m_audioBitRate = nil;
NSString *m_videoCodec = nil;
NSString *m_videoProfile = nil;
NSString *m_videoFileType = nil;
tinystl::pair<sg_pixel_format, OSType> m_pixelFormat;
tinystl::pair<nanoem_frame_index_t, nanoem_frame_index_t> m_lastAppendSample;
Accessory *m_lastActiveAccessory = nullptr;
Model *m_lastActiveModel = nullptr;
PhysicsEngine::SimulationModeType m_lastPhysicsSimulationMode = PhysicsEngine::kSimulationModeDisable;
internal::BlitPass *m_blitterMSAA = nullptr;
CMAudioFormatDescriptionRef m_formatDescription = nullptr;
CVPixelBufferPoolRef m_pixelBufferPool = nullptr;
CVPixelBufferRef m_previousBuffer = nullptr;
IOSurfaceRef m_previousSurface = nullptr;
Vector4 m_blitRect = Vector4(0, 0, 1, 1);
sg_pass_desc m_receivePassDesc;
sg_pass m_receivePass;
sg_pixel_format m_lastPixelFormat = SG_PIXELFORMAT_NONE;
nanoem_frame_index_t m_lastFrameIndex = 0;
nanoem_frame_index_t m_duration = 0;
nanoem_f32_t m_lastDevicePixelViewportRatio = 1.0f;
uint32_t m_videoFPS = 0;
bool m_viewportAspectRatioEnabled = false;
bool m_compatibleWithOpenGL = false;
bool m_compatibleWithMetal = false;
bool m_configured = false;
bool m_cancelled = false;
};
} /* namespace macos */
} /* namespace nanoem */
#endif /* NANOEM_EMAPP_MACOS_BASEVIDEORECORDER_H_ */