优化播放器接口

This commit is contained in:
xiongziliang
2017-08-03 13:55:46 +08:00
parent fcfb434cf2
commit afc36f5ef4
15 changed files with 98 additions and 66 deletions

View File

@@ -22,8 +22,7 @@ MediaPlayer::MediaPlayer() {
MediaPlayer::~MediaPlayer() {
teardown();
}
void MediaPlayer::play(const char* strUrl, const char* strUser, const char* strPwd, eRtpType eType) {
void MediaPlayer::play(const char* strUrl) {
string strPrefix = FindField(strUrl, NULL, "://");
if ((strcasecmp(m_strPrefix.data(),strPrefix.data()) != 0) || strPrefix.empty()) {
//协议切换
@@ -34,9 +33,11 @@ void MediaPlayer::play(const char* strUrl, const char* strUser, const char* strP
m_parser->setOnAudioCB(m_onGetAudioCB);
}
m_parser->setOnPlayResult(m_playResultCB);
m_parser->play(strUrl, strUser, strPwd, eType);
m_parser->mINI::operator=(*this);
m_parser->play(strUrl);
}
void MediaPlayer::pause(bool bPause) {
if (m_parser) {
m_parser->pause(bPause);

View File

@@ -12,8 +12,12 @@
#include <string>
#include "Player.h"
#include "PlayerBase.h"
#include "Rtsp/RtspPlayer.h"
#include "Rtmp/RtmpPlayer.h"
using namespace std;
using namespace ZL::Rtsp;
using namespace ZL::Rtmp;
namespace ZL {
namespace Player {
@@ -24,8 +28,7 @@ public:
MediaPlayer();
virtual ~MediaPlayer();
void play(const char* strUrl, const char *strUser = "", const char *strPwd = "", eRtpType eType = RTP_TCP) override;
void play(const char* strUrl) override;
void pause(bool bPause) override;
void teardown() override;
private:

View File

@@ -8,19 +8,22 @@
#ifndef SRC_PLAYER_PLAYERBASE_H_
#define SRC_PLAYER_PLAYERBASE_H_
#include <map>
#include <memory>
#include <string>
#include <functional>
#include "Player.h"
#include "Network/Socket.h"
#include "Util/mini.h"
using namespace std;
using namespace ZL::Util;
using namespace ZL::Network;
namespace ZL {
namespace Player {
class PlayerBase{
class PlayerBase : public mINI{
public:
typedef std::shared_ptr<PlayerBase> Ptr;
typedef enum {
@@ -32,8 +35,7 @@ public:
PlayerBase(){};
virtual ~PlayerBase(){};
virtual void play(const char* strUrl, const char *strUser = "", const char *strPwd = "", eRtpType eType = RTP_TCP) {};
virtual void play(const char* strUrl) {};
virtual void pause(bool bPause) {};
virtual void teardown() {};