新增支持Python混合编程模式 (#4579)

This commit is contained in:
夏楚
2026-02-10 13:28:42 +08:00
committed by GitHub
parent da9deb352c
commit 6d520ea6a3
25 changed files with 1553 additions and 55 deletions

View File

@@ -243,6 +243,8 @@ MultiMediaSourceMuxer::MultiMediaSourceMuxer(const MediaTuple& tuple, float dur_
// Audio related settings
enableAudio(option.enable_audio);
enableMuteAudio(option.add_mute_audio);
NOTICE_EMIT(BroadcastCreateMuxerArgs, Broadcast::kBroadcastCreateMuxer, _delegate, *this);
}
void MultiMediaSourceMuxer::setMediaListener(const std::weak_ptr<MediaSourceEvent> &listener) {
@@ -705,6 +707,9 @@ bool MultiMediaSourceMuxer::onTrackReady(const Track::Ptr &track) {
if (_mp4) {
ret = _mp4->addTrack(track) ? true : ret;
}
if (_delegate) {
_delegate->addTrack(track);
}
return ret;
}
@@ -764,6 +769,9 @@ void MultiMediaSourceMuxer::onAllTrackReady() {
pr.second.syncTo(*first);
}
}
if (_delegate) {
_delegate->addTrackCompleted();
}
InfoL << "stream: " << shortUrl() << " , codec info: " << getTrackInfoStr(this);
}
@@ -847,6 +855,9 @@ bool MultiMediaSourceMuxer::onTrackFrame_l(const Frame::Ptr &frame_in) {
if (_fmp4) {
ret = _fmp4->inputFrame(frame) ? true : ret;
}
if (_delegate) {
_delegate->inputFrame(frame);
}
if (_ring) {
// 此场景由于直接转发可能存在切换线程引起的数据被缓存在管道所以需要CacheAbleFrame [AUTO-TRANSLATED:528afbb7]
// In this scenario, due to direct forwarding, there may be data cached in the pipeline due to thread switching, so CacheAbleFrame is needed

View File

@@ -29,6 +29,7 @@ class MultiMediaSourceMuxer : public MediaSourceEventInterceptor, public MediaSi
public:
using Ptr = std::shared_ptr<MultiMediaSourceMuxer>;
using RingType = toolkit::RingBuffer<Frame::Ptr>;
using onCreateMuxer = std::function<MediaSinkInterface::Ptr()>;
class Listener {
public:
@@ -249,6 +250,8 @@ private:
toolkit::EventPoller::Ptr _poller;
RingType::Ptr _ring;
MediaSinkInterface::Ptr _delegate;
// 对象个数统计 [AUTO-TRANSLATED:3b43e8c2]
// Object count statistics
toolkit::ObjectStatistic<MultiMediaSourceMuxer> _statistic;

View File

@@ -81,6 +81,8 @@ const string kBroadcastRtcSctpClosed = "kBroadcastRtcSctpClosed";
const string kBroadcastRtcSctpSend = "kBroadcastRtcSctpSend";
const string kBroadcastRtcSctpReceived = "kBroadcastRtcSctpReceived";
const string kBroadcastPlayerCountChanged = "kBroadcastPlayerCountChanged";
const string kBroadcastPlayerProxyFailed = "kBroadcastPlayerProxyFailed";
const string kBroadcastCreateMuxer = "kBroadcastCreateMuxer";
} // namespace Broadcast

View File

@@ -126,7 +126,7 @@ extern const std::string kBroadcastStreamNoneReader;
// rtp推流被动停止时触发 [AUTO-TRANSLATED:43881965]
// Triggered when rtp push stream is passively stopped.
extern const std::string kBroadcastSendRtpStopped;
#define BroadcastSendRtpStoppedArgs MultiMediaSourceMuxer &sender, const std::string &ssrc, const SockException &ex
#define BroadcastSendRtpStoppedArgs MultiMediaSourceMuxer &sender, const std::string &ssrc, const toolkit::SockException &ex
// 更新配置文件事件广播,执行loadIniConfig函数加载配置文件成功后会触发该广播 [AUTO-TRANSLATED:ad4e167d]
// Update configuration file event broadcast. This broadcast will be triggered after the loadIniConfig function loads the configuration file successfully.
@@ -161,6 +161,12 @@ extern const std::string kBroadcastRtcSctpReceived;
extern const std::string kBroadcastPlayerCountChanged;
#define BroadcastPlayerCountChangedArgs const MediaTuple& args, const int& count
extern const std::string kBroadcastPlayerProxyFailed;
#define BroadcastPlayerProxyFailedArgs const PlayerProxy& sender, const toolkit::SockException &ex
extern const std::string kBroadcastCreateMuxer;
#define BroadcastCreateMuxerArgs MediaSinkInterface::Ptr &delegate, const MultiMediaSourceMuxer &sender
#define ReloadConfigTag ((void *)(0xFF))
#define RELOAD_KEY(arg, key) \
do { \

View File

@@ -110,7 +110,9 @@ void PlayerProxy::play(const string &strUrlTmp) {
if (!strongSelf) {
return;
}
if (err) {
NOTICE_EMIT(BroadcastPlayerProxyFailedArgs, Broadcast::kBroadcastPlayerProxyFailed, *strongSelf, err);
}
if (strongSelf->_on_play) {
strongSelf->_on_play(err);
strongSelf->_on_play = nullptr;
@@ -146,6 +148,9 @@ void PlayerProxy::play(const string &strUrlTmp) {
if (!strongSelf) {
return;
}
if (err) {
NOTICE_EMIT(BroadcastPlayerProxyFailedArgs, Broadcast::kBroadcastPlayerProxyFailed, *strongSelf, err);
}
// 注销直接拉流代理产生的流:#532 [AUTO-TRANSLATED:c6343a3b]
// Unregister the stream generated by the direct stream proxy: #532

View File

@@ -18,8 +18,7 @@
namespace mediakit {
struct StreamInfo
{
struct StreamInfo {
TrackType codec_type;
std::string codec_name;
int bitrate;
@@ -30,8 +29,7 @@ struct StreamInfo
int video_height;
float video_fps;
StreamInfo()
{
StreamInfo() {
codec_type = TrackInvalid;
codec_name = "none";
bitrate = -1;
@@ -44,14 +42,12 @@ struct StreamInfo
}
};
struct TranslationInfo
{
struct TranslationInfo {
std::vector<StreamInfo> stream_info;
int byte_speed;
uint64_t start_time_stamp;
TranslationInfo()
{
TranslationInfo() {
byte_speed = -1;
start_time_stamp = 0;
}

View File

@@ -19,7 +19,11 @@ using namespace toolkit;
namespace mediakit {
MP4Muxer::~MP4Muxer() {
closeMP4();
try {
closeMP4();
} catch (std::exception &e) {
WarnL << e.what();
}
}
void MP4Muxer::openMP4(const string &file) {