From 8f847ffb780cddffdd109127f740f581c29bc069 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Tue, 6 Jun 2017 20:08:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Rtmp=E6=8E=A8=E6=B5=81?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_rtmpPusher.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_rtmpPusher.cpp b/tests/test_rtmpPusher.cpp index 11021cde..eb0a9aff 100644 --- a/tests/test_rtmpPusher.cpp +++ b/tests/test_rtmpPusher.cpp @@ -43,9 +43,13 @@ int main(int argc,char *argv[]){ //媒体源"app/stream"已经注册,这时方可新建一个RtmpPusher对象并绑定该媒体源 const_cast(pusher).reset(new RtmpPusher(app,stream)); + pusher->setOnShutdown([](const SockException &ex){ + WarnL << "已断开与服务器连接:" << ex.getErrCode() << " " << ex.what(); + }); + pusher->setOnPublished([](const SockException &ex){ if(ex){ - WarnL << "发布失败:" << ex.what(); + WarnL << "发布失败:" << ex.getErrCode() << " "<< ex.what(); }else{ InfoL << "发布成功,请用播放器打开:rtmp://jizan.iok.la/live/test"; } @@ -54,7 +58,6 @@ int main(int argc,char *argv[]){ //推流地址,请改成你自己的服务器。 //这个范例地址(也是基于mediakit)是可用的,但是带宽只有1mb,访问可能很卡顿。 pusher->publish("rtmp://jizan.iok.la/live/test"); - //如果你想监听RtmpPusher的相关事件,请派生之并重载 onShutdown 与 onPlayResult方法 }); EventPoller::Instance().runLoop();