mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-04 01:37:33 +08:00
release 8.0
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
@@ -23,23 +23,14 @@ public:
|
||||
using Ptr = std::shared_ptr<RtpRing>;
|
||||
using RingType = toolkit::RingBuffer<RtpPacket::Ptr>;
|
||||
|
||||
RtpRing() = default;
|
||||
virtual ~RtpRing() = default;
|
||||
|
||||
/**
|
||||
* 获取rtp环形缓存
|
||||
* @return
|
||||
*/
|
||||
virtual RingType::Ptr getRtpRing() const {
|
||||
return _ring;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置rtp环形缓存
|
||||
* @param ring
|
||||
*/
|
||||
virtual void setRtpRing(const RingType::Ptr &ring) {
|
||||
_ring = ring;
|
||||
void setRtpRing(RingType::Ptr ring) {
|
||||
_ring = std::move(ring);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,17 +65,11 @@ public:
|
||||
_interleaved = interleaved;
|
||||
}
|
||||
|
||||
virtual ~RtpInfo() = default;
|
||||
|
||||
//返回rtp负载最大长度
|
||||
size_t getMaxSize() const {
|
||||
return _mtu_size - RtpPacket::kRtpHeaderSize;
|
||||
}
|
||||
|
||||
uint32_t getSsrc() const {
|
||||
return _ssrc;
|
||||
}
|
||||
|
||||
RtpPacket::Ptr makeRtp(TrackType type,const void *data, size_t len, bool mark, uint64_t stamp);
|
||||
|
||||
private:
|
||||
@@ -96,17 +81,21 @@ private:
|
||||
size_t _mtu_size;
|
||||
};
|
||||
|
||||
class RtpCodec : public RtpRing, public FrameDispatcher, public CodecInfo {
|
||||
class RtpCodec : public RtpRing, public FrameDispatcher {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<RtpCodec>;
|
||||
|
||||
RtpCodec() = default;
|
||||
~RtpCodec() override = default;
|
||||
void setRtpInfo(uint32_t ssrc, size_t mtu_size, uint32_t sample_rate, uint8_t pt, uint8_t interleaved) {
|
||||
_rtp_info.reset(new RtpInfo(ssrc, mtu_size, sample_rate, pt, interleaved));
|
||||
}
|
||||
|
||||
RtpInfo &getRtpInfo() { return *_rtp_info; }
|
||||
|
||||
private:
|
||||
std::unique_ptr<RtpInfo> _rtp_info;
|
||||
};
|
||||
|
||||
}//namespace mediakit
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //ZLMEDIAKIT_RTPCODEC_H
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
@@ -22,7 +22,6 @@ namespace mediakit{
|
||||
|
||||
class MultiCastAddressMaker {
|
||||
public:
|
||||
~MultiCastAddressMaker() = default;
|
||||
static MultiCastAddressMaker& Instance();
|
||||
static bool isMultiCastAddress(uint32_t addr);
|
||||
static std::string toString(uint32_t addr);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
@@ -28,8 +28,7 @@ public:
|
||||
static constexpr SEQ SEQ_MAX = (std::numeric_limits<SEQ>::max)();
|
||||
using iterator = typename std::map<SEQ, T>::iterator;
|
||||
|
||||
PacketSortor() = default;
|
||||
~PacketSortor() = default;
|
||||
virtual ~PacketSortor() = default;
|
||||
|
||||
void setOnSort(std::function<void(SEQ seq, T packet)> cb) { _cb = std::move(cb); }
|
||||
|
||||
@@ -102,7 +101,7 @@ private:
|
||||
ret = next_seq - seq;
|
||||
}
|
||||
if (ret > SEQ_MAX >> 1) {
|
||||
return SEQ_MAX - ret + 1;
|
||||
return SEQ_MAX - ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -201,11 +200,9 @@ public:
|
||||
public:
|
||||
template<typename Type>
|
||||
BadRtpException(Type &&type) : invalid_argument(std::forward<Type>(type)) {}
|
||||
~BadRtpException() = default;
|
||||
};
|
||||
|
||||
RtpTrack();
|
||||
virtual ~RtpTrack() = default;
|
||||
|
||||
void clear();
|
||||
uint32_t getSSRC() const;
|
||||
@@ -230,9 +227,6 @@ public:
|
||||
using OnSorted = std::function<void(RtpPacket::Ptr)>;
|
||||
using BeforeSorted = std::function<void(const RtpPacket::Ptr &)>;
|
||||
|
||||
RtpTrackImp() = default;
|
||||
~RtpTrackImp() override = default;
|
||||
|
||||
void setOnSorted(OnSorted cb);
|
||||
void setBeforeSorted(BeforeSorted cb);
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
@@ -166,6 +166,8 @@ public:
|
||||
// ntp时间戳
|
||||
uint64_t ntp_stamp;
|
||||
|
||||
bool disable_ntp = false;
|
||||
|
||||
static Ptr create();
|
||||
|
||||
private:
|
||||
@@ -232,7 +234,6 @@ public:
|
||||
|
||||
SdpParser() = default;
|
||||
SdpParser(const std::string &sdp) { load(sdp); }
|
||||
~SdpParser() = default;
|
||||
|
||||
void load(const std::string &sdp);
|
||||
bool available() const;
|
||||
@@ -248,7 +249,7 @@ private:
|
||||
/**
|
||||
* rtsp sdp基类
|
||||
*/
|
||||
class Sdp : public CodecInfo {
|
||||
class Sdp {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<Sdp>;
|
||||
|
||||
@@ -303,8 +304,6 @@ public:
|
||||
|
||||
std::string getSdp() const override { return _printer; }
|
||||
|
||||
CodecId getCodecId() const override { return CodecInvalid; }
|
||||
|
||||
float getDuration() const { return _dur_sec; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
@@ -20,8 +20,6 @@ namespace mediakit {
|
||||
class RtspDemuxer : public Demuxer {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<RtspDemuxer>;
|
||||
RtspDemuxer() = default;
|
||||
virtual ~RtspDemuxer() = default;
|
||||
|
||||
/**
|
||||
* 加载sdp
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
@@ -30,8 +30,6 @@ public:
|
||||
*/
|
||||
RtspMediaSourceImp(const MediaTuple& tuple, int ringSize = RTP_GOP_SIZE);
|
||||
|
||||
~RtspMediaSourceImp() override = default;
|
||||
|
||||
/**
|
||||
* 设置sdp
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
|
||||
@@ -1,43 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
|
||||
#include "RtspMuxer.h"
|
||||
#include "Common/config.h"
|
||||
#include "Extension/Factory.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace toolkit;
|
||||
|
||||
#define ENABLE_NTP_STAMP 1
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
void RtspMuxer::onRtp(RtpPacket::Ptr in, bool is_key) {
|
||||
#if ENABLE_NTP_STAMP
|
||||
if (_live) {
|
||||
if (_rtp_stamp[in->type] != in->getHeader()->stamp) {
|
||||
//rtp时间戳变化才计算ntp,节省cpu资源
|
||||
// rtp时间戳变化才计算ntp,节省cpu资源
|
||||
int64_t stamp_ms = in->getStamp() * uint64_t(1000) / in->sample_rate;
|
||||
int64_t stamp_ms_inc;
|
||||
//求rtp时间戳增量
|
||||
// 求rtp时间戳增量
|
||||
_stamp[in->type].revise(stamp_ms, stamp_ms, stamp_ms_inc, stamp_ms_inc);
|
||||
_rtp_stamp[in->type] = in->getHeader()->stamp;
|
||||
_ntp_stamp[in->type] = stamp_ms_inc + _ntp_stamp_start;
|
||||
}
|
||||
|
||||
//rtp拦截入口,此处统一赋值ntp
|
||||
// rtp拦截入口,此处统一赋值ntp
|
||||
in->ntp_stamp = _ntp_stamp[in->type];
|
||||
} else {
|
||||
//点播情况下设置ntp时间戳为rtp时间戳加基准ntp时间戳
|
||||
// 点播情况下设置ntp时间戳为rtp时间戳加基准ntp时间戳
|
||||
in->ntp_stamp = _ntp_stamp_start + (in->getStamp() * uint64_t(1000) / in->sample_rate);
|
||||
}
|
||||
#endif
|
||||
_rtpRing->write(std::move(in), is_key);
|
||||
}
|
||||
|
||||
@@ -54,44 +51,72 @@ RtspMuxer::RtspMuxer(const TitleSdp::Ptr &title) {
|
||||
onRtp(std::move(in), is_key);
|
||||
}));
|
||||
|
||||
#if ENABLE_NTP_STAMP
|
||||
_ntp_stamp_start = getCurrentMillisecond(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RtspMuxer::addTrack(const Track::Ptr &track) {
|
||||
//根据track生成sdp
|
||||
Sdp::Ptr sdp = track->getSdp();
|
||||
auto &encoder = _encoder[track->getTrackType()];
|
||||
if (encoder) {
|
||||
WarnL << "Already add a track kind of: " << track->getTrackTypeStr()
|
||||
<< ", ignore track: " << track->getCodecName();
|
||||
return false;
|
||||
}
|
||||
// payload type 96以后则为动态pt
|
||||
Sdp::Ptr sdp = track->getSdp(96 + _index);
|
||||
if (!sdp) {
|
||||
WarnL << "rtsp复用器不支持该编码:" << track->getCodecName();
|
||||
return false;
|
||||
}
|
||||
|
||||
auto &encoder = _encoder[track->getTrackType()];
|
||||
encoder = Factory::getRtpEncoderBySdp(sdp);
|
||||
encoder = Factory::getRtpEncoderByCodecId(track->getCodecId(), sdp->getPayloadType());
|
||||
if (!encoder) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//设置rtp输出环形缓存
|
||||
{
|
||||
static atomic<uint32_t> s_ssrc(0);
|
||||
uint32_t ssrc = s_ssrc++;
|
||||
if (!ssrc) {
|
||||
// ssrc不能为0
|
||||
ssrc = s_ssrc++;
|
||||
}
|
||||
if (track->getTrackType() == TrackVideo) {
|
||||
// 视频的ssrc是偶数,方便调试
|
||||
ssrc = 2 * ssrc;
|
||||
} else {
|
||||
// 音频ssrc是奇数
|
||||
ssrc = 2 * ssrc + 1;
|
||||
}
|
||||
GET_CONFIG(uint32_t, audio_mtu, Rtp::kAudioMtuSize);
|
||||
GET_CONFIG(uint32_t, video_mtu, Rtp::kVideoMtuSize);
|
||||
auto mtu = track->getTrackType() == TrackVideo ? video_mtu : audio_mtu;
|
||||
encoder->setRtpInfo(ssrc, mtu, sdp->getSampleRate(), sdp->getPayloadType(), 2 * track->getTrackType());
|
||||
}
|
||||
|
||||
// 设置rtp输出环形缓存
|
||||
encoder->setRtpRing(_rtpInterceptor);
|
||||
|
||||
//添加其sdp
|
||||
_sdp.append(sdp->getSdp());
|
||||
auto str = sdp->getSdp();
|
||||
str += "a=control:trackID=";
|
||||
str += std::to_string(_index);
|
||||
str += "\r\n";
|
||||
|
||||
// 添加其sdp
|
||||
_sdp.append(str);
|
||||
trySyncTrack();
|
||||
|
||||
// rtp的时间戳是pts,允许回退
|
||||
_stamp[TrackAudio].enableRollback(true);
|
||||
_stamp[TrackVideo].enableRollback(true);
|
||||
|
||||
++_index;
|
||||
return true;
|
||||
}
|
||||
|
||||
void RtspMuxer::trySyncTrack() {
|
||||
#if ENABLE_NTP_STAMP
|
||||
if (_encoder[TrackAudio] && _encoder[TrackVideo]) {
|
||||
//音频时间戳同步于视频,因为音频时间戳被修改后不影响播放
|
||||
// 音频时间戳同步于视频,因为音频时间戳被修改后不影响播放
|
||||
_stamp[TrackAudio].syncTo(_stamp[TrackVideo]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RtspMuxer::inputFrame(const Frame::Ptr &frame) {
|
||||
@@ -122,5 +147,4 @@ void RtspMuxer::resetTracks() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} /* namespace mediakit */
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
@@ -22,8 +22,6 @@ class RingDelegateHelper : public toolkit::RingDelegate<RtpPacket::Ptr> {
|
||||
public:
|
||||
using onRtp = std::function<void(RtpPacket::Ptr in, bool is_key)> ;
|
||||
|
||||
~RingDelegateHelper() override = default;
|
||||
|
||||
RingDelegateHelper(onRtp on_rtp) {
|
||||
_on_rtp = std::move(on_rtp);
|
||||
}
|
||||
@@ -47,7 +45,6 @@ public:
|
||||
* 构造函数
|
||||
*/
|
||||
RtspMuxer(const TitleSdp::Ptr &title = nullptr);
|
||||
~RtspMuxer() override = default;
|
||||
|
||||
/**
|
||||
* 获取完整的SDP字符串
|
||||
@@ -88,6 +85,7 @@ private:
|
||||
|
||||
private:
|
||||
bool _live = true;
|
||||
uint8_t _index {0};
|
||||
uint32_t _rtp_stamp[TrackMax]{0};
|
||||
uint64_t _ntp_stamp[TrackMax]{0};
|
||||
uint64_t _ntp_stamp_start;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
@@ -479,7 +479,7 @@ void RtspPlayer::handleResPAUSE(const Parser &parser, int type) {
|
||||
DebugL << "seekTo(ms):" << iSeekTo;
|
||||
}
|
||||
|
||||
onPlayResult_l(SockException(Err_success, type == type_seek ? "resum rtsp success" : "rtsp play success"), !_play_check_timer);
|
||||
onPlayResult_l(SockException(Err_success, type == type_seek ? "resume rtsp success" : "rtsp play success"), !_play_check_timer);
|
||||
}
|
||||
|
||||
void RtspPlayer::onWholeRtspPacket(Parser &parser) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
@@ -56,8 +56,6 @@ RtspSession::RtspSession(const Socket::Ptr &sock) : Session(sock) {
|
||||
sock->setSendTimeOutSecond(keep_alive_sec);
|
||||
}
|
||||
|
||||
RtspSession::~RtspSession() = default;
|
||||
|
||||
void RtspSession::onError(const SockException &err) {
|
||||
bool is_player = !_push_src_ownership;
|
||||
uint64_t duration = _alive_ticker.createdTime() / 1000;
|
||||
@@ -679,17 +677,17 @@ void RtspSession::handleReq_Setup(const Parser &parser) {
|
||||
|
||||
switch (_rtp_type) {
|
||||
case Rtsp::RTP_TCP: {
|
||||
if(_push_src){
|
||||
//rtsp推流时,interleaved由推流者决定
|
||||
auto key_values = Parser::parseArgs(parser["Transport"],";","=");
|
||||
int interleaved_rtp = -1 , interleaved_rtcp = -1;
|
||||
if(2 == sscanf(key_values["interleaved"].data(),"%d-%d",&interleaved_rtp,&interleaved_rtcp)){
|
||||
if (_push_src) {
|
||||
// rtsp推流时,interleaved由推流者决定
|
||||
auto key_values = Parser::parseArgs(parser["Transport"], ";", "=");
|
||||
int interleaved_rtp = -1, interleaved_rtcp = -1;
|
||||
if (2 == sscanf(key_values["interleaved"].data(), "%d-%d", &interleaved_rtp, &interleaved_rtcp)) {
|
||||
trackRef->_interleaved = interleaved_rtp;
|
||||
}else{
|
||||
} else {
|
||||
throw SockException(Err_shutdown, "can not find interleaved when setup of rtp over tcp");
|
||||
}
|
||||
}else{
|
||||
//rtsp播放时,由于数据共享分发,所以interleaved必须由服务器决定
|
||||
} else {
|
||||
// rtsp播放时,由于数据共享分发,所以interleaved必须由服务器决定
|
||||
trackRef->_interleaved = 2 * trackRef->_type;
|
||||
}
|
||||
sendRtspResponse("200 OK",
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
@@ -34,7 +34,6 @@ public:
|
||||
using onAuth = std::function<void(bool encrypted, const std::string &pwd_or_md5)>;
|
||||
|
||||
RtspSession(const toolkit::Socket::Ptr &sock);
|
||||
virtual ~RtspSession();
|
||||
////Session override////
|
||||
void onRecv(const toolkit::Buffer::Ptr &buf) override;
|
||||
void onError(const toolkit::SockException &err) override;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
@@ -57,13 +57,16 @@ const char *RtspSplitter::onSearchPacketTail_l(const char *data, size_t len) {
|
||||
}
|
||||
|
||||
ssize_t RtspSplitter::onRecvHeader(const char *data, size_t len) {
|
||||
if(_isRtpPacket){
|
||||
onRtpPacket(data,len);
|
||||
if (_isRtpPacket) {
|
||||
onRtpPacket(data, len);
|
||||
return 0;
|
||||
}
|
||||
if (len == 4 && !memcmp(data, "\r\n\r\n", 4)) {
|
||||
return 0;
|
||||
}
|
||||
_parser.parse(data, len);
|
||||
auto ret = getContentLength(_parser);
|
||||
if(ret == 0){
|
||||
if (ret == 0) {
|
||||
onWholeRtspPacket(_parser);
|
||||
_parser.clear();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
@@ -18,9 +18,6 @@ namespace mediakit{
|
||||
|
||||
class RtspSplitter : public HttpRequestSplitter{
|
||||
public:
|
||||
RtspSplitter() = default;
|
||||
virtual ~RtspSplitter() = default;
|
||||
|
||||
/**
|
||||
* 是否允许接收rtp包
|
||||
* @param enable
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like 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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user