MediaRecorder.h 2.37 KB
Newer Older
xiongziliang committed
1
/*
xiongziliang committed
2
 * MIT License
xzl committed
3
 *
xiongziliang committed
4
 * Copyright (c) 2016-2019 xiongziliang <771730766@qq.com>
xiongziliang committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 *
 * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
xzl committed
25 26
 */

27 28
#ifndef SRC_MEDIAFILE_MEDIARECORDER_H_
#define SRC_MEDIAFILE_MEDIARECORDER_H_
xzl committed
29 30

#include <memory>
xiongzilaing committed
31
#include "Player/PlayerBase.h"
xiongziliang committed
32
#include "Common/MediaSink.h"
xzl committed
33
#include "Mp4Maker.h"
34
#include "HlsRecorder.h"
35

xiongziliang committed
36
using namespace toolkit;
xzl committed
37

xiongziliang committed
38
namespace mediakit {
xzl committed
39

xiongziliang committed
40
class MediaRecorder : public MediaSink{
xzl committed
41 42
public:
	typedef std::shared_ptr<MediaRecorder> Ptr;
43 44 45
	MediaRecorder(const string &strVhost,
                  const string &strApp,
                  const string &strId,
46 47
                  bool enableHls = true,
                  bool enableMp4 = false);
xzl committed
48
	virtual ~MediaRecorder();
49

xiongziliang committed
50 51 52 53 54
	/**
     * 输入frame
     * @param frame
     */
	void inputFrame(const Frame::Ptr &frame) override ;
xzl committed
55

xiongziliang committed
56 57 58 59 60 61
	/**
     * 添加track,内部会调用Track的clone方法
     * 只会克隆sps pps这些信息 ,而不会克隆Delegate相关关系
     * @param track
     */
	void addTrack(const Track::Ptr & track) override;
xzl committed
62
private:
63
#if defined(ENABLE_HLS)
64
	std::shared_ptr<HlsRecorder> _hlsMaker;
65
#endif //defined(ENABLE_HLS)
xzl committed
66

67 68 69
#if defined(ENABLE_MP4V2)
	std::shared_ptr<Mp4Maker> _mp4Maker;
#endif //defined(ENABLE_MP4V2)
xzl committed
70 71
};

xiongziliang committed
72
} /* namespace mediakit */
xzl committed
73

74
#endif /* SRC_MEDIAFILE_MEDIARECORDER_H_ */