release 8.0

This commit is contained in:
夏楚
2023-12-09 16:23:51 +08:00
committed by GitHub
parent 44c82752b3
commit bbe8f4a018
346 changed files with 2529 additions and 3435 deletions

View File

@@ -1,9 +1,9 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* Use of this source code is governed by MIT-like 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.
*/
@@ -21,23 +21,32 @@ namespace mediakit{
/**
* 媒体通道描述类,也支持帧输入输出
*/
class Track : public FrameDispatcher , public CodecInfo{
class Track : public FrameDispatcher, public CodecInfo {
public:
using Ptr = std::shared_ptr<Track>;
/**
* 默认构造
*/
Track() = default;
virtual ~Track() = default;
/**
* 复制拷贝,只能拷贝派生类的信息,
* 环形缓存和代理关系不能拷贝,否则会关系紊乱
*/
Track(const Track &that) { _bit_rate = that._bit_rate; }
/**
* 是否准备好准备好才能获取譬如sps pps等信息
*/
virtual bool ready() = 0;
virtual bool ready() const = 0;
/**
* 克隆接口,用于复制本对象用
* 在调用该接口时只会复制派生类的信息
* 环形缓存和代理关系不能拷贝,否则会关系紊乱
*/
virtual Track::Ptr clone() = 0;
virtual Track::Ptr clone() const = 0;
/**
* 更新track信息比如触发sps/pps解析
@@ -46,9 +55,19 @@ public:
/**
* 生成sdp
* @return sdp对象
* @return sdp对象
*/
virtual Sdp::Ptr getSdp() = 0;
virtual Sdp::Ptr getSdp(uint8_t payload_type) const = 0;
/**
* 获取extra data, 一般用于rtmp/mp4生成
*/
virtual toolkit::Buffer::Ptr getExtraData() const { return nullptr; }
/**
* 设置extra data
*/
virtual void setExtraData(const uint8_t *data, size_t size) {}
/**
* 返回比特率
@@ -62,14 +81,6 @@ public:
*/
virtual void setBitRate(int bit_rate) { _bit_rate = bit_rate; }
/**
* 复制拷贝,只能拷贝派生类的信息,
* 环形缓存和代理关系不能拷贝,否则会关系紊乱
*/
Track(const Track &that){
_bit_rate = that._bit_rate;
}
private:
int _bit_rate = 0;
};
@@ -97,6 +108,40 @@ public:
virtual float getVideoFps() const { return 0; }
};
class VideoTrackImp : public VideoTrack {
public:
using Ptr = std::shared_ptr<VideoTrackImp>;
/**
* 构造函数
* @param codec_id 编码类型
* @param width 宽
* @param height 高
* @param fps 帧率
*/
VideoTrackImp(CodecId codec_id, int width, int height, int fps) {
_codec_id = codec_id;
_width = width;
_height = height;
_fps = fps;
}
int getVideoHeight() const override { return _width; }
int getVideoWidth() const override { return _height; }
float getVideoFps() const override { return _fps; }
bool ready() const override { return true; }
Track::Ptr clone() const override { return std::make_shared<VideoTrackImp>(*this); }
Sdp::Ptr getSdp(uint8_t payload_type) const override { return nullptr; }
CodecId getCodecId() const override { return _codec_id; }
private:
CodecId _codec_id;
int _width = 0;
int _height = 0;
float _fps = 0;
};
/**
* 音频Track派生类支持采样率通道数采用位数信息
*/
@@ -131,7 +176,7 @@ public:
* @param channels 通道数
* @param sample_bit 采样位数一般为16
*/
AudioTrackImp(CodecId codecId,int sample_rate, int channels, int sample_bit){
AudioTrackImp(CodecId codecId, int sample_rate, int channels, int sample_bit){
_codecid = codecId;
_sample_rate = sample_rate;
_channels = channels;
@@ -148,7 +193,7 @@ public:
/**
* 是否已经初始化
*/
bool ready() override {
bool ready() const override {
return true;
}
@@ -172,6 +217,10 @@ public:
int getAudioChannel() const override{
return _channels;
}
Track::Ptr clone() const override { return std::make_shared<AudioTrackImp>(*this); }
Sdp::Ptr getSdp(uint8_t payload_type) const override { return nullptr; }
private:
CodecId _codecid;
int _sample_rate;
@@ -179,9 +228,8 @@ private:
int _sample_bit;
};
class TrackSource{
class TrackSource {
public:
TrackSource() = default;
virtual ~TrackSource() = default;
/**