mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-03 08:57:32 +08:00
整理命名空间 (#1409)
* feat: remove using namespace mediakit in header files. (cherry picked from commit d44aeb339a8a0e1f0455be82b21fe4b1b536299f) * feat: remove using namespace mediakit in FFmpegSource.h * feat: remove using namespace mediakit in RtpExt.h * feat: remove using namespace mediakit in header files. * feat: remove using namespace std in header files. * feat: remove using namespace std in header files when zltoolkit remove std in header * 补充命名空间 * 整理命名空间 * 整理命名空间2 * 修复macos ci * 修复编译问题 * 修复编译问题2 * 修复编译问题3 Co-authored-by: Johnny <hellojinqiang@gmail.com> Co-authored-by: Xiaofeng Wang <wasphin@gmail.com>
This commit is contained in:
@@ -25,9 +25,9 @@
|
||||
#include "Util/ResourcePool.h"
|
||||
#include "Util/NoticeCenter.h"
|
||||
#include "Thread/ThreadPool.h"
|
||||
using namespace std;
|
||||
using namespace toolkit;
|
||||
|
||||
#define RTP_GOP_SIZE 512
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
/**
|
||||
@@ -36,12 +36,12 @@ namespace mediakit {
|
||||
* 只要生成了这两要素,那么要实现rtsp推流、rtsp服务器就很简单了
|
||||
* rtsp推拉流协议中,先传递sdp,然后再协商传输方式(tcp/udp/组播),最后一直传递rtp
|
||||
*/
|
||||
class RtspMediaSource : public MediaSource, public RingDelegate<RtpPacket::Ptr>, private PacketCache<RtpPacket> {
|
||||
class RtspMediaSource : public MediaSource, public toolkit::RingDelegate<RtpPacket::Ptr>, private PacketCache<RtpPacket> {
|
||||
public:
|
||||
typedef ResourcePool<RtpPacket> PoolType;
|
||||
typedef std::shared_ptr<RtspMediaSource> Ptr;
|
||||
typedef std::shared_ptr<List<RtpPacket::Ptr> > RingDataType;
|
||||
typedef RingBuffer<RingDataType> RingType;
|
||||
using PoolType = toolkit::ResourcePool<RtpPacket>;
|
||||
using Ptr = std::shared_ptr<RtspMediaSource>;
|
||||
using RingDataType = std::shared_ptr<toolkit::List<RtpPacket::Ptr> >;
|
||||
using RingType = toolkit::RingBuffer<RingDataType>;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
@@ -50,9 +50,9 @@ public:
|
||||
* @param stream_id 流id
|
||||
* @param ring_size 可以设置固定的环形缓冲大小,0则自适应
|
||||
*/
|
||||
RtspMediaSource(const string &vhost,
|
||||
const string &app,
|
||||
const string &stream_id,
|
||||
RtspMediaSource(const std::string &vhost,
|
||||
const std::string &app,
|
||||
const std::string &stream_id,
|
||||
int ring_size = RTP_GOP_SIZE) :
|
||||
MediaSource(RTSP_SCHEMA, vhost, app, stream_id), _ring_size(ring_size) {}
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
/**
|
||||
* 获取该源的sdp
|
||||
*/
|
||||
const string &getSdp() const {
|
||||
const std::string &getSdp() const {
|
||||
return _sdp;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
/**
|
||||
* 设置sdp
|
||||
*/
|
||||
virtual void setSdp(const string &sdp) {
|
||||
virtual void setSdp(const std::string &sdp) {
|
||||
SdpParser sdp_parser(sdp);
|
||||
_tracks[TrackVideo] = sdp_parser.getTrack(TrackVideo);
|
||||
_tracks[TrackAudio] = sdp_parser.getTrack(TrackAudio);
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
track->_ssrc = rtp->getSSRC();
|
||||
}
|
||||
if (!_ring) {
|
||||
weak_ptr<RtspMediaSource> weakSelf = dynamic_pointer_cast<RtspMediaSource>(shared_from_this());
|
||||
std::weak_ptr<RtspMediaSource> weakSelf = std::dynamic_pointer_cast<RtspMediaSource>(shared_from_this());
|
||||
auto lam = [weakSelf](int size) {
|
||||
auto strongSelf = weakSelf.lock();
|
||||
if (!strongSelf) {
|
||||
@@ -198,7 +198,7 @@ private:
|
||||
* @param rtp_list rtp包列表
|
||||
* @param key_pos 是否包含关键帧
|
||||
*/
|
||||
void onFlush(std::shared_ptr<List<RtpPacket::Ptr> > rtp_list, bool key_pos) override {
|
||||
void onFlush(std::shared_ptr<toolkit::List<RtpPacket::Ptr> > rtp_list, bool key_pos) override {
|
||||
//如果不存在视频,那么就没有存在GOP缓存的意义,所以is_key一直为true确保一直清空GOP缓存
|
||||
_ring->write(std::move(rtp_list), _have_video ? key_pos : true);
|
||||
}
|
||||
@@ -206,7 +206,7 @@ private:
|
||||
private:
|
||||
bool _have_video = false;
|
||||
int _ring_size;
|
||||
string _sdp;
|
||||
std::string _sdp;
|
||||
RingType::Ptr _ring;
|
||||
SdpTrack::Ptr _tracks[TrackMax];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user