ZLMediaKit/src/Record/Recorder.h

86 lines
2.5 KiB
C++
Raw Normal View History

2019-08-08 19:01:45 +08:00
/*
2020-04-04 20:30:09 +08:00
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
2020-04-04 20:30:09 +08:00
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
* may be found in the AUTHORS file in the root of the source tree.
*/
2019-12-04 10:45:38 +08:00
#ifndef SRC_MEDIAFILE_RECORDER_H_
#define SRC_MEDIAFILE_RECORDER_H_
2019-12-04 10:45:38 +08:00
#include <memory>
#include <string>
namespace mediakit {
2019-12-04 10:45:38 +08:00
class MediaSinkInterface;
class ProtocolOption;
2019-12-04 10:45:38 +08:00
2023-05-25 16:23:24 +08:00
struct MediaTuple {
std::string vhost;
std::string app;
std::string stream;
std::string shortUrl() const {
return vhost + '/' + app + '/' + stream;
}
};
class RecordInfo: public MediaTuple {
public:
time_t start_time; // GMT 标准时间,单位秒
float time_len; // 录像长度,单位秒
off_t file_size; // 文件大小,单位 BYTE
std::string file_path; // 文件路径
std::string file_name; // 文件名称
std::string folder; // 文件夹路径
std::string url; // 播放路径
};
2019-12-04 10:45:38 +08:00
class Recorder{
public:
2020-03-20 11:51:24 +08:00
typedef enum {
// 录制hls
type_hls = 0,
// 录制MP4
type_mp4 = 1,
// 录制hls.fmp4
type_hls_fmp4 = 2,
// fmp4直播
type_fmp4 = 3,
// ts直播
type_ts = 4,
2020-03-20 11:51:24 +08:00
} type;
2019-12-04 18:36:30 +08:00
2020-03-20 11:51:24 +08:00
/**
*
* @param type hls还是MP4录制
2020-02-01 22:58:58 +08:00
* @param vhost
* @param app
* @param stream_id id
* @param customized_path
2020-03-20 11:51:24 +08:00
* @return
*/
2023-05-25 16:23:24 +08:00
static std::string getRecordPath(type type, const MediaTuple& tuple, const std::string &customized_path = "");
2020-02-01 22:58:58 +08:00
2020-03-20 11:51:24 +08:00
/**
*
* @param type hls还是MP4录制
2020-02-01 22:58:58 +08:00
* @param vhost
* @param app
* @param stream_id id
* @param customized_path
* @param max_second mp4录制最大切片时间0
2020-03-20 11:51:24 +08:00
* @return nullptr
*/
2023-05-25 16:23:24 +08:00
static std::shared_ptr<MediaSinkInterface> createRecorder(type type, const MediaTuple& tuple, const ProtocolOption &option);
2020-04-05 09:26:29 +08:00
2019-12-04 10:45:38 +08:00
private:
2020-03-20 11:51:24 +08:00
Recorder() = delete;
~Recorder() = delete;
};
2019-12-04 10:45:38 +08:00
} /* namespace mediakit */
#endif /* SRC_MEDIAFILE_RECORDER_H_ */