| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- #ifndef AV_RECORDER_H
- #define AV_RECORDER_H
- /**
- * AV录制器模块
- *
- * 这个模块提供了完整的音视频录制功能,基于AV模块的现有组件构建。
- * 主要特性:
- * - 音频录制:支持多设备采集、混音、实时编码
- * - 视频录制:支持屏幕录制、窗口采集、摄像头录制
- * - 音视频同步:提供精确的音视频同步机制
- * - 模块化设计:可独立使用音频或视频录制器
- * - 高性能:多线程处理,支持硬件加速
- *
- * 使用示例:
- *
- * // 音频录制
- * auto audioRecorder = RecorderFactoryImpl::createAudioRecorder();
- * AudioRecorderParams audioParams;
- * audioParams.outputPath = "output.mp4";
- * audioParams.sampleRate = 44100;
- * audioParams.channels = 2;
- * audioRecorder->initialize(audioParams);
- * audioRecorder->startRecording();
- *
- * // 视频录制
- * auto videoRecorder = RecorderFactoryImpl::createVideoRecorder();
- * VideoRecorderParams videoParams;
- * videoParams.outputPath = "output.mp4";
- * videoParams.width = 1920;
- * videoParams.height = 1080;
- * videoParams.frameRate = 30;
- * videoRecorder->initialize(videoParams);
- * videoRecorder->startRecording();
- *
- * // 音视频同步录制
- * auto avRecorder = RecorderFactoryImpl::createAVRecorder();
- * AVRecorderParams avParams;
- * avParams.outputPath = "output.mp4";
- * avParams.enableAudio = true;
- * avParams.enableVideo = true;
- * avParams.enableSync = true;
- * avRecorder->initialize(avParams);
- * avRecorder->startRecording();
- */
- // 核心接口
- #include "recorder_abstract_recorder.h"
- // 具体实现
- #include "recorder_audio_recorder.h"
- #include "recorder_video_recorder.h"
- #include "recorder_av_recorder.h"
- namespace av {
- namespace recorder {
- /**
- * 录制器模块版本信息
- */
- struct RecorderVersion {
- static constexpr int MAJOR = 1;
- static constexpr int MINOR = 0;
- static constexpr int PATCH = 0;
-
- static std::string toString() {
- return std::to_string(MAJOR) + "." +
- std::to_string(MINOR) + "." +
- std::to_string(PATCH);
- }
- };
- /**
- * 录制器模块初始化
- */
- class RecorderModule {
- public:
- /**
- * 初始化录制器模块
- */
- static ErrorCode initialize();
-
- /**
- * 清理录制器模块
- */
- static void cleanup();
-
- /**
- * 获取模块版本
- */
- static std::string getVersion() {
- return RecorderVersion::toString();
- }
-
- /**
- * 检查模块是否已初始化
- */
- static bool isInitialized();
-
- /**
- * 获取支持的录制格式
- */
- static std::vector<std::string> getSupportedFormats();
-
- /**
- * 获取支持的音频编码器
- */
- static std::vector<std::string> getSupportedAudioCodecs();
-
- /**
- * 获取支持的视频编码器
- */
- static std::vector<std::string> getSupportedVideoCodecs();
- private:
- static bool initialized_;
- };
- /**
- * 便利函数
- */
- namespace utils {
- /**
- * 创建音频录制器的便利函数
- */
- inline std::unique_ptr<AudioRecorder> createAudioRecorder() {
- return RecorderFactoryImpl::createAudioRecorder();
- }
- /**
- * 创建视频录制器的便利函数
- */
- inline std::unique_ptr<VideoRecorder> createVideoRecorder() {
- return RecorderFactoryImpl::createVideoRecorder();
- }
- /**
- * 创建音视频录制器的便利函数
- */
- inline std::unique_ptr<AVRecorder> createAVRecorder() {
- return RecorderFactoryImpl::createAVRecorder();
- }
- /**
- * 获取默认音频参数
- */
- AudioRecorderParams getDefaultAudioParams();
- /**
- * 获取默认视频参数
- */
- VideoRecorderParams getDefaultVideoParams();
- /**
- * 获取默认音视频参数
- */
- AVRecorderParams getDefaultAVParams();
- /**
- * 检查输出路径是否有效
- */
- bool isValidOutputPath(const std::string& path);
- /**
- * 获取推荐的录制参数(基于系统性能)
- */
- VideoRecorderParams getRecommendedVideoParams();
- } // namespace utils
- } // namespace recorder
- } // namespace av
- #endif // AV_RECORDER_H
|