mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-13 03:31:45 +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:
@@ -14,6 +14,8 @@
|
||||
#include "Http/HttpSession.h"
|
||||
#include "Rtsp/RtspSession.h"
|
||||
#include "Record/MP4Recorder.h"
|
||||
|
||||
using namespace toolkit;
|
||||
using namespace mediakit;
|
||||
|
||||
static void* s_tag;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include "Http/HttpBody.h"
|
||||
#include "Http/HttpClient.h"
|
||||
#include "Rtsp/RtspSession.h"
|
||||
|
||||
using namespace toolkit;
|
||||
using namespace mediakit;
|
||||
|
||||
///////////////////////////////////////////RecordInfo/////////////////////////////////////////////
|
||||
@@ -247,7 +249,7 @@ API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str, size_
|
||||
if(!len){
|
||||
len = strlen(str);
|
||||
}
|
||||
return new HttpBody::Ptr(new HttpStringBody(string(str,len)));
|
||||
return new HttpBody::Ptr(new HttpStringBody(std::string(str, len)));
|
||||
}
|
||||
|
||||
API_EXPORT mk_http_body API_CALL mk_http_body_from_file(const char *file_path){
|
||||
|
||||
@@ -15,7 +15,7 @@ using namespace mediakit;
|
||||
|
||||
class H264Splitter : public HttpRequestSplitter {
|
||||
public:
|
||||
using onH264 = function<void(const char *data, size_t len)>;
|
||||
using onH264 = std::function<void(const char *data, size_t len)>;
|
||||
H264Splitter() = default;
|
||||
~H264Splitter() override;
|
||||
void setOnSplitted(onH264 cb);
|
||||
|
||||
@@ -29,7 +29,7 @@ API_EXPORT void API_CALL mk_proxy_player_release(mk_proxy_player ctx) {
|
||||
API_EXPORT void API_CALL mk_proxy_player_set_option(mk_proxy_player ctx, const char *key, const char *val){
|
||||
assert(ctx && key && val);
|
||||
PlayerProxy::Ptr &obj = *((PlayerProxy::Ptr *) ctx);
|
||||
string key_str(key),val_str(val);
|
||||
std::string key_str(key), val_str(val);
|
||||
obj->getPoller()->async([obj,key_str,val_str](){
|
||||
//切换线程再操作
|
||||
(*obj)[key_str] = val_str;
|
||||
@@ -39,7 +39,7 @@ API_EXPORT void API_CALL mk_proxy_player_set_option(mk_proxy_player ctx, const c
|
||||
API_EXPORT void API_CALL mk_proxy_player_play(mk_proxy_player ctx, const char *url) {
|
||||
assert(ctx && url);
|
||||
PlayerProxy::Ptr &obj = *((PlayerProxy::Ptr *) ctx);
|
||||
string url_str(url);
|
||||
std::string url_str(url);
|
||||
obj->getPoller()->async([obj,url_str](){
|
||||
//切换线程再操作
|
||||
obj->play(url_str);
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include <assert.h>
|
||||
#include "mk_pusher.h"
|
||||
#include "Pusher/MediaPusher.h"
|
||||
|
||||
using namespace toolkit;
|
||||
using namespace mediakit;
|
||||
|
||||
API_EXPORT mk_pusher API_CALL mk_pusher_create(const char *schema,const char *vhost,const char *app, const char *stream){
|
||||
@@ -35,7 +37,7 @@ API_EXPORT void API_CALL mk_pusher_release(mk_pusher ctx){
|
||||
API_EXPORT void API_CALL mk_pusher_set_option(mk_pusher ctx, const char *key, const char *val){
|
||||
assert(ctx && key && val);
|
||||
MediaPusher::Ptr &obj = *((MediaPusher::Ptr *)ctx);
|
||||
string key_str(key),val_str(val);
|
||||
std::string key_str(key), val_str(val);
|
||||
obj->getPoller()->async([obj,key_str,val_str](){
|
||||
//切换线程再操作
|
||||
(*obj)[key_str] = val_str;
|
||||
@@ -45,7 +47,7 @@ API_EXPORT void API_CALL mk_pusher_set_option(mk_pusher ctx, const char *key, co
|
||||
API_EXPORT void API_CALL mk_pusher_publish(mk_pusher ctx,const char *url){
|
||||
assert(ctx && url);
|
||||
MediaPusher::Ptr &obj = *((MediaPusher::Ptr *)ctx);
|
||||
string url_str(url);
|
||||
std::string url_str(url);
|
||||
obj->getPoller()->async([obj,url_str](){
|
||||
//切换线程再操作
|
||||
obj->publish(url_str);
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "mk_tcp_private.h"
|
||||
#include "Http/WebSocketClient.h"
|
||||
#include "Http/WebSocketSession.h"
|
||||
|
||||
using namespace toolkit;
|
||||
using namespace mediakit;
|
||||
|
||||
API_EXPORT const char* API_CALL mk_sock_info_peer_ip(const mk_sock_info ctx, char *buf){
|
||||
@@ -62,19 +64,19 @@ API_EXPORT void API_CALL mk_tcp_session_send(const mk_tcp_session ctx,const char
|
||||
|
||||
API_EXPORT void API_CALL mk_tcp_session_send_safe(const mk_tcp_session ctx,const char *data,size_t len){
|
||||
assert(ctx && data);
|
||||
if(!len){
|
||||
if (!len) {
|
||||
len = strlen(data);
|
||||
}
|
||||
try {
|
||||
weak_ptr<TcpSession> weak_session = ((TcpSessionForC *)ctx)->shared_from_this();
|
||||
string str = string(data,len);
|
||||
std::weak_ptr<TcpSession> weak_session = ((TcpSessionForC *)ctx)->shared_from_this();
|
||||
std::string str = std::string(data,len);
|
||||
((TcpSessionForC *)ctx)->async([weak_session,str](){
|
||||
auto session_session = weak_session.lock();
|
||||
if(session_session){
|
||||
session_session->SockSender::send(str);
|
||||
}
|
||||
});
|
||||
}catch (std::exception &ex){
|
||||
} catch (std::exception &ex) {
|
||||
WarnL << "can not got the strong pionter of this mk_tcp_session:" << ex.what();
|
||||
}
|
||||
}
|
||||
@@ -208,13 +210,13 @@ TcpClientForC::Ptr *mk_tcp_client_create_l(mk_tcp_client_events *events, mk_tcp_
|
||||
case mk_type_tcp:
|
||||
return new TcpClientForC::Ptr(new TcpClientForC(events));
|
||||
case mk_type_ssl:
|
||||
return (TcpClientForC::Ptr *)new shared_ptr<TcpSessionWithSSL<TcpClientForC> >(new TcpSessionWithSSL<TcpClientForC>(events));
|
||||
return (TcpClientForC::Ptr *)new std::shared_ptr<TcpSessionWithSSL<TcpClientForC> >(new TcpSessionWithSSL<TcpClientForC>(events));
|
||||
case mk_type_ws:
|
||||
//此处你也可以修改WebSocketHeader::BINARY
|
||||
return (TcpClientForC::Ptr *)new shared_ptr<WebSocketClient<TcpClientForC, WebSocketHeader::TEXT, false> >(new WebSocketClient<TcpClientForC, WebSocketHeader::TEXT, false>(events));
|
||||
return (TcpClientForC::Ptr *)new std::shared_ptr<WebSocketClient<TcpClientForC, WebSocketHeader::TEXT, false> >(new WebSocketClient<TcpClientForC, WebSocketHeader::TEXT, false>(events));
|
||||
case mk_type_wss:
|
||||
//此处你也可以修改WebSocketHeader::BINARY
|
||||
return (TcpClientForC::Ptr *)new shared_ptr<WebSocketClient<TcpClientForC, WebSocketHeader::TEXT, true> >(new WebSocketClient<TcpClientForC, WebSocketHeader::TEXT, true>(events));
|
||||
return (TcpClientForC::Ptr *)new std::shared_ptr<WebSocketClient<TcpClientForC, WebSocketHeader::TEXT, true> >(new WebSocketClient<TcpClientForC, WebSocketHeader::TEXT, true>(events));
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
@@ -253,7 +255,7 @@ API_EXPORT void API_CALL mk_tcp_client_send(mk_tcp_client ctx, const char *data,
|
||||
API_EXPORT void API_CALL mk_tcp_client_send_safe(mk_tcp_client ctx, const char *data, int len){
|
||||
assert(ctx && data);
|
||||
TcpClientForC::Ptr *client = (TcpClientForC::Ptr *)ctx;
|
||||
weak_ptr<TcpClient> weakClient = *client;
|
||||
std::weak_ptr<TcpClient> weakClient = *client;
|
||||
auto buf = BufferRaw::create();
|
||||
buf->assign(data,len);
|
||||
(*client)->async([weakClient,buf](){
|
||||
|
||||
@@ -14,17 +14,16 @@
|
||||
#include "mk_tcp.h"
|
||||
#include "Network/TcpClient.h"
|
||||
#include "Network/TcpSession.h"
|
||||
using namespace toolkit;
|
||||
|
||||
class TcpClientForC : public TcpClient {
|
||||
class TcpClientForC : public toolkit::TcpClient {
|
||||
public:
|
||||
typedef std::shared_ptr<TcpClientForC> Ptr;
|
||||
TcpClientForC(mk_tcp_client_events *events) ;
|
||||
~TcpClientForC() override ;
|
||||
void onRecv(const Buffer::Ptr &pBuf) override;
|
||||
void onErr(const SockException &ex) override;
|
||||
void onRecv(const toolkit::Buffer::Ptr &pBuf) override;
|
||||
void onErr(const toolkit::SockException &ex) override;
|
||||
void onManager() override;
|
||||
void onConnect(const SockException &ex) override;
|
||||
void onConnect(const toolkit::SockException &ex) override;
|
||||
void setClient(mk_tcp_client client);
|
||||
void *_user_data;
|
||||
private:
|
||||
@@ -32,12 +31,12 @@ private:
|
||||
mk_tcp_client _client;
|
||||
};
|
||||
|
||||
class TcpSessionForC : public TcpSession {
|
||||
class TcpSessionForC : public toolkit::TcpSession {
|
||||
public:
|
||||
TcpSessionForC(const Socket::Ptr &pSock) ;
|
||||
TcpSessionForC(const toolkit::Socket::Ptr &pSock) ;
|
||||
~TcpSessionForC() override = default;
|
||||
void onRecv(const Buffer::Ptr &buffer) override ;
|
||||
void onError(const SockException &err) override;
|
||||
void onRecv(const toolkit::Buffer::Ptr &buffer) override ;
|
||||
void onError(const toolkit::SockException &err) override;
|
||||
void onManager() override;
|
||||
void *_user_data;
|
||||
uint16_t _local_port;
|
||||
|
||||
@@ -91,7 +91,7 @@ private:
|
||||
on_mk_timer _cb = nullptr;
|
||||
void *_user_data = nullptr;
|
||||
recursive_mutex _mxt;
|
||||
DelayTask::Ptr _task;
|
||||
EventPoller::DelayTask::Ptr _task;
|
||||
};
|
||||
|
||||
API_EXPORT mk_timer API_CALL mk_timer_create(mk_thread ctx,uint64_t delay_ms,on_mk_timer cb, void *user_data){
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <cstdarg>
|
||||
#include <cassert>
|
||||
|
||||
#include "mk_util.h"
|
||||
#include <assert.h>
|
||||
#include "Util/util.h"
|
||||
#include "Util/logger.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace toolkit;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user