mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-19 14:52:20 +08:00
整理命名空间 (#1409)
* feat: remove using namespace mediakit in header files. (cherry picked from commit d44aeb339a8a0e1f0455be82b21fe4b1b536299f) * feat: remove using namespace mediakit in FFmpegSource.h * feat: remove using namespace mediakit in RtpExt.h * feat: remove using namespace mediakit in header files. * feat: remove using namespace std in header files. * feat: remove using namespace std in header files when zltoolkit remove std in header * 补充命名空间 * 整理命名空间 * 整理命名空间2 * 修复macos ci * 修复编译问题 * 修复编译问题2 * 修复编译问题3 Co-authored-by: Johnny <hellojinqiang@gmail.com> Co-authored-by: Xiaofeng Wang <wasphin@gmail.com>
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
#include "MediaPlayer.h"
|
||||
#include "Rtmp/RtmpPlayerImp.h"
|
||||
#include "Rtsp/RtspPlayerImp.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace toolkit;
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "Rtsp/RtspPlayer.h"
|
||||
#include "Rtmp/RtmpPlayer.h"
|
||||
#include "Thread/TaskExecutor.h"
|
||||
using namespace toolkit;
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
@@ -25,16 +24,16 @@ class MediaPlayer : public PlayerImp<PlayerBase, PlayerBase> {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<MediaPlayer>;
|
||||
|
||||
MediaPlayer(const EventPoller::Ptr &poller = nullptr);
|
||||
MediaPlayer(const toolkit::EventPoller::Ptr &poller = nullptr);
|
||||
~MediaPlayer() override = default;
|
||||
|
||||
void play(const string &url) override;
|
||||
EventPoller::Ptr getPoller();
|
||||
void setOnCreateSocket(Socket::onCreateSocket cb);
|
||||
void play(const std::string &url) override;
|
||||
toolkit::EventPoller::Ptr getPoller();
|
||||
void setOnCreateSocket(toolkit::Socket::onCreateSocket cb);
|
||||
|
||||
private:
|
||||
EventPoller::Ptr _poller;
|
||||
Socket::onCreateSocket _on_create_socket;
|
||||
toolkit::EventPoller::Ptr _poller;
|
||||
toolkit::Socket::onCreateSocket _on_create_socket;
|
||||
};
|
||||
|
||||
} /* namespace mediakit */
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include "Rtmp/RtmpPlayerImp.h"
|
||||
#include "Http/HlsPlayer.h"
|
||||
#include "Http/TsPlayerImp.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace toolkit;
|
||||
|
||||
namespace mediakit {
|
||||
@@ -61,10 +63,10 @@ PlayerBase::Ptr PlayerBase::createPlayer(const EventPoller::Ptr &poller, const s
|
||||
}
|
||||
|
||||
PlayerBase::PlayerBase() {
|
||||
this->mINI::operator[](kTimeoutMS) = 10000;
|
||||
this->mINI::operator[](kMediaTimeoutMS) = 5000;
|
||||
this->mINI::operator[](kBeatIntervalMS) = 5000;
|
||||
this->mINI::operator[](kWaitTrackReady) = true;
|
||||
this->mINI::operator[](Client::kTimeoutMS) = 10000;
|
||||
this->mINI::operator[](Client::kMediaTimeoutMS) = 5000;
|
||||
this->mINI::operator[](Client::kBeatIntervalMS) = 5000;
|
||||
this->mINI::operator[](Client::kWaitTrackReady) = true;
|
||||
}
|
||||
|
||||
///////////////////////////DemuxerSink//////////////////////////////
|
||||
|
||||
@@ -23,16 +23,14 @@
|
||||
#include "Extension/Frame.h"
|
||||
#include "Extension/Track.h"
|
||||
|
||||
using namespace toolkit;
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
class PlayerBase : public TrackSource, public mINI {
|
||||
class PlayerBase : public TrackSource, public toolkit::mINI {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<PlayerBase>;
|
||||
using Event = std::function<void(const SockException &ex)>;
|
||||
using Event = std::function<void(const toolkit::SockException &ex)>;
|
||||
|
||||
static Ptr createPlayer(const EventPoller::Ptr &poller, const string &strUrl);
|
||||
static Ptr createPlayer(const toolkit::EventPoller::Ptr &poller, const std::string &strUrl);
|
||||
|
||||
PlayerBase();
|
||||
~PlayerBase() override = default;
|
||||
@@ -41,7 +39,7 @@ public:
|
||||
* 开始播放
|
||||
* @param url 视频url,支持rtsp/rtmp
|
||||
*/
|
||||
virtual void play(const string &url) {};
|
||||
virtual void play(const std::string &url) {};
|
||||
|
||||
/**
|
||||
* 暂停或恢复
|
||||
@@ -96,7 +94,7 @@ public:
|
||||
/**
|
||||
* 获取所有track
|
||||
*/
|
||||
vector<Track::Ptr> getTracks(bool ready = true) const override { return vector<Track::Ptr>(); };
|
||||
std::vector<Track::Ptr> getTracks(bool ready = true) const override { return std::vector<Track::Ptr>(); };
|
||||
|
||||
/**
|
||||
* 设置一个MediaSource,直接生产rtsp/rtmp代理
|
||||
@@ -116,12 +114,12 @@ public:
|
||||
/**
|
||||
* 设置播放恢复回调
|
||||
*/
|
||||
virtual void setOnResume(const function<void()> &cb) = 0;
|
||||
virtual void setOnResume(const std::function<void()> &cb) = 0;
|
||||
|
||||
protected:
|
||||
virtual void onResume() = 0;
|
||||
virtual void onShutdown(const SockException &ex) = 0;
|
||||
virtual void onPlayResult(const SockException &ex) = 0;
|
||||
virtual void onShutdown(const toolkit::SockException &ex) = 0;
|
||||
virtual void onPlayResult(const toolkit::SockException &ex) = 0;
|
||||
};
|
||||
|
||||
template<typename Parent, typename Delegate>
|
||||
@@ -133,7 +131,7 @@ public:
|
||||
PlayerImp(ArgsType &&...args) : Parent(std::forward<ArgsType>(args)...) {}
|
||||
~PlayerImp() override = default;
|
||||
|
||||
void play(const string &url) override {
|
||||
void play(const std::string &url) override {
|
||||
return _delegate ? _delegate->play(url) : Parent::play(url);
|
||||
}
|
||||
|
||||
@@ -173,12 +171,12 @@ public:
|
||||
return _delegate ? _delegate->seekTo(pos) : Parent::seekTo(pos);
|
||||
}
|
||||
|
||||
vector<Track::Ptr> getTracks(bool ready = true) const override {
|
||||
std::vector<Track::Ptr> getTracks(bool ready = true) const override {
|
||||
return _delegate ? _delegate->getTracks(ready) : Parent::getTracks(ready);
|
||||
}
|
||||
|
||||
std::shared_ptr<SockInfo> getSockInfo() const {
|
||||
return dynamic_pointer_cast<SockInfo>(_delegate);
|
||||
std::shared_ptr<toolkit::SockInfo> getSockInfo() const {
|
||||
return std::dynamic_pointer_cast<toolkit::SockInfo>(_delegate);
|
||||
}
|
||||
|
||||
void setMediaSource(const MediaSource::Ptr &src) override {
|
||||
@@ -188,21 +186,21 @@ public:
|
||||
_media_src = src;
|
||||
}
|
||||
|
||||
void setOnShutdown(const function<void(const SockException &)> &cb) override {
|
||||
void setOnShutdown(const std::function<void(const toolkit::SockException &)> &cb) override {
|
||||
if (_delegate) {
|
||||
_delegate->setOnShutdown(cb);
|
||||
}
|
||||
_on_shutdown = cb;
|
||||
}
|
||||
|
||||
void setOnPlayResult(const function<void(const SockException &ex)> &cb) override {
|
||||
void setOnPlayResult(const std::function<void(const toolkit::SockException &ex)> &cb) override {
|
||||
if (_delegate) {
|
||||
_delegate->setOnPlayResult(cb);
|
||||
}
|
||||
_on_play_result = cb;
|
||||
}
|
||||
|
||||
void setOnResume(const function<void()> &cb) override {
|
||||
void setOnResume(const std::function<void()> &cb) override {
|
||||
if (_delegate) {
|
||||
_delegate->setOnResume(cb);
|
||||
}
|
||||
@@ -210,14 +208,14 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onShutdown(const SockException &ex) override {
|
||||
void onShutdown(const toolkit::SockException &ex) override {
|
||||
if (_on_shutdown) {
|
||||
_on_shutdown(ex);
|
||||
_on_shutdown = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void onPlayResult(const SockException &ex) override {
|
||||
void onPlayResult(const toolkit::SockException &ex) override {
|
||||
if (_on_play_result) {
|
||||
_on_play_result(ex);
|
||||
_on_play_result = nullptr;
|
||||
@@ -231,7 +229,7 @@ protected:
|
||||
}
|
||||
|
||||
protected:
|
||||
function<void()> _on_resume;
|
||||
std::function<void()> _on_resume;
|
||||
PlayerBase::Event _on_shutdown;
|
||||
PlayerBase::Event _on_play_result;
|
||||
MediaSource::Ptr _media_src;
|
||||
@@ -263,7 +261,7 @@ public:
|
||||
~Demuxer() override = default;
|
||||
|
||||
void setTrackListener(TrackListener *listener, bool wait_track_ready = false);
|
||||
vector<Track::Ptr> getTracks(bool trackReady = true) const override;
|
||||
std::vector<Track::Ptr> getTracks(bool trackReady = true) const override;
|
||||
|
||||
protected:
|
||||
bool addTrack(const Track::Ptr &track) override;
|
||||
@@ -273,7 +271,7 @@ protected:
|
||||
private:
|
||||
MediaSink::Ptr _sink;
|
||||
TrackListener *_listener = nullptr;
|
||||
vector<Track::Ptr> _origin_track;
|
||||
std::vector<Track::Ptr> _origin_track;
|
||||
};
|
||||
|
||||
} /* namespace mediakit */
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "Extension/AAC.h"
|
||||
|
||||
using namespace toolkit;
|
||||
using namespace std;
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
#include "Common/Device.h"
|
||||
#include "Player/MediaPlayer.h"
|
||||
#include "Util/TimeTicker.h"
|
||||
using namespace std;
|
||||
using namespace toolkit;
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
@@ -26,9 +24,9 @@ public:
|
||||
|
||||
//如果retry_count<0,则一直重试播放;否则重试retry_count次数
|
||||
//默认一直重试
|
||||
PlayerProxy(const string &vhost, const string &app, const string &stream_id,
|
||||
PlayerProxy(const std::string &vhost, const std::string &app, const std::string &stream_id,
|
||||
bool enable_hls = true, bool enable_mp4 = false,
|
||||
int retry_count = -1, const EventPoller::Ptr &poller = nullptr);
|
||||
int retry_count = -1, const toolkit::EventPoller::Ptr &poller = nullptr);
|
||||
|
||||
~PlayerProxy() override;
|
||||
|
||||
@@ -36,19 +34,19 @@ public:
|
||||
* 设置play结果回调,只触发一次;在play执行之前有效
|
||||
* @param cb 回调对象
|
||||
*/
|
||||
void setPlayCallbackOnce(const function<void(const SockException &ex)> &cb);
|
||||
void setPlayCallbackOnce(const std::function<void(const toolkit::SockException &ex)> &cb);
|
||||
|
||||
/**
|
||||
* 设置主动关闭回调
|
||||
* @param cb 回调对象
|
||||
*/
|
||||
void setOnClose(const function<void(const SockException &ex)> &cb);
|
||||
void setOnClose(const std::function<void(const toolkit::SockException &ex)> &cb);
|
||||
|
||||
/**
|
||||
* 开始拉流播放
|
||||
* @param strUrl
|
||||
*/
|
||||
void play(const string &strUrl) override;
|
||||
void play(const std::string &strUrl) override;
|
||||
|
||||
/**
|
||||
* 获取观看总人数
|
||||
@@ -60,10 +58,10 @@ private:
|
||||
bool close(MediaSource &sender,bool force) override;
|
||||
int totalReaderCount(MediaSource &sender) override;
|
||||
MediaOriginType getOriginType(MediaSource &sender) const override;
|
||||
string getOriginUrl(MediaSource &sender) const override;
|
||||
std::shared_ptr<SockInfo> getOriginSock(MediaSource &sender) const override;
|
||||
std::string getOriginUrl(MediaSource &sender) const override;
|
||||
std::shared_ptr<toolkit::SockInfo> getOriginSock(MediaSource &sender) const override;
|
||||
|
||||
void rePlay(const string &strUrl,int iFailedCnt);
|
||||
void rePlay(const std::string &strUrl,int iFailedCnt);
|
||||
void onPlaySuccess();
|
||||
void setDirectProxy();
|
||||
|
||||
@@ -71,13 +69,13 @@ private:
|
||||
bool _enable_hls;
|
||||
bool _enable_mp4;
|
||||
int _retry_count;
|
||||
string _vhost;
|
||||
string _app;
|
||||
string _stream_id;
|
||||
string _pull_url;
|
||||
Timer::Ptr _timer;
|
||||
function<void(const SockException &ex)> _on_close;
|
||||
function<void(const SockException &ex)> _on_play;
|
||||
std::string _vhost;
|
||||
std::string _app;
|
||||
std::string _stream_id;
|
||||
std::string _pull_url;
|
||||
toolkit::Timer::Ptr _timer;
|
||||
std::function<void(const toolkit::SockException &ex)> _on_close;
|
||||
std::function<void(const toolkit::SockException &ex)> _on_play;
|
||||
MultiMediaSourceMuxer::Ptr _muxer;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user