整理命名空间 (#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

@@ -18,9 +18,6 @@
#include "Util/logger.h"
#include "Thread/WorkThreadPool.h"
using namespace std;
using namespace toolkit;
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b) )
#endif //MIN
@@ -47,14 +44,14 @@ public:
* @param size 请求大小
* @return 字节对象,如果读完了那么请返回nullptr
*/
virtual Buffer::Ptr readData(size_t size) { return nullptr;};
virtual toolkit::Buffer::Ptr readData(size_t size) { return nullptr;};
/**
* 异步请求读取一定字节数返回大小可能小于size
* @param size 请求大小
* @param cb 回调函数
*/
virtual void readDataAsync(size_t size,const function<void(const Buffer::Ptr &buf)> &cb){
virtual void readDataAsync(size_t size,const std::function<void(const toolkit::Buffer::Ptr &buf)> &cb){
//由于unix和linux是通过mmap的方式读取文件所以把读文件操作放在后台线程并不能提高性能
//反而会由于频繁的线程切换导致性能降低以及延时增加,所以我们默认同步获取文件内容
//(其实并没有读,拷贝文件数据时在内核态完成文件读)
@@ -63,20 +60,20 @@ public:
};
/**
* string类型的content
* std::string类型的content
*/
class HttpStringBody : public HttpBody{
public:
typedef std::shared_ptr<HttpStringBody> Ptr;
HttpStringBody(string str);
HttpStringBody(std::string str);
~HttpStringBody() override = default;
ssize_t remainSize() override;
Buffer::Ptr readData(size_t size) override ;
toolkit::Buffer::Ptr readData(size_t size) override ;
private:
size_t _offset = 0;
mutable string _str;
mutable std::string _str;
};
/**
@@ -85,14 +82,14 @@ private:
class HttpBufferBody : public HttpBody{
public:
typedef std::shared_ptr<HttpBufferBody> Ptr;
HttpBufferBody(Buffer::Ptr buffer);
HttpBufferBody(toolkit::Buffer::Ptr buffer);
~HttpBufferBody() override = default;
ssize_t remainSize() override;
Buffer::Ptr readData(size_t size) override;
toolkit::Buffer::Ptr readData(size_t size) override;
private:
Buffer::Ptr _buffer;
toolkit::Buffer::Ptr _buffer;
};
/**
@@ -110,11 +107,11 @@ public:
* @param use_mmap 是否使用mmap方式访问文件
*/
HttpFileBody(const std::shared_ptr<FILE> &fp, size_t offset, size_t max_size, bool use_mmap = true);
HttpFileBody(const string &file_path, bool use_mmap = true);
HttpFileBody(const std::string &file_path, bool use_mmap = true);
~HttpFileBody() override = default;
ssize_t remainSize() override ;
Buffer::Ptr readData(size_t size) override;
toolkit::Buffer::Ptr readData(size_t size) override;
private:
void init(const std::shared_ptr<FILE> &fp,size_t offset,size_t max_size, bool use_mmap);
@@ -124,7 +121,7 @@ private:
size_t _offset = 0;
std::shared_ptr<FILE> _fp;
std::shared_ptr<char> _map_addr;
ResourcePool<BufferRaw> _pool;
toolkit::ResourcePool<toolkit::BufferRaw> _pool;
};
class HttpArgs;
@@ -142,21 +139,21 @@ public:
* @param filePath 文件路径
* @param boundary boundary字符串
*/
HttpMultiFormBody(const HttpArgs &args,const string &filePath,const string &boundary = "0xKhTmLbOuNdArY");
HttpMultiFormBody(const HttpArgs &args,const std::string &filePath,const std::string &boundary = "0xKhTmLbOuNdArY");
virtual ~HttpMultiFormBody(){}
ssize_t remainSize() override ;
Buffer::Ptr readData(size_t size) override;
toolkit::Buffer::Ptr readData(size_t size) override;
public:
static string multiFormBodyPrefix(const HttpArgs &args,const string &boundary,const string &fileName);
static string multiFormBodySuffix(const string &boundary);
static string multiFormContentType(const string &boundary);
static std::string multiFormBodyPrefix(const HttpArgs &args,const std::string &boundary,const std::string &fileName);
static std::string multiFormBodySuffix(const std::string &boundary);
static std::string multiFormContentType(const std::string &boundary);
private:
size_t _offset = 0;
size_t _totalSize;
string _bodyPrefix;
string _bodySuffix;
std::string _bodyPrefix;
std::string _bodySuffix;
HttpFileBody::Ptr _fileBody;
};