mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
修复全局变量初始化顺序错乱导致崩溃的问题
This commit is contained in:
parent
c6a0e3ad66
commit
208b0865bd
@ -266,7 +266,7 @@ API_EXPORT void API_CALL mk_media_start_send_rtp(mk_media ctx, const char *dst_u
|
|||||||
args.is_udp = is_udp;
|
args.is_udp = is_udp;
|
||||||
|
|
||||||
//sender参数无用
|
//sender参数无用
|
||||||
(*obj)->getChannel()->startSendRtp(MediaSource::NullMediaSource, args, [cb, user_data](uint16_t local_port, const SockException &ex){
|
(*obj)->getChannel()->startSendRtp(MediaSource::NullMediaSource(), args, [cb, user_data](uint16_t local_port, const SockException &ex){
|
||||||
if (cb) {
|
if (cb) {
|
||||||
cb(user_data, local_port, ex.getErrCode(), ex.what());
|
cb(user_data, local_port, ex.getErrCode(), ex.what());
|
||||||
}
|
}
|
||||||
@ -277,5 +277,5 @@ API_EXPORT int API_CALL mk_media_stop_send_rtp(mk_media ctx, const char *ssrc){
|
|||||||
assert(ctx);
|
assert(ctx);
|
||||||
MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx;
|
MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx;
|
||||||
//sender参数无用
|
//sender参数无用
|
||||||
return (*obj)->getChannel()->stopSendRtp(MediaSource::NullMediaSource, ssrc ? ssrc : "");
|
return (*obj)->getChannel()->stopSendRtp(MediaSource::NullMediaSource(), ssrc ? ssrc : "");
|
||||||
}
|
}
|
@ -53,8 +53,10 @@ struct MediaSourceNull : public MediaSource {
|
|||||||
int readerCount() override { return 0; }
|
int readerCount() override { return 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::shared_ptr<MediaSource> s_null = std::make_shared<MediaSourceNull>();
|
MediaSource &MediaSource::NullMediaSource() {
|
||||||
MediaSource &MediaSource::NullMediaSource = *s_null;
|
static std::shared_ptr<MediaSource> s_null = std::make_shared<MediaSourceNull>();
|
||||||
|
return *s_null;
|
||||||
|
}
|
||||||
|
|
||||||
MediaSource::MediaSource(const string &schema, const string &vhost, const string &app, const string &stream_id){
|
MediaSource::MediaSource(const string &schema, const string &vhost, const string &app, const string &stream_id){
|
||||||
GET_CONFIG(bool, enableVhost, General::kEnableVhost);
|
GET_CONFIG(bool, enableVhost, General::kEnableVhost);
|
||||||
|
@ -235,7 +235,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
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;
|
static MediaSource& NullMediaSource();
|
||||||
using Ptr = std::shared_ptr<MediaSource>;
|
using Ptr = std::shared_ptr<MediaSource>;
|
||||||
using StreamMap = std::unordered_map<std::string/*stream_id*/, std::weak_ptr<MediaSource> >;
|
using StreamMap = std::unordered_map<std::string/*stream_id*/, std::weak_ptr<MediaSource> >;
|
||||||
using AppStreamMap = std::unordered_map<std::string/*app*/, StreamMap>;
|
using AppStreamMap = std::unordered_map<std::string/*app*/, StreamMap>;
|
||||||
|
@ -78,7 +78,7 @@ static string getTrackInfoStr(const TrackSource *track_src){
|
|||||||
MultiMediaSourceMuxer::MultiMediaSourceMuxer(const string &vhost, const string &app, const string &stream, float dur_sec, const ProtocolOption &option) {
|
MultiMediaSourceMuxer::MultiMediaSourceMuxer(const string &vhost, const string &app, const string &stream, float dur_sec, const ProtocolOption &option) {
|
||||||
_option = option;
|
_option = option;
|
||||||
_get_origin_url = [this, vhost, app, stream]() {
|
_get_origin_url = [this, vhost, app, stream]() {
|
||||||
auto ret = getOriginUrl(MediaSource::NullMediaSource);
|
auto ret = getOriginUrl(MediaSource::NullMediaSource());
|
||||||
if (!ret.empty()) {
|
if (!ret.empty()) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -240,11 +240,11 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &, const MediaSourceEvent::
|
|||||||
WarnL << "stream:" << strong_self->_get_origin_url() << " stop send rtp:" << ssrc;
|
WarnL << "stream:" << strong_self->_get_origin_url() << " stop send rtp:" << ssrc;
|
||||||
strong_self->_rtp_sender.erase(ssrc);
|
strong_self->_rtp_sender.erase(ssrc);
|
||||||
//触发观看人数统计
|
//触发观看人数统计
|
||||||
strong_self->onReaderChanged(MediaSource::NullMediaSource, strong_self->totalReaderCount());
|
strong_self->onReaderChanged(MediaSource::NullMediaSource(), strong_self->totalReaderCount());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
strong_self->_rtp_sender[args.ssrc] = std::move(rtp_sender);
|
strong_self->_rtp_sender[args.ssrc] = std::move(rtp_sender);
|
||||||
strong_self->onReaderChanged(MediaSource::NullMediaSource, strong_self->totalReaderCount());
|
strong_self->onReaderChanged(MediaSource::NullMediaSource(), strong_self->totalReaderCount());
|
||||||
});
|
});
|
||||||
#else
|
#else
|
||||||
cb(0, SockException(Err_other, "该功能未启用,编译时请打开ENABLE_RTPPROXY宏"));
|
cb(0, SockException(Err_other, "该功能未启用,编译时请打开ENABLE_RTPPROXY宏"));
|
||||||
|
Loading…
Reference in New Issue
Block a user