Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
5b43b2c0
Commit
5b43b2c0
authored
Dec 27, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加util相关函数,整理库文件名
parent
528e4fff
隐藏空白字符变更
内嵌
并排
正在显示
25 个修改的文件
包含
229 行增加
和
75 行删除
+229
-75
api/include/mk_common.h
+0
-19
api/include/mk_events.h
+2
-2
api/include/mk_events_objects.h
+2
-2
api/include/mk_httpclient.h
+2
-2
api/include/mk_media.h
+1
-1
api/include/mk_mediakit.h
+10
-9
api/include/mk_player.h
+1
-1
api/include/mk_proxyplayer.h
+1
-1
api/include/mk_pusher.h
+1
-1
api/include/mk_recorder.h
+1
-1
api/include/mk_tcp.h
+1
-1
api/include/mk_util.h
+94
-0
api/source/mk_common.cpp
+1
-14
api/source/mk_events.cpp
+1
-1
api/source/mk_events_objects.cpp
+1
-1
api/source/mk_httpclient.cpp
+1
-1
api/source/mk_media.cpp
+1
-1
api/source/mk_player.cpp
+1
-1
api/source/mk_proxyplayer.cpp
+1
-1
api/source/mk_pusher.cpp
+1
-1
api/source/mk_recorder.cpp
+1
-1
api/source/mk_tcp.cpp
+1
-1
api/source/mk_util.cpp
+69
-0
api/tests/server.c
+17
-6
api/tests/websocket.c
+17
-6
没有找到文件。
api/include/common.h
→
api/include/
mk_
common.h
查看文件 @
5b43b2c0
...
...
@@ -139,25 +139,6 @@ API_EXPORT uint16_t API_CALL mk_rtp_server_start(uint16_t port);
*/
API_EXPORT
uint16_t
API_CALL
mk_shell_server_start
(
uint16_t
port
);
/**
* 打印日志
* @param level 日志级别,支持0~4
* @param file __FILE__
* @param function __FUNCTION__
* @param line __LINE__
* @param fmt printf类型的格式控制字符串
* @param ... 不定长参数
*/
API_EXPORT
void
API_CALL
mk_log_printf
(
int
level
,
const
char
*
file
,
const
char
*
function
,
int
line
,
const
char
*
fmt
,
...);
// 以下宏可以替换printf使用
#define log_trace(fmt,...) mk_log_printf(0,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
#define log_debug(fmt,...) mk_log_printf(1,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
#define log_info(fmt,...) mk_log_printf(2,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
#define log_warn(fmt,...) mk_log_printf(3,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
#define log_error(fmt,...) mk_log_printf(4,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
#define log_printf(lev,fmt,...) mk_log_printf(lev,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
#ifdef __cplusplus
}
#endif
...
...
api/include/events.h
→
api/include/
mk_
events.h
查看文件 @
5b43b2c0
...
...
@@ -27,8 +27,8 @@
#ifndef MK_EVENTS_H
#define MK_EVENTS_H
#include "common.h"
#include "events_objects.h"
#include "
mk_
common.h"
#include "
mk_
events_objects.h"
#ifdef __cplusplus
extern
"C"
{
...
...
api/include/events_objects.h
→
api/include/
mk_
events_objects.h
查看文件 @
5b43b2c0
...
...
@@ -26,8 +26,8 @@
#ifndef MK_EVENT_OBJECTS_H
#define MK_EVENT_OBJECTS_H
#include "common.h"
#include "tcp.h"
#include "
mk_
common.h"
#include "
mk_
tcp.h"
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
api/include/httpclient.h
→
api/include/
mk_
httpclient.h
查看文件 @
5b43b2c0
...
...
@@ -27,8 +27,8 @@
#ifndef MK_HTTPCLIENT_H_
#define MK_HTTPCLIENT_H_
#include "common.h"
#include "events_objects.h"
#include "
mk_
common.h"
#include "
mk_
events_objects.h"
#ifdef __cplusplus
extern
"C"
{
...
...
api/include/media.h
→
api/include/m
k_m
edia.h
查看文件 @
5b43b2c0
...
...
@@ -27,7 +27,7 @@
#ifndef MK_MEDIA_H_
#define MK_MEDIA_H_
#include "common.h"
#include "
mk_
common.h"
#ifdef __cplusplus
extern
"C"
{
...
...
api/include/mediakit.h
→
api/include/m
k_m
ediakit.h
查看文件 @
5b43b2c0
...
...
@@ -27,14 +27,15 @@
#ifndef MK_API_H_
#define MK_API_H_
#include "common.h"
#include "httpclient.h"
#include "media.h"
#include "proxyplayer.h"
#include "recorder.h"
#include "player.h"
#include "pusher.h"
#include "events.h"
#include "tcp.h"
#include "mk_common.h"
#include "mk_httpclient.h"
#include "mk_media.h"
#include "mk_proxyplayer.h"
#include "mk_recorder.h"
#include "mk_player.h"
#include "mk_pusher.h"
#include "mk_events.h"
#include "mk_tcp.h"
#include "mk_util.h"
#endif
/* MK_API_H_ */
api/include/player.h
→
api/include/
mk_
player.h
查看文件 @
5b43b2c0
...
...
@@ -27,7 +27,7 @@
#ifndef MK_PLAYER_H_
#define MK_PLAYER_H_
#include "common.h"
#include "
mk_
common.h"
#ifdef __cplusplus
extern
"C"
{
...
...
api/include/proxyplayer.h
→
api/include/
mk_
proxyplayer.h
查看文件 @
5b43b2c0
...
...
@@ -27,7 +27,7 @@
#ifndef MK_PROXY_PLAYER_H_
#define MK_PROXY_PLAYER_H_
#include "common.h"
#include "
mk_
common.h"
#ifdef __cplusplus
extern
"C"
{
...
...
api/include/pusher.h
→
api/include/
mk_
pusher.h
查看文件 @
5b43b2c0
...
...
@@ -28,7 +28,7 @@
#ifndef MK_PUSHER_H
#define MK_PUSHER_H
#include "common.h"
#include "
mk_
common.h"
#ifdef __cplusplus
extern
"C"
{
...
...
api/include/recorder.h
→
api/include/
mk_
recorder.h
查看文件 @
5b43b2c0
...
...
@@ -27,7 +27,7 @@
#ifndef MK_RECORDER_API_H_
#define MK_RECORDER_API_H_
#include "common.h"
#include "
mk_
common.h"
#ifdef __cplusplus
extern
"C"
{
...
...
api/include/tcp.h
→
api/include/
mk_
tcp.h
查看文件 @
5b43b2c0
...
...
@@ -27,7 +27,7 @@
#ifndef MK_TCP_H
#define MK_TCP_H
#include "common.h"
#include "
mk_
common.h"
#ifdef __cplusplus
extern
"C"
{
...
...
api/include/mk_util.h
0 → 100644
查看文件 @
5b43b2c0
/*
* MIT License
*
* Copyright (c) 2019 xiongziliang <771730766@qq.com>
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef MK_UTIL_H
#define MK_UTIL_H
#include <stdlib.h>
#include "mk_common.h"
#ifdef __cplusplus
extern
"C"
{
#endif
/**
* 获取本程序可执行文件路径
* @return 文件路径,使用完后需要自己free
*/
API_EXPORT
char
*
API_CALL
mk_util_get_exe_path
();
/**
* 获取本程序可执行文件相同目录下文件的绝对路径
* @param relative_path 同目录下文件的路径相对,可以为null
* @return 文件路径,使用完后需要自己free
*/
API_EXPORT
char
*
API_CALL
mk_uitl_get_exe_dir
(
const
char
*
relative_path
);
/**
* 获取unix标准的系统时间戳
* @return 当前系统时间戳
*/
API_EXPORT
uint64_t
API_CALL
mk_uitl_get_current_millisecond
();
/**
* 获取时间字符串
* @param fmt 时间格式,譬如%Y-%m-%d %H:%M:%S
* @return 时间字符串,使用完后需要自己free
*/
API_EXPORT
char
*
API_CALL
mk_uitl_get_current_time_string
(
const
char
*
fmt
);
/**
* 打印二进制为字符串
* @param buf 二进制数据
* @param len 数据长度
* @return 可打印的调试信息,使用完后需要自己free
*/
API_EXPORT
char
*
API_CALL
mk_uitl_hex_dump
(
const
void
*
buf
,
int
len
);
///////////////////////////////////////////日志/////////////////////////////////////////////
/**
* 打印日志
* @param level 日志级别,支持0~4
* @param file __FILE__
* @param function __FUNCTION__
* @param line __LINE__
* @param fmt printf类型的格式控制字符串
* @param ... 不定长参数
*/
API_EXPORT
void
API_CALL
mk_log_printf
(
int
level
,
const
char
*
file
,
const
char
*
function
,
int
line
,
const
char
*
fmt
,
...);
// 以下宏可以替换printf使用
#define log_trace(fmt,...) mk_log_printf(0,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
#define log_debug(fmt,...) mk_log_printf(1,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
#define log_info(fmt,...) mk_log_printf(2,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
#define log_warn(fmt,...) mk_log_printf(3,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
#define log_error(fmt,...) mk_log_printf(4,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
#define log_printf(lev,fmt,...) mk_log_printf(lev,__FILE__,__FUNCTION__,__LINE__,fmt,##__VA_ARGS__)
#ifdef __cplusplus
}
#endif
#endif //MK_UTIL_H
api/source/common.cpp
→
api/source/
mk_
common.cpp
查看文件 @
5b43b2c0
...
...
@@ -24,7 +24,7 @@
* SOFTWARE.
*/
#include "common.h"
#include "
mk_
common.h"
#include <stdarg.h>
#include <unordered_map>
#include "Util/logger.h"
...
...
@@ -206,16 +206,3 @@ API_EXPORT uint16_t API_CALL mk_shell_server_start(uint16_t port){
return
0
;
}
}
API_EXPORT
void
API_CALL
mk_log_printf
(
int
level
,
const
char
*
file
,
const
char
*
function
,
int
line
,
const
char
*
fmt
,
...)
{
assert
(
file
&&
function
&&
fmt
);
LogContextCapturer
info
(
Logger
::
Instance
(),
(
LogLevel
)
level
,
file
,
function
,
line
);
va_list
pArg
;
va_start
(
pArg
,
fmt
);
char
buf
[
4096
];
int
n
=
vsprintf
(
buf
,
fmt
,
pArg
);
buf
[
n
]
=
'\0'
;
va_end
(
pArg
);
info
<<
buf
;
}
api/source/events.cpp
→
api/source/
mk_
events.cpp
查看文件 @
5b43b2c0
...
...
@@ -24,7 +24,7 @@
* SOFTWARE.
*/
#include "events.h"
#include "
mk_
events.h"
#include "Common/config.h"
#include "Common/MediaSource.h"
#include "Http/HttpSession.h"
...
...
api/source/events_objects.cpp
→
api/source/
mk_
events_objects.cpp
查看文件 @
5b43b2c0
...
...
@@ -25,7 +25,7 @@
*/
#include <assert.h>
#include "events_objects.h"
#include "
mk_
events_objects.h"
#include "Common/config.h"
#include "Record/MP4Recorder.h"
#include "Network/TcpSession.h"
...
...
api/source/httpclient.cpp
→
api/source/
mk_
httpclient.cpp
查看文件 @
5b43b2c0
...
...
@@ -23,7 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "httpclient.h"
#include "
mk_
httpclient.h"
#include "Util/logger.h"
#include "Http/HttpDownloader.h"
...
...
api/source/media.cpp
→
api/source/m
k_m
edia.cpp
查看文件 @
5b43b2c0
...
...
@@ -24,7 +24,7 @@
* SOFTWARE.
*/
#include "media.h"
#include "m
k_m
edia.h"
#include "Util/logger.h"
#include "Common/Device.h"
...
...
api/source/player.cpp
→
api/source/
mk_
player.cpp
查看文件 @
5b43b2c0
...
...
@@ -24,7 +24,7 @@
* SOFTWARE.
*/
#include "player.h"
#include "
mk_
player.h"
#include "Util/logger.h"
#include "Player/MediaPlayer.h"
using
namespace
std
;
...
...
api/source/proxyplayer.cpp
→
api/source/
mk_
proxyplayer.cpp
查看文件 @
5b43b2c0
...
...
@@ -24,7 +24,7 @@
* SOFTWARE.
*/
#include "proxyplayer.h"
#include "
mk_
proxyplayer.h"
#include "Player/PlayerProxy.h"
using
namespace
toolkit
;
...
...
api/source/pusher.cpp
→
api/source/
mk_
pusher.cpp
查看文件 @
5b43b2c0
...
...
@@ -25,7 +25,7 @@
*/
#include <assert.h>
#include "pusher.h"
#include "
mk_
pusher.h"
#include "Pusher/MediaPusher.h"
using
namespace
mediakit
;
...
...
api/source/recorder.cpp
→
api/source/
mk_
recorder.cpp
查看文件 @
5b43b2c0
...
...
@@ -24,7 +24,7 @@
* SOFTWARE.
*/
#include "recorder.h"
#include "
mk_
recorder.h"
#include "Rtmp/FlvMuxer.h"
#include "Record/Recorder.h"
using
namespace
toolkit
;
...
...
api/source/tcp.cpp
→
api/source/
mk_
tcp.cpp
查看文件 @
5b43b2c0
...
...
@@ -24,7 +24,7 @@
* SOFTWARE.
*/
#include "tcp.h"
#include "
mk_
tcp.h"
#include "Network/TcpSession.h"
#include "Network/TcpClient.h"
#include "Http/WebSocketClient.h"
...
...
api/source/mk_util.cpp
0 → 100644
查看文件 @
5b43b2c0
/*
* MIT License
*
* Copyright (c) 2019 xiongziliang <771730766@qq.com>
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "mk_util.h"
#include <stdarg.h>
#include "Util/logger.h"
using
namespace
std
;
using
namespace
toolkit
;
API_EXPORT
char
*
API_CALL
mk_util_get_exe_path
(){
return
strdup
(
exePath
().
data
());
}
API_EXPORT
char
*
API_CALL
mk_uitl_get_exe_dir
(
const
char
*
relative_path
){
if
(
relative_path
){
return
strdup
((
exeDir
()
+
relative_path
).
data
());
}
return
strdup
(
exeDir
().
data
());
}
API_EXPORT
uint64_t
API_CALL
mk_uitl_get_current_millisecond
(){
return
getCurrentMillisecond
();
}
API_EXPORT
char
*
API_CALL
mk_uitl_get_current_time_string
(
const
char
*
fmt
){
assert
(
fmt
);
return
strdup
(
getTimeStr
(
fmt
).
data
());
}
API_EXPORT
char
*
API_CALL
mk_uitl_hex_dump
(
const
void
*
buf
,
int
len
){
assert
(
buf
&&
len
>
0
);
return
strdup
(
hexdump
(
buf
,
len
).
data
());
}
API_EXPORT
void
API_CALL
mk_log_printf
(
int
level
,
const
char
*
file
,
const
char
*
function
,
int
line
,
const
char
*
fmt
,
...)
{
assert
(
file
&&
function
&&
fmt
);
LogContextCapturer
info
(
Logger
::
Instance
(),
(
LogLevel
)
level
,
file
,
function
,
line
);
va_list
pArg
;
va_start
(
pArg
,
fmt
);
char
buf
[
4096
];
int
n
=
vsprintf
(
buf
,
fmt
,
pArg
);
buf
[
n
]
=
'\0'
;
va_end
(
pArg
);
info
<<
buf
;
}
api/tests/server.c
查看文件 @
5b43b2c0
...
...
@@ -26,7 +26,7 @@
#include <signal.h>
#include <string.h>
#include "mediakit.h"
#include "m
k_m
ediakit.h"
#ifdef _WIN32
#include "windows.h"
...
...
@@ -396,12 +396,24 @@ static void s_on_exit(int sig){
flag
=
0
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
char
ini_path
[
2048
]
=
{
0
};
strcpy
(
ini_path
,
argv
[
0
]);
strcat
(
ini_path
,
".ini"
);
char
*
ini_path
=
mk_uitl_get_exe_dir
(
"c_api.ini"
);
char
*
ssl_path
=
mk_uitl_get_exe_dir
(
"ssl.p12"
);
mk_config
config
=
{
.
ini
=
ini_path
,
.
ini_is_path
=
1
,
.
log_level
=
0
,
.
ssl
=
ssl_path
,
.
ssl_is_path
=
1
,
.
ssl_pwd
=
NULL
,
.
thread_num
=
0
};
mk_env_init
(
&
config
);
free
(
ini_path
);
free
(
ssl_path
);
mk_env_init1
(
0
,
0
,
1
,
ini_path
,
0
,
NULL
,
NULL
);
mk_http_server_start
(
80
,
0
);
mk_http_server_start
(
443
,
1
);
mk_rtsp_server_start
(
554
,
0
);
mk_rtmp_server_start
(
1935
,
0
);
mk_shell_server_start
(
9000
);
...
...
@@ -424,7 +436,6 @@ int main(int argc, char *argv[]) {
};
mk_events_listen
(
&
events
);
signal
(
SIGINT
,
s_on_exit
);
// 设置退出信号
while
(
flag
)
{
#ifdef _WIN32
...
...
api/tests/websocket.c
查看文件 @
5b43b2c0
...
...
@@ -28,7 +28,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "mediakit.h"
#include "m
k_m
ediakit.h"
#ifdef _WIN32
#include "windows.h"
#else
...
...
@@ -36,6 +36,7 @@
#endif
#define LOG_LEV 4
//修改此宏,可以选择协议类型
#define TCP_TYPE mk_type_ws
static
int
flag
=
1
;
...
...
@@ -194,11 +195,21 @@ void test_client(){
}
int
main
(
int
argc
,
char
*
argv
[])
{
char
ini_path
[
2048
]
=
{
0
};
strcpy
(
ini_path
,
argv
[
0
]);
strcat
(
ini_path
,
".ini"
);
mk_env_init1
(
0
,
0
,
1
,
ini_path
,
0
,
NULL
,
NULL
);
char
*
ini_path
=
mk_uitl_get_exe_dir
(
"c_api.ini"
);
char
*
ssl_path
=
mk_uitl_get_exe_dir
(
"ssl.p12"
);
mk_config
config
=
{
.
ini
=
ini_path
,
.
ini_is_path
=
1
,
.
log_level
=
0
,
.
ssl
=
ssl_path
,
.
ssl_is_path
=
1
,
.
ssl_pwd
=
NULL
,
.
thread_num
=
0
};
mk_env_init
(
&
config
);
free
(
ini_path
);
free
(
ssl_path
);
test_server
();
test_client
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论