diff --git a/api/source/mk_rtp_server.cpp b/api/source/mk_rtp_server.cpp index a36b9363..56402354 100644 --- a/api/source/mk_rtp_server.cpp +++ b/api/source/mk_rtp_server.cpp @@ -9,6 +9,10 @@ */ #include "mk_rtp_server.h" +#include "Util/logger.h" +using namespace toolkit; + +#if defined(ENABLE_RTPPROXY) #include "Rtp/RtpServer.h" using namespace mediakit; @@ -38,3 +42,25 @@ API_EXPORT void API_CALL mk_rtp_server_set_on_detach(mk_rtp_server ctx, on_mk_rt (*server)->setOnDetach(nullptr); } } + +#else + +API_EXPORT mk_rtp_server API_CALL mk_rtp_server_create(uint16_t port, int enable_tcp, const char *stream_id){ + WarnL << "请打开ENABLE_RTPPROXY后再编译"; + return nullptr; +} + +API_EXPORT void API_CALL mk_rtp_server_release(mk_rtp_server ctx){ + WarnL << "请打开ENABLE_RTPPROXY后再编译"; +} + +API_EXPORT uint16_t API_CALL mk_rtp_server_port(mk_rtp_server ctx){ + WarnL << "请打开ENABLE_RTPPROXY后再编译"; + return 0; +} + +API_EXPORT void API_CALL mk_rtp_server_set_on_detach(mk_rtp_server ctx, on_mk_rtp_server_detach cb, void *user_data){ + WarnL << "请打开ENABLE_RTPPROXY后再编译"; +} + +#endif \ No newline at end of file diff --git a/src/Common/MultiMediaSourceMuxer.cpp b/src/Common/MultiMediaSourceMuxer.cpp index 9ef5a678..6b87c768 100644 --- a/src/Common/MultiMediaSourceMuxer.cpp +++ b/src/Common/MultiMediaSourceMuxer.cpp @@ -34,7 +34,10 @@ MultiMuxerPrivate::MultiMuxerPrivate(const string &vhost, const string &app, con } _ts = std::make_shared(vhost, app, stream); + +#if defined(ENABLE_MP4) _fmp4 = std::make_shared(vhost, app, stream); +#endif } void MultiMuxerPrivate::resetTracks() { @@ -47,9 +50,11 @@ void MultiMuxerPrivate::resetTracks() { if (_ts) { _ts->resetTracks(); } +#if defined(ENABLE_MP4) if (_fmp4) { _fmp4->resetTracks(); } +#endif //拷贝智能指针,目的是为了防止跨线程调用设置录像相关api导致的线程竞争问题 auto hls = _hls; @@ -74,9 +79,11 @@ void MultiMuxerPrivate::setMediaListener(const std::weak_ptr & if (_ts) { _ts->setListener(listener); } +#if defined(ENABLE_MP4) if (_fmp4) { _fmp4->setListener(listener); } +#endif auto hls = _hls; if (hls) { hls->setListener(listener); @@ -88,7 +95,9 @@ int MultiMuxerPrivate::totalReaderCount() const { return (_rtsp ? _rtsp->readerCount() : 0) + (_rtmp ? _rtmp->readerCount() : 0) + (_ts ? _ts->readerCount() : 0) + +#if defined(ENABLE_MP4) (_fmp4 ? _fmp4->readerCount() : 0) + +#endif (hls ? hls->readerCount() : 0); } @@ -167,9 +176,11 @@ void MultiMuxerPrivate::onTrackReady(const Track::Ptr &track) { if (_ts) { _ts->addTrack(track); } +#if defined(ENABLE_MP4) if (_fmp4) { _fmp4->addTrack(track); } +#endif //拷贝智能指针,目的是为了防止跨线程调用设置录像相关api导致的线程竞争问题 auto hls = _hls; @@ -187,7 +198,9 @@ bool MultiMuxerPrivate::isEnabled(){ return (_rtmp ? _rtmp->isEnabled() : false) || (_rtsp ? _rtsp->isEnabled() : false) || (_ts ? _ts->isEnabled() : false) || +#if defined(ENABLE_MP4) (_fmp4 ? _fmp4->isEnabled() : false) || +#endif (hls ? hls->isEnabled() : false) || _mp4; } @@ -201,9 +214,11 @@ void MultiMuxerPrivate::onTrackFrame(const Frame::Ptr &frame) { if (_ts) { _ts->inputFrame(frame); } +#if defined(ENABLE_MP4) if (_fmp4) { _fmp4->inputFrame(frame); } +#endif //拷贝智能指针,目的是为了防止跨线程调用设置录像相关api导致的线程竞争问题 //此处使用智能指针拷贝来确保线程安全,比互斥锁性能更优 @@ -254,9 +269,11 @@ void MultiMuxerPrivate::onAllTrackReady() { if (_rtsp) { _rtsp->onAllTrackReady(); } +#if defined(ENABLE_MP4) if (_fmp4) { _fmp4->onAllTrackReady(); } +#endif if (_track_listener) { _track_listener->onAllTrackReady(); } diff --git a/src/Common/MultiMediaSourceMuxer.h b/src/Common/MultiMediaSourceMuxer.h index 04833b06..475268d1 100644 --- a/src/Common/MultiMediaSourceMuxer.h +++ b/src/Common/MultiMediaSourceMuxer.h @@ -59,7 +59,9 @@ private: HlsRecorder::Ptr _hls; MediaSinkInterface::Ptr _mp4; TSMediaSourceMuxer::Ptr _ts; +#if defined(ENABLE_MP4) FMP4MediaSourceMuxer::Ptr _fmp4; +#endif std::weak_ptr _listener; }; diff --git a/src/FMP4/FMP4MediaSourceMuxer.h b/src/FMP4/FMP4MediaSourceMuxer.h index 6922eef8..3ac0ccd0 100644 --- a/src/FMP4/FMP4MediaSourceMuxer.h +++ b/src/FMP4/FMP4MediaSourceMuxer.h @@ -11,6 +11,8 @@ #ifndef ZLMEDIAKIT_FMP4MEDIASOURCEMUXER_H #define ZLMEDIAKIT_FMP4MEDIASOURCEMUXER_H +#if defined(ENABLE_MP4) + #include "FMP4MediaSource.h" #include "Record/MP4Muxer.h" @@ -82,4 +84,6 @@ private: }; }//namespace mediakit + +#endif// defined(ENABLE_MP4) #endif //ZLMEDIAKIT_FMP4MEDIASOURCEMUXER_H