整理代码,添加注释

This commit is contained in:
xiongziliang
2017-09-30 13:00:12 +08:00
parent e6bdfbce5c
commit c367df73a5
9 changed files with 254 additions and 148 deletions

BIN
src/.DS_Store vendored

Binary file not shown.

View File

@@ -37,17 +37,24 @@ namespace Rtmp {
unordered_map<string, RtmpPusher::rtmpCMDHandle> RtmpPusher::g_mapCmd;
RtmpPusher::RtmpPusher(const char *strApp,const char *strStream) {
static onceToken token([]() {
g_mapCmd.emplace("_error",&RtmpPusher::onCmd_result);
g_mapCmd.emplace("_result",&RtmpPusher::onCmd_result);
g_mapCmd.emplace("onStatus",&RtmpPusher::onCmd_onStatus);
}, []() {});
auto src = RtmpMediaSource::find(strApp,strStream);
if (!src) {
auto strErr = StrPrinter << "media source:" << strApp << "/" << strStream << "not found!" << endl;
throw std::runtime_error(strErr);
}
m_pMediaSrc = src;
init(src);
}
RtmpPusher::RtmpPusher(const RtmpMediaSource::Ptr &src){
init(src);
}
void RtmpPusher::init(const RtmpMediaSource::Ptr &src){
static onceToken token([]() {
g_mapCmd.emplace("_error",&RtmpPusher::onCmd_result);
g_mapCmd.emplace("_result",&RtmpPusher::onCmd_result);
g_mapCmd.emplace("onStatus",&RtmpPusher::onCmd_onStatus);
}, []() {});
m_pMediaSrc=src;
}
RtmpPusher::~RtmpPusher() {

View File

@@ -39,6 +39,7 @@ public:
typedef std::shared_ptr<RtmpPusher> Ptr;
typedef std::function<void(const SockException &ex)> Event;
RtmpPusher(const char *strApp,const char *strStream);
RtmpPusher(const RtmpMediaSource::Ptr &src);
virtual ~RtmpPusher();
void publish(const char* strUrl);
@@ -65,6 +66,7 @@ protected:
send(pcRawData, iSize);
}
private:
void init(const RtmpMediaSource::Ptr &src);
void onShutdown(const SockException &ex) {
m_pPublishTimer.reset();
if(m_onShutdown){