Compare commits

...

3 Commits

Author SHA1 Message Date
xia-chu
3aa9b8977c Revert "fix: 解决h265多Tile编码时,只有左侧画面,右侧画面灰色图的问题 (#4699)"
Some checks are pending
Android / build (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
Docker / build (push) Waiting to run
DockerPy / build (push) Waiting to run
Linux / build (push) Waiting to run
Linux_Python / build (push) Waiting to run
macOS / build (push) Waiting to run
macOS_Python / build (push) Waiting to run
Windows / build (push) Waiting to run
Windows_Python / build (push) Waiting to run
This reverts commit d75d35dc7a.
2026-05-03 19:50:09 +08:00
xia-chu
ee05ae159a 修复mp4_as_player设置为1时,on_stream_none_reader回调无效流信息的问题 (#4725) 2026-05-03 19:50:09 +08:00
xia-chu
9bff057860 Revert "修复mp4_as_player设置为1时,on_stream_none_reader回调无效流信息的问题 (#4725)"
This reverts commit 6f9531c5fa.
2026-05-03 19:33:43 +08:00
10 changed files with 46 additions and 7 deletions

View File

@ -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
// 只有FU的最后一个分片且整个帧需要设置mark时才设置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 load part
uint8_t *payload = rtp->getPayload();

View File

@ -67,12 +67,12 @@ ProtocolOption::ProtocolOption() {
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct MediaSourceNull : public MediaSource {
MediaSourceNull(const MediaTuple &tuple) : MediaSource("schema", tuple) {};
MediaSourceNull() : MediaSource("schema", MediaTuple{"vhost", "app", "stream", ""}) {};
int readerCount() override { return 0; }
};
MediaSource &MediaSource::NullMediaSource(const MediaTuple &tuple) {
static std::shared_ptr<MediaSource> s_null = std::make_shared<MediaSourceNull>(tuple);
MediaSource &MediaSource::NullMediaSource() {
static std::shared_ptr<MediaSource> s_null = std::make_shared<MediaSourceNull>();
return *s_null;
}

View File

@ -397,8 +397,7 @@ bool equalMediaTuple(const MediaTuple& a, const MediaTuple& b);
*/
class MediaSource: public TrackSource, public std::enable_shared_from_this<MediaSource> {
public:
static MediaSource &NullMediaSource(const MediaTuple &tuple = {"vhost", "app", "stream" });
static MediaSource& NullMediaSource();
using Ptr = std::shared_ptr<MediaSource>;
MediaSource(const std::string &schema, const MediaTuple& tuple);

View File

@ -319,7 +319,7 @@ bool MultiMediaSourceMuxer::setupRecord(Recorder::type type, bool start, const s
if (_option.mp4_as_player && type == Recorder::type_mp4) {
// 开启关闭mp4录制触发观看人数变化相关事件 [AUTO-TRANSLATED:b63a8deb]
// 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) {
@ -908,6 +908,24 @@ bool MultiMediaSourceMuxer::onTrackFrame_l(const Frame::Ptr &frame_in) {
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(){
GET_CONFIG(uint32_t, stream_none_reader_delay_ms, General::kStreamNoneReaderDelayMS);
if (!_is_enable || _last_check.elapsedTime() > stream_none_reader_delay_ms) {

View File

@ -237,6 +237,8 @@ protected:
bool onTrackFrame(const Frame::Ptr &frame) override;
bool onTrackFrame_l(const Frame::Ptr &frame);
MediaSource::Ptr getAnyMediaSource() const;
private:
void createGopCacheIfNeed(size_t gop_count);
std::shared_ptr<MediaSinkInterface> makeRecorder(Recorder::type type);

View File

@ -73,6 +73,10 @@ public:
_media_src->setInitSegment(getInitSegment());
}
MediaSource::Ptr getMediaSource() const {
return _media_src;
}
protected:
void onSegmentData(std::string string, uint64_t stamp, bool key_frame) override {
if (string.empty()) {

View File

@ -77,6 +77,10 @@ public:
return _option.hls_demand ? (_clear_cache ? true : _enabled) : true;
}
MediaSource::Ptr getMediaSource() const {
return _hls ? _hls->getMediaSource() : nullptr;
}
protected:
bool _enabled = true;
bool _clear_cache = false;

View File

@ -81,6 +81,10 @@ public:
return _option.rtmp_demand ? (_clear_cache ? true : _enabled) : true;
}
MediaSource::Ptr getMediaSource() const {
return _media_src;
}
private:
bool _enabled = true;
bool _clear_cache = false;

View File

@ -80,6 +80,10 @@ public:
return _option.rtsp_demand ? (_clear_cache ? true : _enabled) : true;
}
MediaSource::Ptr getMediaSource() const {
return _media_src;
}
private:
bool _enabled = true;
bool _clear_cache = false;

View File

@ -68,6 +68,10 @@ public:
return _option.ts_demand ? (_clear_cache ? true : _enabled) : true;
}
MediaSource::Ptr getMediaSource() const {
return _media_src;
}
protected:
void onWrite(std::shared_ptr<toolkit::Buffer> buffer, uint64_t timestamp, bool key_pos) override {
if (!buffer) {