mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 12:37:09 +08:00
添加媒体生成源信息
This commit is contained in:
parent
2cf66594e8
commit
5cd8e8ae1c
@ -245,6 +245,18 @@ bool FFmpegSource::close(MediaSource &sender, bool force) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaOriginType FFmpegSource::getOriginType(MediaSource &sender) const{
|
||||||
|
return MediaOriginType::ffmpeg_pull;
|
||||||
|
}
|
||||||
|
|
||||||
|
string FFmpegSource::getOriginUrl(MediaSource &sender) const{
|
||||||
|
return _src_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<SockInfo> FFmpegSource::getOriginSock(MediaSource &sender) const {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void FFmpegSource::onGetMediaSource(const MediaSource::Ptr &src) {
|
void FFmpegSource::onGetMediaSource(const MediaSource::Ptr &src) {
|
||||||
auto listener = src->getListener();
|
auto listener = src->getListener();
|
||||||
if (listener.lock().get() != this) {
|
if (listener.lock().get() != this) {
|
||||||
|
@ -58,8 +58,15 @@ private:
|
|||||||
void startTimer(int timeout_ms);
|
void startTimer(int timeout_ms);
|
||||||
void onGetMediaSource(const MediaSource::Ptr &src);
|
void onGetMediaSource(const MediaSource::Ptr &src);
|
||||||
|
|
||||||
//MediaSourceEvent override
|
///////MediaSourceEvent override///////
|
||||||
|
// 关闭
|
||||||
bool close(MediaSource &sender,bool force) override;
|
bool close(MediaSource &sender,bool force) override;
|
||||||
|
// 获取媒体源类型
|
||||||
|
MediaOriginType getOriginType(MediaSource &sender) const override;
|
||||||
|
//获取媒体源url或者文件路径
|
||||||
|
string getOriginUrl(MediaSource &sender) const override;
|
||||||
|
// 获取媒体源客户端相关信息
|
||||||
|
std::shared_ptr<SockInfo> getOriginSock(MediaSource &sender) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Process _process;
|
Process _process;
|
||||||
|
@ -397,6 +397,20 @@ void installWebApi() {
|
|||||||
item["stream"] = media->getId();
|
item["stream"] = media->getId();
|
||||||
item["readerCount"] = media->readerCount();
|
item["readerCount"] = media->readerCount();
|
||||||
item["totalReaderCount"] = media->totalReaderCount();
|
item["totalReaderCount"] = media->totalReaderCount();
|
||||||
|
item["originType"] = (int) media->getOriginType();
|
||||||
|
item["originTypeStr"] = getOriginTypeString(media->getOriginType());
|
||||||
|
item["originUrl"] = media->getOriginUrl();
|
||||||
|
auto originSock = media->getOriginSock();
|
||||||
|
if (originSock) {
|
||||||
|
item["originSock"]["local_ip"] = originSock->get_local_ip();
|
||||||
|
item["originSock"]["local_port"] = originSock->get_local_port();
|
||||||
|
item["originSock"]["peer_ip"] = originSock->get_peer_ip();
|
||||||
|
item["originSock"]["peer_port"] = originSock->get_peer_port();
|
||||||
|
item["originSock"]["identifier"] = originSock->getIdentifier();
|
||||||
|
} else {
|
||||||
|
item["originSock"] = Json::nullValue;
|
||||||
|
}
|
||||||
|
|
||||||
for(auto &track : media->getTracks()){
|
for(auto &track : media->getTracks()){
|
||||||
Value obj;
|
Value obj;
|
||||||
auto codec_type = track->getTrackType();
|
auto codec_type = track->getTrackType();
|
||||||
|
@ -166,5 +166,9 @@ void DevChannel::initAudio(const AudioInfo &info) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaOriginType DevChannel::getOriginType(MediaSource &sender) const {
|
||||||
|
return MediaOriginType::device_chn;
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace mediakit */
|
} /* namespace mediakit */
|
||||||
|
|
||||||
|
@ -128,6 +128,9 @@ public:
|
|||||||
void inputPCM(char *pcData, int iDataLen, uint32_t uiStamp);
|
void inputPCM(char *pcData, int iDataLen, uint32_t uiStamp);
|
||||||
#endif //ENABLE_FAAC
|
#endif //ENABLE_FAAC
|
||||||
|
|
||||||
|
private:
|
||||||
|
MediaOriginType getOriginType(MediaSource &sender) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#ifdef ENABLE_X264
|
#ifdef ENABLE_X264
|
||||||
|
@ -19,6 +19,20 @@ namespace mediakit {
|
|||||||
recursive_mutex s_media_source_mtx;
|
recursive_mutex s_media_source_mtx;
|
||||||
MediaSource::SchemaVhostAppStreamMap s_media_source_map;
|
MediaSource::SchemaVhostAppStreamMap s_media_source_map;
|
||||||
|
|
||||||
|
string getOriginTypeString(MediaOriginType type){
|
||||||
|
#define SWITCH_CASE(type) case type : return #type
|
||||||
|
switch (type) {
|
||||||
|
SWITCH_CASE(MediaOriginType::unknown);
|
||||||
|
SWITCH_CASE(MediaOriginType::rtmp_push);
|
||||||
|
SWITCH_CASE(MediaOriginType::rtsp_push);
|
||||||
|
SWITCH_CASE(MediaOriginType::rtp_push);
|
||||||
|
SWITCH_CASE(MediaOriginType::pull);
|
||||||
|
SWITCH_CASE(MediaOriginType::ffmpeg_pull);
|
||||||
|
SWITCH_CASE(MediaOriginType::mp4_vod);
|
||||||
|
SWITCH_CASE(MediaOriginType::device_chn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MediaSource::MediaSource(const string &schema, const string &vhost, const string &app, const string &stream_id){
|
MediaSource::MediaSource(const string &schema, const string &vhost, const string &app, const string &stream_id){
|
||||||
GET_CONFIG(bool, enableVhost, General::kEnableVhost);
|
GET_CONFIG(bool, enableVhost, General::kEnableVhost);
|
||||||
if (!enableVhost) {
|
if (!enableVhost) {
|
||||||
@ -76,6 +90,30 @@ int MediaSource::totalReaderCount(){
|
|||||||
return listener->totalReaderCount(*this);
|
return listener->totalReaderCount(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaOriginType MediaSource::getOriginType() const {
|
||||||
|
auto listener = _listener.lock();
|
||||||
|
if (!listener) {
|
||||||
|
return MediaOriginType::unknown;
|
||||||
|
}
|
||||||
|
return listener->getOriginType(const_cast<MediaSource &>(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
string MediaSource::getOriginUrl() const {
|
||||||
|
auto listener = _listener.lock();
|
||||||
|
if (!listener) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return listener->getOriginUrl(const_cast<MediaSource &>(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<SockInfo> MediaSource::getOriginSock() const {
|
||||||
|
auto listener = _listener.lock();
|
||||||
|
if (!listener) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return listener->getOriginSock(const_cast<MediaSource &>(*this));
|
||||||
|
}
|
||||||
|
|
||||||
bool MediaSource::seekTo(uint32_t stamp) {
|
bool MediaSource::seekTo(uint32_t stamp) {
|
||||||
auto listener = _listener.lock();
|
auto listener = _listener.lock();
|
||||||
if(!listener){
|
if(!listener){
|
||||||
@ -365,6 +403,7 @@ bool MediaSource::unregist() {
|
|||||||
/////////////////////////////////////MediaInfo//////////////////////////////////////
|
/////////////////////////////////////MediaInfo//////////////////////////////////////
|
||||||
|
|
||||||
void MediaInfo::parse(const string &url_in){
|
void MediaInfo::parse(const string &url_in){
|
||||||
|
_full_url = url_in;
|
||||||
string url = url_in;
|
string url = url_in;
|
||||||
auto pos = url.find("?");
|
auto pos = url.find("?");
|
||||||
if (pos != string::npos) {
|
if (pos != string::npos) {
|
||||||
@ -486,6 +525,30 @@ void MediaSourceEvent::onReaderChanged(MediaSource &sender, int size){
|
|||||||
}, nullptr);
|
}, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaOriginType MediaSourceEventInterceptor::getOriginType(MediaSource &sender) const {
|
||||||
|
auto listener = _listener.lock();
|
||||||
|
if (!listener) {
|
||||||
|
return MediaOriginType::unknown;
|
||||||
|
}
|
||||||
|
return listener->getOriginType(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
string MediaSourceEventInterceptor::getOriginUrl(MediaSource &sender) const {
|
||||||
|
auto listener = _listener.lock();
|
||||||
|
if (!listener) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return listener->getOriginUrl(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<SockInfo> MediaSourceEventInterceptor::getOriginSock(MediaSource &sender) const {
|
||||||
|
auto listener = _listener.lock();
|
||||||
|
if (!listener) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return listener->getOriginSock(sender);
|
||||||
|
}
|
||||||
|
|
||||||
bool MediaSourceEventInterceptor::seekTo(MediaSource &sender, uint32_t stamp) {
|
bool MediaSourceEventInterceptor::seekTo(MediaSource &sender, uint32_t stamp) {
|
||||||
auto listener = _listener.lock();
|
auto listener = _listener.lock();
|
||||||
if (!listener) {
|
if (!listener) {
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "Util/TimeTicker.h"
|
#include "Util/TimeTicker.h"
|
||||||
#include "Util/NoticeCenter.h"
|
#include "Util/NoticeCenter.h"
|
||||||
#include "Util/List.h"
|
#include "Util/List.h"
|
||||||
|
#include "Network/Socket.h"
|
||||||
#include "Rtsp/Rtsp.h"
|
#include "Rtsp/Rtsp.h"
|
||||||
#include "Rtmp/Rtmp.h"
|
#include "Rtmp/Rtmp.h"
|
||||||
#include "Extension/Track.h"
|
#include "Extension/Track.h"
|
||||||
@ -36,6 +37,19 @@ namespace toolkit{
|
|||||||
|
|
||||||
namespace mediakit {
|
namespace mediakit {
|
||||||
|
|
||||||
|
enum class MediaOriginType : uint8_t {
|
||||||
|
unknown = 0,
|
||||||
|
rtmp_push ,
|
||||||
|
rtsp_push,
|
||||||
|
rtp_push,
|
||||||
|
pull,
|
||||||
|
ffmpeg_pull,
|
||||||
|
mp4_vod,
|
||||||
|
device_chn
|
||||||
|
};
|
||||||
|
|
||||||
|
string getOriginTypeString(MediaOriginType type);
|
||||||
|
|
||||||
class MediaSource;
|
class MediaSource;
|
||||||
class MediaSourceEvent{
|
class MediaSourceEvent{
|
||||||
public:
|
public:
|
||||||
@ -43,6 +57,13 @@ public:
|
|||||||
MediaSourceEvent(){};
|
MediaSourceEvent(){};
|
||||||
virtual ~MediaSourceEvent(){};
|
virtual ~MediaSourceEvent(){};
|
||||||
|
|
||||||
|
// 获取媒体源类型
|
||||||
|
virtual MediaOriginType getOriginType(MediaSource &sender) const { return MediaOriginType::unknown; }
|
||||||
|
// 获取媒体源url或者文件路径
|
||||||
|
virtual string getOriginUrl(MediaSource &sender) const { return ""; }
|
||||||
|
// 获取媒体源客户端相关信息
|
||||||
|
virtual std::shared_ptr<SockInfo> getOriginSock(MediaSource &sender) const { return nullptr; }
|
||||||
|
|
||||||
// 通知拖动进度条
|
// 通知拖动进度条
|
||||||
virtual bool seekTo(MediaSource &sender, uint32_t stamp) { return false; }
|
virtual bool seekTo(MediaSource &sender, uint32_t stamp) { return false; }
|
||||||
// 通知其停止产生流
|
// 通知其停止产生流
|
||||||
@ -76,6 +97,10 @@ public:
|
|||||||
MediaSourceEventInterceptor(){}
|
MediaSourceEventInterceptor(){}
|
||||||
~MediaSourceEventInterceptor() override {}
|
~MediaSourceEventInterceptor() override {}
|
||||||
|
|
||||||
|
MediaOriginType getOriginType(MediaSource &sender) const override;
|
||||||
|
string getOriginUrl(MediaSource &sender) const override;
|
||||||
|
std::shared_ptr<SockInfo> getOriginSock(MediaSource &sender) const override;
|
||||||
|
|
||||||
bool seekTo(MediaSource &sender, uint32_t stamp) override;
|
bool seekTo(MediaSource &sender, uint32_t stamp) override;
|
||||||
bool close(MediaSource &sender, bool force) override;
|
bool close(MediaSource &sender, bool force) override;
|
||||||
int totalReaderCount(MediaSource &sender) override;
|
int totalReaderCount(MediaSource &sender) override;
|
||||||
@ -102,6 +127,7 @@ public:
|
|||||||
void parse(const string &url);
|
void parse(const string &url);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
string _full_url;
|
||||||
string _schema;
|
string _schema;
|
||||||
string _host;
|
string _host;
|
||||||
string _port;
|
string _port;
|
||||||
@ -156,6 +182,13 @@ public:
|
|||||||
// 观看者个数,包括(hls/rtsp/rtmp)
|
// 观看者个数,包括(hls/rtsp/rtmp)
|
||||||
virtual int totalReaderCount();
|
virtual int totalReaderCount();
|
||||||
|
|
||||||
|
// 获取媒体源类型
|
||||||
|
MediaOriginType getOriginType() const;
|
||||||
|
// 获取媒体源url或者文件路径
|
||||||
|
string getOriginUrl() const;
|
||||||
|
// 获取媒体源客户端相关信息
|
||||||
|
std::shared_ptr<SockInfo> getOriginSock() const;
|
||||||
|
|
||||||
// 拖动进度条
|
// 拖动进度条
|
||||||
bool seekTo(uint32_t stamp);
|
bool seekTo(uint32_t stamp);
|
||||||
// 关闭该流
|
// 关闭该流
|
||||||
|
@ -194,6 +194,11 @@ public:
|
|||||||
}
|
}
|
||||||
return Parent::getTracks(trackReady);
|
return Parent::getTracks(trackReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<SockInfo> getSockInfo() const{
|
||||||
|
return dynamic_pointer_cast<SockInfo>(_delegate);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onShutdown(const SockException &ex) override {
|
void onShutdown(const SockException &ex) override {
|
||||||
if (_shutdownCB) {
|
if (_shutdownCB) {
|
||||||
|
@ -112,6 +112,7 @@ void PlayerProxy::play(const string &strUrlTmp) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
MediaPlayer::play(strUrlTmp);
|
MediaPlayer::play(strUrlTmp);
|
||||||
|
_pull_url = strUrlTmp;
|
||||||
|
|
||||||
MediaSource::Ptr mediaSource;
|
MediaSource::Ptr mediaSource;
|
||||||
if(dynamic_pointer_cast<RtspPlayer>(_delegate)){
|
if(dynamic_pointer_cast<RtspPlayer>(_delegate)){
|
||||||
@ -180,6 +181,18 @@ int PlayerProxy::totalReaderCount(MediaSource &sender) {
|
|||||||
return totalReaderCount();
|
return totalReaderCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaOriginType PlayerProxy::getOriginType(MediaSource &sender) const{
|
||||||
|
return MediaOriginType::pull;
|
||||||
|
}
|
||||||
|
|
||||||
|
string PlayerProxy::getOriginUrl(MediaSource &sender) const{
|
||||||
|
return _pull_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<SockInfo> PlayerProxy::getOriginSock(MediaSource &sender) const{
|
||||||
|
return getSockInfo();
|
||||||
|
}
|
||||||
|
|
||||||
class MuteAudioMaker : public FrameDispatcher{
|
class MuteAudioMaker : public FrameDispatcher{
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<MuteAudioMaker> Ptr;
|
typedef std::shared_ptr<MuteAudioMaker> Ptr;
|
||||||
|
@ -59,6 +59,10 @@ private:
|
|||||||
//MediaSourceEvent override
|
//MediaSourceEvent override
|
||||||
bool close(MediaSource &sender,bool force) override;
|
bool close(MediaSource &sender,bool force) override;
|
||||||
int totalReaderCount(MediaSource &sender) override;
|
int totalReaderCount(MediaSource &sender) override;
|
||||||
|
MediaOriginType getOriginType(MediaSource &sender) const override;
|
||||||
|
string getOriginUrl(MediaSource &sender) const override;
|
||||||
|
std::shared_ptr<SockInfo> getOriginSock(MediaSource &sender) const override;
|
||||||
|
|
||||||
void rePlay(const string &strUrl,int iFailedCnt);
|
void rePlay(const string &strUrl,int iFailedCnt);
|
||||||
void onPlaySuccess();
|
void onPlaySuccess();
|
||||||
|
|
||||||
@ -69,6 +73,7 @@ private:
|
|||||||
string _vhost;
|
string _vhost;
|
||||||
string _app;
|
string _app;
|
||||||
string _stream_id;
|
string _stream_id;
|
||||||
|
string _pull_url;
|
||||||
Timer::Ptr _timer;
|
Timer::Ptr _timer;
|
||||||
function<void()> _on_close;
|
function<void()> _on_close;
|
||||||
function<void(const SockException &ex)> _on_play;
|
function<void(const SockException &ex)> _on_play;
|
||||||
|
@ -109,6 +109,11 @@ public:
|
|||||||
}
|
}
|
||||||
_shutdownCB = cb;
|
_shutdownCB = cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<SockInfo> getSockInfo() const{
|
||||||
|
return dynamic_pointer_cast<SockInfo>(_delegate);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PusherBase::Event _shutdownCB;
|
PusherBase::Event _shutdownCB;
|
||||||
PusherBase::Event _publishCB;
|
PusherBase::Event _publishCB;
|
||||||
|
@ -17,24 +17,24 @@ namespace mediakit {
|
|||||||
|
|
||||||
MP4Reader::MP4Reader(const string &strVhost,const string &strApp, const string &strId,const string &filePath ) {
|
MP4Reader::MP4Reader(const string &strVhost,const string &strApp, const string &strId,const string &filePath ) {
|
||||||
_poller = WorkThreadPool::Instance().getPoller();
|
_poller = WorkThreadPool::Instance().getPoller();
|
||||||
auto strFileName = filePath;
|
_file_path = filePath;
|
||||||
if(strFileName.empty()){
|
if(_file_path.empty()){
|
||||||
GET_CONFIG(string,recordPath,Record::kFilePath);
|
GET_CONFIG(string,recordPath,Record::kFilePath);
|
||||||
GET_CONFIG(bool,enableVhost,General::kEnableVhost);
|
GET_CONFIG(bool,enableVhost,General::kEnableVhost);
|
||||||
if(enableVhost){
|
if(enableVhost){
|
||||||
strFileName = strVhost + "/" + strApp + "/" + strId;
|
_file_path = strVhost + "/" + strApp + "/" + strId;
|
||||||
}else{
|
}else{
|
||||||
strFileName = strApp + "/" + strId;
|
_file_path = strApp + "/" + strId;
|
||||||
}
|
}
|
||||||
strFileName = File::absolutePath(strFileName,recordPath);
|
_file_path = File::absolutePath(_file_path,recordPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
_demuxer = std::make_shared<MP4Demuxer>();
|
_demuxer = std::make_shared<MP4Demuxer>();
|
||||||
_demuxer->openMP4(strFileName);
|
_demuxer->openMP4(_file_path);
|
||||||
_mediaMuxer.reset(new MultiMediaSourceMuxer(strVhost, strApp, strId, _demuxer->getDurationMS() / 1000.0, true, true, false, false));
|
_mediaMuxer.reset(new MultiMediaSourceMuxer(strVhost, strApp, strId, _demuxer->getDurationMS() / 1000.0, true, true, false, false));
|
||||||
auto tracks = _demuxer->getTracks(false);
|
auto tracks = _demuxer->getTracks(false);
|
||||||
if(tracks.empty()){
|
if(tracks.empty()){
|
||||||
throw std::runtime_error(StrPrinter << "该mp4文件没有有效的track:" << strFileName);
|
throw std::runtime_error(StrPrinter << "该mp4文件没有有效的track:" << _file_path);
|
||||||
}
|
}
|
||||||
for(auto &track : tracks){
|
for(auto &track : tracks){
|
||||||
_mediaMuxer->addTrack(track);
|
_mediaMuxer->addTrack(track);
|
||||||
@ -153,5 +153,13 @@ int MP4Reader::totalReaderCount(MediaSource &sender) {
|
|||||||
return _mediaMuxer ? _mediaMuxer->totalReaderCount() : sender.readerCount();
|
return _mediaMuxer ? _mediaMuxer->totalReaderCount() : sender.readerCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaOriginType MP4Reader::getOriginType(MediaSource &sender) const {
|
||||||
|
return MediaOriginType::mp4_vod;
|
||||||
|
}
|
||||||
|
|
||||||
|
string MP4Reader::getOriginUrl(MediaSource &sender) const {
|
||||||
|
return _file_path;
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace mediakit */
|
} /* namespace mediakit */
|
||||||
#endif //ENABLE_MP4
|
#endif //ENABLE_MP4
|
@ -41,6 +41,8 @@ private:
|
|||||||
bool seekTo(MediaSource &sender,uint32_t ui32Stamp) override;
|
bool seekTo(MediaSource &sender,uint32_t ui32Stamp) override;
|
||||||
bool close(MediaSource &sender,bool force) override;
|
bool close(MediaSource &sender,bool force) override;
|
||||||
int totalReaderCount(MediaSource &sender) override;
|
int totalReaderCount(MediaSource &sender) override;
|
||||||
|
MediaOriginType getOriginType(MediaSource &sender) const override;
|
||||||
|
string getOriginUrl(MediaSource &sender) const override;
|
||||||
|
|
||||||
bool readSample();
|
bool readSample();
|
||||||
uint32_t getCurrentStamp();
|
uint32_t getCurrentStamp();
|
||||||
@ -50,6 +52,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
bool _have_video = false;
|
bool _have_video = false;
|
||||||
uint32_t _seek_to;
|
uint32_t _seek_to;
|
||||||
|
string _file_path;
|
||||||
recursive_mutex _mtx;
|
recursive_mutex _mtx;
|
||||||
Ticker _seek_ticker;
|
Ticker _seek_ticker;
|
||||||
Timer::Ptr _timer;
|
Timer::Ptr _timer;
|
||||||
|
@ -543,6 +543,18 @@ int RtmpSession::totalReaderCount(MediaSource &sender) {
|
|||||||
return _publisher_src ? _publisher_src->totalReaderCount() : sender.readerCount();
|
return _publisher_src ? _publisher_src->totalReaderCount() : sender.readerCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaOriginType RtmpSession::getOriginType(MediaSource &sender) const{
|
||||||
|
return MediaOriginType::rtmp_push;
|
||||||
|
}
|
||||||
|
|
||||||
|
string RtmpSession::getOriginUrl(MediaSource &sender) const {
|
||||||
|
return _media_info._full_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<SockInfo> RtmpSession::getOriginSock(MediaSource &sender) const {
|
||||||
|
return const_cast<RtmpSession *>(this)->shared_from_this();
|
||||||
|
}
|
||||||
|
|
||||||
void RtmpSession::setSocketFlags(){
|
void RtmpSession::setSocketFlags(){
|
||||||
GET_CONFIG(int, merge_write_ms, General::kMergeWriteMS);
|
GET_CONFIG(int, merge_write_ms, General::kMergeWriteMS);
|
||||||
if (merge_write_ms > 0) {
|
if (merge_write_ms > 0) {
|
||||||
|
@ -69,9 +69,17 @@ private:
|
|||||||
sendResponse(MSG_CMD, invoke.data());
|
sendResponse(MSG_CMD, invoke.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
//MediaSourceEvent override
|
///////MediaSourceEvent override///////
|
||||||
|
// 关闭
|
||||||
bool close(MediaSource &sender, bool force) override;
|
bool close(MediaSource &sender, bool force) override;
|
||||||
|
// 播放总人数
|
||||||
int totalReaderCount(MediaSource &sender) override;
|
int totalReaderCount(MediaSource &sender) override;
|
||||||
|
// 获取媒体源类型
|
||||||
|
MediaOriginType getOriginType(MediaSource &sender) const override;
|
||||||
|
// 获取媒体源url或者文件路径
|
||||||
|
string getOriginUrl(MediaSource &sender) const override;
|
||||||
|
// 获取媒体源客户端相关信息
|
||||||
|
std::shared_ptr<SockInfo> getOriginSock(MediaSource &sender) const override;
|
||||||
|
|
||||||
void setSocketFlags();
|
void setSocketFlags();
|
||||||
string getStreamId(const string &str);
|
string getStreamId(const string &str);
|
||||||
|
@ -26,6 +26,7 @@ namespace mediakit{
|
|||||||
class RtpProcess : public HttpRequestSplitter, public RtpReceiver, public SockInfo, public MediaSinkInterface, public std::enable_shared_from_this<RtpProcess>{
|
class RtpProcess : public HttpRequestSplitter, public RtpReceiver, public SockInfo, public MediaSinkInterface, public std::enable_shared_from_this<RtpProcess>{
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<RtpProcess> Ptr;
|
typedef std::shared_ptr<RtpProcess> Ptr;
|
||||||
|
friend class RtpProcessHelper;
|
||||||
RtpProcess(const string &stream_id);
|
RtpProcess(const string &stream_id);
|
||||||
~RtpProcess();
|
~RtpProcess();
|
||||||
|
|
||||||
|
@ -145,6 +145,18 @@ int RtpProcessHelper::totalReaderCount(MediaSource &sender) {
|
|||||||
return _process ? _process->totalReaderCount() : sender.totalReaderCount();
|
return _process ? _process->totalReaderCount() : sender.totalReaderCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaOriginType RtpProcessHelper::getOriginType(MediaSource &sender) const{
|
||||||
|
return MediaOriginType::rtp_push;
|
||||||
|
}
|
||||||
|
|
||||||
|
string RtpProcessHelper::getOriginUrl(MediaSource &sender) const {
|
||||||
|
return _process ? _process->_media_info._full_url : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<SockInfo> RtpProcessHelper::getOriginSock(MediaSource &sender) const{
|
||||||
|
return _process;
|
||||||
|
}
|
||||||
|
|
||||||
RtpProcess::Ptr &RtpProcessHelper::getProcess() {
|
RtpProcess::Ptr &RtpProcessHelper::getProcess() {
|
||||||
return _process;
|
return _process;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,12 @@ protected:
|
|||||||
bool close(MediaSource &sender,bool force) override;
|
bool close(MediaSource &sender,bool force) override;
|
||||||
// 观看总人数
|
// 观看总人数
|
||||||
int totalReaderCount(MediaSource &sender) override;
|
int totalReaderCount(MediaSource &sender) override;
|
||||||
|
// 获取媒体源类型
|
||||||
|
MediaOriginType getOriginType(MediaSource &sender) const override;
|
||||||
|
// 获取媒体源url或者文件路径
|
||||||
|
string getOriginUrl(MediaSource &sender) const override;
|
||||||
|
// 获取媒体源客户端相关信息
|
||||||
|
std::shared_ptr<SockInfo> getOriginSock(MediaSource &sender) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
weak_ptr<RtpSelector > _parent;
|
weak_ptr<RtpSelector > _parent;
|
||||||
|
@ -1105,6 +1105,18 @@ int RtspSession::totalReaderCount(MediaSource &sender) {
|
|||||||
return _push_src ? _push_src->totalReaderCount() : sender.readerCount();
|
return _push_src ? _push_src->totalReaderCount() : sender.readerCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MediaOriginType RtspSession::getOriginType(MediaSource &sender) const{
|
||||||
|
return MediaOriginType::rtsp_push;
|
||||||
|
}
|
||||||
|
|
||||||
|
string RtspSession::getOriginUrl(MediaSource &sender) const {
|
||||||
|
return _media_info._full_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<SockInfo> RtspSession::getOriginSock(MediaSource &sender) const {
|
||||||
|
return const_cast<RtspSession *>(this)->shared_from_this();
|
||||||
|
}
|
||||||
|
|
||||||
inline void RtspSession::onSendRtpPacket(const RtpPacket::Ptr &pkt){
|
inline void RtspSession::onSendRtpPacket(const RtpPacket::Ptr &pkt){
|
||||||
#if RTSP_SERVER_SEND_RTCP
|
#if RTSP_SERVER_SEND_RTCP
|
||||||
int track_index = getTrackIndexByTrackType(pkt->type);
|
int track_index = getTrackIndexByTrackType(pkt->type);
|
||||||
|
@ -74,11 +74,22 @@ protected:
|
|||||||
void onRtpPacket(const char *data, uint64_t len) override;
|
void onRtpPacket(const char *data, uint64_t len) override;
|
||||||
//从rtsp头中获取Content长度
|
//从rtsp头中获取Content长度
|
||||||
int64_t getContentLength(Parser &parser) override;
|
int64_t getContentLength(Parser &parser) override;
|
||||||
|
|
||||||
////RtpReceiver override////
|
////RtpReceiver override////
|
||||||
void onRtpSorted(const RtpPacket::Ptr &rtp, int track_idx) override;
|
void onRtpSorted(const RtpPacket::Ptr &rtp, int track_idx) override;
|
||||||
////MediaSourceEvent override////
|
|
||||||
|
///////MediaSourceEvent override///////
|
||||||
|
// 关闭
|
||||||
bool close(MediaSource &sender, bool force) override;
|
bool close(MediaSource &sender, bool force) override;
|
||||||
|
// 播放总人数
|
||||||
int totalReaderCount(MediaSource &sender) override;
|
int totalReaderCount(MediaSource &sender) override;
|
||||||
|
// 获取媒体源类型
|
||||||
|
MediaOriginType getOriginType(MediaSource &sender) const override;
|
||||||
|
// 获取媒体源url或者文件路径
|
||||||
|
string getOriginUrl(MediaSource &sender) const override;
|
||||||
|
// 获取媒体源客户端相关信息
|
||||||
|
std::shared_ptr<SockInfo> getOriginSock(MediaSource &sender) const override;
|
||||||
|
|
||||||
/////TcpSession override////
|
/////TcpSession override////
|
||||||
int send(const Buffer::Ptr &pkt) override;
|
int send(const Buffer::Ptr &pkt) override;
|
||||||
//收到RTCP包回调
|
//收到RTCP包回调
|
||||||
|
Loading…
Reference in New Issue
Block a user