2019-08-08 19:01:45 +08:00
|
|
|
|
/*
|
2020-04-04 20:30:09 +08:00
|
|
|
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by MIT license that can be found in the
|
|
|
|
|
* LICENSE file in the root of the source tree. All contributing project authors
|
|
|
|
|
* may be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
2019-03-27 18:41:52 +08:00
|
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include "PusherBase.h"
|
|
|
|
|
#include "Rtsp/RtspPusher.h"
|
|
|
|
|
#include "Rtmp/RtmpPusher.h"
|
|
|
|
|
|
|
|
|
|
using namespace toolkit;
|
2019-03-27 18:56:49 +08:00
|
|
|
|
using namespace mediakit::Client;
|
2019-03-27 18:41:52 +08:00
|
|
|
|
|
|
|
|
|
namespace mediakit {
|
|
|
|
|
|
2019-04-01 10:16:15 +08:00
|
|
|
|
PusherBase::Ptr PusherBase::createPusher(const EventPoller::Ptr &poller,
|
|
|
|
|
const MediaSource::Ptr &src,
|
2019-03-27 18:41:52 +08:00
|
|
|
|
const string & strUrl) {
|
|
|
|
|
static auto releasePusher = [](PusherBase *ptr){
|
|
|
|
|
onceToken token(nullptr,[&](){
|
|
|
|
|
delete ptr;
|
|
|
|
|
});
|
|
|
|
|
ptr->teardown();
|
|
|
|
|
};
|
|
|
|
|
string prefix = FindField(strUrl.data(), NULL, "://");
|
2019-07-20 20:53:50 +08:00
|
|
|
|
|
|
|
|
|
if (strcasecmp("rtsps",prefix.data()) == 0) {
|
|
|
|
|
return PusherBase::Ptr(new TcpClientWithSSL<RtspPusher>(poller,dynamic_pointer_cast<RtspMediaSource>(src)),releasePusher);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-27 18:41:52 +08:00
|
|
|
|
if (strcasecmp("rtsp",prefix.data()) == 0) {
|
2019-04-01 10:16:15 +08:00
|
|
|
|
return PusherBase::Ptr(new RtspPusher(poller,dynamic_pointer_cast<RtspMediaSource>(src)),releasePusher);
|
2019-03-27 18:41:52 +08:00
|
|
|
|
}
|
2019-07-20 20:53:50 +08:00
|
|
|
|
|
|
|
|
|
if (strcasecmp("rtmps",prefix.data()) == 0) {
|
|
|
|
|
return PusherBase::Ptr(new TcpClientWithSSL<RtmpPusher>(poller,dynamic_pointer_cast<RtmpMediaSource>(src)),releasePusher);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-27 18:41:52 +08:00
|
|
|
|
if (strcasecmp("rtmp",prefix.data()) == 0) {
|
2019-04-01 10:16:15 +08:00
|
|
|
|
return PusherBase::Ptr(new RtmpPusher(poller,dynamic_pointer_cast<RtmpMediaSource>(src)),releasePusher);
|
2019-03-27 18:41:52 +08:00
|
|
|
|
}
|
2019-07-20 20:53:50 +08:00
|
|
|
|
|
2019-04-01 10:16:15 +08:00
|
|
|
|
return PusherBase::Ptr(new RtspPusher(poller,dynamic_pointer_cast<RtspMediaSource>(src)),releasePusher);
|
2019-03-27 18:41:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PusherBase::PusherBase() {
|
2019-03-27 18:56:49 +08:00
|
|
|
|
this->mINI::operator[](kTimeoutMS) = 10000;
|
2019-03-27 18:41:52 +08:00
|
|
|
|
this->mINI::operator[](kBeatIntervalMS) = 5000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} /* namespace mediakit */
|