rtsp/rtmp/mp4支持opus并整理代码

This commit is contained in:
xiongziliang
2020-08-01 10:22:12 +08:00
parent b4a3b608ab
commit a22f97c777
32 changed files with 556 additions and 635 deletions

View File

@@ -15,32 +15,22 @@
#include "Common/Device.h"
#include "Player/MediaPlayer.h"
#include "Util/TimeTicker.h"
using namespace std;
using namespace toolkit;
namespace mediakit {
class PlayerProxy :public MediaPlayer,
public std::enable_shared_from_this<PlayerProxy> ,
public MediaSourceEvent{
class PlayerProxy : public MediaPlayer, public MediaSourceEvent, public std::enable_shared_from_this<PlayerProxy> {
public:
typedef std::shared_ptr<PlayerProxy> Ptr;
//如果iRetryCount<0,则一直重试播放;否则重试iRetryCount次数
//如果retry_count<0,则一直重试播放;否则重试retry_count次数
//默认一直重试
PlayerProxy(const string &strVhost,
const string &strApp,
const string &strSrc,
bool bEnableRtsp = true,
bool bEnableRtmp = true,
bool bEnableHls = true,
bool bEnableMp4 = false,
int iRetryCount = -1,
const EventPoller::Ptr &poller = nullptr);
PlayerProxy(const string &vhost, const string &app, const string &stream_id,
bool enable_rtsp = true, bool enable_rtmp = true, bool enable_hls = true, bool enable_mp4 = false,
int retry_count = -1, const EventPoller::Ptr &poller = nullptr);
virtual ~PlayerProxy();
~PlayerProxy() override;
/**
* 设置play结果回调只触发一次在play执行之前有效
@@ -64,27 +54,28 @@ public:
* 获取观看总人数
*/
int totalReaderCount() ;
private:
//MediaSourceEvent override
bool close(MediaSource &sender,bool force) override;
int totalReaderCount(MediaSource &sender) override;
void rePlay(const string &strUrl,int iFailedCnt);
void onPlaySuccess();
private:
bool _bEnableRtsp;
bool _bEnableRtmp;
bool _bEnableHls;
bool _bEnableMp4;
int _iRetryCount;
MultiMediaSourceMuxer::Ptr _mediaMuxer;
string _strVhost;
string _strApp;
string _strSrc;
bool _enable_rtsp;
bool _enable_rtmp;
bool _enable_hls;
bool _enable_mp4;
int _retry_count;
string _vhost;
string _app;
string _stream_id;
Timer::Ptr _timer;
function<void(const SockException &ex)> _playCB;
function<void()> _onClose;
function<void()> _on_close;
function<void(const SockException &ex)> _on_play;
MultiMediaSourceMuxer::Ptr _muxer;
};
} /* namespace mediakit */
#endif /* SRC_DEVICE_PLAYERPROXY_H_ */