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 "MediaPusher.h"
|
|
|
|
|
|
#include "PusherBase.h"
|
|
|
|
|
|
|
|
|
|
|
|
using namespace toolkit;
|
|
|
|
|
|
|
|
|
|
|
|
namespace mediakit {
|
|
|
|
|
|
|
2019-04-01 10:16:15 +08:00
|
|
|
|
MediaPusher::MediaPusher(const MediaSource::Ptr &src,
|
|
|
|
|
|
const EventPoller::Ptr &poller) {
|
2019-03-27 18:41:52 +08:00
|
|
|
|
_src = src;
|
2019-04-01 10:16:15 +08:00
|
|
|
|
_poller = poller;
|
|
|
|
|
|
if(!_poller){
|
|
|
|
|
|
_poller = EventPollerPool::Instance().getPoller();
|
|
|
|
|
|
}
|
2019-03-27 18:41:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MediaPusher::MediaPusher(const string &schema,
|
|
|
|
|
|
const string &strVhost,
|
|
|
|
|
|
const string &strApp,
|
2019-04-01 10:16:15 +08:00
|
|
|
|
const string &strStream,
|
|
|
|
|
|
const EventPoller::Ptr &poller) :
|
|
|
|
|
|
MediaPusher(MediaSource::find(schema,strVhost,strApp,strStream),poller){
|
2019-03-27 18:41:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MediaPusher::~MediaPusher() {
|
|
|
|
|
|
}
|
|
|
|
|
|
void MediaPusher::publish(const string &strUrl) {
|
2019-12-04 10:59:13 +08:00
|
|
|
|
_delegate = PusherBase::createPusher(_poller,_src.lock(),strUrl);
|
|
|
|
|
|
_delegate->setOnShutdown(_shutdownCB);
|
|
|
|
|
|
_delegate->setOnPublished(_publishCB);
|
|
|
|
|
|
_delegate->mINI::operator=(*this);
|
|
|
|
|
|
_delegate->publish(strUrl);
|
2019-03-27 18:41:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EventPoller::Ptr MediaPusher::getPoller(){
|
2019-04-01 10:16:15 +08:00
|
|
|
|
return _poller;
|
2019-03-27 18:41:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} /* namespace mediakit */
|