mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-25 11:07:50 +08:00
Compare commits
3 Commits
c440c45ce4
...
3aa9b8977c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3aa9b8977c | ||
|
|
ee05ae159a | ||
|
|
9bff057860 |
@ -289,7 +289,7 @@ void H265RtpEncoder::packRtpFu(const char *ptr, size_t len, uint64_t pts, bool i
|
|||||||
// Pass in nullptr first, do not copy the payload memory
|
// Pass in nullptr first, do not copy the payload memory
|
||||||
// 只有FU的最后一个分片且整个帧需要设置mark时才设置mark位
|
// 只有FU的最后一个分片且整个帧需要设置mark时才设置mark位
|
||||||
bool mark_bit = fu_end && is_mark;
|
bool mark_bit = fu_end && is_mark;
|
||||||
auto rtp = getRtpInfo().makeRtp(TrackVideo, nullptr, max_size + 3, mark_bit && is_mark, pts); //yzw 帧(不是NALU,多TILE时一帧有多个NALU)最后一个rtp才设置mark位
|
auto rtp = getRtpInfo().makeRtp(TrackVideo, nullptr, max_size + 3, mark_bit, pts);
|
||||||
// rtp payload 负载部分 [AUTO-TRANSLATED:03a5ef9b]
|
// rtp payload 负载部分 [AUTO-TRANSLATED:03a5ef9b]
|
||||||
// rtp payload load part
|
// rtp payload load part
|
||||||
uint8_t *payload = rtp->getPayload();
|
uint8_t *payload = rtp->getPayload();
|
||||||
|
|||||||
@ -67,12 +67,12 @@ ProtocolOption::ProtocolOption() {
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
struct MediaSourceNull : public MediaSource {
|
struct MediaSourceNull : public MediaSource {
|
||||||
MediaSourceNull(const MediaTuple &tuple) : MediaSource("schema", tuple) {};
|
MediaSourceNull() : MediaSource("schema", MediaTuple{"vhost", "app", "stream", ""}) {};
|
||||||
int readerCount() override { return 0; }
|
int readerCount() override { return 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
MediaSource &MediaSource::NullMediaSource(const MediaTuple &tuple) {
|
MediaSource &MediaSource::NullMediaSource() {
|
||||||
static std::shared_ptr<MediaSource> s_null = std::make_shared<MediaSourceNull>(tuple);
|
static std::shared_ptr<MediaSource> s_null = std::make_shared<MediaSourceNull>();
|
||||||
return *s_null;
|
return *s_null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -397,8 +397,7 @@ bool equalMediaTuple(const MediaTuple& a, const MediaTuple& b);
|
|||||||
*/
|
*/
|
||||||
class MediaSource: public TrackSource, public std::enable_shared_from_this<MediaSource> {
|
class MediaSource: public TrackSource, public std::enable_shared_from_this<MediaSource> {
|
||||||
public:
|
public:
|
||||||
static MediaSource &NullMediaSource(const MediaTuple &tuple = {"vhost", "app", "stream" });
|
static MediaSource& NullMediaSource();
|
||||||
|
|
||||||
using Ptr = std::shared_ptr<MediaSource>;
|
using Ptr = std::shared_ptr<MediaSource>;
|
||||||
|
|
||||||
MediaSource(const std::string &schema, const MediaTuple& tuple);
|
MediaSource(const std::string &schema, const MediaTuple& tuple);
|
||||||
|
|||||||
@ -319,7 +319,7 @@ bool MultiMediaSourceMuxer::setupRecord(Recorder::type type, bool start, const s
|
|||||||
if (_option.mp4_as_player && type == Recorder::type_mp4) {
|
if (_option.mp4_as_player && type == Recorder::type_mp4) {
|
||||||
// 开启关闭mp4录制,触发观看人数变化相关事件 [AUTO-TRANSLATED:b63a8deb]
|
// 开启关闭mp4录制,触发观看人数变化相关事件 [AUTO-TRANSLATED:b63a8deb]
|
||||||
// Turn on/off mp4 recording, trigger events related to changes in the number of viewers
|
// Turn on/off mp4 recording, trigger events related to changes in the number of viewers
|
||||||
onReaderChanged(MediaSource::NullMediaSource(_tuple), totalReaderCount());
|
onReaderChanged(*getAnyMediaSource(), totalReaderCount());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -908,6 +908,24 @@ bool MultiMediaSourceMuxer::onTrackFrame_l(const Frame::Ptr &frame_in) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define TRY_SRC(muxer) \
|
||||||
|
if (muxer) { \
|
||||||
|
auto src = muxer->getMediaSource(); \
|
||||||
|
if (src) { \
|
||||||
|
return src; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
MediaSource::Ptr MultiMediaSourceMuxer::getAnyMediaSource() const {
|
||||||
|
TRY_SRC(_fmp4)
|
||||||
|
TRY_SRC(_rtmp)
|
||||||
|
TRY_SRC(_rtsp)
|
||||||
|
TRY_SRC(_ts)
|
||||||
|
TRY_SRC(_hls)
|
||||||
|
TRY_SRC(_hls_fmp4)
|
||||||
|
return MediaSource::NullMediaSource().shared_from_this();
|
||||||
|
}
|
||||||
|
|
||||||
bool MultiMediaSourceMuxer::isEnabled(){
|
bool MultiMediaSourceMuxer::isEnabled(){
|
||||||
GET_CONFIG(uint32_t, stream_none_reader_delay_ms, General::kStreamNoneReaderDelayMS);
|
GET_CONFIG(uint32_t, stream_none_reader_delay_ms, General::kStreamNoneReaderDelayMS);
|
||||||
if (!_is_enable || _last_check.elapsedTime() > stream_none_reader_delay_ms) {
|
if (!_is_enable || _last_check.elapsedTime() > stream_none_reader_delay_ms) {
|
||||||
|
|||||||
@ -237,6 +237,8 @@ protected:
|
|||||||
bool onTrackFrame(const Frame::Ptr &frame) override;
|
bool onTrackFrame(const Frame::Ptr &frame) override;
|
||||||
bool onTrackFrame_l(const Frame::Ptr &frame);
|
bool onTrackFrame_l(const Frame::Ptr &frame);
|
||||||
|
|
||||||
|
MediaSource::Ptr getAnyMediaSource() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createGopCacheIfNeed(size_t gop_count);
|
void createGopCacheIfNeed(size_t gop_count);
|
||||||
std::shared_ptr<MediaSinkInterface> makeRecorder(Recorder::type type);
|
std::shared_ptr<MediaSinkInterface> makeRecorder(Recorder::type type);
|
||||||
|
|||||||
@ -73,6 +73,10 @@ public:
|
|||||||
_media_src->setInitSegment(getInitSegment());
|
_media_src->setInitSegment(getInitSegment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaSource::Ptr getMediaSource() const {
|
||||||
|
return _media_src;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onSegmentData(std::string string, uint64_t stamp, bool key_frame) override {
|
void onSegmentData(std::string string, uint64_t stamp, bool key_frame) override {
|
||||||
if (string.empty()) {
|
if (string.empty()) {
|
||||||
|
|||||||
@ -77,6 +77,10 @@ public:
|
|||||||
return _option.hls_demand ? (_clear_cache ? true : _enabled) : true;
|
return _option.hls_demand ? (_clear_cache ? true : _enabled) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaSource::Ptr getMediaSource() const {
|
||||||
|
return _hls ? _hls->getMediaSource() : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _enabled = true;
|
bool _enabled = true;
|
||||||
bool _clear_cache = false;
|
bool _clear_cache = false;
|
||||||
|
|||||||
@ -81,6 +81,10 @@ public:
|
|||||||
return _option.rtmp_demand ? (_clear_cache ? true : _enabled) : true;
|
return _option.rtmp_demand ? (_clear_cache ? true : _enabled) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaSource::Ptr getMediaSource() const {
|
||||||
|
return _media_src;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _enabled = true;
|
bool _enabled = true;
|
||||||
bool _clear_cache = false;
|
bool _clear_cache = false;
|
||||||
|
|||||||
@ -80,6 +80,10 @@ public:
|
|||||||
return _option.rtsp_demand ? (_clear_cache ? true : _enabled) : true;
|
return _option.rtsp_demand ? (_clear_cache ? true : _enabled) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaSource::Ptr getMediaSource() const {
|
||||||
|
return _media_src;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _enabled = true;
|
bool _enabled = true;
|
||||||
bool _clear_cache = false;
|
bool _clear_cache = false;
|
||||||
|
|||||||
@ -68,6 +68,10 @@ public:
|
|||||||
return _option.ts_demand ? (_clear_cache ? true : _enabled) : true;
|
return _option.ts_demand ? (_clear_cache ? true : _enabled) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaSource::Ptr getMediaSource() const {
|
||||||
|
return _media_src;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onWrite(std::shared_ptr<toolkit::Buffer> buffer, uint64_t timestamp, bool key_pos) override {
|
void onWrite(std::shared_ptr<toolkit::Buffer> buffer, uint64_t timestamp, bool key_pos) override {
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user