整理命名空间 (#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:
夏楚
2022-02-02 20:34:50 +08:00
committed by GitHub
parent 80a0e27d8c
commit c72cf4cbcc
239 changed files with 1887 additions and 1766 deletions

View File

@@ -16,9 +16,6 @@
#include "Util/RingBuffer.h"
#include "Network/Socket.h"
using namespace std;
using namespace toolkit;
namespace mediakit{
typedef enum {
@@ -53,7 +50,7 @@ typedef enum {
/**
* 字符串转媒体类型转
*/
TrackType getTrackType(const string &str);
TrackType getTrackType(const std::string &str);
/**
* 媒体类型转字符串
@@ -65,7 +62,7 @@ const char* getTrackString(TrackType type);
* @param str
* @return
*/
CodecId getCodecId(const string &str);
CodecId getCodecId(const std::string &str);
/**
* 获取编码器名称
@@ -106,7 +103,7 @@ public:
/**
* 帧类型的抽象接口
*/
class Frame : public Buffer, public CodecInfo {
class Frame : public toolkit::Buffer, public CodecInfo {
public:
typedef std::shared_ptr<Frame> Ptr;
virtual ~Frame(){}
@@ -171,7 +168,7 @@ public:
private:
//对象个数统计
ObjectStatistic<Frame> _statistic;
toolkit::ObjectStatistic<Frame> _statistic;
};
class FrameImp : public Frame {
@@ -233,14 +230,14 @@ public:
uint32_t _dts = 0;
uint32_t _pts = 0;
size_t _prefix_size = 0;
BufferLikeString _buffer;
toolkit::BufferLikeString _buffer;
private:
//对象个数统计
ObjectStatistic<FrameImp> _statistic;
toolkit::ObjectStatistic<FrameImp> _statistic;
protected:
friend class ResourcePool_l<FrameImp>;
friend class toolkit::ResourcePool_l<FrameImp>;
FrameImp() = default;
};
@@ -323,7 +320,7 @@ public:
*/
void addDelegate(const FrameWriterInterface::Ptr &delegate){
//_delegates_write可能多线程同时操作
lock_guard<mutex> lck(_mtx);
std::lock_guard<std::mutex> lck(_mtx);
_delegates_write.emplace(delegate.get(),delegate);
_need_update = true;
}
@@ -333,7 +330,7 @@ public:
*/
void delDelegate(FrameWriterInterface *ptr){
//_delegates_write可能多线程同时操作
lock_guard<mutex> lck(_mtx);
std::lock_guard<std::mutex> lck(_mtx);
_delegates_write.erase(ptr);
_need_update = true;
}
@@ -344,7 +341,7 @@ public:
bool inputFrame(const Frame::Ptr &frame) override{
if(_need_update){
//发现代理列表发生变化了,这里同步一次
lock_guard<mutex> lck(_mtx);
std::lock_guard<std::mutex> lck(_mtx);
_delegates_read = _delegates_write;
_need_update = false;
}
@@ -366,9 +363,9 @@ public:
return _delegates_write.size();
}
private:
mutex _mtx;
map<void *,FrameWriterInterface::Ptr> _delegates_read;
map<void *,FrameWriterInterface::Ptr> _delegates_write;
std::mutex _mtx;
std::map<void *,FrameWriterInterface::Ptr> _delegates_read;
std::map<void *,FrameWriterInterface::Ptr> _delegates_write;
bool _need_update = false;
};
@@ -463,7 +460,7 @@ public:
* @param prefix 帧前缀长度
* @param offset buffer有效数据偏移量
*/
FrameWrapper(const Buffer::Ptr &buf, uint32_t dts, uint32_t pts, size_t prefix, size_t offset) : Parent(buf->data() + offset, buf->size() - offset, dts, pts, prefix){
FrameWrapper(const toolkit::Buffer::Ptr &buf, uint32_t dts, uint32_t pts, size_t prefix, size_t offset) : Parent(buf->data() + offset, buf->size() - offset, dts, pts, prefix){
_buf = buf;
}
@@ -476,7 +473,7 @@ public:
* @param offset buffer有效数据偏移量
* @param codec 帧类型
*/
FrameWrapper(const Buffer::Ptr &buf, uint32_t dts, uint32_t pts, size_t prefix, size_t offset, CodecId codec) : Parent(codec, buf->data() + offset, buf->size() - offset, dts, pts, prefix){
FrameWrapper(const toolkit::Buffer::Ptr &buf, uint32_t dts, uint32_t pts, size_t prefix, size_t offset, CodecId codec) : Parent(codec, buf->data() + offset, buf->size() - offset, dts, pts, prefix){
_buf = buf;
}
@@ -488,7 +485,7 @@ public:
}
private:
Buffer::Ptr _buf;
toolkit::Buffer::Ptr _buf;
};
/**
@@ -496,7 +493,7 @@ private:
*/
class FrameMerger {
public:
using onOutput = function<void(uint32_t dts, uint32_t pts, const Buffer::Ptr &buffer, bool have_key_frame)>;
using onOutput = std::function<void(uint32_t dts, uint32_t pts, const toolkit::Buffer::Ptr &buffer, bool have_key_frame)>;
using Ptr = std::shared_ptr<FrameMerger>;
enum {
none = 0,
@@ -508,16 +505,16 @@ public:
~FrameMerger() = default;
void clear();
bool inputFrame(const Frame::Ptr &frame, const onOutput &cb, BufferLikeString *buffer = nullptr);
bool inputFrame(const Frame::Ptr &frame, const onOutput &cb, toolkit::BufferLikeString *buffer = nullptr);
private:
bool willFlush(const Frame::Ptr &frame) const;
void doMerge(BufferLikeString &buffer, const Frame::Ptr &frame) const;
void doMerge(toolkit::BufferLikeString &buffer, const Frame::Ptr &frame) const;
private:
int _type;
bool _have_decode_able_frame = false;
List<Frame::Ptr> _frame_cache;
toolkit::List<Frame::Ptr> _frame_cache;
};
}//namespace mediakit