diff --git a/.gitignore b/.gitignore index 61eb6410..ffb0e5b3 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ /build/ /3rdpart/media-server/.idea/ /ios/ +/cmake-build-* diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 53b5145e..3b5de80f 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 53b5145e292e8ad6499bd5bbf4d52484303f41be +Subproject commit 3b5de80f9effe28c4a38fef5beec50eadfc916cf diff --git a/3rdpart/assert.h b/3rdpart/assert.h index efb2224f..c3b4b1c2 100644 --- a/3rdpart/assert.h +++ b/3rdpart/assert.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/Android/app/src/main/cpp/native-lib.cpp b/Android/app/src/main/cpp/native-lib.cpp index ddcdd389..ba3a309b 100644 --- a/Android/app/src/main/cpp/native-lib.cpp +++ b/Android/app/src/main/cpp/native-lib.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/CMakeLists.txt b/CMakeLists.txt index aec266ac..783cdd99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,13 +20,14 @@ set(RELEASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/release) if (CMAKE_SYSTEM_NAME MATCHES "Linux") SET(LIBRARY_OUTPUT_PATH ${RELEASE_DIR}/linux/${BuildType}) SET(EXECUTABLE_OUTPUT_PATH ${RELEASE_DIR}/linux/${BuildType}) - add_compile_options(-fPIC) + add_compile_options(-fPIC -Wall -Wno-sign-compare -Wno-unused-variable -Wno-unused-value) elseif (CMAKE_SYSTEM_NAME MATCHES "Windows") SET(LIBRARY_OUTPUT_PATH ${RELEASE_DIR}/windows/${BuildType}) SET(EXECUTABLE_OUTPUT_PATH ${RELEASE_DIR}/windows/${BuildType}) elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") SET(LIBRARY_OUTPUT_PATH ${RELEASE_DIR}/mac/${BuildType}) SET(EXECUTABLE_OUTPUT_PATH ${RELEASE_DIR}/mac/${BuildType}) + add_compile_options(-Wall -Wno-sign-compare -Wno-unused-variable -Wno-unused-value) endif () LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH}) @@ -104,7 +105,8 @@ if(${CMAKE_BUILD_TYPE} MATCHES "Release") endif() endif() -set(VS_FALGS "/wd4819 /wd4996 /wd4018 /wd4267 /wd4244 /wd4101 /wd4828 /wd4309 /wd4573" ) +#set(VS_FALGS "/wd4819 /wd4996 /wd4018 /wd4267 /wd4244 /wd4101 /wd4828 /wd4309 /wd4573 /wd4996" ) +set(VS_FALGS "/wd4018" ) #添加mpeg用于支持ts生成 if(ENABLE_HLS) @@ -167,7 +169,7 @@ if (NOT WIN32) list(REMOVE_ITEM ToolKit_src_list ${ToolKit_Root}/win32/getopt.c) else() #防止Windows.h包含Winsock.h - add_definitions(-DWIN32_LEAN_AND_MEAN -DMP4V2_NO_STDINT_DEFS -DOS_WINDOWS) + add_definitions(-DWIN32_LEAN_AND_MEAN -DMP4V2_NO_STDINT_DEFS -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS) endif () #添加库 diff --git a/README_en.md b/README_en.md index 7193f7b2..a89d0ded 100644 --- a/README_en.md +++ b/README_en.md @@ -82,7 +82,7 @@ It is recommended to compile on Ubuntu or MacOS,compiling on windows is cumber ### Before build - **You must use git to clone the complete code. Do not download the source code by downloading zip package. Otherwise, the sub-module code will not be downloaded by default.You can do it like this:** ``` -git clone https://github.com/xiongziliang/ZLMediaKit.git +git clone https://github.com/xia-chu/ZLMediaKit.git cd ZLMediaKit git submodule update --init ``` diff --git a/api/include/mk_common.h b/api/include/mk_common.h index d93f1124..34c7ecd2 100755 --- a/api/include/mk_common.h +++ b/api/include/mk_common.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -12,6 +12,7 @@ #define MK_COMMON_H #include +#include #if defined(_WIN32) diff --git a/api/include/mk_events.h b/api/include/mk_events.h index c3334621..e99dfc71 100644 --- a/api/include/mk_events.h +++ b/api/include/mk_events.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -148,8 +148,8 @@ typedef struct { * @param is_player 客户端是否为播放器 */ void (API_CALL *on_mk_flow_report)(const mk_media_info url_info, - uint64_t total_bytes, - uint64_t total_seconds, + size_t total_bytes, + size_t total_seconds, int is_player, const mk_sock_info sender); } mk_events; diff --git a/api/include/mk_events_objects.h b/api/include/mk_events_objects.h index f348f511..485f4704 100644 --- a/api/include/mk_events_objects.h +++ b/api/include/mk_events_objects.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -24,7 +24,7 @@ API_EXPORT uint64_t API_CALL mk_mp4_info_get_start_time(const mk_mp4_info ctx); // 录像长度,单位秒 API_EXPORT float API_CALL mk_mp4_info_get_time_len(const mk_mp4_info ctx); // 文件大小,单位 BYTE -API_EXPORT uint64_t API_CALL mk_mp4_info_get_file_size(const mk_mp4_info ctx); +API_EXPORT size_t API_CALL mk_mp4_info_get_file_size(const mk_mp4_info ctx); // 文件路径 API_EXPORT const char* API_CALL mk_mp4_info_get_file_path(const mk_mp4_info ctx); // 文件名称 @@ -58,7 +58,7 @@ API_EXPORT const char* API_CALL mk_parser_get_tail(const mk_parser ctx); //Parser::getValues()["key"],获取HTTP头中特定字段 API_EXPORT const char* API_CALL mk_parser_get_header(const mk_parser ctx,const char *key); //Parser::Content(),获取HTTP body -API_EXPORT const char* API_CALL mk_parser_get_content(const mk_parser ctx, int *length); +API_EXPORT const char* API_CALL mk_parser_get_content(const mk_parser ctx, size_t *length); ///////////////////////////////////////////MediaInfo///////////////////////////////////////////// //MediaInfo对象的C映射 @@ -143,7 +143,7 @@ typedef void* mk_http_body; * @param str 字符串指针 * @param len 字符串长度,为0则用strlen获取 */ -API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str,int len); +API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str,size_t len); /** * 生成HttpFileBody diff --git a/api/include/mk_httpclient.h b/api/include/mk_httpclient.h index 39d5fcb4..3aea1a35 100755 --- a/api/include/mk_httpclient.h +++ b/api/include/mk_httpclient.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -129,7 +129,7 @@ API_EXPORT const char* API_CALL mk_http_requester_get_response_header(mk_http_re * @param length 返回body长度,可以为null * @return body指针 */ -API_EXPORT const char* API_CALL mk_http_requester_get_response_body(mk_http_requester ctx, int *length); +API_EXPORT const char* API_CALL mk_http_requester_get_response_body(mk_http_requester ctx, size_t *length); /** * 在收到HTTP回复后可调用该方法获取响应 diff --git a/api/include/mk_media.h b/api/include/mk_media.h index 7fcdf1c9..2423ffba 100755 --- a/api/include/mk_media.h +++ b/api/include/mk_media.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -47,7 +47,7 @@ API_EXPORT void API_CALL mk_media_release(mk_media ctx); * @param height 视频高度 * @param fps 视频fps */ -API_EXPORT void API_CALL mk_media_init_video(mk_media ctx, int track_id, int width, int height, int fps); +API_EXPORT void API_CALL mk_media_init_video(mk_media ctx, int track_id, int width, int height, float fps); /** * 添加音频轨道 diff --git a/api/include/mk_mediakit.h b/api/include/mk_mediakit.h index 18cfd589..9f85700d 100755 --- a/api/include/mk_mediakit.h +++ b/api/include/mk_mediakit.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/include/mk_player.h b/api/include/mk_player.h index 555116a5..c63942c6 100755 --- a/api/include/mk_player.h +++ b/api/include/mk_player.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -37,7 +37,7 @@ typedef void(API_CALL *on_mk_play_event)(void *user_data,int err_code,const char * @param dts 解码时间戳,单位毫秒 * @param pts 显示时间戳,单位毫秒 */ -typedef void(API_CALL *on_mk_play_data)(void *user_data,int track_type,int codec_id,void *data,int len,uint32_t dts,uint32_t pts); +typedef void(API_CALL *on_mk_play_data)(void *user_data,int track_type,int codec_id,void *data,size_t len, uint32_t dts,uint32_t pts); /** * 创建一个播放器,支持rtmp[s]/rtsp[s] @@ -125,7 +125,7 @@ API_EXPORT int API_CALL mk_player_video_height(mk_player ctx); /** * 获取视频帧率 */ -API_EXPORT int API_CALL mk_player_video_fps(mk_player ctx); +API_EXPORT float API_CALL mk_player_video_fps(mk_player ctx); /** * 获取音频codec_id -1:不存在 0:H264,1:H265,2:AAC 3.G711A 4.G711U diff --git a/api/include/mk_proxyplayer.h b/api/include/mk_proxyplayer.h index 3964af78..82844fdf 100644 --- a/api/include/mk_proxyplayer.h +++ b/api/include/mk_proxyplayer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/include/mk_pusher.h b/api/include/mk_pusher.h index b6423b08..4beb9d10 100644 --- a/api/include/mk_pusher.h +++ b/api/include/mk_pusher.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/include/mk_recorder.h b/api/include/mk_recorder.h index c14563ed..5b1b8b71 100644 --- a/api/include/mk_recorder.h +++ b/api/include/mk_recorder.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/include/mk_rtp_server.h b/api/include/mk_rtp_server.h index 451cf766..bd7f594c 100644 --- a/api/include/mk_rtp_server.h +++ b/api/include/mk_rtp_server.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/include/mk_tcp.h b/api/include/mk_tcp.h index 71048585..6e40e27e 100644 --- a/api/include/mk_tcp.h +++ b/api/include/mk_tcp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -53,9 +53,9 @@ API_EXPORT mk_sock_info API_CALL mk_tcp_session_get_sock_info(const mk_tcp_sessi //TcpSession::safeShutdown() API_EXPORT void API_CALL mk_tcp_session_shutdown(const mk_tcp_session ctx,int err,const char *err_msg); //TcpSession::send() -API_EXPORT void API_CALL mk_tcp_session_send(const mk_tcp_session ctx,const char *data,int len); +API_EXPORT void API_CALL mk_tcp_session_send(const mk_tcp_session ctx,const char *data,size_t len); //切换到该对象所在线程后再TcpSession::send() -API_EXPORT void API_CALL mk_tcp_session_send_safe(const mk_tcp_session ctx,const char *data,int len); +API_EXPORT void API_CALL mk_tcp_session_send_safe(const mk_tcp_session ctx,const char *data,size_t len); ///////////////////////////////////////////自定义tcp服务///////////////////////////////////////////// @@ -74,7 +74,7 @@ typedef struct { * @param data 数据指针 * @param len 数据长度 */ - void (API_CALL *on_mk_tcp_session_data)(uint16_t server_port,mk_tcp_session session,const char *data,int len); + void (API_CALL *on_mk_tcp_session_data)(uint16_t server_port,mk_tcp_session session,const char *data,size_t len); /** * 每隔2秒的定时器,用于管理超时等任务 @@ -164,7 +164,7 @@ typedef struct { * @param data 数据指针 * @param len 数据长度 */ - void (API_CALL *on_mk_tcp_client_data)(mk_tcp_client client,const char *data,int len); + void (API_CALL *on_mk_tcp_client_data)(mk_tcp_client client,const char *data,size_t len); /** * 每隔2秒的定时器,用于管理超时等任务 diff --git a/api/include/mk_thread.h b/api/include/mk_thread.h index d37f04c8..0426d711 100644 --- a/api/include/mk_thread.h +++ b/api/include/mk_thread.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/include/mk_util.h b/api/include/mk_util.h index 63d761f1..8adbe513 100644 --- a/api/include/mk_util.h +++ b/api/include/mk_util.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/source/mk_common.cpp b/api/source/mk_common.cpp index 1b84707e..7bea645a 100644 --- a/api/source/mk_common.cpp +++ b/api/source/mk_common.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -89,9 +89,9 @@ API_EXPORT void API_CALL mk_env_init1(int thread_num, if (ini && ini[0]) { //设置配置文件 if (ini_is_path) { - try{ + try { mINI::Instance().parseFile(ini); - }catch (std::exception &ex) { + } catch (std::exception &) { InfoL << "dump ini file to:" << ini; mINI::Instance().dumpFile(ini); } diff --git a/api/source/mk_events.cpp b/api/source/mk_events.cpp index ace60eb0..7e21d011 100644 --- a/api/source/mk_events.cpp +++ b/api/source/mk_events.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/source/mk_events_objects.cpp b/api/source/mk_events_objects.cpp index 8ac9a4cb..f6f0feee 100644 --- a/api/source/mk_events_objects.cpp +++ b/api/source/mk_events_objects.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -31,7 +31,7 @@ API_EXPORT float API_CALL mk_mp4_info_get_time_len(const mk_mp4_info ctx){ return info->time_len; } -API_EXPORT uint64_t API_CALL mk_mp4_info_get_file_size(const mk_mp4_info ctx){ +API_EXPORT size_t API_CALL mk_mp4_info_get_file_size(const mk_mp4_info ctx){ assert(ctx); RecordInfo *info = (RecordInfo *)ctx; return info->file_size; @@ -115,7 +115,7 @@ API_EXPORT const char* API_CALL mk_parser_get_header(const mk_parser ctx,const c Parser *parser = (Parser *)ctx; return parser->getHeader()[key].c_str(); } -API_EXPORT const char* API_CALL mk_parser_get_content(const mk_parser ctx, int *length){ +API_EXPORT const char* API_CALL mk_parser_get_content(const mk_parser ctx, size_t *length){ assert(ctx); Parser *parser = (Parser *)ctx; if(length){ @@ -246,7 +246,7 @@ API_EXPORT void API_CALL mk_media_source_for_each(void *user_data, on_mk_media_s } ///////////////////////////////////////////HttpBody///////////////////////////////////////////// -API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str,int len){ +API_EXPORT mk_http_body API_CALL mk_http_body_from_string(const char *str, size_t len){ assert(str); if(!len){ len = strlen(str); diff --git a/api/source/mk_httpclient.cpp b/api/source/mk_httpclient.cpp index dbafa55a..50e02b86 100755 --- a/api/source/mk_httpclient.cpp +++ b/api/source/mk_httpclient.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -113,7 +113,7 @@ API_EXPORT const char* API_CALL mk_http_requester_get_response_header(mk_http_re return (*obj)->response()[key].c_str(); } -API_EXPORT const char* API_CALL mk_http_requester_get_response_body(mk_http_requester ctx, int *length){ +API_EXPORT const char* API_CALL mk_http_requester_get_response_body(mk_http_requester ctx, size_t *length){ assert(ctx); HttpRequester::Ptr *obj = (HttpRequester::Ptr *)ctx; if(length){ diff --git a/api/source/mk_media.cpp b/api/source/mk_media.cpp index e0fd39da..fefee282 100755 --- a/api/source/mk_media.cpp +++ b/api/source/mk_media.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -131,7 +131,7 @@ API_EXPORT void API_CALL mk_media_release(mk_media ctx) { delete obj; } -API_EXPORT void API_CALL mk_media_init_video(mk_media ctx, int track_id, int width, int height, int fps){ +API_EXPORT void API_CALL mk_media_init_video(mk_media ctx, int track_id, int width, int height, float fps){ assert(ctx); MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx; VideoInfo info; diff --git a/api/source/mk_player.cpp b/api/source/mk_player.cpp index 98bf6253..44f373af 100755 --- a/api/source/mk_player.cpp +++ b/api/source/mk_player.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -218,7 +218,7 @@ API_EXPORT int API_CALL mk_player_video_height(mk_player ctx) { return track ? track->getVideoHeight() : 0; } -API_EXPORT int API_CALL mk_player_video_fps(mk_player ctx) { +API_EXPORT float API_CALL mk_player_video_fps(mk_player ctx) { assert(ctx); MediaPlayerForC &obj = **((MediaPlayerForC::Ptr *)ctx); auto track = dynamic_pointer_cast(obj->getTrack(TrackVideo)); diff --git a/api/source/mk_proxyplayer.cpp b/api/source/mk_proxyplayer.cpp index 0ae63f1d..97f31567 100644 --- a/api/source/mk_proxyplayer.cpp +++ b/api/source/mk_proxyplayer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/source/mk_pusher.cpp b/api/source/mk_pusher.cpp index 06558f79..5ef6323a 100644 --- a/api/source/mk_pusher.cpp +++ b/api/source/mk_pusher.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/source/mk_recorder.cpp b/api/source/mk_recorder.cpp index 087bb3e9..550179ec 100644 --- a/api/source/mk_recorder.cpp +++ b/api/source/mk_recorder.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/source/mk_rtp_server.cpp b/api/source/mk_rtp_server.cpp index 56402354..16dfa74d 100644 --- a/api/source/mk_rtp_server.cpp +++ b/api/source/mk_rtp_server.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/source/mk_tcp.cpp b/api/source/mk_tcp.cpp index 793ad31f..b4d45148 100644 --- a/api/source/mk_tcp.cpp +++ b/api/source/mk_tcp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -51,7 +51,7 @@ API_EXPORT void API_CALL mk_tcp_session_shutdown(const mk_tcp_session ctx,int er session->safeShutdown(SockException((ErrCode)err,err_msg)); } -API_EXPORT void API_CALL mk_tcp_session_send(const mk_tcp_session ctx,const char *data,int len){ +API_EXPORT void API_CALL mk_tcp_session_send(const mk_tcp_session ctx,const char *data, size_t len){ assert(ctx && data); if(!len){ len = strlen(data); @@ -60,7 +60,7 @@ API_EXPORT void API_CALL mk_tcp_session_send(const mk_tcp_session ctx,const char session->SockSender::send(data,len); } -API_EXPORT void API_CALL mk_tcp_session_send_safe(const mk_tcp_session ctx,const char *data,int len){ +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){ len = strlen(data); diff --git a/api/source/mk_tcp_private.h b/api/source/mk_tcp_private.h index fd48fc3b..5a4090b2 100644 --- a/api/source/mk_tcp_private.h +++ b/api/source/mk_tcp_private.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/source/mk_thread.cpp b/api/source/mk_thread.cpp index fca1cec6..4dce6911 100644 --- a/api/source/mk_thread.cpp +++ b/api/source/mk_thread.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/source/mk_util.cpp b/api/source/mk_util.cpp index 0a4a9eca..18c21fef 100644 --- a/api/source/mk_util.cpp +++ b/api/source/mk_util.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -15,15 +15,19 @@ using namespace std; using namespace toolkit; +#ifndef _WIN32 +#define _strdup strdup +#endif + API_EXPORT char* API_CALL mk_util_get_exe_path(){ - return strdup(exePath().data()); + return _strdup(exePath().data()); } API_EXPORT char* API_CALL mk_util_get_exe_dir(const char *relative_path){ if(relative_path){ - return strdup((exeDir() + relative_path).data()); + return _strdup((exeDir() + relative_path).data()); } - return strdup(exeDir().data()); + return _strdup(exeDir().data()); } API_EXPORT uint64_t API_CALL mk_util_get_current_millisecond(){ @@ -32,12 +36,12 @@ API_EXPORT uint64_t API_CALL mk_util_get_current_millisecond(){ API_EXPORT char* API_CALL mk_util_get_current_time_string(const char *fmt){ assert(fmt); - return strdup(getTimeStr(fmt).data()); + return _strdup(getTimeStr(fmt).data()); } API_EXPORT char* API_CALL mk_util_hex_dump(const void *buf, int len){ assert(buf && len > 0); - return strdup(hexdump(buf,len).data()); + 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, ...) { @@ -46,7 +50,7 @@ API_EXPORT void API_CALL mk_log_printf(int level, const char *file, const char * va_list pArg; va_start(pArg, fmt); char buf[4096]; - int n = vsprintf(buf, fmt, pArg); + auto n = vsnprintf(buf, sizeof(buf), fmt, pArg); buf[n] = '\0'; va_end(pArg); info << buf; diff --git a/api/tests/server.c b/api/tests/server.c index f518b80f..c8cf9834 100644 --- a/api/tests/server.c +++ b/api/tests/server.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/api/tests/websocket.c b/api/tests/websocket.c index a2427275..19d989e9 100644 --- a/api/tests/websocket.c +++ b/api/tests/websocket.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -52,7 +52,7 @@ void API_CALL on_mk_tcp_session_create(uint16_t server_port,mk_tcp_session sessi * @param data 数据指针 * @param len 数据长度 */ -void API_CALL on_mk_tcp_session_data(uint16_t server_port,mk_tcp_session session,const char *data,int len){ +void API_CALL on_mk_tcp_session_data(uint16_t server_port,mk_tcp_session session,const char *data,size_t len){ char ip[64]; log_printf(LOG_LEV,"from %s %d, data[%d]: %s",mk_tcp_session_peer_ip(session,ip),(int)mk_tcp_session_peer_port(session), len,data); mk_tcp_session_send(session,"echo:",0); @@ -129,7 +129,7 @@ void API_CALL on_mk_tcp_client_disconnect(mk_tcp_client client,int code,const ch * @param data 数据指针 * @param len 数据长度 */ -void API_CALL on_mk_tcp_client_data(mk_tcp_client client,const char *data,int len){ +void API_CALL on_mk_tcp_client_data(mk_tcp_client client,const char *data,size_t len){ log_printf(LOG_LEV,"data[%d]:%s",len,data); } diff --git a/build_for_linux.sh b/build_for_linux.sh index afd674e1..1963ac49 100755 --- a/build_for_linux.sh +++ b/build_for_linux.sh @@ -1,6 +1,6 @@ #!/bin/bash cd .. -git clone --depth=1 https://github.com/xiongziliang/ZLMediaKit.git +git clone --depth=1 https://github.com/xia-chu/ZLMediaKit.git cd ZLMediaKit git submodule init git submodule update diff --git a/build_for_mac.sh b/build_for_mac.sh index fb812db6..5463f4e9 100755 --- a/build_for_mac.sh +++ b/build_for_mac.sh @@ -1,6 +1,6 @@ #!/bin/bash cd .. -git clone --depth=1 https://github.com/xiongziliang/ZLMediaKit.git +git clone --depth=1 https://github.com/xia-chu/ZLMediaKit.git cd ZLMediaKit git submodule init git submodule update diff --git a/docker/ubuntu16.04/Dockerfile.devel b/docker/ubuntu16.04/Dockerfile.devel index 56044904..476cca53 100644 --- a/docker/ubuntu16.04/Dockerfile.devel +++ b/docker/ubuntu16.04/Dockerfile.devel @@ -32,7 +32,7 @@ RUN apt-get update && \ RUN mkdir -p /opt/media WORKDIR /opt/media -RUN git clone --depth=1 https://github.com/xiongziliang/ZLMediaKit && \ +RUN git clone --depth=1 https://github.com/xia-chu/ZLMediaKit && \ cd ZLMediaKit && git submodule update --init --recursive && \ mkdir -p build release/linux/Release/ diff --git a/docker/ubuntu16.04/Dockerfile.runtime b/docker/ubuntu16.04/Dockerfile.runtime index a21ec505..4b84e017 100644 --- a/docker/ubuntu16.04/Dockerfile.runtime +++ b/docker/ubuntu16.04/Dockerfile.runtime @@ -31,7 +31,7 @@ RUN apt-get update && \ RUN mkdir -p /opt/media WORKDIR /opt/media -RUN git clone --depth=1 https://github.com/xiongziliang/ZLMediaKit && \ +RUN git clone --depth=1 https://github.com/xia-chu/ZLMediaKit && \ cd ZLMediaKit && git submodule update --init --recursive && \ mkdir -p build release/linux/Release/ diff --git a/docker/ubuntu18.04/Dockerfile.devel b/docker/ubuntu18.04/Dockerfile.devel index 3cc05989..05109cee 100644 --- a/docker/ubuntu18.04/Dockerfile.devel +++ b/docker/ubuntu18.04/Dockerfile.devel @@ -33,7 +33,7 @@ RUN apt-get update && \ RUN mkdir -p /opt/media WORKDIR /opt/media -RUN git clone --depth=1 https://github.com/xiongziliang/ZLMediaKit && \ +RUN git clone --depth=1 https://github.com/xia-chu/ZLMediaKit && \ cd ZLMediaKit && git submodule update --init --recursive && \ mkdir -p build release/linux/Release/ diff --git a/docker/ubuntu18.04/Dockerfile.runtime b/docker/ubuntu18.04/Dockerfile.runtime index 72095512..ce3b6496 100644 --- a/docker/ubuntu18.04/Dockerfile.runtime +++ b/docker/ubuntu18.04/Dockerfile.runtime @@ -31,7 +31,7 @@ RUN apt-get update && \ RUN mkdir -p /opt/media WORKDIR /opt/media -RUN git clone --depth=1 https://github.com/xiongziliang/ZLMediaKit && \ +RUN git clone --depth=1 https://github.com/xia-chu/ZLMediaKit && \ cd ZLMediaKit && git submodule update --init --recursive && \ mkdir -p build release/linux/Release/ diff --git a/server/FFmpegSource.cpp b/server/FFmpegSource.cpp index 62e0e404..331ecdcc 100644 --- a/server/FFmpegSource.cpp +++ b/server/FFmpegSource.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -110,7 +110,7 @@ void FFmpegSource::play(const string &src_url,const string &dst_url,int timeout_ } else{ //推流给其他服务器的,通过判断FFmpeg进程是否在线判断是否成功 weak_ptr weakSelf = shared_from_this(); - _timer = std::make_shared(timeout_ms / 1000,[weakSelf,cb,timeout_ms](){ + _timer = std::make_shared(timeout_ms / 1000.0f,[weakSelf,cb,timeout_ms](){ auto strongSelf = weakSelf.lock(); if(!strongSelf){ //自身已经销毁 @@ -191,7 +191,7 @@ void FFmpegSource::findAsync(int maxWaitMS, const function weakSelf = shared_from_this(); - _timer = std::make_shared(1, [weakSelf, timeout_ms]() { + _timer = std::make_shared(1.0f, [weakSelf, timeout_ms]() { auto strongSelf = weakSelf.lock(); if (!strongSelf) { //自身已经销毁 @@ -294,7 +294,7 @@ void FFmpegSnap::makeSnap(const string &play_url, const string &save_path, float std::shared_ptr process = std::make_shared(); process->run(cmd,ffmpeg_log.empty() ? "" : File::absolutePath("",ffmpeg_log)); //定时器延时应该减去后台任务启动的延时 - auto delayTask = EventPollerPool::Instance().getPoller()->doDelayTask(timeout_sec * 1000 - elapsed_ms,[process,cb](){ + auto delayTask = EventPollerPool::Instance().getPoller()->doDelayTask((uint64_t)(timeout_sec * 1000 - elapsed_ms),[process,cb](){ if(process->wait(false)){ //FFmpeg进程还在运行,超时就关闭它 process->kill(2000); diff --git a/server/FFmpegSource.h b/server/FFmpegSource.h index 48c21ae7..cabb7bb8 100644 --- a/server/FFmpegSource.h +++ b/server/FFmpegSource.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/server/Process.cpp b/server/Process.cpp index b899499f..fab4c515 100644 --- a/server/Process.cpp +++ b/server/Process.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -47,7 +47,7 @@ void Process::run(const string &cmd, const string &log_file_tmp) { if (!fp) { fprintf(stderr, "open log file %s failed:%d(%s)\r\n", log_file.data(), get_uv_error(), get_uv_errmsg()); } else { - auto log_fd = (HANDLE)(_get_osfhandle(fileno(fp))); + auto log_fd = (HANDLE)(_get_osfhandle(_fileno(fp))); // dup to stdout and stderr. si.wShowWindow = SW_HIDE; // STARTF_USESHOWWINDOW:The wShowWindow member contains additional information. diff --git a/server/Process.h b/server/Process.h index e408649c..371b83b7 100644 --- a/server/Process.h +++ b/server/Process.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/server/System.cpp b/server/System.cpp index f38b6fe1..2769fcb5 100644 --- a/server/System.cpp +++ b/server/System.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/server/System.h b/server/System.h index 22abdc86..58fb59f3 100644 --- a/server/System.h +++ b/server/System.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/server/WebApi.cpp b/server/WebApi.cpp index e43867f4..44306347 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -187,7 +187,7 @@ static inline void addHttpListener(){ const HttpBody::Ptr &body) { //body默认为空 - int64_t size = 0; + size_t size = 0; if (body && body->remainSize()) { //有body,获取body大小 size = body->remainSize(); @@ -572,7 +572,7 @@ void installWebApi() { CHECK_SECRET(); uint16_t local_port = allArgs["local_port"].as(); string &peer_ip = allArgs["peer_ip"]; - uint64_t count_hit = 0; + size_t count_hit = 0; list session_list; SessionMap::Instance().for_each_session([&](const string &id,const TcpSession::Ptr &session){ @@ -923,7 +923,7 @@ void installWebApi() { Json::Value paths(arrayValue); //这是筛选日期,获取文件夹列表 File::scanDir(record_path, [&](const string &path, bool isDir) { - int pos = path.rfind('/'); + auto pos = path.rfind('/'); if (pos != string::npos) { string relative_path = path.substr(pos + 1); if (search_mp4) { diff --git a/server/WebApi.h b/server/WebApi.h index 6876d8d5..286fde41 100755 --- a/server/WebApi.h +++ b/server/WebApi.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/server/WebHook.cpp b/server/WebHook.cpp index 128c2c83..8da8c2dc 100755 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/server/WebHook.h b/server/WebHook.h index 6cde95b0..77093a58 100755 --- a/server/WebHook.h +++ b/server/WebHook.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/server/main.cpp b/server/main.cpp index 864ab197..75264ff3 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -214,7 +214,7 @@ int start_main(int argc,char *argv[]) { CMD_main cmd_main; try { cmd_main.operator()(argc, argv); - } catch (ExitException &ex) { + } catch (ExitException &) { return 0; } catch (std::exception &ex) { cout << ex.what() << endl; diff --git a/src/Codec/AACEncoder.cpp b/src/Codec/AACEncoder.cpp index e14c054b..4a335e03 100644 --- a/src/Codec/AACEncoder.cpp +++ b/src/Codec/AACEncoder.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Codec/AACEncoder.h b/src/Codec/AACEncoder.h index 29440518..b236a66f 100644 --- a/src/Codec/AACEncoder.h +++ b/src/Codec/AACEncoder.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Codec/H264Encoder.cpp b/src/Codec/H264Encoder.cpp index bddb6ea8..b8bc3e9c 100644 --- a/src/Codec/H264Encoder.cpp +++ b/src/Codec/H264Encoder.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Codec/H264Encoder.h b/src/Codec/H264Encoder.h index e60760c4..1229dd89 100644 --- a/src/Codec/H264Encoder.h +++ b/src/Codec/H264Encoder.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Common/Device.cpp b/src/Common/Device.cpp index ed0b6fe7..5e7073dc 100644 --- a/src/Common/Device.cpp +++ b/src/Common/Device.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Common/Device.h b/src/Common/Device.h index 675f7522..effd1afa 100644 --- a/src/Common/Device.h +++ b/src/Common/Device.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Common/MediaSink.cpp b/src/Common/MediaSink.cpp index 02bf904a..782b6e3b 100644 --- a/src/Common/MediaSink.cpp +++ b/src/Common/MediaSink.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Common/MediaSink.h b/src/Common/MediaSink.h index 45afe88d..129545c6 100644 --- a/src/Common/MediaSink.h +++ b/src/Common/MediaSink.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -117,13 +117,13 @@ private: void checkTrackIfReady(const Track::Ptr &track); void checkTrackIfReady_l(const Track::Ptr &track); private: + bool _all_track_ready = false; + size_t _max_track_size = 2; mutable recursive_mutex _mtx; unordered_map _track_map; unordered_map > _frame_unread; unordered_map > _track_ready_callback; - bool _all_track_ready = false; Ticker _ticker; - int _max_track_size = 2; }; diff --git a/src/Common/MediaSource.cpp b/src/Common/MediaSource.cpp index 92a9bd22..1825113e 100644 --- a/src/Common/MediaSource.cpp +++ b/src/Common/MediaSource.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -521,7 +521,7 @@ void MediaSourceEvent::onReaderChanged(MediaSource &sender, int size){ bool is_mp4_vod = sender.getApp() == record_app; weak_ptr weak_sender = sender.shared_from_this(); - _async_close_timer = std::make_shared(stream_none_reader_delay / 1000.0, [weak_sender, is_mp4_vod]() { + _async_close_timer = std::make_shared(stream_none_reader_delay / 1000.0f, [weak_sender, is_mp4_vod]() { auto strong_sender = weak_sender.lock(); if (!strong_sender) { //对象已经销毁 @@ -672,7 +672,7 @@ std::shared_ptr MediaSourceEventInterceptor::getDelegate() con /////////////////////////////////////FlushPolicy////////////////////////////////////// -static bool isFlushAble_default(bool is_video, uint64_t last_stamp, uint64_t new_stamp, int cache_size) { +static bool isFlushAble_default(bool is_video, uint64_t last_stamp, uint64_t new_stamp, size_t cache_size) { if (new_stamp + 500 < last_stamp) { //时间戳回退比较大(可能seek中),由于rtp中时间戳是pts,是可能存在一定程度的回退的 return true; @@ -682,7 +682,7 @@ static bool isFlushAble_default(bool is_video, uint64_t last_stamp, uint64_t new return last_stamp != new_stamp || cache_size >= 1024; } -static bool isFlushAble_merge(bool is_video, uint64_t last_stamp, uint64_t new_stamp, int cache_size, int merge_ms) { +static bool isFlushAble_merge(bool is_video, uint64_t last_stamp, uint64_t new_stamp, size_t cache_size, int merge_ms) { if (new_stamp + 500 < last_stamp) { //时间戳回退比较大(可能seek中),由于rtp中时间戳是pts,是可能存在一定程度的回退的 return true; @@ -698,7 +698,7 @@ static bool isFlushAble_merge(bool is_video, uint64_t last_stamp, uint64_t new_s return cache_size >= 1024; } -bool FlushPolicy::isFlushAble(bool is_video, bool is_key, uint64_t new_stamp, int cache_size) { +bool FlushPolicy::isFlushAble(bool is_video, bool is_key, uint64_t new_stamp, size_t cache_size) { bool flush_flag = false; if (is_key && is_video) { //遇到关键帧flush掉前面的数据,确保关键帧为该组数据的第一帧,确保GOP缓存有效 diff --git a/src/Common/MediaSource.h b/src/Common/MediaSource.h index 41a228c2..dd5308da 100644 --- a/src/Common/MediaSource.h +++ b/src/Common/MediaSource.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -148,7 +148,7 @@ public: /** * 添加统计字节 */ - BytesSpeed& operator += (uint64_t bytes) { + BytesSpeed& operator += (size_t bytes) { _bytes += bytes; if (_bytes > 1024 * 1024) { //数据大于1MB就计算一次网速 @@ -169,12 +169,12 @@ public: } private: - uint64_t computeSpeed() { + int computeSpeed() { auto elapsed = _ticker.elapsedTime(); if (!elapsed) { return _speed; } - _speed = _bytes * 1000 / elapsed; + _speed = (int)(_bytes * 1000 / elapsed); _ticker.resetTime(); _bytes = 0; return _speed; @@ -182,7 +182,7 @@ private: private: int _speed = 0; - uint64_t _bytes = 0; + size_t _bytes = 0; Ticker _ticker; }; @@ -304,7 +304,7 @@ public: FlushPolicy() = default; ~FlushPolicy() = default; - bool isFlushAble(bool is_video, bool is_key, uint64_t new_stamp, int cache_size); + bool isFlushAble(bool is_video, bool is_key, uint64_t new_stamp, size_t cache_size); private: uint64_t _last_stamp[2] = {0, 0}; diff --git a/src/Common/MultiMediaSourceMuxer.cpp b/src/Common/MultiMediaSourceMuxer.cpp index 80ab20f6..e90480b2 100644 --- a/src/Common/MultiMediaSourceMuxer.cpp +++ b/src/Common/MultiMediaSourceMuxer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * -* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). +* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -404,14 +404,14 @@ public: ~FrameModifyStamp() override {} uint32_t dts() const override{ - return _dts; + return (uint32_t)_dts; } uint32_t pts() const override{ - return _pts; + return (uint32_t)_pts; } - uint32_t prefixSize() const override { + size_t prefixSize() const override { return _frame->prefixSize(); } @@ -431,7 +431,7 @@ public: return _frame->data(); } - uint32_t size() const override { + size_t size() const override { return _frame->size(); } diff --git a/src/Common/MultiMediaSourceMuxer.h b/src/Common/MultiMediaSourceMuxer.h index d1a19032..a2caacf3 100644 --- a/src/Common/MultiMediaSourceMuxer.h +++ b/src/Common/MultiMediaSourceMuxer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Common/Parser.cpp b/src/Common/Parser.cpp index abb749dd..307e80ff 100644 --- a/src/Common/Parser.cpp +++ b/src/Common/Parser.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -12,12 +12,12 @@ namespace mediakit{ -string FindField(const char* buf, const char* start, const char *end ,int bufSize) { +string FindField(const char* buf, const char* start, const char *end ,size_t bufSize) { if(bufSize <=0 ){ bufSize = strlen(buf); } const char *msg_start = buf, *msg_end = buf + bufSize; - int len = 0; + size_t len = 0; if (start != NULL) { len = strlen(start); msg_start = strstr(buf, start); diff --git a/src/Common/Parser.h b/src/Common/Parser.h index 00d2a4cb..3f4d078b 100644 --- a/src/Common/Parser.h +++ b/src/Common/Parser.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -19,7 +19,7 @@ using namespace toolkit; namespace mediakit{ -string FindField(const char *buf, const char *start, const char *end, int bufSize = 0); +string FindField(const char *buf, const char *start, const char *end, size_t bufSize = 0); struct StrCaseCompare { bool operator()(const string &__x, const string &__y) const { diff --git a/src/Common/Stamp.cpp b/src/Common/Stamp.cpp index dc3b36e5..f679aab8 100644 --- a/src/Common/Stamp.cpp +++ b/src/Common/Stamp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -101,7 +101,7 @@ void Stamp::revise_l2(int64_t dts, int64_t pts, int64_t &dts_out, int64_t &pts_o } //pts和dts的差值 - int pts_dts_diff = pts - dts; + auto pts_dts_diff = pts - dts; if (_last_dts_in != dts) { //时间戳发生变更 diff --git a/src/Common/Stamp.h b/src/Common/Stamp.h index 30d41157..77af2823 100644 --- a/src/Common/Stamp.h +++ b/src/Common/Stamp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Common/config.cpp b/src/Common/config.cpp index d4fd3887..38f5c49a 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -30,7 +30,7 @@ bool loadIniConfig(const char *ini_path){ mINI::Instance().parseFile(ini); NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastReloadConfig); return true; - }catch (std::exception &ex) { + }catch (std::exception &) { InfoL << "dump ini file to:" << ini; mINI::Instance().dumpFile(ini); return false; diff --git a/src/Common/config.h b/src/Common/config.h index 4c41e1f9..df624cc3 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Extension/AAC.cpp b/src/Extension/AAC.cpp index 30b4cf2f..2f1691ec 100644 --- a/src/Extension/AAC.cpp +++ b/src/Extension/AAC.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -15,6 +15,7 @@ namespace mediakit{ +#ifndef ENABLE_MP4 unsigned const samplingFrequencyTable[16] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, 0, 0, 0 }; class AdtsHeader{ @@ -91,8 +92,9 @@ static void parseAacConfig(const string &config, AdtsHeader &adts) { adts.adts_buffer_fullness = 2047; adts.no_raw_data_blocks_in_frame = 0; } +#endif// ENABLE_MP4 -int getAacFrameLength(const uint8_t *data, int bytes) { +int getAacFrameLength(const uint8_t *data, size_t bytes) { uint16_t len; if (bytes < 7) return -1; if (0xFF != data[0] || 0xF0 != (data[1] & 0xF0)) { @@ -102,7 +104,7 @@ int getAacFrameLength(const uint8_t *data, int bytes) { return len; } -string makeAacConfig(const uint8_t *hex, int length){ +string makeAacConfig(const uint8_t *hex, size_t length){ #ifndef ENABLE_MP4 if (!(hex[0] == 0xFF && (hex[1] & 0xF0) == 0xF0)) { return ""; @@ -140,11 +142,11 @@ string makeAacConfig(const uint8_t *hex, int length){ #endif } -int dumpAacConfig(const string &config, int length, uint8_t *out, int out_size) { +int dumpAacConfig(const string &config, size_t length, uint8_t *out, size_t out_size) { #ifndef ENABLE_MP4 AdtsHeader header; parseAacConfig(config, header); - header.aac_frame_length = ADTS_HEADER_LEN + length; + header.aac_frame_length = (decltype(header.aac_frame_length))(ADTS_HEADER_LEN + length); dumpAdtsHeader(header, out); return ADTS_HEADER_LEN; #else diff --git a/src/Extension/AAC.h b/src/Extension/AAC.h index 0dd5ecaf..61ff4b66 100644 --- a/src/Extension/AAC.h +++ b/src/Extension/AAC.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -17,9 +17,9 @@ namespace mediakit{ -string makeAacConfig(const uint8_t *hex, int length); -int getAacFrameLength(const uint8_t *hex, int length); -int dumpAacConfig(const string &config, int length, uint8_t *out, int out_size); +string makeAacConfig(const uint8_t *hex, size_t length); +int getAacFrameLength(const uint8_t *hex, size_t length); +int dumpAacConfig(const string &config, size_t length, uint8_t *out, size_t out_size); bool parseAacConfig(const string &config, int &samplerate, int &channels); /** diff --git a/src/Extension/AACRtmp.cpp b/src/Extension/AACRtmp.cpp index 759687d7..b028763f 100644 --- a/src/Extension/AACRtmp.cpp +++ b/src/Extension/AACRtmp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -41,7 +41,7 @@ void AACRtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) { } } -void AACRtmpDecoder::onGetAAC(const char* data, int len, uint32_t stamp) { +void AACRtmpDecoder::onGetAAC(const char* data, size_t len, uint32_t stamp) { auto frame = ResourcePoolHelper::obtainObj(); frame->_codec_id = CodecAAC; diff --git a/src/Extension/AACRtmp.h b/src/Extension/AACRtmp.h index 741da220..e00a9f71 100644 --- a/src/Extension/AACRtmp.h +++ b/src/Extension/AACRtmp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -37,7 +37,7 @@ public: } private: - void onGetAAC(const char *data, int len, uint32_t stamp); + void onGetAAC(const char *data, size_t len, uint32_t stamp); private: string _aac_cfg; diff --git a/src/Extension/AACRtp.cpp b/src/Extension/AACRtp.cpp index 8790cfeb..0c648048 100644 --- a/src/Extension/AACRtp.cpp +++ b/src/Extension/AACRtp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -31,22 +31,22 @@ void AACRtpEncoder::inputFrame(const Frame::Ptr &frame) { auto iLen = frame->size() - frame->prefixSize(); uiStamp %= cycleMS; - char *ptr = (char *) pcData; - int iSize = iLen; + auto *ptr = (char *) pcData; + auto iSize = iLen; while (iSize > 0) { if (iSize <= _ui32MtuSize - 20) { _aucSectionBuf[0] = 0; _aucSectionBuf[1] = 16; - _aucSectionBuf[2] = iLen >> 5; - _aucSectionBuf[3] = (iLen & 0x1F) << 3; + _aucSectionBuf[2] = (iLen >> 5) & 0xFF; + _aucSectionBuf[3] = ((iLen & 0x1F) << 3) & 0xFF; memcpy(_aucSectionBuf + 4, ptr, iSize); makeAACRtp(_aucSectionBuf, iSize + 4, true, uiStamp); break; } _aucSectionBuf[0] = 0; _aucSectionBuf[1] = 16; - _aucSectionBuf[2] = (iLen) >> 5; - _aucSectionBuf[3] = (iLen & 0x1F) << 3; + _aucSectionBuf[2] = ((iLen) >> 5) & 0xFF; + _aucSectionBuf[3] = ((iLen & 0x1F) << 3) & 0xFF; memcpy(_aucSectionBuf + 4, ptr, _ui32MtuSize - 20); makeAACRtp(_aucSectionBuf, _ui32MtuSize - 16, false, uiStamp); ptr += (_ui32MtuSize - 20); @@ -54,7 +54,7 @@ void AACRtpEncoder::inputFrame(const Frame::Ptr &frame) { } } -void AACRtpEncoder::makeAACRtp(const void *data, unsigned int len, bool mark, uint32_t uiStamp) { +void AACRtpEncoder::makeAACRtp(const void *data, size_t len, bool mark, uint32_t uiStamp) { RtpCodec::inputRtp(makeRtp(getTrackType(), data, len, mark, uiStamp), false); } diff --git a/src/Extension/AACRtp.h b/src/Extension/AACRtp.h index 7e284c8e..fe029f64 100644 --- a/src/Extension/AACRtp.h +++ b/src/Extension/AACRtp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -43,9 +43,9 @@ private: void flushData(); private: - FrameImp::Ptr _frame; - string _aac_cfg; uint32_t _last_dts = 0; + string _aac_cfg; + FrameImp::Ptr _frame; }; @@ -77,7 +77,7 @@ public: void inputFrame(const Frame::Ptr &frame) override; private: - void makeAACRtp(const void *pData, unsigned int uiLen, bool bMark, uint32_t uiStamp); + void makeAACRtp(const void *pData, size_t uiLen, bool bMark, uint32_t uiStamp); private: unsigned char _aucSectionBuf[1600]; diff --git a/src/Extension/CommonRtmp.cpp b/src/Extension/CommonRtmp.cpp index 41fec6ec..858228ca 100644 --- a/src/Extension/CommonRtmp.cpp +++ b/src/Extension/CommonRtmp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Extension/CommonRtmp.h b/src/Extension/CommonRtmp.h index 1f676507..48f64d22 100644 --- a/src/Extension/CommonRtmp.h +++ b/src/Extension/CommonRtmp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Extension/CommonRtp.cpp b/src/Extension/CommonRtp.cpp index 14fd37f7..1a8dc6cf 100644 --- a/src/Extension/CommonRtp.cpp +++ b/src/Extension/CommonRtp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Extension/CommonRtp.h b/src/Extension/CommonRtp.h index 4345c641..a6ff279e 100644 --- a/src/Extension/CommonRtp.h +++ b/src/Extension/CommonRtp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Extension/Factory.cpp b/src/Extension/Factory.cpp index fa2248de..88e3ad4e 100644 --- a/src/Extension/Factory.cpp +++ b/src/Extension/Factory.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Extension/Factory.h b/src/Extension/Factory.h index 74b70c58..d8265f0b 100644 --- a/src/Extension/Factory.h +++ b/src/Extension/Factory.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Extension/Frame.cpp b/src/Extension/Frame.cpp index 45c2db38..ba8a6a9d 100644 --- a/src/Extension/Frame.cpp +++ b/src/Extension/Frame.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -58,10 +58,10 @@ public: } private: - Frame::Ptr _frame; - BufferRaw::Ptr _buffer; bool _key; bool _config; + Frame::Ptr _frame; + BufferRaw::Ptr _buffer; }; Frame::Ptr Frame::getCacheAbleFrame(const Frame::Ptr &frame){ diff --git a/src/Extension/Frame.h b/src/Extension/Frame.h index 2d64b744..b9628698 100644 --- a/src/Extension/Frame.h +++ b/src/Extension/Frame.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -101,7 +101,7 @@ public: * 前缀长度,譬如264前缀为0x00 00 00 01,那么前缀长度就是4 * aac前缀则为7个字节 */ - virtual uint32_t prefixSize() const = 0; + virtual size_t prefixSize() const = 0; /** * 返回是否为关键帧 @@ -132,7 +132,7 @@ public: return (char *)_buffer.data(); } - uint32_t size() const override { + size_t size() const override { return _buffer.size(); } @@ -144,7 +144,7 @@ public: return _pts ? _pts : _dts; } - uint32_t prefixSize() const override{ + size_t prefixSize() const override{ return _prefix_size; } @@ -162,10 +162,10 @@ public: public: CodecId _codec_id = CodecInvalid; - BufferLikeString _buffer; uint32_t _dts = 0; uint32_t _pts = 0; - uint32_t _prefix_size = 0; + size_t _prefix_size = 0; + BufferLikeString _buffer; }; /** @@ -178,7 +178,7 @@ template class FrameInternal : public Parent{ public: typedef std::shared_ptr Ptr; - FrameInternal(const Frame::Ptr &parent_frame, char *ptr, uint32_t size, int prefix_size) + FrameInternal(const Frame::Ptr &parent_frame, char *ptr, size_t size, size_t prefix_size) : Parent(ptr, size, parent_frame->dts(), parent_frame->pts(), prefix_size) { _parent_frame = parent_frame; } @@ -301,7 +301,7 @@ public: /** * 返回代理个数 */ - int size() const { + size_t size() const { return _delegates_write.size(); } private: @@ -318,12 +318,12 @@ class FrameFromPtr : public Frame{ public: typedef std::shared_ptr Ptr; - FrameFromPtr(CodecId codec_id, char *ptr, uint32_t size, uint32_t dts, uint32_t pts = 0, int prefix_size = 0) + FrameFromPtr(CodecId codec_id, char *ptr, size_t size, uint32_t dts, uint32_t pts = 0, size_t prefix_size = 0) : FrameFromPtr(ptr, size, dts, pts, prefix_size) { _codec_id = codec_id; } - FrameFromPtr(char *ptr, uint32_t size, uint32_t dts, uint32_t pts = 0, int prefix_size = 0){ + FrameFromPtr(char *ptr, size_t size, uint32_t dts, uint32_t pts = 0, size_t prefix_size = 0){ _ptr = ptr; _size = size; _dts = dts; @@ -335,7 +335,7 @@ public: return _ptr; } - uint32_t size() const override { + size_t size() const override { return _size; } @@ -347,7 +347,7 @@ public: return _pts ? _pts : dts(); } - uint32_t prefixSize() const override{ + size_t prefixSize() const override{ return _prefix_size; } @@ -379,10 +379,10 @@ protected: protected: char *_ptr; - uint32_t _size; uint32_t _dts; uint32_t _pts = 0; - uint32_t _prefix_size; + size_t _size; + size_t _prefix_size; CodecId _codec_id = CodecInvalid; }; @@ -402,7 +402,7 @@ public: * @param prefix 帧前缀长度 * @param offset buffer有效数据偏移量 */ - FrameWrapper(const Buffer::Ptr &buf, int64_t dts, int64_t pts, int prefix, int offset) : Parent(buf->data() + offset, buf->size() - offset, dts, pts, prefix){ + 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){ _buf = buf; } @@ -415,7 +415,7 @@ public: * @param offset buffer有效数据偏移量 * @param codec 帧类型 */ - FrameWrapper(const Buffer::Ptr &buf, int64_t dts, int64_t pts, int prefix, int offset, CodecId codec) : Parent(codec, buf->data() + offset, buf->size() - offset, dts, pts, prefix){ + 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){ _buf = buf; } diff --git a/src/Extension/G711.cpp b/src/Extension/G711.cpp index 9943e97f..9f3e8ec5 100644 --- a/src/Extension/G711.cpp +++ b/src/Extension/G711.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Extension/G711.h b/src/Extension/G711.h index f7d82ee7..69f87764 100644 --- a/src/Extension/G711.h +++ b/src/Extension/G711.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Extension/H264.cpp b/src/Extension/H264.cpp index 84fc3e1c..29d9cc84 100644 --- a/src/Extension/H264.cpp +++ b/src/Extension/H264.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -15,13 +15,13 @@ using namespace toolkit; namespace mediakit{ -bool getAVCInfo(const char * sps,int sps_len,int &iVideoWidth, int &iVideoHeight, float &iVideoFps){ +static bool getAVCInfo(const char * sps,size_t sps_len,int &iVideoWidth, int &iVideoHeight, float &iVideoFps){ T_GetBitContext tGetBitBuf; T_SPS tH264SpsInfo; memset(&tGetBitBuf,0,sizeof(tGetBitBuf)); memset(&tH264SpsInfo,0,sizeof(tH264SpsInfo)); tGetBitBuf.pu8Buf = (uint8_t*)sps + 1; - tGetBitBuf.iBufSize = sps_len - 1; + tGetBitBuf.iBufSize = (int)(sps_len - 1); if(0 != h264DecSeqParameterSet((void *) &tGetBitBuf, &tH264SpsInfo)){ return false; } @@ -31,11 +31,11 @@ bool getAVCInfo(const char * sps,int sps_len,int &iVideoWidth, int &iVideoHeight return true; } -bool getAVCInfo(const string& strSps,int &iVideoWidth, int &iVideoHeight, float &iVideoFps) { - return getAVCInfo(strSps.data(),strSps.size(),iVideoWidth,iVideoHeight,iVideoFps); +bool getAVCInfo(const string &strSps, int &iVideoWidth, int &iVideoHeight, float &iVideoFps) { + return getAVCInfo(strSps.data(), strSps.size(), iVideoWidth, iVideoHeight, iVideoFps); } -const char *memfind(const char *buf, int len, const char *subbuf, int sublen) { +static const char *memfind(const char *buf, size_t len, const char *subbuf, size_t sublen) { for (auto i = 0; i < len - sublen; ++i) { if (memcmp(buf + i, subbuf, sublen) == 0) { return buf + i; @@ -44,10 +44,10 @@ const char *memfind(const char *buf, int len, const char *subbuf, int sublen) { return NULL; } -void splitH264(const char *ptr, int len, int prefix, const std::function &cb) { +void splitH264(const char *ptr, size_t len, size_t prefix, const std::function &cb) { auto start = ptr + prefix; auto end = ptr + len; - int next_prefix; + size_t next_prefix; while (true) { auto next_start = memfind(start, end - start, "\x00\x00\x01", 3); if (next_start) { @@ -74,7 +74,7 @@ void splitH264(const char *ptr, int len, int prefix, const std::function &cb); -int prefixSize(const char *ptr, int len); +bool getAVCInfo(const string &strSps,int &iVideoWidth, int &iVideoHeight, float &iVideoFps); +void splitH264(const char *ptr, size_t len, size_t prefix, const std::function &cb); +size_t prefixSize(const char *ptr, size_t len); /** * 264帧类 */ @@ -64,7 +64,7 @@ class H264FrameNoCacheAble : public FrameFromPtr { public: typedef std::shared_ptr Ptr; - H264FrameNoCacheAble(char *ptr,uint32_t size,uint32_t dts , uint32_t pts ,int prefix_size = 4){ + H264FrameNoCacheAble(char *ptr,size_t size,uint32_t dts , uint32_t pts ,size_t prefix_size = 4){ _ptr = ptr; _size = size; _dts = dts; @@ -183,7 +183,7 @@ public: int type = H264_TYPE(*((uint8_t *)frame->data() + frame->prefixSize())); if(type != H264Frame::NAL_B_P && type != H264Frame::NAL_IDR){ //非I/B/P帧情况下,split一下,防止多个帧粘合在一起 - splitH264(frame->data(), frame->size(), frame->prefixSize(), [&](const char *ptr, int len, int prefix) { + splitH264(frame->data(), frame->size(), frame->prefixSize(), [&](const char *ptr, size_t len, size_t prefix) { H264FrameInternal::Ptr sub_frame = std::make_shared(frame, (char *)ptr, len, prefix); inputFrame_l(sub_frame); }); @@ -310,14 +310,14 @@ public: (uint8_t(strSPS[3])); // profile_idc|constraint_setN_flag|level_idc } memset(strTemp, 0, 100); - sprintf(strTemp, "%06X", profile_level_id); + snprintf(strTemp, sizeof(strTemp), "%06X", profile_level_id); _printer << strTemp; _printer << "; sprop-parameter-sets="; memset(strTemp, 0, 100); - av_base64_encode(strTemp, 100, (uint8_t *) strSPS.data(), strSPS.size()); + av_base64_encode(strTemp, 100, (uint8_t *) strSPS.data(), (int)strSPS.size()); _printer << strTemp << ","; memset(strTemp, 0, 100); - av_base64_encode(strTemp, 100, (uint8_t *) strPPS.data(), strPPS.size()); + av_base64_encode(strTemp, 100, (uint8_t *) strPPS.data(), (int)strPPS.size()); _printer << strTemp << "\r\n"; _printer << "a=control:trackID=" << (int)TrackVideo << "\r\n"; } diff --git a/src/Extension/H264Rtmp.cpp b/src/Extension/H264Rtmp.cpp index 20e58da1..98b12abc 100644 --- a/src/Extension/H264Rtmp.cpp +++ b/src/Extension/H264Rtmp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -97,8 +97,8 @@ void H264RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) { } if (pkt->buffer.size() > 9) { - uint32_t iTotalLen = pkt->buffer.size(); - uint32_t iOffset = 5; + auto iTotalLen = pkt->buffer.size(); + size_t iOffset = 5; uint8_t *cts_ptr = (uint8_t *) (pkt->buffer.data() + 2); int32_t cts = (((cts_ptr[0] << 16) | (cts_ptr[1] << 8) | (cts_ptr[2])) + 0xff800000) ^ 0xff800000; auto pts = pkt->time_stamp + cts; @@ -117,7 +117,7 @@ void H264RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) { } } -inline void H264RtmpDecoder::onGetH264(const char* pcData, int iLen, uint32_t dts,uint32_t pts) { +inline void H264RtmpDecoder::onGetH264(const char* pcData, size_t iLen, uint32_t dts,uint32_t pts) { if(iLen == 0){ return; } @@ -213,7 +213,7 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) { _lastPacket->type_id = MSG_VIDEO; } - auto size = htonl(iLen); + uint32_t size = htonl((uint32_t)iLen); _lastPacket->buffer.append((char *) &size, 4); _lastPacket->buffer.append(pcData, iLen); _lastPacket->body_size = _lastPacket->buffer.size(); @@ -238,16 +238,16 @@ void H264RtmpEncoder::makeVideoConfigPkt() { rtmpPkt->buffer.push_back(_sps[1]); // profile rtmpPkt->buffer.push_back(_sps[2]); // compat rtmpPkt->buffer.push_back(_sps[3]); // level - rtmpPkt->buffer.push_back(0xff); // 6 bits reserved + 2 bits nal size length - 1 (11) - rtmpPkt->buffer.push_back(0xe1); // 3 bits reserved + 5 bits number of sps (00001) + rtmpPkt->buffer.push_back((char)0xff); // 6 bits reserved + 2 bits nal size length - 1 (11) + rtmpPkt->buffer.push_back((char)0xe1); // 3 bits reserved + 5 bits number of sps (00001) //sps - uint16_t size = _sps.size(); + uint16_t size = (uint16_t)_sps.size(); size = htons(size); rtmpPkt->buffer.append((char *) &size, 2); rtmpPkt->buffer.append(_sps); //pps rtmpPkt->buffer.push_back(1); // version - size = _pps.size(); + size = (uint16_t)_pps.size(); size = htons(size); rtmpPkt->buffer.append((char *) &size, 2); rtmpPkt->buffer.append(_pps); diff --git a/src/Extension/H264Rtmp.h b/src/Extension/H264Rtmp.h index 3921fc79..92b37dfc 100644 --- a/src/Extension/H264Rtmp.h +++ b/src/Extension/H264Rtmp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -40,7 +40,7 @@ public: } protected: - void onGetH264(const char *pcData, int iLen, uint32_t dts,uint32_t pts); + void onGetH264(const char *pcData, size_t iLen, uint32_t dts,uint32_t pts); H264Frame::Ptr obtainFrame(); protected: diff --git a/src/Extension/H264Rtp.cpp b/src/Extension/H264Rtp.cpp index 2dac8cb7..76463672 100644 --- a/src/Extension/H264Rtp.cpp +++ b/src/Extension/H264Rtp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -72,7 +72,7 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) { 30-31 undefined - */ const uint8_t *frame = (uint8_t *) rtppack->data() + rtppack->offset; - int length = rtppack->size() - rtppack->offset; + auto length = rtppack->size() - rtppack->offset; int nal_type = *frame & 0x1F; int nal_suffix = *frame & (~0x1F); @@ -92,7 +92,7 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) { bool haveIDR = false; auto ptr = frame + 1; while (true) { - int off = ptr - frame; + size_t off = ptr - frame; if (off >= length) { break; } @@ -198,7 +198,7 @@ void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) { auto len = frame->size() - frame->prefixSize(); auto pts = frame->pts() % cycleMS; auto nal_type = H264_TYPE(ptr[0]); - auto payload_size = _ui32MtuSize - 2; + size_t payload_size = _ui32MtuSize - 2; //超过MTU则按照FU-A模式打包 if (len > payload_size + 1) { @@ -209,7 +209,7 @@ void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) { unsigned char s_e_r_flags; bool fu_a_start = true; bool mark_bit = false; - int offset = 1; + size_t offset = 1; while (!mark_bit) { if (len <= offset + payload_size) { //FU-A end @@ -247,7 +247,7 @@ void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) { } } -void H264RtpEncoder::makeH264Rtp(const void* data, unsigned int len, bool mark, bool gop_pos, uint32_t uiStamp) { +void H264RtpEncoder::makeH264Rtp(const void* data, size_t len, bool mark, bool gop_pos, uint32_t uiStamp) { RtpCodec::inputRtp(makeRtp(getTrackType(), data, len, mark, uiStamp), gop_pos); } diff --git a/src/Extension/H264Rtp.h b/src/Extension/H264Rtp.h index 89e09c59..c28b601f 100644 --- a/src/Extension/H264Rtp.h +++ b/src/Extension/H264Rtp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -41,14 +41,16 @@ public: CodecId getCodecId() const override{ return CodecH264; } + private: bool decodeRtp(const RtpPacket::Ptr &rtp); void onGetH264(const H264Frame::Ptr &frame); H264Frame::Ptr obtainFrame(); + private: + int _lastSeq = 0; H264Frame::Ptr _h264frame; DtsGenerator _dts_generator; - int _lastSeq = 0; }; /** @@ -77,8 +79,9 @@ public: * @param frame 帧数据,必须 */ void inputFrame(const Frame::Ptr &frame) override; + private: - void makeH264Rtp(const void *pData, unsigned int uiLen, bool bMark, bool gop_pos, uint32_t uiStamp); + void makeH264Rtp(const void *pData, size_t uiLen, bool bMark, bool gop_pos, uint32_t uiStamp); }; }//namespace mediakit{ diff --git a/src/Extension/H265.cpp b/src/Extension/H265.cpp index 0283f33c..179b09d8 100644 --- a/src/Extension/H265.cpp +++ b/src/Extension/H265.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -14,7 +14,7 @@ namespace mediakit{ -bool getHEVCInfo(const char * vps, int vps_len,const char * sps,int sps_len,int &iVideoWidth, int &iVideoHeight, float &iVideoFps){ +bool getHEVCInfo(const char * vps, size_t vps_len,const char * sps,size_t sps_len,int &iVideoWidth, int &iVideoHeight, float &iVideoFps){ T_GetBitContext tGetBitBuf; T_HEVCSPS tH265SpsInfo; T_HEVCVPS tH265VpsInfo; @@ -22,7 +22,7 @@ bool getHEVCInfo(const char * vps, int vps_len,const char * sps,int sps_len,int memset(&tGetBitBuf,0,sizeof(tGetBitBuf)); memset(&tH265VpsInfo,0,sizeof(tH265VpsInfo)); tGetBitBuf.pu8Buf = (uint8_t*)vps+2; - tGetBitBuf.iBufSize = vps_len-2; + tGetBitBuf.iBufSize = (int)(vps_len-2); if(0 != h265DecVideoParameterSet((void *) &tGetBitBuf, &tH265VpsInfo)){ return false; } @@ -32,7 +32,7 @@ bool getHEVCInfo(const char * vps, int vps_len,const char * sps,int sps_len,int memset(&tGetBitBuf,0,sizeof(tGetBitBuf)); memset(&tH265SpsInfo,0,sizeof(tH265SpsInfo)); tGetBitBuf.pu8Buf = (uint8_t*)sps+2; - tGetBitBuf.iBufSize = sps_len-2; + tGetBitBuf.iBufSize = (int)(sps_len-2); if(0 != h265DecSeqParameterSet((void *) &tGetBitBuf, &tH265SpsInfo)){ return false; } @@ -47,7 +47,7 @@ bool getHEVCInfo(const char * vps, int vps_len,const char * sps,int sps_len,int } bool getHEVCInfo(const string &strVps, const string &strSps, int &iVideoWidth, int &iVideoHeight, float &iVideoFps) { - return getHEVCInfo(strVps.data(),strVps.size(),strSps.data(),strSps.size(),iVideoWidth,iVideoHeight,iVideoFps); + return getHEVCInfo(strVps.data(), strVps.size(), strSps.data(), strSps.size(), iVideoWidth, iVideoHeight,iVideoFps); } Sdp::Ptr H265Track::getSdp() { diff --git a/src/Extension/H265.h b/src/Extension/H265.h index a4014c2f..1f94e06e 100644 --- a/src/Extension/H265.h +++ b/src/Extension/H265.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -86,7 +86,7 @@ class H265FrameNoCacheAble : public FrameFromPtr { public: typedef std::shared_ptr Ptr; - H265FrameNoCacheAble(char *ptr, uint32_t size, uint32_t dts,uint32_t pts, int prefix_size = 4) { + H265FrameNoCacheAble(char *ptr, size_t size, uint32_t dts,uint32_t pts, size_t prefix_size = 4) { _ptr = ptr; _size = size; _dts = dts; @@ -197,7 +197,7 @@ public: void inputFrame(const Frame::Ptr &frame) override{ int type = H265_TYPE(*((uint8_t *)frame->data() + frame->prefixSize())); if(frame->configFrame() || type == H265Frame::NAL_SEI_PREFIX){ - splitH264(frame->data(), frame->size(), frame->prefixSize(), [&](const char *ptr, int len, int prefix){ + splitH264(frame->data(), frame->size(), frame->prefixSize(), [&](const char *ptr, size_t len, size_t prefix){ H265FrameInternal::Ptr sub_frame = std::make_shared(frame, (char*)ptr, len, prefix); inputFrame_l(sub_frame); }); diff --git a/src/Extension/H265Rtmp.cpp b/src/Extension/H265Rtmp.cpp index dddf5379..8b91b059 100644 --- a/src/Extension/H265Rtmp.cpp +++ b/src/Extension/H265Rtmp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -75,8 +75,8 @@ void H265RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) { } if (pkt->buffer.size() > 9) { - uint32_t iTotalLen = pkt->buffer.size(); - uint32_t iOffset = 5; + auto iTotalLen = pkt->buffer.size(); + size_t iOffset = 5; uint8_t *cts_ptr = (uint8_t *) (pkt->buffer.data() + 2); int32_t cts = (((cts_ptr[0] << 16) | (cts_ptr[1] << 8) | (cts_ptr[2])) + 0xff800000) ^ 0xff800000; auto pts = pkt->time_stamp + cts; @@ -95,7 +95,7 @@ void H265RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) { } } -inline void H265RtmpDecoder::onGetH265(const char* pcData, int iLen, uint32_t dts,uint32_t pts) { +inline void H265RtmpDecoder::onGetH265(const char* pcData, size_t iLen, uint32_t dts,uint32_t pts) { if(iLen == 0){ return; } @@ -196,7 +196,7 @@ void H265RtmpEncoder::inputFrame(const Frame::Ptr &frame) { _lastPacket->type_id = MSG_VIDEO; } - auto size = htonl(iLen); + uint32_t size = htonl((uint32_t)iLen); _lastPacket->buffer.append((char *) &size, 4); _lastPacket->buffer.append(pcData, iLen); _lastPacket->body_size = _lastPacket->buffer.size(); @@ -221,7 +221,7 @@ void H265RtmpEncoder::makeVideoConfigPkt() { string vps_sps_pps = string("\x00\x00\x00\x01", 4) + _vps + string("\x00\x00\x00\x01", 4) + _sps + string("\x00\x00\x00\x01", 4) + _pps; - h265_annexbtomp4(&hevc, vps_sps_pps.data(), vps_sps_pps.size(), NULL, 0, NULL, NULL); + h265_annexbtomp4(&hevc, vps_sps_pps.data(), (int)vps_sps_pps.size(), NULL, 0, NULL, NULL); uint8_t extra_data[1024]; int extra_data_size = mpeg4_hevc_decoder_configuration_record_save(&hevc, extra_data, sizeof(extra_data)); if (extra_data_size == -1) { diff --git a/src/Extension/H265Rtmp.h b/src/Extension/H265Rtmp.h index c46396ff..ef2f96ba 100644 --- a/src/Extension/H265Rtmp.h +++ b/src/Extension/H265Rtmp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -40,7 +40,7 @@ public: } protected: - void onGetH265(const char *pcData, int iLen, uint32_t dts,uint32_t pts); + void onGetH265(const char *pcData, size_t iLen, uint32_t dts,uint32_t pts); H265Frame::Ptr obtainFrame(); protected: @@ -73,14 +73,16 @@ public: * 生成config包 */ void makeConfigPacket() override; + private: void makeVideoConfigPkt(); + private: + bool _gotSpsPps = false; string _vps; string _sps; string _pps; H265Track::Ptr _track; - bool _gotSpsPps = false; RtmpPacket::Ptr _lastPacket; }; diff --git a/src/Extension/H265Rtp.cpp b/src/Extension/H265Rtp.cpp index dc07b180..6735fb57 100644 --- a/src/Extension/H265Rtp.cpp +++ b/src/Extension/H265Rtp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -64,7 +64,7 @@ bool H265RtpDecoder::inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) { bool H265RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) { const uint8_t *frame = (uint8_t *) rtppack->data() + rtppack->offset; - int length = rtppack->size() - rtppack->offset; + auto length = rtppack->size() - rtppack->offset; int nal = H265_TYPE(frame[0]); if (nal > 50){ @@ -154,7 +154,7 @@ void H265RtpEncoder::inputFrame(const Frame::Ptr &frame) { auto len = frame->size() - frame->prefixSize(); auto pts = frame->pts() % cycleMS; auto nal_type = H265_TYPE(ptr[0]); //获取NALU的5bit 帧类型 - auto payload_size = _ui32MtuSize - 3; + size_t payload_size = _ui32MtuSize - 3; //超过MTU,按照FU方式打包 if (len > payload_size + 2) { @@ -162,7 +162,7 @@ void H265RtpEncoder::inputFrame(const Frame::Ptr &frame) { unsigned char s_e_flags; bool fu_start = true; bool mark_bit = false; - int offset = 2; + size_t offset = 2; while (!mark_bit) { if (len <= offset + payload_size) { //FU end @@ -202,7 +202,7 @@ void H265RtpEncoder::inputFrame(const Frame::Ptr &frame) { } } -void H265RtpEncoder::makeH265Rtp(int nal_type,const void* data, unsigned int len, bool mark, bool first_packet, uint32_t uiStamp) { +void H265RtpEncoder::makeH265Rtp(int nal_type,const void* data, size_t len, bool mark, bool first_packet, uint32_t uiStamp) { RtpCodec::inputRtp(makeRtp(getTrackType(),data,len,mark,uiStamp),first_packet && H265Frame::isKeyFrame(nal_type)); } diff --git a/src/Extension/H265Rtp.h b/src/Extension/H265Rtp.h index 6c8bbe38..1f50a8bd 100644 --- a/src/Extension/H265Rtp.h +++ b/src/Extension/H265Rtp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -42,14 +42,16 @@ public: CodecId getCodecId() const override{ return CodecH265; } + private: bool decodeRtp(const RtpPacket::Ptr &rtp); void onGetH265(const H265Frame::Ptr &frame); H265Frame::Ptr obtainFrame(); + private: + int _lastSeq = 0; H265Frame::Ptr _h265frame; DtsGenerator _dts_generator; - int _lastSeq = 0; }; /** @@ -79,7 +81,7 @@ public: */ void inputFrame(const Frame::Ptr &frame) override; private: - void makeH265Rtp(int nal_type,const void *pData, unsigned int uiLen, bool bMark, bool first_packet,uint32_t uiStamp); + void makeH265Rtp(int nal_type,const void *pData, size_t uiLen, bool bMark, bool first_packet,uint32_t uiStamp); }; }//namespace mediakit{ diff --git a/src/Extension/L16.cpp b/src/Extension/L16.cpp index 8cc0c977..1ae5f265 100644 --- a/src/Extension/L16.cpp +++ b/src/Extension/L16.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Extension/L16.h b/src/Extension/L16.h index 38b3f131..ed19f6dd 100644 --- a/src/Extension/L16.h +++ b/src/Extension/L16.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Extension/Opus.cpp b/src/Extension/Opus.cpp index ada06174..64777d28 100644 --- a/src/Extension/Opus.cpp +++ b/src/Extension/Opus.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Extension/Opus.h b/src/Extension/Opus.h index 5402d4a9..382ee8c8 100644 --- a/src/Extension/Opus.h +++ b/src/Extension/Opus.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Extension/Track.h b/src/Extension/Track.h index 70f02ead..aa03d8da 100644 --- a/src/Extension/Track.h +++ b/src/Extension/Track.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/FMP4/FMP4MediaSource.h b/src/FMP4/FMP4MediaSource.h index 16fb2ab2..95856434 100644 --- a/src/FMP4/FMP4MediaSource.h +++ b/src/FMP4/FMP4MediaSource.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/FMP4/FMP4MediaSourceMuxer.h b/src/FMP4/FMP4MediaSourceMuxer.h index 6d133db5..4b6410a0 100644 --- a/src/FMP4/FMP4MediaSourceMuxer.h +++ b/src/FMP4/FMP4MediaSourceMuxer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Http/HlsParser.cpp b/src/Http/HlsParser.cpp index 60e578d7..ae876c4c 100644 --- a/src/Http/HlsParser.cpp +++ b/src/Http/HlsParser.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -129,7 +129,7 @@ int HlsParser::getTargetDur() const { return _target_dur; } -int HlsParser::getSequence() const { +int64_t HlsParser::getSequence() const { return _sequence; } diff --git a/src/Http/HlsParser.h b/src/Http/HlsParser.h index 7a0ed7fe..9ced4158 100644 --- a/src/Http/HlsParser.h +++ b/src/Http/HlsParser.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -68,7 +68,7 @@ public: /** * #EXT-X-MEDIA-SEQUENCE字段值,该m3u8序号 */ - int getSequence() const; + int64_t getSequence() const; /** * 内部是否含有子m3u8 diff --git a/src/Http/HlsPlayer.cpp b/src/Http/HlsPlayer.cpp index 232e3453..dd30f6be 100644 --- a/src/Http/HlsPlayer.cpp +++ b/src/Http/HlsPlayer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -12,7 +12,7 @@ namespace mediakit { HlsPlayer::HlsPlayer(const EventPoller::Ptr &poller){ - _segment.setOnSegment([this](const char *data, uint64_t len) { onPacket(data, len); }); + _segment.setOnSegment([this](const char *data, size_t len) { onPacket(data, len); }); setPoller(poller ? poller : EventPollerPool::Instance().getPoller()); } @@ -28,7 +28,7 @@ void HlsPlayer::play_l(){ teardown_l(SockException(Err_shutdown, "所有hls url都尝试播放失败!")); return; } - float playTimeOutSec = (*this)[Client::kTimeoutMS].as() / 1000.0; + float playTimeOutSec = (*this)[Client::kTimeoutMS].as() / 1000.0f; setMethod("GET"); if(!(*this)[kNetAdapter].empty()) { setNetAdapter((*this)[kNetAdapter]); @@ -83,7 +83,7 @@ void HlsPlayer::playNextTs(bool force){ strongSelf->playNextTs(true); } else { //下一个切片慢点播放 - strongSelf->_timer_ts.reset(new Timer(delay / 1000.0, [weakSelf, delay]() { + strongSelf->_timer_ts.reset(new Timer(delay / 1000.0f, [weakSelf, delay]() { auto strongSelf = weakSelf.lock(); if (!strongSelf) { return false; @@ -94,7 +94,7 @@ void HlsPlayer::playNextTs(bool force){ } }); - _http_ts_player->setOnPacket([weakSelf](const char *data, uint64_t len) { + _http_ts_player->setOnPacket([weakSelf](const char *data, size_t len) { auto strongSelf = weakSelf.lock(); if (!strongSelf) { return; @@ -153,7 +153,7 @@ void HlsPlayer::onParsed(bool is_m3u8_inner,int64_t sequence,const map 0) { - return HlsParser::getTargetDur(); + return (float)HlsParser::getTargetDur(); } - return 1; + return 1.0f; } void HlsPlayer::onDisconnect(const SockException &ex) { @@ -232,7 +232,7 @@ void HlsPlayer::playDelay(){ }, getPoller())); } -void HlsPlayer::onPacket_l(const char *data, uint64_t len){ +void HlsPlayer::onPacket_l(const char *data, size_t len){ _segment.input(data,len); } @@ -246,7 +246,7 @@ void HlsPlayerImp::setOnPacket(const TSSegment::onSegment &cb){ _on_ts = cb; } -void HlsPlayerImp::onPacket(const char *data,uint64_t len) { +void HlsPlayerImp::onPacket(const char *data,size_t len) { if (_on_ts) { _on_ts(data, len); } @@ -276,7 +276,7 @@ void HlsPlayerImp::onPlayResult(const SockException &ex) { weak_ptr weakSelf = dynamic_pointer_cast(shared_from_this()); //每50毫秒执行一次 - _timer = std::make_shared(0.05, [weakSelf]() { + _timer = std::make_shared(0.05f, [weakSelf]() { auto strongSelf = weakSelf.lock(); if (!strongSelf) { return false; diff --git a/src/Http/HlsPlayer.h b/src/Http/HlsPlayer.h index 0e99b47b..238b2764 100644 --- a/src/Http/HlsPlayer.h +++ b/src/Http/HlsPlayer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -46,7 +46,7 @@ protected: * @param data ts数据负载 * @param len ts包长度 */ - virtual void onPacket(const char *data, uint64_t len) = 0; + virtual void onPacket(const char *data, size_t len) = 0; private: /** @@ -63,7 +63,7 @@ private: * @return 返回后续content的长度;-1:后续数据全是content;>=0:固定长度content * 需要指出的是,在http头中带有Content-Length字段时,该返回值无效 */ - int64_t onResponseHeader(const string &status,const HttpHeader &headers) override; + size_t onResponseHeader(const string &status,const HttpHeader &headers) override; /** * 收到http conten数据 * @param buf 数据指针 @@ -71,7 +71,7 @@ private: * @param recvedSize 已收数据大小(包含本次数据大小),当其等于totalSize时将触发onResponseCompleted回调 * @param totalSize 总数据大小 */ - void onResponseBody(const char *buf,int64_t size,int64_t recvedSize,int64_t totalSize) override; + void onResponseBody(const char *buf,size_t size,size_t recvedSize,size_t totalSize) override; /** * 接收http回复完毕, @@ -98,7 +98,7 @@ private: void playNextTs(bool force = false); void teardown_l(const SockException &ex); void play_l(); - void onPacket_l(const char *data, uint64_t len); + void onPacket_l(const char *data, size_t len); private: struct UrlComp { @@ -131,7 +131,7 @@ public: void setOnPacket(const TSSegment::onSegment &cb); private: - void onPacket(const char *data, uint64_t len) override; + void onPacket(const char *data, size_t len) override; void onAllTrackReady() override; void onPlayResult(const SockException &ex) override; vector getTracks(bool trackReady = true) const override; diff --git a/src/Http/HttpBody.cpp b/src/Http/HttpBody.cpp index 9abf523f..d36cb47c 100644 --- a/src/Http/HttpBody.cpp +++ b/src/Http/HttpBody.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -26,11 +26,12 @@ namespace mediakit { HttpStringBody::HttpStringBody(const string &str){ _str = str; } -uint64_t HttpStringBody::remainSize() { + +size_t HttpStringBody::remainSize() { return _str.size() - _offset; } -Buffer::Ptr HttpStringBody::readData(uint32_t size) { +Buffer::Ptr HttpStringBody::readData(size_t size) { size = MIN(remainSize(),size); if(!size){ //没有剩余字节了 @@ -55,11 +56,19 @@ HttpFileBody::HttpFileBody(const string &filePath){ } } -HttpFileBody::HttpFileBody(const std::shared_ptr &fp, uint64_t offset, uint64_t max_size) { +HttpFileBody::HttpFileBody(const std::shared_ptr &fp, size_t offset, size_t max_size) { init(fp,offset,max_size); } -void HttpFileBody::init(const std::shared_ptr &fp,uint64_t offset,uint64_t max_size){ +#if defined(_WIN32) || defined(_WIN64) + #define fseek64 _fseeki64 + #define ftell64 _ftelli64 +#else + #define fseek64 fseek + #define ftell64 ftell +#endif + +void HttpFileBody::init(const std::shared_ptr &fp,size_t offset, size_t max_size){ _fp = fp; _max_size = max_size; #ifdef ENABLE_MMAP @@ -85,7 +94,7 @@ void HttpFileBody::init(const std::shared_ptr &fp,uint64_t offset,uint64_t #endif if(!_map_addr && offset && fp.get()){ //未映射,那么fseek设置偏移量 - fseek(fp.get(), offset, SEEK_SET); + fseek64(fp.get(), offset, SEEK_SET); } } @@ -93,30 +102,30 @@ void HttpFileBody::init(const std::shared_ptr &fp,uint64_t offset,uint64_t class BufferMmap : public Buffer{ public: typedef std::shared_ptr Ptr; - BufferMmap(const std::shared_ptr &map_addr,uint64_t offset,int size){ + BufferMmap(const std::shared_ptr &map_addr, size_t offset, size_t size) { _map_addr = map_addr; _data = map_addr.get() + offset; _size = size; - }; - virtual ~BufferMmap(){}; + } + ~BufferMmap() override{}; //返回数据长度 char *data() const override { return _data; } - uint32_t size() const override{ + size_t size() const override{ return _size; } private: std::shared_ptr _map_addr; char *_data; - uint32_t _size; + size_t _size; }; -uint64_t HttpFileBody::remainSize() { +size_t HttpFileBody::remainSize() { return _max_size - _offset; } -Buffer::Ptr HttpFileBody::readData(uint32_t size) { +Buffer::Ptr HttpFileBody::readData(size_t size) { size = MIN(remainSize(),size); if(!size){ //没有剩余字节了 @@ -124,7 +133,7 @@ Buffer::Ptr HttpFileBody::readData(uint32_t size) { } if(!_map_addr){ //fread模式 - int iRead; + size_t iRead; auto ret = _pool.obtain(); ret->setCapacity(size + 1); do{ @@ -171,11 +180,11 @@ HttpMultiFormBody::HttpMultiFormBody(const HttpArgs &args,const string &filePath _totalSize = _bodyPrefix.size() + _bodySuffix.size() + _fileBody->remainSize(); } -uint64_t HttpMultiFormBody::remainSize() { +size_t HttpMultiFormBody::remainSize() { return _totalSize - _offset; } -Buffer::Ptr HttpMultiFormBody::readData(uint32_t size){ +Buffer::Ptr HttpMultiFormBody::readData(size_t size){ if(_bodyPrefix.size()){ auto ret = std::make_shared(_bodyPrefix); _offset += _bodyPrefix.size(); @@ -212,11 +221,11 @@ string HttpMultiFormBody::multiFormBodySuffix(const string &boundary){ return body; } -uint64_t HttpMultiFormBody::fileSize(FILE *fp) { - auto current = ftell(fp); - fseek(fp,0L,SEEK_END); /* 定位到文件末尾 */ - auto end = ftell(fp); /* 得到文件大小 */ - fseek(fp,current,SEEK_SET); +size_t HttpMultiFormBody::fileSize(FILE *fp) { + auto current = ftell64(fp); + fseek64(fp, 0L, SEEK_END); /* 定位到文件末尾 */ + auto end = ftell64(fp); /* 得到文件大小 */ + fseek64(fp, current, SEEK_SET); return end - current; } diff --git a/src/Http/HttpBody.h b/src/Http/HttpBody.h index 9c3064da..43177b8c 100644 --- a/src/Http/HttpBody.h +++ b/src/Http/HttpBody.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -33,52 +33,33 @@ namespace mediakit { class HttpBody : public std::enable_shared_from_this{ public: typedef std::shared_ptr Ptr; - HttpBody(){ -// _async_read_thread = WorkThreadPool::Instance().getPoller(); - } + HttpBody(){} + virtual ~HttpBody(){} /** - * 剩余数据大小,如果返回>=INT64_MAX, 那么就不设置content-length + * 剩余数据大小,如果返回-1, 那么就不设置content-length */ - virtual uint64_t remainSize() { return 0;}; + virtual size_t remainSize() { return 0;}; /** * 读取一定字节数,返回大小可能小于size * @param size 请求大小 * @return 字节对象,如果读完了,那么请返回nullptr */ - virtual Buffer::Ptr readData(uint32_t size) { return nullptr;}; + virtual Buffer::Ptr readData(size_t size) { return nullptr;}; /** * 异步请求读取一定字节数,返回大小可能小于size * @param size 请求大小 * @param cb 回调函数 */ - virtual void readDataAsync(uint32_t size,const function &cb){ -#if 0 - if(size >= remainSize()){ - //假如剩余数据很小,那么同步获取(为了优化性能) - cb(readData(size)); - return; - } - //如果是大文件,那么后台读取 - weak_ptr weakSelf = shared_from_this(); - _async_read_thread->async([cb,size,weakSelf](){ - auto strongSelf = weakSelf.lock(); - if(strongSelf){ - cb(strongSelf->readData(size)); - } - }); -#else + virtual void readDataAsync(size_t size,const function &cb){ //由于unix和linux是通过mmap的方式读取文件,所以把读文件操作放在后台线程并不能提高性能 //反而会由于频繁的线程切换导致性能降低以及延时增加,所以我们默认同步获取文件内容 //(其实并没有读,拷贝文件数据时在内核态完成文件读) cb(readData(size)); -#endif } -private: -// EventPoller::Ptr _async_read_thread; }; /** @@ -89,11 +70,12 @@ public: typedef std::shared_ptr Ptr; HttpStringBody(const string &str); virtual ~HttpStringBody(){} - uint64_t remainSize() override ; - Buffer::Ptr readData(uint32_t size) override ; + size_t remainSize() override; + Buffer::Ptr readData(size_t size) override ; + private: + size_t _offset = 0; mutable string _str; - uint64_t _offset = 0; }; /** @@ -109,18 +91,20 @@ public: * @param offset 相对文件头的偏移量 * @param max_size 最大读取字节数,未判断是否大于文件真实大小 */ - HttpFileBody(const std::shared_ptr &fp,uint64_t offset,uint64_t max_size); + HttpFileBody(const std::shared_ptr &fp,size_t offset,size_t max_size); HttpFileBody(const string &file_path); ~HttpFileBody(){}; - uint64_t remainSize() override ; - Buffer::Ptr readData(uint32_t size) override; + size_t remainSize() override ; + Buffer::Ptr readData(size_t size) override; + private: - void init(const std::shared_ptr &fp,uint64_t offset,uint64_t max_size); + void init(const std::shared_ptr &fp,size_t offset,size_t max_size); + private: + size_t _max_size; + size_t _offset = 0; std::shared_ptr _fp; - uint64_t _max_size; - uint64_t _offset = 0; std::shared_ptr _map_addr; ResourcePool _pool; }; @@ -142,18 +126,20 @@ public: */ HttpMultiFormBody(const HttpArgs &args,const string &filePath,const string &boundary = "0xKhTmLbOuNdArY"); virtual ~HttpMultiFormBody(){} - uint64_t remainSize() override ; - Buffer::Ptr readData(uint32_t size) override; + size_t remainSize() override ; + 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 uint64_t fileSize(FILE *fp); + static size_t fileSize(FILE *fp); static string multiFormContentType(const string &boundary); + private: + size_t _offset = 0; + size_t _totalSize; string _bodyPrefix; string _bodySuffix; - uint64_t _offset = 0; - uint64_t _totalSize; HttpFileBody::Ptr _fileBody; }; diff --git a/src/Http/HttpChunkedSplitter.cpp b/src/Http/HttpChunkedSplitter.cpp index fd074491..40a139ee 100644 --- a/src/Http/HttpChunkedSplitter.cpp +++ b/src/Http/HttpChunkedSplitter.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -13,7 +13,7 @@ namespace mediakit{ -const char *HttpChunkedSplitter::onSearchPacketTail(const char *data, uint64_t len) { +const char *HttpChunkedSplitter::onSearchPacketTail(const char *data, size_t len) { auto pos = strstr(data,"\r\n"); if(!pos){ return nullptr; @@ -21,11 +21,11 @@ const char *HttpChunkedSplitter::onSearchPacketTail(const char *data, uint64_t l return pos + 2; } -void HttpChunkedSplitter::onRecvContent(const char *data, uint64_t len) { +void HttpChunkedSplitter::onRecvContent(const char *data, size_t len) { onRecvChunk(data,len - 2); } -int64_t HttpChunkedSplitter::onRecvHeader(const char *data, uint64_t len) { +size_t HttpChunkedSplitter::onRecvHeader(const char *data, size_t len) { string str(data,len - 2); int ret; sscanf(str.data(),"%X",&ret); diff --git a/src/Http/HttpChunkedSplitter.h b/src/Http/HttpChunkedSplitter.h index 5ba586a4..5ae77ab7 100644 --- a/src/Http/HttpChunkedSplitter.h +++ b/src/Http/HttpChunkedSplitter.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -21,22 +21,25 @@ public: /** * len == 0时代表结束 */ - typedef std::function onChunkData; + typedef std::function onChunkData; HttpChunkedSplitter(const onChunkData &cb){ _onChunkData = cb; }; ~HttpChunkedSplitter() override {} ; + protected: - int64_t onRecvHeader(const char *data,uint64_t len) override; - void onRecvContent(const char *data,uint64_t len) override; - const char *onSearchPacketTail(const char *data,uint64_t len) override; + size_t onRecvHeader(const char *data,size_t len) override; + void onRecvContent(const char *data,size_t len) override; + const char *onSearchPacketTail(const char *data,size_t len) override; + protected: - virtual void onRecvChunk(const char *data,uint64_t len){ + virtual void onRecvChunk(const char *data,size_t len){ if(_onChunkData){ _onChunkData(data,len); } }; + private: onChunkData _onChunkData; }; diff --git a/src/Http/HttpClient.cpp b/src/Http/HttpClient.cpp index 05baa5ab..af372a6f 100644 --- a/src/Http/HttpClient.cpp +++ b/src/Http/HttpClient.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -129,7 +129,7 @@ void HttpClient::onErr(const SockException &ex) { onDisconnect(ex); } -int64_t HttpClient::onRecvHeader(const char *data, uint64_t len) { +size_t HttpClient::onRecvHeader(const char *data, size_t len) { _parser.Parse(data); if(_parser.Url() == "302" || _parser.Url() == "301"){ auto newUrl = _parser["Location"]; @@ -156,7 +156,7 @@ int64_t HttpClient::onRecvHeader(const char *data, uint64_t len) { if(_parser["Transfer-Encoding"] == "chunked"){ //如果Transfer-Encoding字段等于chunked,则认为后续的content是不限制长度的 _totalBodySize = -1; - _chunkedSplitter = std::make_shared([this](const char *data,uint64_t len){ + _chunkedSplitter = std::make_shared([this](const char *data,size_t len){ if(len > 0){ auto recvedBodySize = _recvedBodySize + len; onResponseBody(data, len, recvedBodySize, INT64_MAX); @@ -181,7 +181,7 @@ int64_t HttpClient::onRecvHeader(const char *data, uint64_t len) { return -1; } -void HttpClient::onRecvContent(const char *data, uint64_t len) { +void HttpClient::onRecvContent(const char *data, size_t len) { if(_chunkedSplitter){ _chunkedSplitter->input(data,len); return; diff --git a/src/Http/HttpClient.h b/src/Http/HttpClient.h index e69e9694..1e380c1a 100644 --- a/src/Http/HttpClient.h +++ b/src/Http/HttpClient.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -110,7 +110,7 @@ protected: * @return 返回后续content的长度;-1:后续数据全是content;>=0:固定长度content * 需要指出的是,在http头中带有Content-Length字段时,该返回值无效 */ - virtual int64_t onResponseHeader(const string &status,const HttpHeader &headers){ + virtual size_t onResponseHeader(const string &status,const HttpHeader &headers){ DebugL << status; //无Content-Length字段时默认后面全是content return -1; @@ -123,7 +123,7 @@ protected: * @param recvedSize 已收数据大小(包含本次数据大小),当其等于totalSize时将触发onResponseCompleted回调 * @param totalSize 总数据大小 */ - virtual void onResponseBody(const char *buf,int64_t size,int64_t recvedSize,int64_t totalSize){ + virtual void onResponseBody(const char *buf,size_t size,size_t recvedSize,size_t totalSize){ DebugL << size << " " << recvedSize << " " << totalSize; }; @@ -149,19 +149,23 @@ protected: virtual bool onRedirectUrl(const string &url,bool temporary){ return true;}; //HttpRequestSplitter override - int64_t onRecvHeader(const char *data,uint64_t len) override ; - void onRecvContent(const char *data,uint64_t len) override; + size_t onRecvHeader(const char *data,size_t len) override; + void onRecvContent(const char *data,size_t len) override; + protected: virtual void onConnect(const SockException &ex) override; virtual void onRecv(const Buffer::Ptr &pBuf) override; virtual void onErr(const SockException &ex) override; virtual void onFlush() override; virtual void onManager() override; + private: void onResponseCompleted_l(); void checkCookie(HttpHeader &headers ); + protected: bool _isHttps; + private: string _url; HttpHeader _header; @@ -169,8 +173,8 @@ private: string _method; string _path; //recv - int64_t _recvedBodySize; - int64_t _totalBodySize; + size_t _recvedBodySize; + size_t _totalBodySize; Parser _parser; string _lastHost; Ticker _aliveTicker; diff --git a/src/Http/HttpClientImp.cpp b/src/Http/HttpClientImp.cpp index 4f87708b..f9228a10 100644 --- a/src/Http/HttpClientImp.cpp +++ b/src/Http/HttpClientImp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Http/HttpClientImp.h b/src/Http/HttpClientImp.h index 25093f1b..4d59ce8f 100644 --- a/src/Http/HttpClientImp.h +++ b/src/Http/HttpClientImp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Http/HttpConst.cpp b/src/Http/HttpConst.cpp index 7b12548c..f0572ea7 100644 --- a/src/Http/HttpConst.cpp +++ b/src/Http/HttpConst.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Http/HttpConst.h b/src/Http/HttpConst.h index f4be7596..4c098500 100644 --- a/src/Http/HttpConst.h +++ b/src/Http/HttpConst.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Http/HttpCookie.cpp b/src/Http/HttpCookie.cpp index 260708ae..cb95ca47 100644 --- a/src/Http/HttpCookie.cpp +++ b/src/Http/HttpCookie.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -25,7 +25,7 @@ void HttpCookie::setPath(const string &path){ void HttpCookie::setHost(const string &host){ _host = host; } -static uint32_t timeStrToInt(const string &date){ +static time_t timeStrToInt(const string &date){ struct tm tt; strptime(date.data(),"%a, %b %d %Y %H:%M:%S %Z",&tt); return mktime(&tt); @@ -34,7 +34,6 @@ void HttpCookie::setExpires(const string &expires,const string &server_date){ _expire = timeStrToInt(expires); if(!server_date.empty()){ _expire = time(NULL) + (_expire - timeStrToInt(server_date)); -// DebugL << (timeStrToInt(expires) - timeStrToInt(server_date)) / 60; } } void HttpCookie::setKeyVal(const string &key,const string &val){ diff --git a/src/Http/HttpCookie.h b/src/Http/HttpCookie.h index b9ab99b5..8179eaed 100644 --- a/src/Http/HttpCookie.h +++ b/src/Http/HttpCookie.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -42,9 +42,9 @@ public: private: string _host; string _path = "/"; - uint32_t _expire = 0; string _key; string _val; + time_t _expire = 0; }; diff --git a/src/Http/HttpCookieManager.cpp b/src/Http/HttpCookieManager.cpp index ef4bbc01..4351663f 100644 --- a/src/Http/HttpCookieManager.cpp +++ b/src/Http/HttpCookieManager.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -75,7 +75,7 @@ INSTANCE_IMP(HttpCookieManager); HttpCookieManager::HttpCookieManager() { //定时删除过期的cookie,防止内存膨胀 - _timer = std::make_shared(10,[this](){ + _timer = std::make_shared(10.0f,[this](){ onManager(); return true; }, nullptr); diff --git a/src/Http/HttpCookieManager.h b/src/Http/HttpCookieManager.h index 74792e55..260995fb 100644 --- a/src/Http/HttpCookieManager.h +++ b/src/Http/HttpCookieManager.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Http/HttpDownloader.cpp b/src/Http/HttpDownloader.cpp index a634c114..0bab074c 100644 --- a/src/Http/HttpDownloader.cpp +++ b/src/Http/HttpDownloader.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -47,7 +47,7 @@ void HttpDownloader::startDownload(const string& url, const string& filePath,boo sendRequest(url,timeOutSecond); } -int64_t HttpDownloader::onResponseHeader(const string& status,const HttpHeader& headers) { +size_t HttpDownloader::onResponseHeader(const string& status,const HttpHeader& headers) { if(status != "200" && status != "206"){ //失败 shutdown(SockException(Err_shutdown,StrPrinter << "Http Status:" << status)); @@ -56,7 +56,7 @@ int64_t HttpDownloader::onResponseHeader(const string& status,const HttpHeader& return -1; } -void HttpDownloader::onResponseBody(const char* buf, int64_t size, int64_t recvedSize, int64_t totalSize) { +void HttpDownloader::onResponseBody(const char* buf, size_t size, size_t recvedSize, size_t totalSize) { if(_saveFile){ fwrite(buf,size,1,_saveFile); } diff --git a/src/Http/HttpDownloader.h b/src/Http/HttpDownloader.h index 77ecb384..1cf7d501 100644 --- a/src/Http/HttpDownloader.h +++ b/src/Http/HttpDownloader.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -31,11 +31,12 @@ public: _onResult = cb; } private: - int64_t onResponseHeader(const string &status,const HttpHeader &headers) override; - void onResponseBody(const char *buf,int64_t size,int64_t recvedSize,int64_t totalSize) override; + size_t onResponseHeader(const string &status, const HttpHeader &headers) override; + void onResponseBody(const char *buf, size_t size, size_t recvedSize, size_t totalSize) override; void onResponseCompleted() override; void onDisconnect(const SockException &ex) override; void closeFile(); + private: FILE *_saveFile = nullptr; string _filePath; diff --git a/src/Http/HttpFileManager.cpp b/src/Http/HttpFileManager.cpp index 0e64cb2d..d99a1f5c 100644 --- a/src/Http/HttpFileManager.cpp +++ b/src/Http/HttpFileManager.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -564,9 +564,9 @@ void HttpResponseInvokerImp::responseFile(const StrCaseMap &requestHeader, } auto &strRange = const_cast(requestHeader)["Range"]; - int64_t iRangeStart = 0; - int64_t iRangeEnd = 0; - int64_t fileSize = HttpMultiFormBody::fileSize(fp.get()); + size_t iRangeStart = 0; + size_t iRangeEnd = 0; + size_t fileSize = HttpMultiFormBody::fileSize(fp.get()); int code; if (strRange.size() == 0) { diff --git a/src/Http/HttpFileManager.h b/src/Http/HttpFileManager.h index e8a2181d..f88d29ae 100644 --- a/src/Http/HttpFileManager.h +++ b/src/Http/HttpFileManager.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Http/HttpRequestSplitter.cpp b/src/Http/HttpRequestSplitter.cpp index 160d7243..e609b4d9 100644 --- a/src/Http/HttpRequestSplitter.cpp +++ b/src/Http/HttpRequestSplitter.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -15,7 +15,7 @@ using namespace toolkit; namespace mediakit { -void HttpRequestSplitter::input(const char *data,uint64_t len) { +void HttpRequestSplitter::input(const char *data,size_t len) { const char *ptr = data; if(!_remain_data.empty()){ _remain_data.append(data,len); @@ -44,7 +44,7 @@ void HttpRequestSplitter::input(const char *data,uint64_t len) { } //_content_len == 0,这是请求头 const char *header_ptr = ptr; - int64_t header_size = index - ptr; + auto header_size = index - ptr; ptr = index; _remain_data_size = len - (ptr - data); _content_len = onRecvHeader(header_ptr, header_size); @@ -101,7 +101,7 @@ void HttpRequestSplitter::input(const char *data,uint64_t len) { _remain_data.clear(); } -void HttpRequestSplitter::setContentLen(int64_t content_len) { +void HttpRequestSplitter::setContentLen(size_t content_len) { _content_len = content_len; } @@ -111,7 +111,7 @@ void HttpRequestSplitter::reset() { _remain_data.clear(); } -const char *HttpRequestSplitter::onSearchPacketTail(const char *data,uint64_t len) { +const char *HttpRequestSplitter::onSearchPacketTail(const char *data,size_t len) { auto pos = strstr(data,"\r\n\r\n"); if(pos == nullptr){ return nullptr; @@ -119,7 +119,7 @@ const char *HttpRequestSplitter::onSearchPacketTail(const char *data,uint64_t le return pos + 4; } -int64_t HttpRequestSplitter::remainDataSize() { +size_t HttpRequestSplitter::remainDataSize() { return _remain_data_size; } diff --git a/src/Http/HttpRequestSplitter.h b/src/Http/HttpRequestSplitter.h index d832a230..254f8260 100644 --- a/src/Http/HttpRequestSplitter.h +++ b/src/Http/HttpRequestSplitter.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -28,7 +28,8 @@ public: * @param data 需要添加的数据 * @param len 数据长度 */ - virtual void input(const char *data,uint64_t len); + virtual void input(const char *data,size_t len); + protected: /** * 收到请求头 @@ -40,7 +41,7 @@ protected: * 0 : 代表为后面数据还是请求头, * >0 : 代表后面数据为固定长度content,此时将缓存content并等到所有content接收完毕一次性通过onRecvContent函数回调出去 */ - virtual int64_t onRecvHeader(const char *data,uint64_t len) = 0; + virtual size_t onRecvHeader(const char *data,size_t len) = 0; /** * 收到content分片或全部数据 @@ -48,7 +49,7 @@ protected: * @param data content分片或全部数据 * @param len 数据长度 */ - virtual void onRecvContent(const char *data,uint64_t len) {}; + virtual void onRecvContent(const char *data,size_t len) {}; /** * 判断数据中是否有包尾 @@ -56,12 +57,12 @@ protected: * @param len 数据长度 * @return nullptr代表未找到包位,否则返回包尾指针 */ - virtual const char *onSearchPacketTail(const char *data, uint64_t len); + virtual const char *onSearchPacketTail(const char *data, size_t len); /** * 设置content len */ - void setContentLen(int64_t content_len); + void setContentLen(size_t content_len); /** * 恢复初始设置 @@ -71,11 +72,12 @@ protected: /** * 剩余数据大小 */ - int64_t remainDataSize(); + size_t remainDataSize(); + private: + size_t _content_len = 0; + size_t _remain_data_size = 0; BufferLikeString _remain_data; - int64_t _content_len = 0; - int64_t _remain_data_size = 0; }; } /* namespace mediakit */ diff --git a/src/Http/HttpRequester.cpp b/src/Http/HttpRequester.cpp index 64233622..fb3a72df 100644 --- a/src/Http/HttpRequester.cpp +++ b/src/Http/HttpRequester.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -19,13 +19,13 @@ HttpRequester::~HttpRequester(){ } -int64_t HttpRequester::onResponseHeader(const string &status,const HttpHeader &headers) { +size_t HttpRequester::onResponseHeader(const string &status,const HttpHeader &headers) { _strRecvBody.clear(); //无Content-Length字段时默认后面没有content return 0; } -void HttpRequester::onResponseBody(const char *buf,int64_t size,int64_t recvedSize,int64_t totalSize) { +void HttpRequester::onResponseBody(const char *buf,size_t size,size_t recvedSize,size_t totalSize) { _strRecvBody.append(buf,size); } diff --git a/src/Http/HttpRequester.h b/src/Http/HttpRequester.h index 693fdf4d..3853fb5c 100644 --- a/src/Http/HttpRequester.h +++ b/src/Http/HttpRequester.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -26,8 +26,8 @@ public: void startRequester(const string &url,const HttpRequesterResult &onResult,float timeOutSecond = 10); void clear() override ; private: - int64_t onResponseHeader(const string &status,const HttpHeader &headers) override; - void onResponseBody(const char *buf,int64_t size,int64_t recvedSize,int64_t totalSize) override; + size_t onResponseHeader(const string &status,const HttpHeader &headers) override; + void onResponseBody(const char *buf,size_t size,size_t recvedSize,size_t totalSize) override; void onResponseCompleted() override; void onDisconnect(const SockException &ex) override; private: diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index a543d494..15ed9e9b 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -31,15 +31,15 @@ HttpSession::~HttpSession() { TraceP(this); } -void HttpSession::Handle_Req_HEAD(int64_t &content_len){ +void HttpSession::Handle_Req_HEAD(size_t &content_len){ //暂时全部返回200 OK,因为HTTP GET存在按需生成流的操作,所以不能按照HTTP GET的流程返回 //如果直接返回404,那么又会导致按需生成流的逻辑失效,所以HTTP HEAD在静态文件或者已存在资源时才有效 //对于按需生成流的直播场景并不适用 sendResponse(200, true); } -int64_t HttpSession::onRecvHeader(const char *header,uint64_t len) { - typedef void (HttpSession::*HttpCMDHandle)(int64_t &); +size_t HttpSession::onRecvHeader(const char *header,size_t len) { + typedef void (HttpSession::*HttpCMDHandle)(size_t &); static unordered_map s_func_map; static onceToken token([]() { s_func_map.emplace("GET",&HttpSession::Handle_Req_GET); @@ -61,7 +61,7 @@ int64_t HttpSession::onRecvHeader(const char *header,uint64_t len) { _origin = _parser["Origin"]; //默认后面数据不是content而是header - int64_t content_len = 0; + size_t content_len = 0; auto &fun = it->second; try { (this->*fun)(content_len); @@ -75,7 +75,7 @@ int64_t HttpSession::onRecvHeader(const char *header,uint64_t len) { return content_len; } -void HttpSession::onRecvContent(const char *data,uint64_t len) { +void HttpSession::onRecvContent(const char *data,size_t len) { if(_contentCallBack){ if(!_contentCallBack(data,len)){ _contentCallBack = nullptr; @@ -271,8 +271,8 @@ bool HttpSession::checkLiveStreamFMP4(const function &cb){ //本对象已经销毁 return; } - int i = 0; - int size = fmp4_list->size(); + size_t i = 0; + auto size = fmp4_list->size(); fmp4_list->for_each([&](const FMP4Packet::Ptr &ts) { strong_self->onWrite(ts, ++i == size); }); @@ -311,8 +311,8 @@ bool HttpSession::checkLiveStreamTS(const function &cb){ //本对象已经销毁 return; } - int i = 0; - int size = ts_list->size(); + size_t i = 0; + auto size = ts_list->size(); ts_list->for_each([&](const TSPacket::Ptr &ts) { strong_self->onWrite(ts, ++i == size); }); @@ -353,15 +353,15 @@ bool HttpSession::checkLiveStreamFlv(const function &cb){ }); } -void HttpSession::Handle_Req_GET(int64_t &content_len) { +void HttpSession::Handle_Req_GET(size_t &content_len) { Handle_Req_GET_l(content_len, true); } -void HttpSession::Handle_Req_GET_l(int64_t &content_len, bool sendBody) { +void HttpSession::Handle_Req_GET_l(size_t &content_len, bool sendBody) { //先看看是否为WebSocket请求 if (checkWebSocket()) { content_len = -1; - _contentCallBack = [this](const char *data, uint64_t len) { + _contentCallBack = [this](const char *data, size_t len) { WebSocketSplitter::decode((uint8_t *) data, len); //_contentCallBack是可持续的,后面还要处理后续数据 return true; @@ -506,7 +506,7 @@ void HttpSession::sendResponse(int code, GET_CONFIG(uint32_t,keepAliveSec,Http::kKeepAliveSecond); //body默认为空 - int64_t size = 0; + size_t size = 0; if (body && body->remainSize()) { //有body,获取body大小 size = body->remainSize(); @@ -515,7 +515,7 @@ void HttpSession::sendResponse(int code, if(no_content_length){ //http-flv直播是Keep-Alive类型 bClose = false; - }else if(size >= INT64_MAX){ + }else if(size >= INT64_MAX || size < 0 ){ //不固定长度的body,那么发送完body后应该关闭socket,以便浏览器做下载完毕的判断 bClose = true; } @@ -642,10 +642,10 @@ bool HttpSession::emitHttpEvent(bool doInvoke){ return consumed; } -void HttpSession::Handle_Req_POST(int64_t &content_len) { - GET_CONFIG(uint64_t,maxReqSize,Http::kMaxReqSize); +void HttpSession::Handle_Req_POST(size_t &content_len) { + GET_CONFIG(size_t,maxReqSize,Http::kMaxReqSize); - int64_t totalContentLen = _parser["Content-Length"].empty() ? -1 : atoll(_parser["Content-Length"].data()); + size_t totalContentLen = _parser["Content-Length"].empty() ? -1 : atoll(_parser["Content-Length"].data()); if(totalContentLen == 0){ //content为空 @@ -658,7 +658,7 @@ void HttpSession::Handle_Req_POST(int64_t &content_len) { //返回固定长度的content content_len = totalContentLen; auto parserCopy = _parser; - _contentCallBack = [this,parserCopy](const char *data,uint64_t len){ + _contentCallBack = [this,parserCopy](const char *data,size_t len){ //恢复http头 _parser = parserCopy; //设置content @@ -674,10 +674,10 @@ void HttpSession::Handle_Req_POST(int64_t &content_len) { //返回不固定长度的content content_len = -1; auto parserCopy = _parser; - std::shared_ptr recvedContentLen = std::make_shared(0); + std::shared_ptr recvedContentLen = std::make_shared(0); bool bClose = !strcasecmp(_parser["Connection"].data(),"close"); - _contentCallBack = [this,parserCopy,totalContentLen,recvedContentLen,bClose](const char *data,uint64_t len){ + _contentCallBack = [this,parserCopy,totalContentLen,recvedContentLen,bClose](const char *data,size_t len){ *(recvedContentLen) += len; onRecvUnlimitedContent(parserCopy,data,len,totalContentLen,*(recvedContentLen)); diff --git a/src/Http/HttpSession.h b/src/Http/HttpSession.h index e3bc7e4a..16652b82 100644 --- a/src/Http/HttpSession.h +++ b/src/Http/HttpSession.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -57,8 +57,8 @@ protected: std::shared_ptr getSharedPtr() override; //HttpRequestSplitter override - int64_t onRecvHeader(const char *data,uint64_t len) override; - void onRecvContent(const char *data,uint64_t len) override; + size_t onRecvHeader(const char *data,size_t len) override; + void onRecvContent(const char *data,size_t len) override; /** * 重载之用于处理不定长度的content @@ -71,9 +71,9 @@ protected: */ virtual void onRecvUnlimitedContent(const Parser &header, const char *data, - uint64_t len, - uint64_t totalSize, - uint64_t recvedSize){ + size_t len, + size_t totalSize, + size_t recvedSize){ shutdown(SockException(Err_shutdown,"http post content is too huge,default closed")); } @@ -101,10 +101,10 @@ protected: void onWebSocketDecodeComplete(const WebSocketHeader &header_in) override; private: - void Handle_Req_GET(int64_t &content_len); - void Handle_Req_GET_l(int64_t &content_len, bool sendBody); - void Handle_Req_POST(int64_t &content_len); - void Handle_Req_HEAD(int64_t &content_len); + void Handle_Req_GET(size_t &content_len); + void Handle_Req_GET_l(size_t &content_len, bool sendBody); + void Handle_Req_POST(size_t &content_len); + void Handle_Req_HEAD(size_t &content_len); bool checkLiveStream(const string &schema, const string &url_suffix, const function &cb); @@ -135,7 +135,7 @@ private: TSMediaSource::RingType::RingReader::Ptr _ts_reader; FMP4MediaSource::RingType::RingReader::Ptr _fmp4_reader; //处理content数据的callback - function _contentCallBack; + function _contentCallBack; }; diff --git a/src/Http/HttpTSPlayer.cpp b/src/Http/HttpTSPlayer.cpp index cd6d6fb0..eb43e478 100644 --- a/src/Http/HttpTSPlayer.cpp +++ b/src/Http/HttpTSPlayer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -13,13 +13,13 @@ namespace mediakit { HttpTSPlayer::HttpTSPlayer(const EventPoller::Ptr &poller, bool split_ts){ _split_ts = split_ts; - _segment.setOnSegment([this](const char *data, uint64_t len) { onPacket(data, len); }); + _segment.setOnSegment([this](const char *data, size_t len) { onPacket(data, len); }); setPoller(poller ? poller : EventPollerPool::Instance().getPoller()); } HttpTSPlayer::~HttpTSPlayer() {} -int64_t HttpTSPlayer::onResponseHeader(const string &status, const HttpClient::HttpHeader &headers) { +size_t HttpTSPlayer::onResponseHeader(const string &status, const HttpClient::HttpHeader &headers) { _status = status; if (status != "200" && status != "206") { //http状态码不符合预期 @@ -35,7 +35,7 @@ int64_t HttpTSPlayer::onResponseHeader(const string &status, const HttpClient::H return -1; } -void HttpTSPlayer::onResponseBody(const char *buf, int64_t size, int64_t recvedSize, int64_t totalSize) { +void HttpTSPlayer::onResponseBody(const char *buf, size_t size, size_t recvedSize, size_t totalSize) { if (_status != "200" && _status != "206") { return; } @@ -68,7 +68,7 @@ void HttpTSPlayer::onDisconnect(const SockException &ex) { } } -void HttpTSPlayer::onPacket(const char *data, uint64_t len) { +void HttpTSPlayer::onPacket(const char *data, size_t len) { if (_on_segment) { _on_segment(data, len); } diff --git a/src/Http/HttpTSPlayer.h b/src/Http/HttpTSPlayer.h index 7dc985f0..0fee37f9 100644 --- a/src/Http/HttpTSPlayer.h +++ b/src/Http/HttpTSPlayer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2020 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -33,13 +33,13 @@ public: protected: ///HttpClient override/// - int64_t onResponseHeader(const string &status,const HttpHeader &headers) override; - void onResponseBody(const char *buf,int64_t size,int64_t recvedSize,int64_t totalSize) override; + size_t onResponseHeader(const string &status,const HttpHeader &headers) override; + void onResponseBody(const char *buf,size_t size,size_t recvedSize,size_t totalSize) override; void onResponseCompleted() override; void onDisconnect(const SockException &ex) override ; //收到ts包 - virtual void onPacket(const char *data, uint64_t len); + virtual void onPacket(const char *data, size_t len); private: //是否为mpegts负载 diff --git a/src/Http/WebSocketClient.h b/src/Http/WebSocketClient.h index 17a0febc..dd6e131e 100644 --- a/src/Http/WebSocketClient.h +++ b/src/Http/WebSocketClient.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -32,7 +32,7 @@ class HttpWsClient; template class ClientTypeImp : public ClientType { public: - typedef function onBeforeSendCB; + typedef function onBeforeSendCB; friend class HttpWsClient; template @@ -43,7 +43,7 @@ protected: /** * 发送前拦截并打包为websocket协议 */ - int send(Buffer::Ptr buf) override{ + size_t send(Buffer::Ptr buf) override{ if(_beforeSendCB){ return _beforeSendCB(buf); } @@ -120,7 +120,7 @@ protected: * @return 返回后续content的长度;-1:后续数据全是content;>=0:固定长度content * 需要指出的是,在http头中带有Content-Length字段时,该返回值无效 */ - int64_t onResponseHeader(const string &status,const HttpHeader &headers) override { + size_t onResponseHeader(const string &status,const HttpHeader &headers) override { if(status == "101"){ auto Sec_WebSocket_Accept = encodeBase64(SHA1::encode_bin(_Sec_WebSocket_Key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11")); if(Sec_WebSocket_Accept == const_cast(headers)["Sec-WebSocket-Accept"]){ @@ -147,7 +147,7 @@ protected: /** * 接收websocket负载数据 */ - void onResponseBody(const char *buf,int64_t size,int64_t recvedSize,int64_t totalSize) override{ + void onResponseBody(const char *buf,size_t size,size_t recvedSize,size_t totalSize) override{ if(_onRecv){ //完成websocket握手后,拦截websocket数据并解析 _onRecv(buf, size); @@ -220,7 +220,7 @@ protected: * @param len 负载数据长度 * @param recved 已接收数据长度(包含本次数据长度),等于header._payload_len时则接受完毕 */ - void onWebSocketDecodePayload(const WebSocketHeader &header, const uint8_t *ptr, uint64_t len, uint64_t recved) override{ + void onWebSocketDecodePayload(const WebSocketHeader &header, const uint8_t *ptr, size_t len, size_t recved) override{ _payload_section.append((char *)ptr,len); } @@ -316,7 +316,7 @@ private: //触发连接成功事件 _delegate.onConnect(ex); //拦截websocket数据接收 - _onRecv = [this](const char *data, int len){ + _onRecv = [this](const char *data, size_t len){ //解析websocket数据包 this->WebSocketSplitter::decode((uint8_t *)data, len); }; @@ -337,7 +337,7 @@ private: private: string _Sec_WebSocket_Key; - function _onRecv; + function _onRecv; ClientTypeImp &_delegate; string _payload_section; string _payload_cache; diff --git a/src/Http/WebSocketSession.h b/src/Http/WebSocketSession.h index 0a8d7163..80c8179d 100644 --- a/src/Http/WebSocketSession.h +++ b/src/Http/WebSocketSession.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -19,7 +19,7 @@ */ class SendInterceptor{ public: - typedef function onBeforeSendCB; + typedef function onBeforeSendCB; SendInterceptor() = default; virtual ~SendInterceptor() = default; virtual void setOnBeforeSendCB(const onBeforeSendCB &cb) = 0; @@ -35,7 +35,7 @@ public: typedef std::shared_ptr Ptr; TcpSessionTypeImp(const Parser &header, const HttpSession &parent, const Socket::Ptr &pSock) : - _identifier(parent.getIdentifier()), TcpSessionType(pSock) {} + TcpSessionType(pSock), _identifier(parent.getIdentifier()) {} ~TcpSessionTypeImp() {} @@ -53,7 +53,7 @@ protected: * @param buf 需要截取的数据 * @return 数据字节数 */ - int send(Buffer::Ptr buf) override { + size_t send(Buffer::Ptr buf) override { if (_beforeSendCB) { return _beforeSendCB(buf); } @@ -65,8 +65,8 @@ protected: } private: - onBeforeSendCB _beforeSendCB; string _identifier; + onBeforeSendCB _beforeSendCB; }; template @@ -157,7 +157,7 @@ protected: /** * 收到websocket数据包负载 */ - void onWebSocketDecodePayload(const WebSocketHeader &packet,const uint8_t *ptr,uint64_t len,uint64_t recved) override { + void onWebSocketDecodePayload(const WebSocketHeader &packet,const uint8_t *ptr,size_t len,size_t recved) override { _payload_section.append((char *)ptr,len); } diff --git a/src/Http/WebSocketSplitter.cpp b/src/Http/WebSocketSplitter.cpp index 701b373b..569a71ad 100644 --- a/src/Http/WebSocketSplitter.cpp +++ b/src/Http/WebSocketSplitter.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -53,7 +53,7 @@ do{ \ } \ }while(0) \ -void WebSocketSplitter::decode(uint8_t *data,uint64_t len) { +void WebSocketSplitter::decode(uint8_t *data,size_t len) { uint8_t *ptr = data; if(!_got_header) { //还没有获取数据头 @@ -107,9 +107,9 @@ begin_decode: //进入后面逻辑代表已经获取到了webSocket协议头, - uint64_t remain = len - (ptr - data); + auto remain = len - (ptr - data); if(remain > 0){ - uint64_t payload_slice_len = remain; + auto payload_slice_len = remain; if(payload_slice_len + _payload_offset > _payload_len){ payload_slice_len = _payload_len - _payload_offset; } @@ -138,7 +138,7 @@ begin_decode: _remain_data.clear(); } -void WebSocketSplitter::onPayloadData(uint8_t *data, uint64_t len) { +void WebSocketSplitter::onPayloadData(uint8_t *data, size_t len) { if(_mask_flag){ for(int i = 0; i < len ; ++i,++data){ *(data) ^= _mask[(i + _mask_offset) % 4]; @@ -150,7 +150,7 @@ void WebSocketSplitter::onPayloadData(uint8_t *data, uint64_t len) { void WebSocketSplitter::encode(const WebSocketHeader &header,const Buffer::Ptr &buffer) { string ret; - uint64_t len = buffer ? buffer->size() : 0; + auto len = buffer ? buffer->size() : 0; uint8_t byte = header._fin << 7 | ((header._reserved & 0x07) << 4) | (header._opcode & 0x0F) ; ret.push_back(byte); @@ -164,7 +164,7 @@ void WebSocketSplitter::encode(const WebSocketHeader &header,const Buffer::Ptr & byte |= 126; ret.push_back(byte); - auto len_low = htons(len); + uint16_t len_low = htons((uint16_t)len); ret.append((char *)&len_low,2); }else{ byte |= 127; diff --git a/src/Http/WebSocketSplitter.h b/src/Http/WebSocketSplitter.h index 02d5d2eb..4b43722d 100644 --- a/src/Http/WebSocketSplitter.h +++ b/src/Http/WebSocketSplitter.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -60,7 +60,7 @@ public: uint8_t _reserved; Type _opcode; bool _mask_flag; - uint64_t _payload_len; + size_t _payload_len; vector _mask; }; @@ -71,7 +71,7 @@ public: template WebSocketBuffer(WebSocketHeader::Type headType, bool fin, ARGS &&...args) - : _head_type(headType), _fin(fin), BufferString(std::forward(args)...) {} + : BufferString(std::forward(args)...), _fin(fin), _head_type(headType){} ~WebSocketBuffer() override {} @@ -80,8 +80,8 @@ public: bool isFinished() const { return _fin; }; private: - WebSocketHeader::Type _head_type; bool _fin; + WebSocketHeader::Type _head_type; }; class WebSocketSplitter : public WebSocketHeader{ diff --git a/src/Http/strCoding.cpp b/src/Http/strCoding.cpp index 59bb29fe..7c2d27e4 100644 --- a/src/Http/strCoding.cpp +++ b/src/Http/strCoding.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -70,7 +70,7 @@ string strCoding::UrlEncode(const string &str) { string strCoding::UrlDecode(const string &str) { string output = ""; char tmp[2]; - int i = 0, len = str.length(); + size_t i = 0, len = str.length(); while (i < len) { if (str[i] == '%') { if(i > len - 3){ @@ -138,10 +138,10 @@ string strCoding::GB2312ToUTF8(const string &str) { auto len = str.size(); auto pText = str.data(); char buf[4] = { 0 }; - int nLength = len * 3; + auto nLength = len * 3; char* pOut = new char[nLength]; memset(pOut, 0, nLength); - int i = 0, j = 0; + size_t i = 0, j = 0; while (i < len) { //如果是英文直接复制就可以 diff --git a/src/Http/strCoding.h b/src/Http/strCoding.h index da634067..6a59b154 100644 --- a/src/Http/strCoding.h +++ b/src/Http/strCoding.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Player/MediaPlayer.cpp b/src/Player/MediaPlayer.cpp index 694b656e..7660c660 100644 --- a/src/Player/MediaPlayer.cpp +++ b/src/Player/MediaPlayer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Player/MediaPlayer.h b/src/Player/MediaPlayer.h index 0e41deb1..b25029b2 100644 --- a/src/Player/MediaPlayer.h +++ b/src/Player/MediaPlayer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Player/PlayerBase.cpp b/src/Player/PlayerBase.cpp index c29c4c27..df1a3de1 100644 --- a/src/Player/PlayerBase.cpp +++ b/src/Player/PlayerBase.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Player/PlayerBase.h b/src/Player/PlayerBase.h index 72a79b80..adf12ccf 100644 --- a/src/Player/PlayerBase.h +++ b/src/Player/PlayerBase.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Player/PlayerProxy.cpp b/src/Player/PlayerProxy.cpp index c6e73a40..299c4774 100644 --- a/src/Player/PlayerProxy.cpp +++ b/src/Player/PlayerProxy.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Player/PlayerProxy.h b/src/Player/PlayerProxy.h index bdd57f23..3d41d55a 100644 --- a/src/Player/PlayerProxy.h +++ b/src/Player/PlayerProxy.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Pusher/MediaPusher.cpp b/src/Pusher/MediaPusher.cpp index 822f5103..d7055bc7 100644 --- a/src/Pusher/MediaPusher.cpp +++ b/src/Pusher/MediaPusher.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Pusher/MediaPusher.h b/src/Pusher/MediaPusher.h index 2e2f985e..d2994cc5 100644 --- a/src/Pusher/MediaPusher.h +++ b/src/Pusher/MediaPusher.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Pusher/PusherBase.cpp b/src/Pusher/PusherBase.cpp index a9e0ea39..b7e91d89 100644 --- a/src/Pusher/PusherBase.cpp +++ b/src/Pusher/PusherBase.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Pusher/PusherBase.h b/src/Pusher/PusherBase.h index 6a19fa48..f1ae0d9f 100644 --- a/src/Pusher/PusherBase.h +++ b/src/Pusher/PusherBase.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Record/HlsMaker.cpp b/src/Record/HlsMaker.cpp index a91b3e05..0fe92d05 100644 --- a/src/Record/HlsMaker.cpp +++ b/src/Record/HlsMaker.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -59,7 +59,7 @@ void HlsMaker::makeIndexFile(bool eof) { } -void HlsMaker::inputData(void *data, uint32_t len, uint32_t timestamp, bool is_idr_fast_packet) { +void HlsMaker::inputData(void *data, size_t len, uint32_t timestamp, bool is_idr_fast_packet) { if (data && len) { if (is_idr_fast_packet) { //尝试切片ts diff --git a/src/Record/HlsMaker.h b/src/Record/HlsMaker.h index 7eff8e10..dcd96c4a 100644 --- a/src/Record/HlsMaker.h +++ b/src/Record/HlsMaker.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -38,7 +38,7 @@ public: * @param timestamp 毫秒时间戳 * @param is_idr_fast_packet 是否为关键帧第一个包 */ - void inputData(void *data, uint32_t len, uint32_t timestamp, bool is_idr_fast_packet); + void inputData(void *data, size_t len, uint32_t timestamp, bool is_idr_fast_packet); /** * 是否为直播 @@ -56,27 +56,27 @@ protected: * @param index * @return */ - virtual string onOpenSegment(int index) = 0; + virtual string onOpenSegment(uint64_t index) = 0; /** * 删除ts切片文件回调 * @param index */ - virtual void onDelSegment(int index) = 0; + virtual void onDelSegment(uint64_t index) = 0; /** * 写ts切片文件回调 * @param data * @param len */ - virtual void onWriteSegment(const char *data, int len) = 0; + virtual void onWriteSegment(const char *data, size_t len) = 0; /** * 写m3u8文件回调 * @param data * @param len */ - virtual void onWriteHls(const char *data, int len) = 0; + virtual void onWriteHls(const char *data, size_t len) = 0; /** * 上一个 ts 切片写入完成, 可在这里进行通知处理 diff --git a/src/Record/HlsMakerImp.cpp b/src/Record/HlsMakerImp.cpp index 4cd9cf76..ebf34094 100644 --- a/src/Record/HlsMakerImp.cpp +++ b/src/Record/HlsMakerImp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -50,7 +50,7 @@ void HlsMakerImp::clearCache() { } } -string HlsMakerImp::onOpenSegment(int index) { +string HlsMakerImp::onOpenSegment(uint64_t index) { string segment_name, segment_path; { auto strDate = getTimeStr("%Y-%m-%d"); @@ -79,7 +79,7 @@ string HlsMakerImp::onOpenSegment(int index) { return segment_name + "?" + _params; } -void HlsMakerImp::onDelSegment(int index) { +void HlsMakerImp::onDelSegment(uint64_t index) { auto it = _segment_file_paths.find(index); if (it == _segment_file_paths.end()) { return; @@ -88,7 +88,7 @@ void HlsMakerImp::onDelSegment(int index) { _segment_file_paths.erase(it); } -void HlsMakerImp::onWriteSegment(const char *data, int len) { +void HlsMakerImp::onWriteSegment(const char *data, size_t len) { if (_file) { fwrite(data, len, 1, _file.get()); } @@ -97,7 +97,7 @@ void HlsMakerImp::onWriteSegment(const char *data, int len) { } } -void HlsMakerImp::onWriteHls(const char *data, int len) { +void HlsMakerImp::onWriteHls(const char *data, size_t len) { auto hls = makeFile(_path_hls); if (hls) { fwrite(data, len, 1, hls.get()); @@ -116,7 +116,7 @@ void HlsMakerImp::onFlushLastSegment(uint32_t duration_ms) { if (broadcastRecordTs) { //关闭ts文件以便获取正确的文件大小 _file = nullptr; - _info.time_len = duration_ms / 1000.0; + _info.time_len = duration_ms / 1000.0f; struct stat fileData; stat(_info.file_path.data(), &fileData); _info.file_size = fileData.st_size; diff --git a/src/Record/HlsMakerImp.h b/src/Record/HlsMakerImp.h index 155909b7..9b9b9484 100644 --- a/src/Record/HlsMakerImp.h +++ b/src/Record/HlsMakerImp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -51,10 +51,10 @@ public: void clearCache(); protected: - string onOpenSegment(int index) override ; - void onDelSegment(int index) override; - void onWriteSegment(const char *data, int len) override; - void onWriteHls(const char *data, int len) override; + string onOpenSegment(uint64_t index) override ; + void onDelSegment(uint64_t index) override; + void onWriteSegment(const char *data, size_t len) override; + void onWriteHls(const char *data, size_t len) override; void onFlushLastSegment(uint32_t duration_ms) override; private: @@ -69,7 +69,7 @@ private: std::shared_ptr _file; std::shared_ptr _file_buf; HlsMediaSource::Ptr _media_src; - map _segment_file_paths; + map _segment_file_paths; }; }//namespace mediakit diff --git a/src/Record/HlsMediaSource.cpp b/src/Record/HlsMediaSource.cpp index 99f2022e..d2dadd9d 100644 --- a/src/Record/HlsMediaSource.cpp +++ b/src/Record/HlsMediaSource.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -49,7 +49,7 @@ HlsCookieData::~HlsCookieData() { } } -void HlsCookieData::addByteUsage(uint64_t bytes) { +void HlsCookieData::addByteUsage(size_t bytes) { addReaderCount(); _bytes += bytes; _ticker.resetTime(); diff --git a/src/Record/HlsMediaSource.h b/src/Record/HlsMediaSource.h index aa624b83..c31d84c0 100644 --- a/src/Record/HlsMediaSource.h +++ b/src/Record/HlsMediaSource.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -79,7 +79,7 @@ public: _list_cb.emplace_back(std::move(cb)); } - void onSegmentSize(uint64_t bytes) { + void onSegmentSize(size_t bytes) { _speed[TrackVideo] += bytes; } @@ -95,7 +95,7 @@ public: typedef std::shared_ptr Ptr; HlsCookieData(const MediaInfo &info, const std::shared_ptr &sock_info); ~HlsCookieData(); - void addByteUsage(uint64_t bytes); + void addByteUsage(size_t bytes); private: void addReaderCount(); diff --git a/src/Record/HlsRecorder.h b/src/Record/HlsRecorder.h index 5b076d36..d4c31d61 100644 --- a/src/Record/HlsRecorder.h +++ b/src/Record/HlsRecorder.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -21,7 +21,7 @@ public: HlsRecorder(const string &m3u8_file, const string ¶ms){ GET_CONFIG(uint32_t, hlsNum, Hls::kSegmentNum); GET_CONFIG(uint32_t, hlsBufSize, Hls::kFileBufSize); - GET_CONFIG(uint32_t, hlsDuration, Hls::kSegmentDuration); + GET_CONFIG(float, hlsDuration, Hls::kSegmentDuration); _hls = std::make_shared(m3u8_file, params, hlsBufSize, hlsDuration, hlsNum); //清空上次的残余文件 _hls->clearCache(); @@ -73,7 +73,7 @@ public: } private: - void onTs(const void *packet, int bytes, uint32_t timestamp, bool is_idr_fast_packet) override { + void onTs(const void *packet, size_t bytes, uint32_t timestamp, bool is_idr_fast_packet) override { _hls->inputData((char *) packet, bytes, timestamp, is_idr_fast_packet); } diff --git a/src/Record/MP4.cpp b/src/Record/MP4.cpp index 684e4be3..679e750a 100644 --- a/src/Record/MP4.cpp +++ b/src/Record/MP4.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -197,22 +197,22 @@ void MP4FileDisk::closeFile() { _file = nullptr; } -int MP4FileDisk::onRead(void *data, uint64_t bytes) { +int MP4FileDisk::onRead(void *data, size_t bytes) { if (bytes == fread(data, 1, bytes, _file.get())){ return 0; } return 0 != ferror(_file.get()) ? ferror(_file.get()) : -1 /*EOF*/; } -int MP4FileDisk::onWrite(const void *data, uint64_t bytes) { +int MP4FileDisk::onWrite(const void *data, size_t bytes) { return bytes == fwrite(data, 1, bytes, _file.get()) ? 0 : ferror(_file.get()); } -int MP4FileDisk::onSeek(uint64_t offset) { +int MP4FileDisk::onSeek(size_t offset) { return fseek64(_file.get(), offset, SEEK_SET); } -uint64_t MP4FileDisk::onTell() { +size_t MP4FileDisk::onTell() { return ftell64(_file.get()); } @@ -225,15 +225,15 @@ string MP4FileMemory::getAndClearMemory(){ return ret; } -uint64_t MP4FileMemory::fileSize() const{ +size_t MP4FileMemory::fileSize() const{ return _memory.size(); } -uint64_t MP4FileMemory::onTell(){ +size_t MP4FileMemory::onTell(){ return _offset; } -int MP4FileMemory::onSeek(uint64_t offset){ +int MP4FileMemory::onSeek(size_t offset){ if (offset > _memory.size()) { return -1; } @@ -241,7 +241,7 @@ int MP4FileMemory::onSeek(uint64_t offset){ return 0; } -int MP4FileMemory::onRead(void *data, uint64_t bytes){ +int MP4FileMemory::onRead(void *data, size_t bytes){ if (_offset >= _memory.size()) { //EOF return -1; @@ -252,7 +252,7 @@ int MP4FileMemory::onRead(void *data, uint64_t bytes){ return 0; } -int MP4FileMemory::onWrite(const void *data, uint64_t bytes){ +int MP4FileMemory::onWrite(const void *data, size_t bytes){ if (_offset + bytes > _memory.size()) { //需要扩容 _memory.resize(_offset + bytes); diff --git a/src/Record/MP4.h b/src/Record/MP4.h index 3b7ae1c3..3d01ce88 100644 --- a/src/Record/MP4.h +++ b/src/Record/MP4.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -62,14 +62,14 @@ public: /** * 获取文件读写位置 */ - virtual uint64_t onTell() = 0; + virtual size_t onTell() = 0; /** * seek至文件某处 * @param offset 文件偏移量 * @return 是否成功(0成功) */ - virtual int onSeek(uint64_t offset) = 0; + virtual int onSeek(size_t offset) = 0; /** * 从文件读取一定数据 @@ -77,7 +77,7 @@ public: * @param bytes 指针长度 * @return 是否成功(0成功) */ - virtual int onRead(void *data, uint64_t bytes) = 0; + virtual int onRead(void *data, size_t bytes) = 0; /** * 写入文件一定数据 @@ -85,7 +85,7 @@ public: * @param bytes 数据长度 * @return 是否成功(0成功) */ - virtual int onWrite(const void *data, uint64_t bytes) = 0; + virtual int onWrite(const void *data, size_t bytes) = 0; }; //磁盘MP4文件类 @@ -108,10 +108,10 @@ public: void closeFile(); protected: - uint64_t onTell() override; - int onSeek(uint64_t offset) override; - int onRead(void *data, uint64_t bytes) override; - int onWrite(const void *data, uint64_t bytes) override; + size_t onTell() override; + int onSeek(size_t offset) override; + int onRead(void *data, size_t bytes) override; + int onWrite(const void *data, size_t bytes) override; private: std::shared_ptr _file; @@ -126,7 +126,7 @@ public: /** * 获取文件大小 */ - uint64_t fileSize() const; + size_t fileSize() const; /** * 获取并清空文件缓存 @@ -134,13 +134,13 @@ public: string getAndClearMemory(); protected: - uint64_t onTell() override; - int onSeek(uint64_t offset) override; - int onRead(void *data, uint64_t bytes) override; - int onWrite(const void *data, uint64_t bytes) override; + size_t onTell() override; + int onSeek(size_t offset) override; + int onRead(void *data, size_t bytes) override; + int onWrite(const void *data, size_t bytes) override; private: - uint64_t _offset = 0; + size_t _offset = 0; string _memory; }; diff --git a/src/Record/MP4Demuxer.cpp b/src/Record/MP4Demuxer.cpp index f4fa5a13..1b38dac2 100644 --- a/src/Record/MP4Demuxer.cpp +++ b/src/Record/MP4Demuxer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -225,9 +225,9 @@ Frame::Ptr MP4Demuxer::makeFrame(uint32_t track_id, const Buffer::Ptr &buf, int6 offset += (frame_len + 4); } if (codec == CodecH264) { - return std::make_shared >(buf, dts, pts, 4, DATA_OFFSET); + return std::make_shared >(buf, (uint32_t)dts, (uint32_t)pts, 4, DATA_OFFSET); } - return std::make_shared >(buf, dts, pts, 4, DATA_OFFSET); + return std::make_shared >(buf, (uint32_t)dts, (uint32_t)pts, 4, DATA_OFFSET); } case CodecAAC: { @@ -235,13 +235,13 @@ Frame::Ptr MP4Demuxer::makeFrame(uint32_t track_id, const Buffer::Ptr &buf, int6 assert(track); //加上adts头 dumpAacConfig(track->getAacCfg(), buf->size() - DATA_OFFSET, (uint8_t *) buf->data() + (DATA_OFFSET - ADTS_HEADER_LEN), ADTS_HEADER_LEN); - return std::make_shared >(buf, dts, pts, ADTS_HEADER_LEN, DATA_OFFSET - ADTS_HEADER_LEN, codec); + return std::make_shared >(buf, (uint32_t)dts, (uint32_t)pts, ADTS_HEADER_LEN, DATA_OFFSET - ADTS_HEADER_LEN, codec); } case CodecOpus: case CodecG711A: case CodecG711U: { - return std::make_shared >(buf, dts, pts, 0, DATA_OFFSET, codec); + return std::make_shared >(buf, (uint32_t)dts, (uint32_t)pts, 0, DATA_OFFSET, codec); } default: return nullptr; diff --git a/src/Record/MP4Demuxer.h b/src/Record/MP4Demuxer.h index 2512602c..5d19b3a9 100644 --- a/src/Record/MP4Demuxer.h +++ b/src/Record/MP4Demuxer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Record/MP4Muxer.cpp b/src/Record/MP4Muxer.cpp index f5b79032..e84fa6e4 100644 --- a/src/Record/MP4Muxer.cpp +++ b/src/Record/MP4Muxer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -104,7 +104,7 @@ void MP4MuxerInterface::inputFrame(const Frame::Ptr &frame) { BufferLikeString merged; merged.reserve(back->size() + 1024); _frameCached.for_each([&](const Frame::Ptr &frame) { - uint32_t nalu_size = frame->size() - frame->prefixSize(); + uint32_t nalu_size = (uint32_t)(frame->size() - frame->prefixSize()); nalu_size = htonl(nalu_size); merged.append((char *) &nalu_size, 4); merged.append(frame->data() + frame->prefixSize(), frame->size() - frame->prefixSize()); @@ -249,7 +249,7 @@ void MP4MuxerInterface::addTrack(const Track::Ptr &track) { struct mpeg4_avc_t avc = {0}; string sps_pps = string("\x00\x00\x00\x01", 4) + h264_track->getSps() + string("\x00\x00\x00\x01", 4) + h264_track->getPps(); - h264_annexbtomp4(&avc, sps_pps.data(), sps_pps.size(), NULL, 0, NULL, NULL); + h264_annexbtomp4(&avc, sps_pps.data(), (int)sps_pps.size(), NULL, 0, NULL, NULL); uint8_t extra_data[1024]; int extra_data_size = mpeg4_avc_decoder_configuration_record_save(&avc, extra_data, sizeof(extra_data)); @@ -284,7 +284,7 @@ void MP4MuxerInterface::addTrack(const Track::Ptr &track) { string vps_sps_pps = string("\x00\x00\x00\x01", 4) + h265_track->getVps() + string("\x00\x00\x00\x01", 4) + h265_track->getSps() + string("\x00\x00\x00\x01", 4) + h265_track->getPps(); - h265_annexbtomp4(&hevc, vps_sps_pps.data(), vps_sps_pps.size(), NULL, 0, NULL, NULL); + h265_annexbtomp4(&hevc, vps_sps_pps.data(), (int)vps_sps_pps.size(), NULL, 0, NULL, NULL); uint8_t extra_data[1024]; int extra_data_size = mpeg4_hevc_decoder_configuration_record_save(&hevc, extra_data, sizeof(extra_data)); diff --git a/src/Record/MP4Muxer.h b/src/Record/MP4Muxer.h index 479e98d5..98a6ca4d 100644 --- a/src/Record/MP4Muxer.h +++ b/src/Record/MP4Muxer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Record/MP4Reader.cpp b/src/Record/MP4Reader.cpp index 12d3eb63..4363733b 100644 --- a/src/Record/MP4Reader.cpp +++ b/src/Record/MP4Reader.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -31,7 +31,7 @@ MP4Reader::MP4Reader(const string &strVhost,const string &strApp, const string & _demuxer = std::make_shared(); _demuxer->openMP4(_file_path); - _mediaMuxer.reset(new MultiMediaSourceMuxer(strVhost, strApp, strId, _demuxer->getDurationMS() / 1000.0, true, true, false, false)); + _mediaMuxer.reset(new MultiMediaSourceMuxer(strVhost, strApp, strId, _demuxer->getDurationMS() / 1000.0f, true, true, false, false)); auto tracks = _demuxer->getTracks(false); if(tracks.empty()){ throw std::runtime_error(StrPrinter << "该mp4文件没有有效的track:" << _file_path); @@ -89,7 +89,7 @@ void MP4Reader::startReadMP4() { } uint32_t MP4Reader::getCurrentStamp() { - return _seek_to + _seek_ticker.elapsedTime(); + return (uint32_t)(_seek_to + _seek_ticker.elapsedTime()); } void MP4Reader::setCurrentStamp(uint32_t ui32Stamp){ @@ -117,7 +117,7 @@ bool MP4Reader::seekTo(uint32_t ui32Stamp){ if(!_have_video){ //没有视频,不需要搜索关键帧 //设置当前时间戳 - setCurrentStamp(stamp); + setCurrentStamp((uint32_t)stamp); return true; } //搜索到下一帧关键帧 diff --git a/src/Record/MP4Reader.h b/src/Record/MP4Reader.h index de374de5..c3791fa6 100644 --- a/src/Record/MP4Reader.h +++ b/src/Record/MP4Reader.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Record/MP4Recorder.cpp b/src/Record/MP4Recorder.cpp index 431ed8ca..c357d047 100644 --- a/src/Record/MP4Recorder.cpp +++ b/src/Record/MP4Recorder.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -75,7 +75,7 @@ void MP4Recorder::asyncClose() { auto info = _info; WorkThreadPool::Instance().getExecutor()->async([muxer,strFileTmp,strFile,info]() { //获取文件录制时间,放在关闭mp4之前是为了忽略关闭mp4执行时间 - const_cast(info).time_len = ::time(NULL) - info.start_time; + const_cast(info).time_len = (float)(::time(NULL) - info.start_time); //关闭mp4非常耗时,所以要放在后台线程执行 muxer->closeMP4(); diff --git a/src/Record/MP4Recorder.h b/src/Record/MP4Recorder.h index 0270ea62..cf862889 100644 --- a/src/Record/MP4Recorder.h +++ b/src/Record/MP4Recorder.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Record/Recorder.cpp b/src/Record/Recorder.cpp index e678715b..54803eae 100644 --- a/src/Record/Recorder.cpp +++ b/src/Record/Recorder.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Record/Recorder.h b/src/Record/Recorder.h index d7ec133f..d535ae1a 100644 --- a/src/Record/Recorder.h +++ b/src/Record/Recorder.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Record/TsMuxer.cpp b/src/Record/TsMuxer.cpp index 84273fc6..065d35b2 100644 --- a/src/Record/TsMuxer.cpp +++ b/src/Record/TsMuxer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -124,7 +124,7 @@ void TsMuxer::inputFrame(const Frame::Ptr &frame) { } track_info.stamp.revise(back->dts(), back->pts(), dts_out, pts_out); //取视频时间戳为TS的时间戳 - _timestamp = dts_out; + _timestamp = (uint32_t)dts_out; mpeg_ts_write(_context, track_info.track_id, back->keyFrame() ? 0x0001 : 0, pts_out * 90LL,dts_out * 90LL, merged_frame->data(), merged_frame->size()); _frameCached.clear(); } @@ -143,7 +143,7 @@ void TsMuxer::inputFrame(const Frame::Ptr &frame) { track_info.stamp.revise(frame->dts(), frame->pts(), dts_out, pts_out); if(!_have_video){ //没有视频时,才以音频时间戳为TS的时间戳 - _timestamp = dts_out; + _timestamp = (uint32_t)dts_out; } mpeg_ts_write(_context, track_info.track_id, frame->keyFrame() ? 0x0001 : 0, pts_out * 90LL, dts_out * 90LL, frame->data(), frame->size()); break; diff --git a/src/Record/TsMuxer.h b/src/Record/TsMuxer.h index 74c97da2..2b512f07 100644 --- a/src/Record/TsMuxer.h +++ b/src/Record/TsMuxer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -50,7 +50,7 @@ protected: * @param timestamp 时间戳,单位毫秒 * @param is_idr_fast_packet 是否为关键帧的第一个TS包,用于确保ts切片第一帧为关键帧 */ - virtual void onTs(const void *packet, int bytes,uint32_t timestamp,bool is_idr_fast_packet) = 0; + virtual void onTs(const void *packet, size_t bytes,uint32_t timestamp,bool is_idr_fast_packet) = 0; private: void init(); @@ -88,7 +88,7 @@ public: void inputFrame(const Frame::Ptr &frame) override {} protected: - virtual void onTs(const void *packet, int bytes,uint32_t timestamp,bool is_idr_fast_packet) = 0; + virtual void onTs(const void *packet, size_t bytes,uint32_t timestamp,bool is_idr_fast_packet) = 0; }; }//namespace mediakit diff --git a/src/Rtmp/FlvMuxer.cpp b/src/Rtmp/FlvMuxer.cpp index 7418a436..5ff3cdb3 100644 --- a/src/Rtmp/FlvMuxer.cpp +++ b/src/Rtmp/FlvMuxer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -59,8 +59,8 @@ void FlvMuxer::start(const EventPoller::Ptr &poller,const RtmpMediaSource::Ptr & return; } - int i = 0; - int size = pkt->size(); + size_t i = 0; + auto size = pkt->size(); pkt->for_each([&](const RtmpPacket::Ptr &rtmp){ strongSelf->onWriteRtmp(rtmp, ++i == size); }); @@ -140,14 +140,14 @@ void FlvMuxer::onWriteFlvTag(const RtmpPacket::Ptr &pkt, uint32_t time_stamp , b void FlvMuxer::onWriteFlvTag(uint8_t type, const Buffer::Ptr &buffer, uint32_t time_stamp, bool flush) { RtmpTagHeader header; header.type = type; - set_be24(header.data_size, buffer->size()); + set_be24(header.data_size, (uint32_t)buffer->size()); header.timestamp_ex = (uint8_t) ((time_stamp >> 24) & 0xff); set_be24(header.timestamp, time_stamp & 0xFFFFFF); //tag header onWrite(std::make_shared((char *)&header, sizeof(header)), false); //tag data onWrite(buffer, false); - auto size = htonl((buffer->size() + sizeof(header))); + uint32_t size = htonl((uint32_t)(buffer->size() + sizeof(header))); //PreviousTagSize onWrite(std::make_shared((char *)&size,4), flush); } @@ -155,7 +155,7 @@ void FlvMuxer::onWriteFlvTag(uint8_t type, const Buffer::Ptr &buffer, uint32_t t void FlvMuxer::onWriteRtmp(const RtmpPacket::Ptr &pkt,bool flush) { int64_t dts_out; _stamp[pkt->type_id % 2].revise(pkt->time_stamp, 0, dts_out, dts_out); - onWriteFlvTag(pkt, dts_out,flush); + onWriteFlvTag(pkt, (uint32_t)dts_out,flush); } void FlvMuxer::stop() { diff --git a/src/Rtmp/FlvMuxer.h b/src/Rtmp/FlvMuxer.h index fa16a1c8..fd2995a2 100644 --- a/src/Rtmp/FlvMuxer.h +++ b/src/Rtmp/FlvMuxer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtmp/Rtmp.cpp b/src/Rtmp/Rtmp.cpp index 0c80692c..cd497114 100644 --- a/src/Rtmp/Rtmp.cpp +++ b/src/Rtmp/Rtmp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtmp/Rtmp.h b/src/Rtmp/Rtmp.h index f9f9790a..fa331e79 100644 --- a/src/Rtmp/Rtmp.h +++ b/src/Rtmp/Rtmp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -129,20 +129,20 @@ public: class RtmpPacket : public Buffer{ public: typedef std::shared_ptr Ptr; - uint8_t type_id; - uint32_t body_size = 0; - uint32_t time_stamp = 0; bool is_abs_stamp = false; + uint8_t type_id; + uint32_t time_stamp = 0; uint32_t ts_field = 0; uint32_t stream_index; uint32_t chunk_id; + size_t body_size = 0; BufferLikeString buffer; public: char *data() const override{ return (char*)buffer.data(); } - uint32_t size() const override { + size_t size() const override { return buffer.size(); } @@ -242,7 +242,7 @@ public: typedef std::shared_ptr Ptr; TitleMeta(float dur_sec = 0, - uint64_t fileSize = 0, + size_t fileSize = 0, const map &header = map()){ _metadata.set("duration", dur_sec); _metadata.set("fileSize", 0); diff --git a/src/Rtmp/RtmpCodec.h b/src/Rtmp/RtmpCodec.h index 15a4496a..8e409718 100644 --- a/src/Rtmp/RtmpCodec.h +++ b/src/Rtmp/RtmpCodec.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtmp/RtmpDemuxer.cpp b/src/Rtmp/RtmpDemuxer.cpp index 5225ce32..38cffe8c 100644 --- a/src/Rtmp/RtmpDemuxer.cpp +++ b/src/Rtmp/RtmpDemuxer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -25,7 +25,7 @@ bool RtmpDemuxer::loadMetaData(const AMFValue &val){ const AMFValue *videocodecid = nullptr; val.object_for_each([&](const string &key, const AMFValue &val) { if (key == "duration") { - _fDuration = val.as_number(); + _fDuration = (float)val.as_number(); return; } if (key == "audiosamplerate") { diff --git a/src/Rtmp/RtmpDemuxer.h b/src/Rtmp/RtmpDemuxer.h index f339ced3..29bfdd7c 100644 --- a/src/Rtmp/RtmpDemuxer.h +++ b/src/Rtmp/RtmpDemuxer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtmp/RtmpMediaSource.h b/src/Rtmp/RtmpMediaSource.h index 483ff1ba..ed2c312f 100644 --- a/src/Rtmp/RtmpMediaSource.h +++ b/src/Rtmp/RtmpMediaSource.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtmp/RtmpMediaSourceImp.h b/src/Rtmp/RtmpMediaSourceImp.h index f293a3a0..350a7812 100644 --- a/src/Rtmp/RtmpMediaSourceImp.h +++ b/src/Rtmp/RtmpMediaSourceImp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtmp/RtmpMediaSourceMuxer.h b/src/Rtmp/RtmpMediaSourceMuxer.h index f998a3a2..36e3886f 100644 --- a/src/Rtmp/RtmpMediaSourceMuxer.h +++ b/src/Rtmp/RtmpMediaSourceMuxer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtmp/RtmpMuxer.cpp b/src/Rtmp/RtmpMuxer.cpp index a44266c2..a593490a 100644 --- a/src/Rtmp/RtmpMuxer.cpp +++ b/src/Rtmp/RtmpMuxer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtmp/RtmpMuxer.h b/src/Rtmp/RtmpMuxer.h index 6533e9a4..dbe05bc1 100644 --- a/src/Rtmp/RtmpMuxer.h +++ b/src/Rtmp/RtmpMuxer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtmp/RtmpPlayer.cpp b/src/Rtmp/RtmpPlayer.cpp index e6483707..2b128ca7 100644 --- a/src/Rtmp/RtmpPlayer.cpp +++ b/src/Rtmp/RtmpPlayer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -72,7 +72,7 @@ void RtmpPlayer::play(const string &strUrl) { } weak_ptr weak_self = dynamic_pointer_cast(shared_from_this()); - float play_timeout_sec = (*this)[kTimeoutMS].as() / 1000.0; + float play_timeout_sec = (*this)[kTimeoutMS].as() / 1000.0f; _play_timer.reset(new Timer(play_timeout_sec, [weak_self]() { auto strong_self = weak_self.lock(); if (!strong_self) { @@ -131,7 +131,7 @@ void RtmpPlayer::onPlayResult_l(const SockException &ex, bool handshake_done) { return true; }; //创建rtmp数据接收超时检测定时器 - _rtmp_recv_timer = std::make_shared(timeout_ms / 2000.0, lam, getPoller()); + _rtmp_recv_timer = std::make_shared(timeout_ms / 2000.0f, lam, getPoller()); } else { shutdown(SockException(Err_shutdown,"teardown")); } @@ -253,12 +253,12 @@ inline void RtmpPlayer::send_pause(bool pause) { _beat_timer.reset(); if (pause) { weak_ptr weakSelf = dynamic_pointer_cast(shared_from_this()); - _beat_timer.reset(new Timer((*this)[kBeatIntervalMS].as() / 1000.0, [weakSelf]() { + _beat_timer.reset(new Timer((*this)[kBeatIntervalMS].as() / 1000.0f, [weakSelf]() { auto strongSelf = weakSelf.lock(); if (!strongSelf) { return false; } - uint32_t timeStamp = ::time(NULL); + uint32_t timeStamp = (uint32_t)::time(NULL); strongSelf->sendUserControl(CONTROL_PING_REQUEST, timeStamp); return true; }, getPoller())); diff --git a/src/Rtmp/RtmpPlayer.h b/src/Rtmp/RtmpPlayer.h index 4a712a67..81a5ef19 100644 --- a/src/Rtmp/RtmpPlayer.h +++ b/src/Rtmp/RtmpPlayer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtmp/RtmpPlayerImp.h b/src/Rtmp/RtmpPlayerImp.h index 4ac573c6..af243acd 100644 --- a/src/Rtmp/RtmpPlayerImp.h +++ b/src/Rtmp/RtmpPlayerImp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -43,7 +43,7 @@ public: void seekTo(float fProgress) override { fProgress = MAX(float(0), MIN(fProgress, float(1.0))); - seekToMilliSecond(fProgress * getDuration() * 1000); + seekToMilliSecond((uint32_t)(fProgress * getDuration() * 1000)); } void play(const string &strUrl) override { diff --git a/src/Rtmp/RtmpProtocol.cpp b/src/Rtmp/RtmpProtocol.cpp index 427510a1..f92ba994 100644 --- a/src/Rtmp/RtmpProtocol.cpp +++ b/src/Rtmp/RtmpProtocol.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -29,7 +29,7 @@ using namespace toolkit; #include #include -static string openssl_HMACsha256(const void *key, unsigned int key_len, const void *data,unsigned int data_len){ +static string openssl_HMACsha256(const void *key, size_t key_len, const void *data, size_t data_len){ std::shared_ptr out(new char[32], [](char *ptr) { delete[] ptr; }); unsigned int out_len; @@ -37,7 +37,7 @@ static string openssl_HMACsha256(const void *key, unsigned int key_len, const vo //openssl 1.1.0新增api,老版本api作废 HMAC_CTX *ctx = HMAC_CTX_new(); HMAC_CTX_reset(ctx); - HMAC_Init_ex(ctx, key, key_len, EVP_sha256(), NULL); + HMAC_Init_ex(ctx, key, (int)key_len, EVP_sha256(), NULL); HMAC_Update(ctx, (unsigned char*)data, data_len); HMAC_Final(ctx, (unsigned char *)out.get(), &out_len); HMAC_CTX_reset(ctx); @@ -57,7 +57,7 @@ static string openssl_HMACsha256(const void *key, unsigned int key_len, const vo namespace mediakit { RtmpProtocol::RtmpProtocol() { - _next_step_func = [this](const char *data, uint64_t len) { + _next_step_func = [this](const char *data, size_t len) { return handle_C0C1(data, len); }; } @@ -86,7 +86,7 @@ void RtmpProtocol::reset() { //////////Rtmp parser////////// HttpRequestSplitter::reset(); _stream_index = STREAM_CONTROL; - _next_step_func = [this](const char *data, uint64_t len) { + _next_step_func = [this](const char *data, size_t len) { return handle_C0C1(data, len); }; } @@ -172,7 +172,7 @@ void RtmpProtocol::sendRequest(int cmd, const string& str) { class BufferPartial : public Buffer { public: - BufferPartial(const Buffer::Ptr &buffer, uint32_t offset, uint32_t size){ + BufferPartial(const Buffer::Ptr &buffer, size_t offset, size_t size){ _buffer = buffer; _data = buffer->data() + offset; _size = size; @@ -184,13 +184,13 @@ public: return _data; } - uint32_t size() const override{ + size_t size() const override{ return _size; } private: char *_data; - uint32_t _size; + size_t _size; Buffer::Ptr _buffer; }; @@ -215,7 +215,7 @@ void RtmpProtocol::sendRtmp(uint8_t type, uint32_t stream_index, const Buffer::P header->flags = (chunk_id & 0x3f) | (0 << 6); header->type_id = type; set_be24(header->time_stamp, ext_stamp ? 0xFFFFFF : stamp); - set_be24(header->body_size, buf->size()); + set_be24(header->body_size, (uint32_t)buf->size()); set_le32(header->stream_index, stream_index); //发送rtmp头 onSendRawData(std::move(buffer_header)); @@ -237,7 +237,7 @@ void RtmpProtocol::sendRtmp(uint8_t type, uint32_t stream_index, const Buffer::P buffer_flags->data()[0] = (chunk_id & 0x3f) | (3 << 6); size_t offset = 0; - uint32_t totalSize = sizeof(RtmpHeader); + size_t totalSize = sizeof(RtmpHeader); while (offset < buf->size()) { if (offset) { onSendRawData(buffer_flags); @@ -253,18 +253,18 @@ void RtmpProtocol::sendRtmp(uint8_t type, uint32_t stream_index, const Buffer::P totalSize += chunk; offset += chunk; } - _bytes_sent += totalSize; + _bytes_sent += (uint32_t)totalSize; if (_windows_size > 0 && _bytes_sent - _bytes_sent_last >= _windows_size) { _bytes_sent_last = _bytes_sent; sendAcknowledgement(_bytes_sent); } } -void RtmpProtocol::onParseRtmp(const char *data, uint64_t size) { +void RtmpProtocol::onParseRtmp(const char *data, size_t size) { input(data, size); } -const char *RtmpProtocol::onSearchPacketTail(const char *data,uint64_t len){ +const char *RtmpProtocol::onSearchPacketTail(const char *data,size_t len){ //移动拷贝提高性能 auto next_step_func(std::move(_next_step_func)); //执行下一步 @@ -283,13 +283,13 @@ void RtmpProtocol::startClientSession(const function &func) { onSendRawData(obtainBuffer(&handshake_head, 1)); RtmpHandshake c1(0); onSendRawData(obtainBuffer((char *) (&c1), sizeof(c1))); - _next_step_func = [this, func](const char *data, uint64_t len) { + _next_step_func = [this, func](const char *data, size_t len) { //等待 S0+S1+S2 return handle_S0S1S2(data, len, func); }; } -const char* RtmpProtocol::handle_S0S1S2(const char *data, uint64_t len, const function &func) { +const char* RtmpProtocol::handle_S0S1S2(const char *data, size_t len, const function &func) { if (len < 1 + 2 * C1_HANDSHARK_SIZE) { //数据不够 return nullptr; @@ -301,7 +301,7 @@ const char* RtmpProtocol::handle_S0S1S2(const char *data, uint64_t len, const fu const char *pcC2 = data + 1; onSendRawData(obtainBuffer(pcC2, C1_HANDSHARK_SIZE)); //握手结束 - _next_step_func = [this](const char *data, uint64_t len) { + _next_step_func = [this](const char *data, size_t len) { //握手结束并且开始进入解析命令模式 return handle_rtmp(data, len); }; @@ -310,7 +310,7 @@ const char* RtmpProtocol::handle_S0S1S2(const char *data, uint64_t len, const fu } ////for server //// -const char * RtmpProtocol::handle_C0C1(const char *data, uint64_t len) { +const char * RtmpProtocol::handle_C0C1(const char *data, size_t len) { if (len < 1 + C1_HANDSHARK_SIZE) { //need more data! return nullptr; @@ -343,7 +343,7 @@ void RtmpProtocol::handle_C1_simple(const char *data){ //发送S2 onSendRawData(obtainBuffer(data + 1, C1_HANDSHARK_SIZE)); //等待C2 - _next_step_func = [this](const char *data, uint64_t len) { + _next_step_func = [this](const char *data, size_t len) { //握手结束并且开始进入解析命令模式 return handle_C2(data, len); }; @@ -370,7 +370,7 @@ void RtmpProtocol::handle_C1_complex(const char *data){ send_complex_S0S1S2(0, digest); // InfoL << "schema0"; - } catch (std::exception &ex) { + } catch (std::exception &) { //貌似flash从来都不用schema1 // WarnL << "try rtmp complex schema0 failed:" << ex.what(); try { @@ -387,7 +387,7 @@ void RtmpProtocol::handle_C1_complex(const char *data){ send_complex_S0S1S2(1, digest); // InfoL << "schema1"; - } catch (std::exception &ex) { + } catch (std::exception &) { // WarnL << "try rtmp complex schema1 failed:" << ex.what(); handle_C1_simple(data); } @@ -506,18 +506,18 @@ void RtmpProtocol::send_complex_S0S1S2(int schemeType,const string &digest){ memcpy((char *) &s2 + C1_HANDSHARK_SIZE - C1_DIGEST_SIZE, s2_digest.data(), C1_DIGEST_SIZE); onSendRawData(obtainBuffer((char *) &s2, sizeof(s2))); //等待C2 - _next_step_func = [this](const char *data, uint64_t len) { + _next_step_func = [this](const char *data, size_t len) { return handle_C2(data, len); }; } #endif //ENABLE_OPENSSL -const char* RtmpProtocol::handle_C2(const char *data, uint64_t len) { +const char* RtmpProtocol::handle_C2(const char *data, size_t len) { if (len < C1_HANDSHARK_SIZE) { //need more data! return nullptr; } - _next_step_func = [this](const char *data, uint64_t len) { + _next_step_func = [this](const char *data, size_t len) { return handle_rtmp(data, len); }; @@ -527,7 +527,7 @@ const char* RtmpProtocol::handle_C2(const char *data, uint64_t len) { static const size_t HEADER_LENGTH[] = {12, 8, 4, 1}; -const char* RtmpProtocol::handle_rtmp(const char *data, uint64_t len) { +const char* RtmpProtocol::handle_rtmp(const char *data, size_t len) { auto ptr = data; while (len) { int offset = 0; @@ -757,7 +757,7 @@ BufferRaw::Ptr RtmpProtocol::obtainBuffer() { return std::make_shared() ;//_bufferPool.obtain(); } -BufferRaw::Ptr RtmpProtocol::obtainBuffer(const void *data, int len) { +BufferRaw::Ptr RtmpProtocol::obtainBuffer(const void *data, size_t len) { auto buffer = obtainBuffer(); buffer->assign((const char *) data, len); return buffer; diff --git a/src/Rtmp/RtmpProtocol.h b/src/Rtmp/RtmpProtocol.h index e20fce30..a571e274 100644 --- a/src/Rtmp/RtmpProtocol.h +++ b/src/Rtmp/RtmpProtocol.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -33,7 +33,7 @@ public: RtmpProtocol(); virtual ~RtmpProtocol(); - void onParseRtmp(const char *data, uint64_t size); + void onParseRtmp(const char *data, size_t size); //作为客户端发送c0c1,等待s0s1s2并且回调 void startClientSession(const function &cb); @@ -48,13 +48,13 @@ protected: protected: //// HttpRequestSplitter override //// - int64_t onRecvHeader(const char *data,uint64_t len) override { return 0; } - const char *onSearchPacketTail(const char *data,uint64_t len) override; + size_t onRecvHeader(const char *data, size_t len) override { return 0; } + const char *onSearchPacketTail(const char *data, size_t len) override; protected: void reset(); BufferRaw::Ptr obtainBuffer(); - BufferRaw::Ptr obtainBuffer(const void *data, int len); + BufferRaw::Ptr obtainBuffer(const void *data, size_t len); void sendAcknowledgement(uint32_t size); void sendAcknowledgementSize(uint32_t size); @@ -81,10 +81,10 @@ private: void send_complex_S0S1S2(int schemeType,const string &digest); #endif //ENABLE_OPENSSL - const char* handle_S0S1S2(const char *data, uint64_t len, const function &func); - const char* handle_C0C1(const char *data, uint64_t len); - const char* handle_C2(const char *data, uint64_t len); - const char* handle_rtmp(const char *data, uint64_t len); + const char* handle_S0S1S2(const char *data, size_t len, const function &func); + const char* handle_C0C1(const char *data, size_t len); + const char* handle_C2(const char *data, size_t len); + const char* handle_rtmp(const char *data, size_t len); void handle_chunk(RtmpPacket &chunk_data); protected: @@ -106,7 +106,7 @@ private: uint32_t _bandwidth = 2500000; uint8_t _band_limit_type = 2; //////////Rtmp parser////////// - function _next_step_func; + function _next_step_func; ////////////Chunk//////////// unordered_map _map_chunk_data; }; diff --git a/src/Rtmp/RtmpPusher.cpp b/src/Rtmp/RtmpPusher.cpp index 3043e7a0..1267d49b 100644 --- a/src/Rtmp/RtmpPusher.cpp +++ b/src/Rtmp/RtmpPusher.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -92,7 +92,7 @@ void RtmpPusher::publish(const string &url) { } weak_ptr weakSelf = dynamic_pointer_cast(shared_from_this()); - float publishTimeOutSec = (*this)[kTimeoutMS].as() / 1000.0; + float publishTimeOutSec = (*this)[kTimeoutMS].as() / 1000.0f; _publish_timer.reset(new Timer(publishTimeOutSec, [weakSelf]() { auto strongSelf = weakSelf.lock(); if (!strongSelf) { @@ -210,8 +210,8 @@ inline void RtmpPusher::send_metaData(){ return; } - int i = 0; - int size = pkt->size(); + size_t i = 0; + auto size = pkt->size(); strong_self->setSendFlushFlag(false); pkt->for_each([&](const RtmpPacket::Ptr &rtmp) { if (++i == size) { diff --git a/src/Rtmp/RtmpPusher.h b/src/Rtmp/RtmpPusher.h index a1ac0d9c..8e237911 100644 --- a/src/Rtmp/RtmpPusher.h +++ b/src/Rtmp/RtmpPusher.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtmp/RtmpSession.cpp b/src/Rtmp/RtmpSession.cpp index 9b82600f..96584532 100644 --- a/src/Rtmp/RtmpSession.cpp +++ b/src/Rtmp/RtmpSession.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -277,8 +277,8 @@ void RtmpSession::sendPlayResponse(const string &err,const RtmpMediaSource::Ptr if(strongSelf->_paused){ return; } - int i = 0; - int size = pkt->size(); + size_t i = 0; + auto size = pkt->size(); strongSelf->setSendFlushFlag(false); pkt->for_each([&](const RtmpPacket::Ptr &rtmp){ if(++i == size){ @@ -482,7 +482,7 @@ void RtmpSession::onRtmpChunk(RtmpPacket &chunk_data) { if (rtmp_modify_stamp) { int64_t dts_out; _stamp[chunk_data.type_id % 2].revise(chunk_data.time_stamp, chunk_data.time_stamp, dts_out, dts_out, true); - chunk_data.time_stamp = dts_out; + chunk_data.time_stamp = (uint32_t)dts_out; } if (!_set_meta_data && !chunk_data.isCfgFrame()) { @@ -508,7 +508,7 @@ void RtmpSession::onCmd_seek(AMFDecoder &dec) { status.set("description", "Seeking."); sendReply("onStatus", nullptr, status); - auto milliSeconds = dec.load().as_number(); + auto milliSeconds = (uint32_t)(dec.load().as_number()); InfoP(this) << "rtmp seekTo(ms):" << milliSeconds; auto strong_src = _player_src.lock(); if (strong_src) { @@ -520,7 +520,7 @@ void RtmpSession::onSendMedia(const RtmpPacket::Ptr &pkt) { //rtmp播放器时间戳从零开始 int64_t dts_out; _stamp[pkt->type_id % 2].revise(pkt->time_stamp, 0, dts_out, dts_out); - sendRtmp(pkt->type_id, pkt->stream_index, pkt, dts_out, pkt->chunk_id); + sendRtmp(pkt->type_id, pkt->stream_index, pkt, (uint32_t)dts_out, pkt->chunk_id); } diff --git a/src/Rtmp/RtmpSession.h b/src/Rtmp/RtmpSession.h index e608ca4c..1ecec693 100644 --- a/src/Rtmp/RtmpSession.h +++ b/src/Rtmp/RtmpSession.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtmp/amf.cpp b/src/Rtmp/amf.cpp index c2db49a3..70f68b18 100644 --- a/src/Rtmp/amf.cpp +++ b/src/Rtmp/amf.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -178,7 +178,7 @@ double AMFValue::as_number() const { int AMFValue::as_integer() const { switch (_type) { case AMF_NUMBER: - return _value.number; + return (int)_value.number; case AMF_INTEGER: return _value.integer; case AMF_BOOLEAN: @@ -319,7 +319,9 @@ enum { AMFEncoder & AMFEncoder::operator <<(const char *s) { if (s) { buf += char(AMF0_STRING); - uint16_t str_len = htons(strlen(s)); + auto len = strlen(s); + assert(len <= 0xFFFF); + uint16_t str_len = htons((uint16_t)len); buf.append((char *) &str_len, 2); buf += s; } else { @@ -331,7 +333,8 @@ AMFEncoder & AMFEncoder::operator <<(const char *s) { AMFEncoder & AMFEncoder::operator <<(const std::string &s) { if (!s.empty()) { buf += char(AMF0_STRING); - uint16_t str_len = htons(s.size()); + assert(s.size() <= 0xFFFF); + uint16_t str_len = htons((uint16_t)s.size()); buf.append((char *) &str_len, 2); buf += s; } else { @@ -361,7 +364,7 @@ AMFEncoder & AMFEncoder::operator <<(const double n) { memcpy(&encoded, &n, 8); uint32_t val = htonl(encoded >> 32); buf.append((char *) &val, 4); - val = htonl(encoded); + val = htonl(encoded & 0xFFFFFFFF); buf.append((char *) &val, 4); return *this; } @@ -398,7 +401,7 @@ AMFEncoder & AMFEncoder::operator <<(const AMFValue& value) { break; case AMF_ECMA_ARRAY: { buf += char(AMF0_ECMA_ARRAY); - uint32_t sz = htonl(value.getMap().size()); + uint32_t sz = htonl((uint32_t)value.getMap().size()); buf.append((char *) &sz, 4); for (auto &pr : value.getMap()) { write_key(pr.first); @@ -416,7 +419,7 @@ AMFEncoder & AMFEncoder::operator <<(const AMFValue& value) { break; case AMF_STRICT_ARRAY: { buf += char(AMF0_STRICT_ARRAY); - uint32_t sz = htonl(value.getArr().size()); + uint32_t sz = htonl((uint32_t)value.getArr().size()); buf.append((char *) &sz, 4); for (auto &val : value.getArr()) { *this << val; @@ -431,7 +434,8 @@ AMFEncoder & AMFEncoder::operator <<(const AMFValue& value) { } void AMFEncoder::write_key(const std::string& s) { - uint16_t str_len = htons(s.size()); + assert(s.size() <= 0xFFFF); + uint16_t str_len = htons((uint16_t)s.size()); buf.append((char *) &str_len, 2); buf += s; } @@ -510,9 +514,9 @@ unsigned int AMFDecoder::load() { template<> int AMFDecoder::load() { if (version == 3) { - return load(); + return (int)load(); } else { - return load(); + return (int)load(); } } diff --git a/src/Rtmp/amf.h b/src/Rtmp/amf.h index 44153da3..2c5384cd 100644 --- a/src/Rtmp/amf.h +++ b/src/Rtmp/amf.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtmp/utils.cpp b/src/Rtmp/utils.cpp index 8f039c4b..f57b2c5a 100644 --- a/src/Rtmp/utils.cpp +++ b/src/Rtmp/utils.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtmp/utils.h b/src/Rtmp/utils.h index 50b14cc1..9acad755 100644 --- a/src/Rtmp/utils.h +++ b/src/Rtmp/utils.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtp/Decoder.cpp b/src/Rtp/Decoder.cpp index 5f184583..a2e3f88a 100644 --- a/src/Rtp/Decoder.cpp +++ b/src/Rtp/Decoder.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -54,17 +54,17 @@ DecoderImp::Ptr DecoderImp::createDecoder(Type type, MediaSinkInterface *sink){ return DecoderImp::Ptr(new DecoderImp(decoder, sink)); } -int DecoderImp::input(const uint8_t *data, int bytes){ +size_t DecoderImp::input(const uint8_t *data, size_t bytes){ return _decoder->input(data, bytes); } DecoderImp::DecoderImp(const Decoder::Ptr &decoder, MediaSinkInterface *sink){ _decoder = decoder; _sink = sink; - _decoder->setOnDecode([this](int stream, int codecid, int flags, int64_t pts, int64_t dts, const void *data, int bytes) { + _decoder->setOnDecode([this](int stream, int codecid, int flags, int64_t pts, int64_t dts, const void *data, size_t bytes) { onDecode(stream, codecid, flags, pts, dts, data, bytes); }); - _decoder->setOnStream([this](int stream, int codecid, const void *extra, int bytes, int finish) { + _decoder->setOnStream([this](int stream, int codecid, const void *extra, size_t bytes, int finish) { onStream(stream, codecid, extra, bytes, finish); }); } @@ -118,7 +118,7 @@ void FrameMerger::inputFrame(const Frame::Ptr &frame,const function((char *) data, bytes, dts, pts,0); + auto frame = std::make_shared((char *) data, bytes, (uint32_t)dts, (uint32_t)pts,0); _merger.inputFrame(frame,[this](uint32_t dts, uint32_t pts, const Buffer::Ptr &buffer) { onFrame(std::make_shared >(buffer, dts, pts, prefixSize(buffer->data(), buffer->size()), 0)); }); @@ -185,7 +185,7 @@ void DecoderImp::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d } case PSI_STREAM_H265: { - auto frame = std::make_shared((char *) data, bytes, dts, pts, 0); + auto frame = std::make_shared((char *) data, bytes, (uint32_t)dts, (uint32_t)pts, 0); _merger.inputFrame(frame,[this](uint32_t dts, uint32_t pts, const Buffer::Ptr &buffer) { onFrame(std::make_shared >(buffer, dts, pts, prefixSize(buffer->data(), buffer->size()), 0)); }); @@ -198,19 +198,19 @@ void DecoderImp::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d //这不是aac break; } - onFrame(std::make_shared(CodecAAC, (char *) data, bytes, dts, 0, ADTS_HEADER_LEN)); + onFrame(std::make_shared(CodecAAC, (char *) data, bytes, (uint32_t)dts, 0, ADTS_HEADER_LEN)); break; } case PSI_STREAM_AUDIO_G711A: case PSI_STREAM_AUDIO_G711U: { auto codec = codecid == PSI_STREAM_AUDIO_G711A ? CodecG711A : CodecG711U; - onFrame(std::make_shared(codec, (char *) data, bytes, dts)); + onFrame(std::make_shared(codec, (char *) data, bytes, (uint32_t)dts)); break; } case PSI_STREAM_AUDIO_OPUS: { - onFrame(std::make_shared(CodecOpus, (char *) data, bytes, dts)); + onFrame(std::make_shared(CodecOpus, (char *) data, bytes, (uint32_t)dts)); break; } @@ -225,8 +225,8 @@ void DecoderImp::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d } } #else -void DecoderImp::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t dts,const void *data,int bytes) {} -void DecoderImp::onStream(int stream,int codecid,const void *extra,int bytes,int finish) {} +void DecoderImp::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t dts,const void *data,size_t bytes) {} +void DecoderImp::onStream(int stream,int codecid,const void *extra,size_t bytes,int finish) {} #endif void DecoderImp::onTrack(const Track::Ptr &track) { diff --git a/src/Rtp/Decoder.h b/src/Rtp/Decoder.h index 3340a2b9..7f53a062 100644 --- a/src/Rtp/Decoder.h +++ b/src/Rtp/Decoder.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -22,10 +22,10 @@ namespace mediakit { class Decoder { public: typedef std::shared_ptr Ptr; - typedef std::function onDecode; - typedef std::function onStream; + typedef std::function onDecode; + typedef std::function onStream; - virtual int input(const uint8_t *data, int bytes) = 0; + virtual size_t input(const uint8_t *data, size_t bytes) = 0; virtual void setOnDecode(onDecode cb) = 0; virtual void setOnStream(onStream cb) = 0; @@ -57,7 +57,7 @@ public: ~DecoderImp() = default; static Ptr createDecoder(Type type, MediaSinkInterface *sink); - int input(const uint8_t *data, int bytes); + size_t input(const uint8_t *data, size_t bytes); protected: void onTrack(const Track::Ptr &track); @@ -65,8 +65,8 @@ protected: private: DecoderImp(const Decoder::Ptr &decoder, MediaSinkInterface *sink); - void onDecode(int stream, int codecid, int flags, int64_t pts, int64_t dts, const void *data, int bytes); - void onStream(int stream, int codecid, const void *extra, int bytes, int finish); + void onDecode(int stream, int codecid, int flags, int64_t pts, int64_t dts, const void *data, size_t bytes); + void onStream(int stream, int codecid, const void *extra, size_t bytes, int finish); private: Decoder::Ptr _decoder; diff --git a/src/Rtp/GB28181Process.cpp b/src/Rtp/GB28181Process.cpp index d0bc1500..5cbee72c 100644 --- a/src/Rtp/GB28181Process.cpp +++ b/src/Rtp/GB28181Process.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -18,7 +18,7 @@ namespace mediakit{ //判断是否为ts负载 -static inline bool checkTS(const uint8_t *packet, int bytes){ +static inline bool checkTS(const uint8_t *packet, size_t bytes){ return bytes % TS_PACKET_SIZE == 0 && packet[0] == TS_SYNC_BYTE; } @@ -30,7 +30,7 @@ GB28181Process::GB28181Process(const MediaInfo &media_info, MediaSinkInterface * GB28181Process::~GB28181Process() {} -bool GB28181Process::inputRtp(bool, const char *data, int data_len) { +bool GB28181Process::inputRtp(bool, const char *data, size_t data_len) { return handleOneRtp(0, TrackVideo, 90000, (unsigned char *) data, data_len); } @@ -73,7 +73,7 @@ void GB28181Process::onRtpSorted(const RtpPacket::Ptr &rtp, int) { _rtp_decoder->inputRtp(rtp, false); } -const char *GB28181Process::onSearchPacketTail(const char *packet,uint64_t bytes){ +const char *GB28181Process::onSearchPacketTail(const char *packet,size_t bytes){ try { auto ret = _decoder->input((uint8_t *) packet, bytes); if (ret > 0) { diff --git a/src/Rtp/GB28181Process.h b/src/Rtp/GB28181Process.h index 76da3f1d..85c41b0a 100644 --- a/src/Rtp/GB28181Process.h +++ b/src/Rtp/GB28181Process.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -33,12 +33,12 @@ public: * @param data_len rtp数据长度 * @return 是否解析成功 */ - bool inputRtp(bool, const char *data, int data_len) override; + bool inputRtp(bool, const char *data, size_t data_len) override; protected: void onRtpSorted(const RtpPacket::Ptr &rtp, int track_index) override ; - const char *onSearchPacketTail(const char *data,uint64_t len) override; - int64_t onRecvHeader(const char *data,uint64_t len) override { return 0; }; + const char *onSearchPacketTail(const char *data,size_t len) override; + size_t onRecvHeader(const char *data,size_t len) override { return 0; }; private: void onRtpDecode(const Frame::Ptr &frame); diff --git a/src/Rtp/PSDecoder.cpp b/src/Rtp/PSDecoder.cpp index 1c7a3b4e..4d3629d7 100644 --- a/src/Rtp/PSDecoder.cpp +++ b/src/Rtp/PSDecoder.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -44,7 +44,7 @@ PSDecoder::~PSDecoder() { ps_demuxer_destroy((struct ps_demuxer_t*)_ps_demuxer); } -int PSDecoder::input(const uint8_t *data, int bytes) { +size_t PSDecoder::input(const uint8_t *data, size_t bytes) { return ps_demuxer_input((struct ps_demuxer_t*)_ps_demuxer,data,bytes); } diff --git a/src/Rtp/PSDecoder.h b/src/Rtp/PSDecoder.h index 2be0dca3..7f9d1016 100644 --- a/src/Rtp/PSDecoder.h +++ b/src/Rtp/PSDecoder.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -21,7 +21,7 @@ class PSDecoder : public Decoder { public: PSDecoder(); ~PSDecoder(); - int input(const uint8_t* data, int bytes) override; + size_t input(const uint8_t* data, size_t bytes) override; void setOnDecode(onDecode cb) override; void setOnStream(onStream cb) override; diff --git a/src/Rtp/PSEncoder.cpp b/src/Rtp/PSEncoder.cpp index 7bd55d3f..4b7cf80e 100644 --- a/src/Rtp/PSEncoder.cpp +++ b/src/Rtp/PSEncoder.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -142,7 +142,7 @@ void PSEncoder::inputFrame(const Frame::Ptr &frame) { merged_frame = std::make_shared >(std::move(merged)); } track_info.stamp.revise(back->dts(), back->pts(), dts_out, pts_out); - _timestamp = dts_out; + _timestamp = (uint32_t)dts_out; ps_muxer_input(_muxer.get(), track_info.track_id, back->keyFrame() ? 0x0001 : 0, pts_out * 90LL, dts_out * 90LL, merged_frame->data(), merged_frame->size()); _frameCached.clear(); @@ -160,7 +160,7 @@ void PSEncoder::inputFrame(const Frame::Ptr &frame) { default: { track_info.stamp.revise(frame->dts(), frame->pts(), dts_out, pts_out); - _timestamp = dts_out; + _timestamp = (uint32_t)dts_out; ps_muxer_input(_muxer.get(), track_info.track_id, frame->keyFrame() ? 0x0001 : 0, pts_out * 90LL, dts_out * 90LL, frame->data(), frame->size()); } diff --git a/src/Rtp/PSEncoder.h b/src/Rtp/PSEncoder.h index 4e643cc6..8ca8ce17 100644 --- a/src/Rtp/PSEncoder.h +++ b/src/Rtp/PSEncoder.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtp/ProcessInterface.h b/src/Rtp/ProcessInterface.h index c15879e1..ee5c0f53 100644 --- a/src/Rtp/ProcessInterface.h +++ b/src/Rtp/ProcessInterface.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -30,7 +30,7 @@ public: * @param data_len rtp数据长度 * @return 是否解析成功 */ - virtual bool inputRtp(bool is_udp, const char *data, int data_len) = 0; + virtual bool inputRtp(bool is_udp, const char *data, size_t data_len) = 0; }; }//namespace mediakit diff --git a/src/Rtp/RtpCache.cpp b/src/Rtp/RtpCache.cpp index 3069d306..44661273 100644 --- a/src/Rtp/RtpCache.cpp +++ b/src/Rtp/RtpCache.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtp/RtpCache.h b/src/Rtp/RtpCache.h index d0e94517..6162a1a0 100644 --- a/src/Rtp/RtpCache.h +++ b/src/Rtp/RtpCache.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtp/RtpProcess.cpp b/src/Rtp/RtpProcess.cpp index 942feec9..c234ae20 100644 --- a/src/Rtp/RtpProcess.cpp +++ b/src/Rtp/RtpProcess.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -70,7 +70,7 @@ RtpProcess::~RtpProcess() { } } -bool RtpProcess::inputRtp(bool is_udp, const Socket::Ptr &sock, const char *data, int len, const struct sockaddr *addr, uint32_t *dts_out) { +bool RtpProcess::inputRtp(bool is_udp, const Socket::Ptr &sock, const char *data, size_t len, const struct sockaddr *addr, uint32_t *dts_out) { GET_CONFIG(bool, check_source, RtpProxy::kCheckSource); //检查源是否合法 if (!_addr) { @@ -94,7 +94,7 @@ bool RtpProcess::inputRtp(bool is_udp, const Socket::Ptr &sock, const char *data _total_bytes += len; if (_save_file_rtp) { - uint16_t size = len; + uint16_t size = (uint16_t)len; size = htons(size); fwrite((uint8_t *) &size, 2, 1, _save_file_rtp.get()); fwrite((uint8_t *) data, len, 1, _save_file_rtp.get()); @@ -210,7 +210,7 @@ void RtpProcess::emitOnPublish() { if (err.empty()) { strongSelf->_muxer = std::make_shared(strongSelf->_media_info._vhost, strongSelf->_media_info._app, - strongSelf->_media_info._streamid, 0, + strongSelf->_media_info._streamid, 0.0f, true, true, enableHls, enableMP4); strongSelf->_muxer->setMediaListener(strongSelf); InfoP(strongSelf) << "允许RTP推流"; diff --git a/src/Rtp/RtpProcess.h b/src/Rtp/RtpProcess.h index 40e3d8cb..bd533553 100644 --- a/src/Rtp/RtpProcess.h +++ b/src/Rtp/RtpProcess.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -36,7 +36,7 @@ public: * @param dts_out 解析出最新的dts * @return 是否解析成功 */ - bool inputRtp(bool is_udp, const Socket::Ptr &sock, const char *data, int len, const struct sockaddr *addr , uint32_t *dts_out = nullptr); + bool inputRtp(bool is_udp, const Socket::Ptr &sock, const char *data, size_t len, const struct sockaddr *addr , uint32_t *dts_out = nullptr); /** * 是否超时,用于超时移除对象 diff --git a/src/Rtp/RtpSelector.cpp b/src/Rtp/RtpSelector.cpp index a589f843..57e84451 100644 --- a/src/Rtp/RtpSelector.cpp +++ b/src/Rtp/RtpSelector.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -22,7 +22,7 @@ void RtpSelector::clear(){ _map_rtp_process.clear(); } -bool RtpSelector::inputRtp(const Socket::Ptr &sock, const char *data, int data_len, +bool RtpSelector::inputRtp(const Socket::Ptr &sock, const char *data, size_t data_len, const struct sockaddr *addr,uint32_t *dts_out) { uint32_t ssrc = 0; if (!getSSRC(data, data_len, ssrc)) { @@ -41,7 +41,7 @@ bool RtpSelector::inputRtp(const Socket::Ptr &sock, const char *data, int data_l return false; } -bool RtpSelector::getSSRC(const char *data,int data_len, uint32_t &ssrc){ +bool RtpSelector::getSSRC(const char *data, size_t data_len, uint32_t &ssrc){ if (data_len < 12) { return false; } @@ -69,7 +69,7 @@ void RtpSelector::createTimer() { if (!_timer) { //创建超时管理定时器 weak_ptr weakSelf = shared_from_this(); - _timer = std::make_shared(3.0, [weakSelf] { + _timer = std::make_shared(3.0f, [weakSelf] { auto strongSelf = weakSelf.lock(); if (!strongSelf) { return false; diff --git a/src/Rtp/RtpSelector.h b/src/Rtp/RtpSelector.h index fbe61e9c..b37a8b42 100644 --- a/src/Rtp/RtpSelector.h +++ b/src/Rtp/RtpSelector.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -46,7 +46,7 @@ public: RtpSelector(); ~RtpSelector(); - static bool getSSRC(const char *data,int data_len, uint32_t &ssrc); + static bool getSSRC(const char *data,size_t data_len, uint32_t &ssrc); static RtpSelector &Instance(); /** @@ -63,7 +63,7 @@ public: * @param dts_out 解析出最新的dts * @return 是否成功 */ - bool inputRtp(const Socket::Ptr &sock, const char *data, int data_len, + bool inputRtp(const Socket::Ptr &sock, const char *data, size_t data_len, const struct sockaddr *addr, uint32_t *dts_out = nullptr); /** @@ -86,9 +86,9 @@ private: void createTimer(); private: - unordered_map _map_rtp_process; - recursive_mutex _mtx_map; Timer::Ptr _timer; + recursive_mutex _mtx_map; + unordered_map _map_rtp_process; }; }//namespace mediakit diff --git a/src/Rtp/RtpSender.cpp b/src/Rtp/RtpSender.cpp index 203b2567..0ca406b1 100644 --- a/src/Rtp/RtpSender.cpp +++ b/src/Rtp/RtpSender.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -127,8 +127,8 @@ void RtpSender::onFlushRtpList(shared_ptr > rtp_list) { auto is_udp = _is_udp; auto socket = _socket; _poller->async([rtp_list, is_udp, socket]() { - int i = 0; - int size = rtp_list->size(); + size_t i = 0; + auto size = rtp_list->size(); rtp_list->for_each([&](Buffer::Ptr &packet) { if (is_udp) { //udp模式,rtp over tcp前4个字节可以忽略 @@ -152,7 +152,7 @@ void RtpSender::onErr(const SockException &ex, bool is_connect) { } weak_ptr weak_self = shared_from_this(); - _connect_timer = std::make_shared(10.0, [weak_self]() { + _connect_timer = std::make_shared(10.0f, [weak_self]() { auto strong_self = weak_self.lock(); if (!strong_self) { return false; diff --git a/src/Rtp/RtpSender.h b/src/Rtp/RtpSender.h index 684c6fd4..243fe354 100644 --- a/src/Rtp/RtpSender.h +++ b/src/Rtp/RtpSender.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtp/RtpServer.cpp b/src/Rtp/RtpServer.cpp index cb4f79d9..42a4b73f 100644 --- a/src/Rtp/RtpServer.cpp +++ b/src/Rtp/RtpServer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtp/RtpServer.h b/src/Rtp/RtpServer.h index cc3d5aaa..9f8668ae 100644 --- a/src/Rtp/RtpServer.h +++ b/src/Rtp/RtpServer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtp/RtpSession.cpp b/src/Rtp/RtpSession.cpp index cfea27f6..fed21095 100644 --- a/src/Rtp/RtpSession.cpp +++ b/src/Rtp/RtpSession.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -56,7 +56,7 @@ void RtpSession::onManager() { } } -void RtpSession::onRtpPacket(const char *data, uint64_t len) { +void RtpSession::onRtpPacket(const char *data, size_t len) { if (len > 1024 * 10) { throw SockException(Err_shutdown, StrPrinter << "rtp包长度异常(" << len << "),发送端可能缓存溢出并覆盖"); } diff --git a/src/Rtp/RtpSession.h b/src/Rtp/RtpSession.h index 9c411b9a..60fa0654 100644 --- a/src/Rtp/RtpSession.h +++ b/src/Rtp/RtpSession.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -36,7 +36,7 @@ protected: // 观看总人数 int totalReaderCount(MediaSource &sender) override; // 收到rtp回调 - void onRtpPacket(const char *data, uint64_t len) override; + void onRtpPacket(const char *data, size_t len) override; private: Ticker _ticker; diff --git a/src/Rtp/RtpSplitter.cpp b/src/Rtp/RtpSplitter.cpp index 6cc8900b..9692b2ff 100644 --- a/src/Rtp/RtpSplitter.cpp +++ b/src/Rtp/RtpSplitter.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -19,7 +19,7 @@ static const int kEHOME_OFFSET = 256; RtpSplitter::RtpSplitter() {} RtpSplitter::~RtpSplitter() {} -int64_t RtpSplitter::onRecvHeader(const char *data,uint64_t len){ +size_t RtpSplitter::onRecvHeader(const char *data,size_t len){ //忽略偏移量 data += _offset; len -= _offset; @@ -34,14 +34,14 @@ int64_t RtpSplitter::onRecvHeader(const char *data,uint64_t len){ return 0; } -static bool isEhome(const char *data, uint64_t len){ +static bool isEhome(const char *data, size_t len){ if (len < 4) { return false; } return memcmp(data, kEHOME_MAGIC, sizeof(kEHOME_MAGIC) - 1) == 0; } -const char *RtpSplitter::onSearchPacketTail(const char *data, uint64_t len) { +const char *RtpSplitter::onSearchPacketTail(const char *data, size_t len) { if (len < 4) { //数据不够 return nullptr; @@ -70,7 +70,7 @@ const char *RtpSplitter::onSearchPacketTail(const char *data, uint64_t len) { return onSearchPacketTail_l(data, len); } -const char *RtpSplitter::onSearchPacketTail_l(const char *data, uint64_t len) { +const char *RtpSplitter::onSearchPacketTail_l(const char *data, size_t len) { //这是rtp包 uint16_t length = (((uint8_t *) data)[0] << 8) | ((uint8_t *) data)[1]; if (len < length + 2) { diff --git a/src/Rtp/RtpSplitter.h b/src/Rtp/RtpSplitter.h index 68e10cbc..e2cd9942 100644 --- a/src/Rtp/RtpSplitter.h +++ b/src/Rtp/RtpSplitter.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -27,16 +27,16 @@ protected: * @param data RTP包数据指针 * @param len RTP包数据长度 */ - virtual void onRtpPacket(const char *data, uint64_t len) = 0; + virtual void onRtpPacket(const char *data, size_t len) = 0; protected: - int64_t onRecvHeader(const char *data, uint64_t len) override; - const char *onSearchPacketTail(const char *data, uint64_t len) override; - const char *onSearchPacketTail_l(const char *data, uint64_t len); + size_t onRecvHeader(const char *data, size_t len) override; + const char *onSearchPacketTail(const char *data, size_t len) override; + const char *onSearchPacketTail_l(const char *data, size_t len); private: - int _offset = 0; bool _is_ehome = false; + size_t _offset = 0; }; }//namespace mediakit diff --git a/src/Rtp/TSDecoder.cpp b/src/Rtp/TSDecoder.cpp index 8bd2b995..7b8f1b28 100644 --- a/src/Rtp/TSDecoder.cpp +++ b/src/Rtp/TSDecoder.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -11,7 +11,7 @@ #include "TSDecoder.h" namespace mediakit { -bool TSSegment::isTSPacket(const char *data, int len){ +bool TSSegment::isTSPacket(const char *data, size_t len){ return len == TS_PACKET_SIZE && ((uint8_t*)data)[0] == TS_SYNC_BYTE; } @@ -19,7 +19,7 @@ void TSSegment::setOnSegment(const TSSegment::onSegment &cb) { _onSegment = cb; } -int64_t TSSegment::onRecvHeader(const char *data, uint64_t len) { +size_t TSSegment::onRecvHeader(const char *data, size_t len) { if (!isTSPacket(data, len)) { WarnL << "不是ts包:" << (int) (data[0]) << " " << len; return 0; @@ -28,7 +28,7 @@ int64_t TSSegment::onRecvHeader(const char *data, uint64_t len) { return 0; } -const char *TSSegment::onSearchPacketTail(const char *data, uint64_t len) { +const char *TSSegment::onSearchPacketTail(const char *data, size_t len) { if (len < _size + 1) { if (len == _size && ((uint8_t *) data)[0] == TS_SYNC_BYTE) { return data + _size; @@ -51,7 +51,7 @@ const char *TSSegment::onSearchPacketTail(const char *data, uint64_t len) { #if defined(ENABLE_HLS) #include "mpeg-ts.h" TSDecoder::TSDecoder() : _ts_segment() { - _ts_segment.setOnSegment([this](const char *data,uint64_t len){ + _ts_segment.setOnSegment([this](const char *data, size_t len){ ts_demuxer_input(_demuxer_ctx,(uint8_t*)data,len); }); _demuxer_ctx = ts_demuxer_create([](void* param, int program, int stream, int codecid, int flags, int64_t pts, int64_t dts, const void* data, size_t bytes){ @@ -77,7 +77,7 @@ TSDecoder::~TSDecoder() { ts_demuxer_destroy(_demuxer_ctx); } -int TSDecoder::input(const uint8_t *data, int bytes) { +size_t TSDecoder::input(const uint8_t *data, size_t bytes) { if (TSSegment::isTSPacket((char *)data, bytes)) { return ts_demuxer_input(_demuxer_ctx, (uint8_t *) data, bytes); } diff --git a/src/Rtp/TSDecoder.h b/src/Rtp/TSDecoder.h index 6f6b5d9d..533a0322 100644 --- a/src/Rtp/TSDecoder.h +++ b/src/Rtp/TSDecoder.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -24,16 +24,18 @@ namespace mediakit { //TS包分割器,用于split一个一个的ts包 class TSSegment : public HttpRequestSplitter { public: - typedef std::function onSegment; - TSSegment(int size = TS_PACKET_SIZE) : _size(size){} + typedef std::function onSegment; + TSSegment(size_t size = TS_PACKET_SIZE) : _size(size){} ~TSSegment(){} void setOnSegment(const onSegment &cb); - static bool isTSPacket(const char *data, int len); + static bool isTSPacket(const char *data, size_t len); + protected: - int64_t onRecvHeader(const char *data, uint64_t len) override ; - const char *onSearchPacketTail(const char *data, uint64_t len) override ; + size_t onRecvHeader(const char *data, size_t len) override ; + const char *onSearchPacketTail(const char *data, size_t len) override ; + private: - int _size; + size_t _size; onSegment _onSegment; }; @@ -43,7 +45,7 @@ class TSDecoder : public Decoder { public: TSDecoder(); ~TSDecoder(); - int input(const uint8_t* data, int bytes) override ; + size_t input(const uint8_t* data, size_t bytes) override ; void setOnDecode(onDecode cb) override; void setOnStream(onStream cb) override; diff --git a/src/Rtsp/RtpCodec.cpp b/src/Rtsp/RtpCodec.cpp index 6930b1e2..3292ced4 100644 --- a/src/Rtsp/RtpCodec.cpp +++ b/src/Rtsp/RtpCodec.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -12,44 +12,44 @@ namespace mediakit{ -RtpPacket::Ptr RtpInfo::makeRtp(TrackType type, const void* data, unsigned int len, bool mark, uint32_t uiStamp) { - uint16_t ui16RtpLen = len + 12; - uint32_t ts = htonl((_ui32SampleRate / 1000) * uiStamp); +RtpPacket::Ptr RtpInfo::makeRtp(TrackType type, const void* data, size_t len, bool mark, uint32_t stamp) { + uint16_t payload_len = (uint16_t)(len + 12); + uint32_t ts = htonl((_ui32SampleRate / 1000) * stamp); uint16_t sq = htons(_ui16Sequence); uint32_t sc = htonl(_ui32Ssrc); - auto rtppkt = ResourcePoolHelper::obtainObj(); - rtppkt->setCapacity(len + 16); - rtppkt->setSize(len + 16); + auto rtp_ptr = ResourcePoolHelper::obtainObj(); + rtp_ptr->setCapacity(len + 16); + rtp_ptr->setSize(len + 16); - unsigned char *pucRtp = (unsigned char *)rtppkt->data(); - pucRtp[0] = '$'; - pucRtp[1] = _ui8Interleaved; - pucRtp[2] = ui16RtpLen >> 8; - pucRtp[3] = ui16RtpLen & 0x00FF; - pucRtp[4] = 0x80; - pucRtp[5] = (mark << 7) | _ui8PayloadType; - memcpy(&pucRtp[6], &sq, 2); - memcpy(&pucRtp[8], &ts, 4); + auto *rtp = (unsigned char *)rtp_ptr->data(); + rtp[0] = '$'; + rtp[1] = _ui8Interleaved; + rtp[2] = payload_len >> 8; + rtp[3] = payload_len & 0xFF; + rtp[4] = 0x80; + rtp[5] = (mark << 7) | _ui8PayloadType; + memcpy(&rtp[6], &sq, 2); + memcpy(&rtp[8], &ts, 4); //ssrc - memcpy(&pucRtp[12], &sc, 4); + memcpy(&rtp[12], &sc, 4); if(data){ //payload - memcpy(&pucRtp[16], data, len); + memcpy(&rtp[16], data, len); } - rtppkt->PT = _ui8PayloadType; - rtppkt->interleaved = _ui8Interleaved; - rtppkt->mark = mark; - rtppkt->sequence = _ui16Sequence; - rtppkt->timeStamp = uiStamp; - rtppkt->ssrc = _ui32Ssrc; - rtppkt->type = type; - rtppkt->offset = 16; + rtp_ptr->PT = _ui8PayloadType; + rtp_ptr->interleaved = _ui8Interleaved; + rtp_ptr->mark = mark; + rtp_ptr->sequence = _ui16Sequence; + rtp_ptr->timeStamp = stamp; + rtp_ptr->ssrc = _ui32Ssrc; + rtp_ptr->type = type; + rtp_ptr->offset = 16; _ui16Sequence++; - _ui32TimeStamp = uiStamp; - return rtppkt; + _ui32TimeStamp = stamp; + return rtp_ptr; } }//namespace mediakit diff --git a/src/Rtsp/RtpCodec.h b/src/Rtsp/RtpCodec.h index ef4bed35..b3cb639a 100644 --- a/src/Rtsp/RtpCodec.h +++ b/src/Rtsp/RtpCodec.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -105,7 +105,7 @@ public: uint32_t getMtuSize() const { return _ui32MtuSize; } - RtpPacket::Ptr makeRtp(TrackType type,const void *pData, unsigned int uiLen, bool bMark, uint32_t uiStamp); + RtpPacket::Ptr makeRtp(TrackType type,const void *data, size_t len, bool mark, uint32_t stamp); protected: uint32_t _ui32Ssrc; diff --git a/src/Rtsp/RtpMultiCaster.cpp b/src/Rtsp/RtpMultiCaster.cpp index 27226540..2b2f7eba 100644 --- a/src/Rtsp/RtpMultiCaster.cpp +++ b/src/Rtsp/RtpMultiCaster.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -132,8 +132,8 @@ RtpMultiCaster::RtpMultiCaster(SocketHelper &helper, const string &local_ip, con _rtp_reader = src->getRing()->attach(helper.getPoller()); _rtp_reader->setReadCB([this](const RtspMediaSource::RingDataType &pkt) { - int i = 0; - int size = pkt->size(); + size_t i = 0; + auto size = pkt->size(); pkt->for_each([&](const RtpPacket::Ptr &rtp) { auto &sock = _udp_sock[rtp->type]; sock->send(std::make_shared(rtp, 4), nullptr, 0, ++i == size); diff --git a/src/Rtsp/RtpMultiCaster.h b/src/Rtsp/RtpMultiCaster.h index 8f8e76a6..8303ed42 100644 --- a/src/Rtsp/RtpMultiCaster.h +++ b/src/Rtsp/RtpMultiCaster.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtsp/RtpReceiver.cpp b/src/Rtsp/RtpReceiver.cpp index 977a3d4a..620d8319 100644 --- a/src/Rtsp/RtpReceiver.cpp +++ b/src/Rtsp/RtpReceiver.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -30,7 +30,7 @@ RtpReceiver::RtpReceiver() { } RtpReceiver::~RtpReceiver() {} -bool RtpReceiver::handleOneRtp(int track_index, TrackType type, int samplerate, unsigned char *rtp_raw_ptr, unsigned int rtp_raw_len) { +bool RtpReceiver::handleOneRtp(int track_index, TrackType type, int samplerate, unsigned char *rtp_raw_ptr, size_t rtp_raw_len) { if (rtp_raw_len < 12) { WarnL << "rtp包太小:" << rtp_raw_len; return false; @@ -128,8 +128,8 @@ bool RtpReceiver::handleOneRtp(int track_index, TrackType type, int samplerate, uint8_t *payload_ptr = (uint8_t *) rtp.data(); payload_ptr[0] = '$'; payload_ptr[1] = rtp.interleaved; - payload_ptr[2] = rtp_raw_len >> 8; - payload_ptr[3] = (rtp_raw_len & 0x00FF); + payload_ptr[2] = (rtp_raw_len >> 8) & 0xFF; + payload_ptr[3] = rtp_raw_len & 0xFF; //添加rtp over tcp前4个字节的偏移量 rtp.offset += 4; //拷贝rtp负载 @@ -148,15 +148,15 @@ void RtpReceiver::clear() { } } -void RtpReceiver::setPoolSize(int size) { +void RtpReceiver::setPoolSize(size_t size) { _rtp_pool.setSize(size); } -int RtpReceiver::getJitterSize(int track_index) const{ +size_t RtpReceiver::getJitterSize(int track_index) const{ return _rtp_sortor[track_index].getJitterSize(); } -int RtpReceiver::getCycleCount(int track_index) const{ +size_t RtpReceiver::getCycleCount(int track_index) const{ return _rtp_sortor[track_index].getCycleCount(); } diff --git a/src/Rtsp/RtpReceiver.h b/src/Rtsp/RtpReceiver.h index 9832f649..4aab788a 100644 --- a/src/Rtsp/RtpReceiver.h +++ b/src/Rtsp/RtpReceiver.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -21,7 +21,7 @@ using namespace toolkit; namespace mediakit { -template +template class PacketSortor { public: PacketSortor() = default; @@ -44,14 +44,14 @@ public: /** * 获取排序缓存长度 */ - int getJitterSize() const{ + size_t getJitterSize() const{ return _rtp_sort_cache_map.size(); } /** * 获取seq回环次数 */ - int getCycleCount() const{ + size_t getCycleCount() const{ return _seq_cycle_count; } @@ -151,9 +151,9 @@ private: //下次应该输出的SEQ SEQ _next_seq_out = 0; //seq回环次数计数 - uint32_t _seq_cycle_count = 0; + size_t _seq_cycle_count = 0; //排序缓存长度 - uint32_t _max_sort_size = kMin; + size_t _max_sort_size = kMin; //rtp排序缓存,根据seq排序 map _rtp_sort_cache_map; //回调 @@ -175,7 +175,7 @@ protected: * @param rtp_raw_len rtp数据指针长度 * @return 解析成功返回true */ - bool handleOneRtp(int track_index, TrackType type, int samplerate, unsigned char *rtp_raw_ptr, unsigned int rtp_raw_len); + bool handleOneRtp(int track_index, TrackType type, int samplerate, unsigned char *rtp_raw_ptr, size_t rtp_raw_len); /** * rtp数据包排序后输出 @@ -185,15 +185,15 @@ protected: virtual void onRtpSorted(const RtpPacket::Ptr &rtp, int track_index) {} void clear(); - void setPoolSize(int size); - int getJitterSize(int track_index) const; - int getCycleCount(int track_index) const; + void setPoolSize(size_t size); + size_t getJitterSize(int track_index) const; + size_t getCycleCount(int track_index) const; uint32_t getSSRC(int track_index) const; private: uint32_t _ssrc[2] = {0, 0}; //ssrc不匹配计数 - uint32_t _ssrc_err_count[2] = {0, 0}; + size_t _ssrc_err_count[2] = {0, 0}; //rtp排序缓存,根据seq排序 PacketSortor _rtp_sortor[2]; //rtp循环池 diff --git a/src/Rtsp/Rtsp.cpp b/src/Rtsp/Rtsp.cpp index f63bd30a..0467dc38 100644 --- a/src/Rtsp/Rtsp.cpp +++ b/src/Rtsp/Rtsp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -215,8 +215,8 @@ void SdpParser::load(const string &sdp) { if (strcmp(start, "now") == 0) { strcpy(start, "0"); } - track._start = atof(start); - track._end = atof(end); + track._start = (float)atof(start); + track._end = (float)atof(end); track._duration = track._end - track._start; } } diff --git a/src/Rtsp/Rtsp.h b/src/Rtsp/Rtsp.h index eb27510b..e57cf74a 100644 --- a/src/Rtsp/Rtsp.h +++ b/src/Rtsp/Rtsp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -71,15 +71,15 @@ typedef enum { class RtpPacket : public BufferRaw{ public: typedef std::shared_ptr Ptr; + bool mark; uint8_t interleaved; uint8_t PT; - bool mark; + TrackType type; + uint16_t sequence; //时间戳,单位毫秒 uint32_t timeStamp; - uint16_t sequence; uint32_t ssrc; - uint32_t offset; - TrackType type; + size_t offset; }; class RtpPayload{ diff --git a/src/Rtsp/RtspDemuxer.cpp b/src/Rtsp/RtspDemuxer.cpp index cee1aab4..151e51d9 100644 --- a/src/Rtsp/RtspDemuxer.cpp +++ b/src/Rtsp/RtspDemuxer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtsp/RtspDemuxer.h b/src/Rtsp/RtspDemuxer.h index ae98e48a..082ccf6d 100644 --- a/src/Rtsp/RtspDemuxer.h +++ b/src/Rtsp/RtspDemuxer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtsp/RtspMediaSource.h b/src/Rtsp/RtspMediaSource.h index 77b5d97b..5ad736d1 100644 --- a/src/Rtsp/RtspMediaSource.h +++ b/src/Rtsp/RtspMediaSource.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtsp/RtspMediaSourceImp.h b/src/Rtsp/RtspMediaSourceImp.h index a5cf5130..4ecc93b7 100644 --- a/src/Rtsp/RtspMediaSourceImp.h +++ b/src/Rtsp/RtspMediaSourceImp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtsp/RtspMediaSourceMuxer.h b/src/Rtsp/RtspMediaSourceMuxer.h index 18059910..b03cf1fc 100644 --- a/src/Rtsp/RtspMediaSourceMuxer.h +++ b/src/Rtsp/RtspMediaSourceMuxer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtsp/RtspMuxer.cpp b/src/Rtsp/RtspMuxer.cpp index cb6e3969..f9af385e 100644 --- a/src/Rtsp/RtspMuxer.cpp +++ b/src/Rtsp/RtspMuxer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtsp/RtspMuxer.h b/src/Rtsp/RtspMuxer.h index 89251e6c..97cd1000 100644 --- a/src/Rtsp/RtspMuxer.h +++ b/src/Rtsp/RtspMuxer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index 4f1dc306..59ad0e15 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -89,7 +89,7 @@ void RtspPlayer::play(const string &strUrl){ DebugL << url._url << " " << (url._user.size() ? url._user : "null") << " " << (url._passwd.size() ? url._passwd : "null") << " " << _rtp_type; weak_ptr weakSelf = dynamic_pointer_cast(shared_from_this()); - float playTimeOutSec = (*this)[kTimeoutMS].as() / 1000.0; + float playTimeOutSec = (*this)[kTimeoutMS].as() / 1000.0f; _play_check_timer.reset(new Timer(playTimeOutSec, [weakSelf]() { auto strongSelf=weakSelf.lock(); if(!strongSelf) { @@ -197,10 +197,6 @@ void RtspPlayer::handleResDESCRIBE(const Parser& parser) { //解析sdp _sdp_track = sdpParser.getAvailableTrack(); auto title = sdpParser.getTrack(TrackTitle); - bool is_play_back = false; - if(title && title->_duration ){ - is_play_back = true; - } if (_sdp_track.empty()) { throw std::runtime_error("无有效的Sdp Track"); @@ -455,7 +451,7 @@ void RtspPlayer::handleResPAUSE(const Parser& parser,int type) { if (strStart == "now") { strStart = "0"; } - iSeekTo = 1000 * atof(strStart.data()); + iSeekTo = (uint32_t)(1000 * atof(strStart.data())); DebugL << "seekTo(ms):" << iSeekTo; } @@ -476,7 +472,7 @@ void RtspPlayer::onWholeRtspPacket(Parser &parser) { } } -void RtspPlayer::onRtpPacket(const char *data, uint64_t len) { +void RtspPlayer::onRtpPacket(const char *data, size_t len) { int trackIdx = -1; uint8_t interleaved = data[1]; if(interleaved %2 == 0){ @@ -489,7 +485,7 @@ void RtspPlayer::onRtpPacket(const char *data, uint64_t len) { } //此处预留rtcp处理函数 -void RtspPlayer::onRtcpPacket(int track_idx, SdpTrack::Ptr &track, unsigned char *data, unsigned int len){} +void RtspPlayer::onRtcpPacket(int track_idx, SdpTrack::Ptr &track, unsigned char *data, size_t len){} #if 0 //改代码提取自FFmpeg,参考之 @@ -582,13 +578,13 @@ void RtspPlayer::sendReceiverReport(bool over_tcp, int track_idx){ pui8Rtcp_RR[15] = 0x00; //FIXME: max sequence received - int cycleCount = getCycleCount(track_idx); - pui8Rtcp_RR[16] = cycleCount >> 8; + uint16_t cycleCount = (uint16_t)getCycleCount(track_idx); + pui8Rtcp_RR[16] = (cycleCount >> 8) & 0xFF; pui8Rtcp_RR[17] = cycleCount & 0xFF; pui8Rtcp_RR[18] = counter.pktCnt >> 8; pui8Rtcp_RR[19] = counter.pktCnt & 0xFF; - uint32_t jitter = htonl(getJitterSize(track_idx)); + uint32_t jitter = htonl((uint32_t)getJitterSize(track_idx)); //FIXME: jitter memcpy(pui8Rtcp_RR + 20, &jitter, 4); /* last SR timestamp */ @@ -636,7 +632,7 @@ float RtspPlayer::getPacketLossRate(TrackType type) const{ if (_rtp_seq_now[track_idx] - _rtp_seq_start[track_idx] + 1 == 0) { return 0; } - return 1.0 - (double) _rtp_recv_count[track_idx] / (_rtp_seq_now[track_idx] - _rtp_seq_start[track_idx] + 1); + return (float)(1.0f - (double) _rtp_recv_count[track_idx] / (_rtp_seq_now[track_idx] - _rtp_seq_start[track_idx] + 1)); } catch (...) { uint64_t totalRecv = 0; uint64_t totalSend = 0; @@ -647,7 +643,7 @@ float RtspPlayer::getPacketLossRate(TrackType type) const{ if (totalSend == 0) { return 0; } - return 1.0 - (double) totalRecv / totalSend; + return (float)(1.0f - (double) totalRecv / totalSend); } } @@ -710,7 +706,7 @@ void RtspPlayer::sendRtspRequest(const string &cmd, const string &url,const StrC //base64认证 string authStr = StrPrinter << (*this)[kRtspUser] << ":" << (*this)[kRtspPwd]; char authStrBase64[1024] = {0}; - av_base64_encode(authStrBase64,sizeof(authStrBase64),(uint8_t *)authStr.data(),authStr.size()); + av_base64_encode(authStrBase64, sizeof(authStrBase64), (uint8_t *) authStr.data(), (int) authStr.size()); header.emplace("Authorization",StrPrinter << "Basic " << authStrBase64 ); } } @@ -794,7 +790,7 @@ void RtspPlayer::onPlayResult_l(const SockException &ex , bool handshake_done) { return true; }; //创建rtp数据接收超时检测定时器 - _rtp_check_timer = std::make_shared(timeoutMS / 2000.0, lam, getPoller()); + _rtp_check_timer = std::make_shared(timeoutMS / 2000.0f, lam, getPoller()); } else { sendTeardown(); } diff --git a/src/Rtsp/RtspPlayer.h b/src/Rtsp/RtspPlayer.h index fa459aa3..87f9e3de 100644 --- a/src/Rtsp/RtspPlayer.h +++ b/src/Rtsp/RtspPlayer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -62,7 +62,7 @@ protected: * @param data * @param len */ - void onRtpPacket(const char *data,uint64_t len) override ; + void onRtpPacket(const char *data,size_t len) override ; /** * rtp数据包排序后输出 @@ -78,7 +78,7 @@ protected: * @param data rtcp内容 * @param len rtcp内容长度 */ - virtual void onRtcpPacket(int track_idx, SdpTrack::Ptr &track, unsigned char *data, unsigned int len); + virtual void onRtcpPacket(int track_idx, SdpTrack::Ptr &track, unsigned char *data, size_t len); /////////////TcpClient override///////////// void onConnect(const SockException &err) override; diff --git a/src/Rtsp/RtspPlayerImp.h b/src/Rtsp/RtspPlayerImp.h index 814a4299..af9c031b 100644 --- a/src/Rtsp/RtspPlayerImp.h +++ b/src/Rtsp/RtspPlayerImp.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -44,7 +44,7 @@ public: void seekTo(float fProgress) override { fProgress = MAX(float(0), MIN(fProgress, float(1.0))); - seekToMilliSecond(fProgress * getDuration() * 1000); + seekToMilliSecond((uint32_t)(fProgress * getDuration() * 1000)); } private: diff --git a/src/Rtsp/RtspPusher.cpp b/src/Rtsp/RtspPusher.cpp index 5b330785..db7eba9d 100644 --- a/src/Rtsp/RtspPusher.cpp +++ b/src/Rtsp/RtspPusher.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -76,7 +76,7 @@ void RtspPusher::publish(const string &url_str) { << (url._passwd.size() ? url._passwd : "null") << " " << _rtp_type; weak_ptr weak_self = dynamic_pointer_cast(shared_from_this()); - float publish_timeout_sec = (*this)[kTimeoutMS].as() / 1000.0; + float publish_timeout_sec = (*this)[kTimeoutMS].as() / 1000.0f; _publish_timer.reset(new Timer(publish_timeout_sec, [weak_self]() { auto strong_self = weak_self.lock(); if (!strong_self) { @@ -316,8 +316,8 @@ void RtspPusher::sendOptions() { inline void RtspPusher::sendRtpPacket(const RtspMediaSource::RingDataType &pkt) { switch (_rtp_type) { case Rtsp::RTP_TCP: { - int i = 0; - int size = pkt->size(); + size_t i = 0; + auto size = pkt->size(); setSendFlushFlag(false); pkt->for_each([&](const RtpPacket::Ptr &rtp) { if (++i == size) { @@ -330,8 +330,8 @@ inline void RtspPusher::sendRtpPacket(const RtspMediaSource::RingDataType &pkt) } case Rtsp::RTP_UDP: { - int i = 0; - int size = pkt->size(); + size_t i = 0; + auto size = pkt->size(); pkt->for_each([&](const RtpPacket::Ptr &rtp) { int iTrackIndex = getTrackIndexByTrackType(rtp->type); auto &pSock = _udp_socks[iTrackIndex]; @@ -385,7 +385,7 @@ void RtspPusher::sendRecord() { }); if (_rtp_type != Rtsp::RTP_TCP) { /////////////////////////心跳///////////////////////////////// - _beat_timer.reset(new Timer((*this)[kBeatIntervalMS].as() / 1000.0, [weak_self]() { + _beat_timer.reset(new Timer((*this)[kBeatIntervalMS].as() / 1000.0f, [weak_self]() { auto strong_self = weak_self.lock(); if (!strong_self) { return false; @@ -460,7 +460,7 @@ void RtspPusher::sendRtspRequest(const string &cmd, const string &url,const StrC //base64认证 string authStr = StrPrinter << (*this)[kRtspUser] << ":" << (*this)[kRtspPwd]; char authStrBase64[1024] = {0}; - av_base64_encode(authStrBase64, sizeof(authStrBase64), (uint8_t *) authStr.data(), authStr.size()); + av_base64_encode(authStrBase64, sizeof(authStrBase64), (uint8_t *) authStr.data(), (int)authStr.size()); header.emplace("Authorization", StrPrinter << "Basic " << authStrBase64); } } diff --git a/src/Rtsp/RtspPusher.h b/src/Rtsp/RtspPusher.h index 3d4225db..dd0b27ff 100644 --- a/src/Rtsp/RtspPusher.h +++ b/src/Rtsp/RtspPusher.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -51,7 +51,7 @@ protected: //RtspSplitter override void onWholeRtspPacket(Parser &parser) override ; - void onRtpPacket(const char *data,uint64_t len) override {}; + void onRtpPacket(const char *data,size_t len) override {}; private: void onPublishResult(const SockException &ex, bool handshake_done); diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index d016fa90..9cb2c7bc 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -170,7 +170,7 @@ void RtspSession::onWholeRtspPacket(Parser &parser) { parser.Clear(); } -void RtspSession::onRtpPacket(const char *data, uint64_t len) { +void RtspSession::onRtpPacket(const char *data, size_t len) { if(!_push_src){ return; } @@ -181,13 +181,13 @@ void RtspSession::onRtpPacket(const char *data, uint64_t len) { handleOneRtp(track_idx, _sdp_track[track_idx]->_type, _sdp_track[track_idx]->_samplerate, (unsigned char *) data + 4, len - 4); }else{ auto track_idx = getTrackIndexByInterleaved(interleaved - 1); - onRtcpPacket(track_idx, _sdp_track[track_idx], (unsigned char *) data + 4, len - 4); + onRtcpPacket(track_idx, _sdp_track[track_idx], data + 4, len - 4); } } -void RtspSession::onRtcpPacket(int track_idx, SdpTrack::Ptr &track, unsigned char *data, unsigned int len){} +void RtspSession::onRtcpPacket(int track_idx, SdpTrack::Ptr &track, const char *data, size_t len){} -int64_t RtspSession::getContentLength(Parser &parser) { +size_t RtspSession::getContentLength(Parser &parser) { if(parser.Method() == "POST"){ //http post请求的content数据部分是base64编码后的rtsp请求信令包 return remainDataSize(); @@ -438,7 +438,7 @@ void RtspSession::onAuthFailed(const string &realm,const string &why,bool close) void RtspSession::onAuthBasic(const string &realm,const string &auth_base64){ //base64认证 char user_pwd_buf[512]; - av_base64_decode((uint8_t *) user_pwd_buf, auth_base64.data(), auth_base64.size()); + av_base64_decode((uint8_t *) user_pwd_buf, auth_base64.data(), (int)auth_base64.size()); auto user_pwd_vec = split(user_pwd_buf, ":"); if (user_pwd_vec.size() < 2) { //认证信息格式不合法,回复401 Unauthorized @@ -767,9 +767,9 @@ void RtspSession::handleReq_Play(const Parser &parser) { if (strStart == "now") { strStart = "0"; } - iStartTime = 1000 * atof(strStart.data()); + iStartTime = 1000 * (float)atof(strStart.data()); InfoP(this) << "rtsp seekTo(ms):" << iStartTime; - useGOP = !play_src->seekTo(iStartTime); + useGOP = !play_src->seekTo((uint32_t)iStartTime); } else if (play_src->totalReaderCount() == 0) { //第一个消费者 play_src->seekTo(0); @@ -933,7 +933,7 @@ inline void RtspSession::onRcvPeerUdpData(int interleaved, const Buffer::Ptr &bu _udp_connected_flags.emplace(interleaved); _rtcp_socks[(interleaved - 1) / 2]->setSendPeerAddr(&addr); } - onRtcpPacket((interleaved - 1) / 2, _sdp_track[(interleaved - 1) / 2], (unsigned char *) buf->data(), buf->size()); + onRtcpPacket((interleaved - 1) / 2, _sdp_track[(interleaved - 1) / 2], buf->data(), buf->size()); } } @@ -1030,7 +1030,7 @@ bool RtspSession::sendRtspResponse(const string &res_code, const StrCaseMap &hea return send(std::make_shared(std::move(printer))) > 0 ; } -int RtspSession::send(Buffer::Ptr pkt){ +size_t RtspSession::send(Buffer::Ptr pkt){ // if(!_enableSendRtp){ // DebugP(this) << pkt->data(); // } @@ -1134,8 +1134,8 @@ inline void RtspSession::onSendRtpPacket(const RtpPacket::Ptr &pkt){ void RtspSession::sendRtpPacket(const RtspMediaSource::RingDataType &pkt) { switch (_rtp_type) { case Rtsp::RTP_TCP: { - int i = 0; - int size = pkt->size(); + size_t i = 0; + auto size = pkt->size(); setSendFlushFlag(false); pkt->for_each([&](const RtpPacket::Ptr &rtp) { onSendRtpPacket(rtp); @@ -1147,8 +1147,8 @@ void RtspSession::sendRtpPacket(const RtspMediaSource::RingDataType &pkt) { } break; case Rtsp::RTP_UDP: { - int i = 0; - int size = pkt->size(); + size_t i = 0; + auto size = pkt->size(); pkt->for_each([&](const RtpPacket::Ptr &rtp) { onSendRtpPacket(rtp); int track_index = getTrackIndexByTrackType(rtp->type); @@ -1188,8 +1188,8 @@ void RtspSession::sendSenderReport(bool over_tcp, int track_index) { uint32_t ssrc = htonl(track->_ssrc); memcpy(&rtcp_sr[4], &ssrc, 4); - uint64_t msw; - uint64_t lsw; + uint32_t msw; + uint32_t lsw; struct timeval tv; gettimeofday(&tv, NULL); msw = tv.tv_sec + 0x83AA7E80; /* 0x83AA7E80 is the number of seconds from 1900 to 1970 */ diff --git a/src/Rtsp/RtspSession.h b/src/Rtsp/RtspSession.h index 23dd52bb..a1e15094 100644 --- a/src/Rtsp/RtspSession.h +++ b/src/Rtsp/RtspSession.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -37,20 +37,20 @@ class RtspSession; class BufferRtp : public Buffer{ public: typedef std::shared_ptr Ptr; - BufferRtp(Buffer::Ptr pkt, uint32_t offset = 0) : _rtp(std::move(pkt)), _offset(offset) {} + BufferRtp(Buffer::Ptr pkt, size_t offset = 0) : _offset(offset),_rtp(std::move(pkt)) {} ~BufferRtp() override{} char *data() const override { return (char *)_rtp->data() + _offset; } - uint32_t size() const override { + size_t size() const override { return _rtp->size() - _offset; } private: + size_t _offset; Buffer::Ptr _rtp; - uint32_t _offset; }; class RtspSession: public TcpSession, public RtspSplitter, public RtpReceiver , public MediaSourceEvent{ @@ -73,9 +73,9 @@ protected: //收到完整的rtsp包回调,包括sdp等content数据 void onWholeRtspPacket(Parser &parser) override; //收到rtp包回调 - void onRtpPacket(const char *data, uint64_t len) override; + void onRtpPacket(const char *data, size_t len) override; //从rtsp头中获取Content长度 - int64_t getContentLength(Parser &parser) override; + size_t getContentLength(Parser &parser) override; ////RtpReceiver override//// void onRtpSorted(const RtpPacket::Ptr &rtp, int track_idx) override; @@ -93,9 +93,9 @@ protected: std::shared_ptr getOriginSock(MediaSource &sender) const override; /////TcpSession override//// - int send(Buffer::Ptr pkt) override; + size_t send(Buffer::Ptr pkt) override; //收到RTCP包回调 - virtual void onRtcpPacket(int track_idx, SdpTrack::Ptr &track, unsigned char *data, unsigned int len); + virtual void onRtcpPacket(int track_idx, SdpTrack::Ptr &track, const char *data, size_t len); private: //处理options方法,获取服务器能力 @@ -171,7 +171,7 @@ private: //收到的seq,回复时一致 int _cseq = 0; //rtsp推流起始时间戳,目的是为了同步 - int64_t _start_stamp[2] = {-1, -1}; + int32_t _start_stamp[2] = {-1, -1}; //消耗的总流量 uint64_t _bytes_usage = 0; //ContentBase diff --git a/src/Rtsp/RtspSplitter.cpp b/src/Rtsp/RtspSplitter.cpp index 527659af..e647423b 100644 --- a/src/Rtsp/RtspSplitter.cpp +++ b/src/Rtsp/RtspSplitter.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -15,7 +15,7 @@ namespace mediakit{ -const char *RtspSplitter::onSearchPacketTail(const char *data, uint64_t len) { +const char *RtspSplitter::onSearchPacketTail(const char *data, size_t len) { auto ret = onSearchPacketTail_l(data, len); if(ret){ return ret; @@ -32,7 +32,7 @@ const char *RtspSplitter::onSearchPacketTail(const char *data, uint64_t len) { return ret; } -const char *RtspSplitter::onSearchPacketTail_l(const char *data, uint64_t len) { +const char *RtspSplitter::onSearchPacketTail_l(const char *data, size_t len) { if(!_enableRecvRtp || data[0] != '$'){ //这是rtsp包 _isRtpPacket = false; @@ -53,7 +53,7 @@ const char *RtspSplitter::onSearchPacketTail_l(const char *data, uint64_t len) { return data + 4 + length; } -int64_t RtspSplitter::onRecvHeader(const char *data, uint64_t len) { +size_t RtspSplitter::onRecvHeader(const char *data, size_t len) { if(_isRtpPacket){ onRtpPacket(data,len); return 0; @@ -67,7 +67,7 @@ int64_t RtspSplitter::onRecvHeader(const char *data, uint64_t len) { return ret; } -void RtspSplitter::onRecvContent(const char *data, uint64_t len) { +void RtspSplitter::onRecvContent(const char *data, size_t len) { _parser.setContent(string(data,len)); onWholeRtspPacket(_parser); _parser.Clear(); @@ -77,7 +77,7 @@ void RtspSplitter::enableRecvRtp(bool enable) { _enableRecvRtp = enable; } -int64_t RtspSplitter::getContentLength(Parser &parser) { +size_t RtspSplitter::getContentLength(Parser &parser) { return atoi(parser["Content-Length"].data()); } diff --git a/src/Rtsp/RtspSplitter.h b/src/Rtsp/RtspSplitter.h index a1a443c2..25bde7c5 100644 --- a/src/Rtsp/RtspSplitter.h +++ b/src/Rtsp/RtspSplitter.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -38,19 +38,21 @@ protected: * @param data * @param len */ - virtual void onRtpPacket(const char *data,uint64_t len) = 0; + virtual void onRtpPacket(const char *data,size_t len) = 0; /** * 从rtsp头中获取Content长度 * @param parser * @return */ - virtual int64_t getContentLength(Parser &parser); + virtual size_t getContentLength(Parser &parser); + protected: - const char *onSearchPacketTail(const char *data,uint64_t len) override ; - const char *onSearchPacketTail_l(const char *data,uint64_t len) ; - int64_t onRecvHeader(const char *data,uint64_t len) override; - void onRecvContent(const char *data,uint64_t len) override; + const char *onSearchPacketTail(const char *data,size_t len) override ; + const char *onSearchPacketTail_l(const char *data,size_t len) ; + size_t onRecvHeader(const char *data,size_t len) override; + void onRecvContent(const char *data,size_t len) override; + private: bool _enableRecvRtp = false; bool _isRtpPacket = false; diff --git a/src/Rtsp/UDPServer.cpp b/src/Rtsp/UDPServer.cpp index ce69652e..d721f9c6 100644 --- a/src/Rtsp/UDPServer.cpp +++ b/src/Rtsp/UDPServer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Rtsp/UDPServer.h b/src/Rtsp/UDPServer.h index 137eb576..ec2aa27d 100644 --- a/src/Rtsp/UDPServer.h +++ b/src/Rtsp/UDPServer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Shell/ShellCMD.h b/src/Shell/ShellCMD.h index a401f73f..b0697725 100644 --- a/src/Shell/ShellCMD.h +++ b/src/Shell/ShellCMD.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/Shell/ShellSession.cpp b/src/Shell/ShellSession.cpp index 0345d879..368ee395 100644 --- a/src/Shell/ShellSession.cpp +++ b/src/Shell/ShellSession.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -79,7 +79,7 @@ inline bool ShellSession::onCommandLine(const string& line) { std::shared_ptr ss(new stringstream); CMDRegister::Instance()(line,ss); SockSender::send(ss->str()); - }catch(ExitException &ex){ + }catch(ExitException &){ return false; }catch(std::exception &ex){ SockSender::send(ex.what()); diff --git a/src/Shell/ShellSession.h b/src/Shell/ShellSession.h index dd7d1bb6..5d38b503 100644 --- a/src/Shell/ShellSession.h +++ b/src/Shell/ShellSession.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/TS/TSMediaSource.h b/src/TS/TSMediaSource.h index 10e6fe77..b0d2f03a 100644 --- a/src/TS/TSMediaSource.h +++ b/src/TS/TSMediaSource.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/src/TS/TSMediaSourceMuxer.h b/src/TS/TSMediaSourceMuxer.h index a8cf9efc..46a3725b 100644 --- a/src/TS/TSMediaSourceMuxer.h +++ b/src/TS/TSMediaSourceMuxer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -66,7 +66,7 @@ public: } protected: - void onTs(const void *data, int len,uint32_t timestamp,bool is_idr_fast_packet) override{ + void onTs(const void *data, size_t len,uint32_t timestamp,bool is_idr_fast_packet) override{ if(!data || !len){ return; } diff --git a/tests/DeviceHK/DeviceHK.cpp b/tests/DeviceHK/DeviceHK.cpp index 563cee8c..44cf5dd9 100644 --- a/tests/DeviceHK/DeviceHK.cpp +++ b/tests/DeviceHK/DeviceHK.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/tests/DeviceHK/DeviceHK.h b/tests/DeviceHK/DeviceHK.h index 92f5de64..22d69841 100644 --- a/tests/DeviceHK/DeviceHK.h +++ b/tests/DeviceHK/DeviceHK.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/tests/FFMpegDecoder.h b/tests/FFMpegDecoder.h index 465a87de..eccec883 100644 --- a/tests/FFMpegDecoder.h +++ b/tests/FFMpegDecoder.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/tests/YuvDisplayer.h b/tests/YuvDisplayer.h index 2b5fcf3c..1d29ec60 100644 --- a/tests/YuvDisplayer.h +++ b/tests/YuvDisplayer.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/tests/bom.cpp b/tests/bom.cpp index d541858b..8c778787 100644 --- a/tests/bom.cpp +++ b/tests/bom.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/tests/tab.cpp b/tests/tab.cpp index 98acd45e..c3512fe6 100644 --- a/tests/tab.cpp +++ b/tests/tab.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -44,8 +44,8 @@ public: vector split(const string& s, const char *delim) { vector ret; - int last = 0; - int index = s.find(delim, last); + size_t last = 0; + auto index = s.find(delim, last); while (index != string::npos) { if (index - last >= 0) { ret.push_back(s.substr(last, index - last)); diff --git a/tests/test_benchmark.cpp b/tests/test_benchmark.cpp index 75693fd9..595db720 100644 --- a/tests/test_benchmark.cpp +++ b/tests/test_benchmark.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/tests/test_httpApi.cpp b/tests/test_httpApi.cpp index 2c816714..29ef7b23 100644 --- a/tests/test_httpApi.cpp +++ b/tests/test_httpApi.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/tests/test_httpClient.cpp b/tests/test_httpClient.cpp index c4f7d35a..8f5b73e7 100644 --- a/tests/test_httpClient.cpp +++ b/tests/test_httpClient.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/tests/test_player.cpp b/tests/test_player.cpp index f6ff3e78..95421da5 100644 --- a/tests/test_player.cpp +++ b/tests/test_player.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/tests/test_pusher.cpp b/tests/test_pusher.cpp index fe7f1b0b..f79d4495 100644 --- a/tests/test_pusher.cpp +++ b/tests/test_pusher.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -56,7 +56,7 @@ void createPusher(const EventPoller::Ptr &poller, const string &schema,const str //推流失败或断开延迟2秒后重试推流 void rePushDelay(const EventPoller::Ptr &poller,const string &schema,const string &vhost,const string &app, const string &stream, const string &url) { - g_timer = std::make_shared(2,[poller,schema,vhost,app, stream, url]() { + g_timer = std::make_shared(2.0f,[poller,schema,vhost,app, stream, url]() { InfoL << "Re-Publishing..."; //重新推流 createPusher(poller,schema,vhost,app, stream, url); diff --git a/tests/test_pusherMp4.cpp b/tests/test_pusherMp4.cpp index 49fcf6fe..25ee64e9 100644 --- a/tests/test_pusherMp4.cpp +++ b/tests/test_pusherMp4.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors @@ -86,7 +86,7 @@ void rePushDelay(const EventPoller::Ptr &poller, const string &stream, const string &filePath, const string &url) { - g_timer = std::make_shared(2,[poller,schema,vhost,app, stream, filePath,url]() { + g_timer = std::make_shared(2.0f,[poller,schema,vhost,app, stream, filePath,url]() { InfoL << "Re-Publishing..."; //重新推流 createPusher(poller,schema,vhost,app, stream, filePath,url); diff --git a/tests/test_rtp.cpp b/tests/test_rtp.cpp index 24d9ac83..2c4b521e 100644 --- a/tests/test_rtp.cpp +++ b/tests/test_rtp.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/tests/test_server.cpp b/tests/test_server.cpp index 4e37b447..86506ee5 100644 --- a/tests/test_server.cpp +++ b/tests/test_server.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/tests/test_sortor.cpp b/tests/test_sortor.cpp index 7c697b82..19570706 100644 --- a/tests/test_sortor.cpp +++ b/tests/test_sortor.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/tests/test_wsClient.cpp b/tests/test_wsClient.cpp index 26b1970a..57b9e520 100644 --- a/tests/test_wsClient.cpp +++ b/tests/test_wsClient.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/tests/test_wsServer.cpp b/tests/test_wsServer.cpp index 1a342cef..6590baae 100644 --- a/tests/test_wsServer.cpp +++ b/tests/test_wsServer.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * - * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit). + * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). * * Use of this source code is governed by MIT license that can be found in the * LICENSE file in the root of the source tree. All contributing project authors diff --git a/www/readme/index.html b/www/readme/index.html index 964500e1..32a9e712 100644 --- a/www/readme/index.html +++ b/www/readme/index.html @@ -1,7 +1,7 @@ 欢迎使用ZLMediaKit -

欢迎使用ZLMediaKit,请阅读wiki 获取更多帮助!

+

欢迎使用ZLMediaKit,请阅读wiki 获取更多帮助!


ZLMediaKit