全面整理代码,去除编译警告

This commit is contained in:
xia-chu 2021-01-17 18:31:50 +08:00
parent fb1e35a39a
commit b6cbc87712
272 changed files with 936 additions and 933 deletions

1
.gitignore vendored
View File

@ -45,3 +45,4 @@
/build/ /build/
/3rdpart/media-server/.idea/ /3rdpart/media-server/.idea/
/ios/ /ios/
/cmake-build-*

@ -1 +1 @@
Subproject commit 53b5145e292e8ad6499bd5bbf4d52484303f41be Subproject commit 3b5de80f9effe28c4a38fef5beec50eadfc916cf

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -20,13 +20,14 @@ set(RELEASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/release)
if (CMAKE_SYSTEM_NAME MATCHES "Linux") if (CMAKE_SYSTEM_NAME MATCHES "Linux")
SET(LIBRARY_OUTPUT_PATH ${RELEASE_DIR}/linux/${BuildType}) SET(LIBRARY_OUTPUT_PATH ${RELEASE_DIR}/linux/${BuildType})
SET(EXECUTABLE_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") elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
SET(LIBRARY_OUTPUT_PATH ${RELEASE_DIR}/windows/${BuildType}) SET(LIBRARY_OUTPUT_PATH ${RELEASE_DIR}/windows/${BuildType})
SET(EXECUTABLE_OUTPUT_PATH ${RELEASE_DIR}/windows/${BuildType}) SET(EXECUTABLE_OUTPUT_PATH ${RELEASE_DIR}/windows/${BuildType})
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
SET(LIBRARY_OUTPUT_PATH ${RELEASE_DIR}/mac/${BuildType}) SET(LIBRARY_OUTPUT_PATH ${RELEASE_DIR}/mac/${BuildType})
SET(EXECUTABLE_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 () endif ()
LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH}) LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH})
@ -104,7 +105,8 @@ if(${CMAKE_BUILD_TYPE} MATCHES "Release")
endif() endif()
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" )
#mpegts #mpegts
if(ENABLE_HLS) if(ENABLE_HLS)
@ -167,7 +169,7 @@ if (NOT WIN32)
list(REMOVE_ITEM ToolKit_src_list ${ToolKit_Root}/win32/getopt.c) list(REMOVE_ITEM ToolKit_src_list ${ToolKit_Root}/win32/getopt.c)
else() else()
#Windows.hWinsock.h #Windows.hWinsock.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 () endif ()
# #

View File

@ -82,7 +82,7 @@ It is recommended to compile on Ubuntu or MacOScompiling on windows is cumber
### Before build ### 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:** - **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 cd ZLMediaKit
git submodule update --init git submodule update --init
``` ```

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -12,6 +12,7 @@
#define MK_COMMON_H #define MK_COMMON_H
#include <stdint.h> #include <stdint.h>
#include <stddef.h>
#if defined(_WIN32) #if defined(_WIN32)

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -148,8 +148,8 @@ typedef struct {
* @param is_player * @param is_player
*/ */
void (API_CALL *on_mk_flow_report)(const mk_media_info url_info, void (API_CALL *on_mk_flow_report)(const mk_media_info url_info,
uint64_t total_bytes, size_t total_bytes,
uint64_t total_seconds, size_t total_seconds,
int is_player, int is_player,
const mk_sock_info sender); const mk_sock_info sender);
} mk_events; } mk_events;

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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); API_EXPORT float API_CALL mk_mp4_info_get_time_len(const mk_mp4_info ctx);
// 文件大小,单位 BYTE // 文件大小,单位 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); 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头中特定字段 //Parser::getValues()["key"],获取HTTP头中特定字段
API_EXPORT const char* API_CALL mk_parser_get_header(const mk_parser ctx,const char *key); API_EXPORT const char* API_CALL mk_parser_get_header(const mk_parser ctx,const char *key);
//Parser::Content(),获取HTTP body //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/////////////////////////////////////////////
//MediaInfo对象的C映射 //MediaInfo对象的C映射
@ -143,7 +143,7 @@ typedef void* mk_http_body;
* @param str * @param str
* @param len 0strlen获取 * @param len 0strlen获取
*/ */
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 * HttpFileBody

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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 * @param length body长度,null
* @return body指针 * @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回复后可调用该方法获取响应 * HTTP回复后可调用该方法获取响应

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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 height
* @param fps fps * @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);
/** /**
* *

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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 dts
* @param pts * @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] * ,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 0H2641H2652AAC 3.G711A 4.G711U * codec_id -1 0H2641H2652AAC 3.G711A 4.G711U

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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() //TcpSession::safeShutdown()
API_EXPORT void API_CALL mk_tcp_session_shutdown(const mk_tcp_session ctx,int err,const char *err_msg); API_EXPORT void API_CALL mk_tcp_session_shutdown(const mk_tcp_session ctx,int err,const char *err_msg);
//TcpSession::send() //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() //切换到该对象所在线程后再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服务///////////////////////////////////////////// ///////////////////////////////////////////自定义tcp服务/////////////////////////////////////////////
@ -74,7 +74,7 @@ typedef struct {
* @param data * @param data
* @param len * @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 * 2
@ -164,7 +164,7 @@ typedef struct {
* @param data * @param data
* @param len * @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 * 2

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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 && ini[0]) {
//设置配置文件 //设置配置文件
if (ini_is_path) { if (ini_is_path) {
try{ try {
mINI::Instance().parseFile(ini); mINI::Instance().parseFile(ini);
}catch (std::exception &ex) { } catch (std::exception &) {
InfoL << "dump ini file to:" << ini; InfoL << "dump ini file to:" << ini;
mINI::Instance().dumpFile(ini); mINI::Instance().dumpFile(ini);
} }

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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; 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); assert(ctx);
RecordInfo *info = (RecordInfo *)ctx; RecordInfo *info = (RecordInfo *)ctx;
return info->file_size; 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; Parser *parser = (Parser *)ctx;
return parser->getHeader()[key].c_str(); 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); assert(ctx);
Parser *parser = (Parser *)ctx; Parser *parser = (Parser *)ctx;
if(length){ if(length){
@ -246,7 +246,7 @@ API_EXPORT void API_CALL mk_media_source_for_each(void *user_data, on_mk_media_s
} }
///////////////////////////////////////////HttpBody///////////////////////////////////////////// ///////////////////////////////////////////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); assert(str);
if(!len){ if(!len){
len = strlen(str); len = strlen(str);

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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(); 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); assert(ctx);
HttpRequester::Ptr *obj = (HttpRequester::Ptr *)ctx; HttpRequester::Ptr *obj = (HttpRequester::Ptr *)ctx;
if(length){ if(length){

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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; 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); assert(ctx);
MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx; MediaHelper::Ptr *obj = (MediaHelper::Ptr *) ctx;
VideoInfo info; VideoInfo info;

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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; 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); assert(ctx);
MediaPlayerForC &obj = **((MediaPlayerForC::Ptr *)ctx); MediaPlayerForC &obj = **((MediaPlayerForC::Ptr *)ctx);
auto track = dynamic_pointer_cast<VideoTrack>(obj->getTrack(TrackVideo)); auto track = dynamic_pointer_cast<VideoTrack>(obj->getTrack(TrackVideo));

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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)); 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); assert(ctx && data);
if(!len){ if(!len){
len = strlen(data); 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); 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); assert(ctx && data);
if(!len){ if(!len){
len = strlen(data); len = strlen(data);

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -15,15 +15,19 @@
using namespace std; using namespace std;
using namespace toolkit; using namespace toolkit;
#ifndef _WIN32
#define _strdup strdup
#endif
API_EXPORT char* API_CALL mk_util_get_exe_path(){ 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){ API_EXPORT char* API_CALL mk_util_get_exe_dir(const char *relative_path){
if(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(){ 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){ API_EXPORT char* API_CALL mk_util_get_current_time_string(const char *fmt){
assert(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){ API_EXPORT char* API_CALL mk_util_hex_dump(const void *buf, int len){
assert(buf && len > 0); 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, ...) { 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_list pArg;
va_start(pArg, fmt); va_start(pArg, fmt);
char buf[4096]; char buf[4096];
int n = vsprintf(buf, fmt, pArg); auto n = vsnprintf(buf, sizeof(buf), fmt, pArg);
buf[n] = '\0'; buf[n] = '\0';
va_end(pArg); va_end(pArg);
info << buf; info << buf;

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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 data
* @param len * @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]; 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); 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); 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 data
* @param len * @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); log_printf(LOG_LEV,"data[%d]:%s",len,data);
} }

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
cd .. cd ..
git clone --depth=1 https://github.com/xiongziliang/ZLMediaKit.git git clone --depth=1 https://github.com/xia-chu/ZLMediaKit.git
cd ZLMediaKit cd ZLMediaKit
git submodule init git submodule init
git submodule update git submodule update

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
cd .. cd ..
git clone --depth=1 https://github.com/xiongziliang/ZLMediaKit.git git clone --depth=1 https://github.com/xia-chu/ZLMediaKit.git
cd ZLMediaKit cd ZLMediaKit
git submodule init git submodule init
git submodule update git submodule update

View File

@ -32,7 +32,7 @@ RUN apt-get update && \
RUN mkdir -p /opt/media RUN mkdir -p /opt/media
WORKDIR /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 && \ cd ZLMediaKit && git submodule update --init --recursive && \
mkdir -p build release/linux/Release/ mkdir -p build release/linux/Release/

View File

@ -31,7 +31,7 @@ RUN apt-get update && \
RUN mkdir -p /opt/media RUN mkdir -p /opt/media
WORKDIR /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 && \ cd ZLMediaKit && git submodule update --init --recursive && \
mkdir -p build release/linux/Release/ mkdir -p build release/linux/Release/

View File

@ -33,7 +33,7 @@ RUN apt-get update && \
RUN mkdir -p /opt/media RUN mkdir -p /opt/media
WORKDIR /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 && \ cd ZLMediaKit && git submodule update --init --recursive && \
mkdir -p build release/linux/Release/ mkdir -p build release/linux/Release/

View File

@ -31,7 +31,7 @@ RUN apt-get update && \
RUN mkdir -p /opt/media RUN mkdir -p /opt/media
WORKDIR /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 && \ cd ZLMediaKit && git submodule update --init --recursive && \
mkdir -p build release/linux/Release/ mkdir -p build release/linux/Release/

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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{ } else{
//推流给其他服务器的通过判断FFmpeg进程是否在线判断是否成功 //推流给其他服务器的通过判断FFmpeg进程是否在线判断是否成功
weak_ptr<FFmpegSource> weakSelf = shared_from_this(); weak_ptr<FFmpegSource> weakSelf = shared_from_this();
_timer = std::make_shared<Timer>(timeout_ms / 1000,[weakSelf,cb,timeout_ms](){ _timer = std::make_shared<Timer>(timeout_ms / 1000.0f,[weakSelf,cb,timeout_ms](){
auto strongSelf = weakSelf.lock(); auto strongSelf = weakSelf.lock();
if(!strongSelf){ if(!strongSelf){
//自身已经销毁 //自身已经销毁
@ -191,7 +191,7 @@ void FFmpegSource::findAsync(int maxWaitMS, const function<void(const MediaSourc
*/ */
void FFmpegSource::startTimer(int timeout_ms) { void FFmpegSource::startTimer(int timeout_ms) {
weak_ptr<FFmpegSource> weakSelf = shared_from_this(); weak_ptr<FFmpegSource> weakSelf = shared_from_this();
_timer = std::make_shared<Timer>(1, [weakSelf, timeout_ms]() { _timer = std::make_shared<Timer>(1.0f, [weakSelf, timeout_ms]() {
auto strongSelf = weakSelf.lock(); auto strongSelf = weakSelf.lock();
if (!strongSelf) { if (!strongSelf) {
//自身已经销毁 //自身已经销毁
@ -294,7 +294,7 @@ void FFmpegSnap::makeSnap(const string &play_url, const string &save_path, float
std::shared_ptr<Process> process = std::make_shared<Process>(); std::shared_ptr<Process> process = std::make_shared<Process>();
process->run(cmd,ffmpeg_log.empty() ? "" : File::absolutePath("",ffmpeg_log)); 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)){ if(process->wait(false)){
//FFmpeg进程还在运行超时就关闭它 //FFmpeg进程还在运行超时就关闭它
process->kill(2000); process->kill(2000);

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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) { if (!fp) {
fprintf(stderr, "open log file %s failed:%d(%s)\r\n", log_file.data(), get_uv_error(), get_uv_errmsg()); fprintf(stderr, "open log file %s failed:%d(%s)\r\n", log_file.data(), get_uv_error(), get_uv_errmsg());
} else { } else {
auto log_fd = (HANDLE)(_get_osfhandle(fileno(fp))); auto log_fd = (HANDLE)(_get_osfhandle(_fileno(fp)));
// dup to stdout and stderr. // dup to stdout and stderr.
si.wShowWindow = SW_HIDE; si.wShowWindow = SW_HIDE;
// STARTF_USESHOWWINDOW:The wShowWindow member contains additional information. // STARTF_USESHOWWINDOW:The wShowWindow member contains additional information.

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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) { const HttpBody::Ptr &body) {
//body默认为空 //body默认为空
int64_t size = 0; size_t size = 0;
if (body && body->remainSize()) { if (body && body->remainSize()) {
//有body获取body大小 //有body获取body大小
size = body->remainSize(); size = body->remainSize();
@ -572,7 +572,7 @@ void installWebApi() {
CHECK_SECRET(); CHECK_SECRET();
uint16_t local_port = allArgs["local_port"].as<uint16_t>(); uint16_t local_port = allArgs["local_port"].as<uint16_t>();
string &peer_ip = allArgs["peer_ip"]; string &peer_ip = allArgs["peer_ip"];
uint64_t count_hit = 0; size_t count_hit = 0;
list<TcpSession::Ptr> session_list; list<TcpSession::Ptr> session_list;
SessionMap::Instance().for_each_session([&](const string &id,const TcpSession::Ptr &session){ SessionMap::Instance().for_each_session([&](const string &id,const TcpSession::Ptr &session){
@ -923,7 +923,7 @@ void installWebApi() {
Json::Value paths(arrayValue); Json::Value paths(arrayValue);
//这是筛选日期,获取文件夹列表 //这是筛选日期,获取文件夹列表
File::scanDir(record_path, [&](const string &path, bool isDir) { File::scanDir(record_path, [&](const string &path, bool isDir) {
int pos = path.rfind('/'); auto pos = path.rfind('/');
if (pos != string::npos) { if (pos != string::npos) {
string relative_path = path.substr(pos + 1); string relative_path = path.substr(pos + 1);
if (search_mp4) { if (search_mp4) {

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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; CMD_main cmd_main;
try { try {
cmd_main.operator()(argc, argv); cmd_main.operator()(argc, argv);
} catch (ExitException &ex) { } catch (ExitException &) {
return 0; return 0;
} catch (std::exception &ex) { } catch (std::exception &ex) {
cout << ex.what() << endl; cout << ex.what() << endl;

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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(const Track::Ptr &track);
void checkTrackIfReady_l(const Track::Ptr &track); void checkTrackIfReady_l(const Track::Ptr &track);
private: private:
bool _all_track_ready = false;
size_t _max_track_size = 2;
mutable recursive_mutex _mtx; mutable recursive_mutex _mtx;
unordered_map<int,Track::Ptr> _track_map; unordered_map<int,Track::Ptr> _track_map;
unordered_map<int,List<Frame::Ptr> > _frame_unread; unordered_map<int,List<Frame::Ptr> > _frame_unread;
unordered_map<int,function<void()> > _track_ready_callback; unordered_map<int,function<void()> > _track_ready_callback;
bool _all_track_ready = false;
Ticker _ticker; Ticker _ticker;
int _max_track_size = 2;
}; };

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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; bool is_mp4_vod = sender.getApp() == record_app;
weak_ptr<MediaSource> weak_sender = sender.shared_from_this(); weak_ptr<MediaSource> weak_sender = sender.shared_from_this();
_async_close_timer = std::make_shared<Timer>(stream_none_reader_delay / 1000.0, [weak_sender, is_mp4_vod]() { _async_close_timer = std::make_shared<Timer>(stream_none_reader_delay / 1000.0f, [weak_sender, is_mp4_vod]() {
auto strong_sender = weak_sender.lock(); auto strong_sender = weak_sender.lock();
if (!strong_sender) { if (!strong_sender) {
//对象已经销毁 //对象已经销毁
@ -672,7 +672,7 @@ std::shared_ptr<MediaSourceEvent> MediaSourceEventInterceptor::getDelegate() con
/////////////////////////////////////FlushPolicy////////////////////////////////////// /////////////////////////////////////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) { if (new_stamp + 500 < last_stamp) {
//时间戳回退比较大(可能seek中)由于rtp中时间戳是pts是可能存在一定程度的回退的 //时间戳回退比较大(可能seek中)由于rtp中时间戳是pts是可能存在一定程度的回退的
return true; 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; 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) { if (new_stamp + 500 < last_stamp) {
//时间戳回退比较大(可能seek中)由于rtp中时间戳是pts是可能存在一定程度的回退的 //时间戳回退比较大(可能seek中)由于rtp中时间戳是pts是可能存在一定程度的回退的
return true; 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; 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; bool flush_flag = false;
if (is_key && is_video) { if (is_key && is_video) {
//遇到关键帧flush掉前面的数据确保关键帧为该组数据的第一帧确保GOP缓存有效 //遇到关键帧flush掉前面的数据确保关键帧为该组数据的第一帧确保GOP缓存有效

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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; _bytes += bytes;
if (_bytes > 1024 * 1024) { if (_bytes > 1024 * 1024) {
//数据大于1MB就计算一次网速 //数据大于1MB就计算一次网速
@ -169,12 +169,12 @@ public:
} }
private: private:
uint64_t computeSpeed() { int computeSpeed() {
auto elapsed = _ticker.elapsedTime(); auto elapsed = _ticker.elapsedTime();
if (!elapsed) { if (!elapsed) {
return _speed; return _speed;
} }
_speed = _bytes * 1000 / elapsed; _speed = (int)(_bytes * 1000 / elapsed);
_ticker.resetTime(); _ticker.resetTime();
_bytes = 0; _bytes = 0;
return _speed; return _speed;
@ -182,7 +182,7 @@ private:
private: private:
int _speed = 0; int _speed = 0;
uint64_t _bytes = 0; size_t _bytes = 0;
Ticker _ticker; Ticker _ticker;
}; };
@ -304,7 +304,7 @@ public:
FlushPolicy() = default; FlushPolicy() = default;
~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: private:
uint64_t _last_stamp[2] = {0, 0}; uint64_t _last_stamp[2] = {0, 0};

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -404,14 +404,14 @@ public:
~FrameModifyStamp() override {} ~FrameModifyStamp() override {}
uint32_t dts() const override{ uint32_t dts() const override{
return _dts; return (uint32_t)_dts;
} }
uint32_t pts() const override{ uint32_t pts() const override{
return _pts; return (uint32_t)_pts;
} }
uint32_t prefixSize() const override { size_t prefixSize() const override {
return _frame->prefixSize(); return _frame->prefixSize();
} }
@ -431,7 +431,7 @@ public:
return _frame->data(); return _frame->data();
} }
uint32_t size() const override { size_t size() const override {
return _frame->size(); return _frame->size();
} }

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -12,12 +12,12 @@
namespace mediakit{ 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 ){ if(bufSize <=0 ){
bufSize = strlen(buf); bufSize = strlen(buf);
} }
const char *msg_start = buf, *msg_end = buf + bufSize; const char *msg_start = buf, *msg_end = buf + bufSize;
int len = 0; size_t len = 0;
if (start != NULL) { if (start != NULL) {
len = strlen(start); len = strlen(start);
msg_start = strstr(buf, start); msg_start = strstr(buf, start);

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -19,7 +19,7 @@ using namespace toolkit;
namespace mediakit{ 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 { struct StrCaseCompare {
bool operator()(const string &__x, const string &__y) const { bool operator()(const string &__x, const string &__y) const {

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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的差值 //pts和dts的差值
int pts_dts_diff = pts - dts; auto pts_dts_diff = pts - dts;
if (_last_dts_in != dts) { if (_last_dts_in != dts) {
//时间戳发生变更 //时间戳发生变更

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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); mINI::Instance().parseFile(ini);
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastReloadConfig); NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastReloadConfig);
return true; return true;
}catch (std::exception &ex) { }catch (std::exception &) {
InfoL << "dump ini file to:" << ini; InfoL << "dump ini file to:" << ini;
mINI::Instance().dumpFile(ini); mINI::Instance().dumpFile(ini);
return false; return false;

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -15,6 +15,7 @@
namespace mediakit{ 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 }; unsigned const samplingFrequencyTable[16] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, 0, 0, 0 };
class AdtsHeader{ class AdtsHeader{
@ -91,8 +92,9 @@ static void parseAacConfig(const string &config, AdtsHeader &adts) {
adts.adts_buffer_fullness = 2047; adts.adts_buffer_fullness = 2047;
adts.no_raw_data_blocks_in_frame = 0; 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; uint16_t len;
if (bytes < 7) return -1; if (bytes < 7) return -1;
if (0xFF != data[0] || 0xF0 != (data[1] & 0xF0)) { if (0xFF != data[0] || 0xF0 != (data[1] & 0xF0)) {
@ -102,7 +104,7 @@ int getAacFrameLength(const uint8_t *data, int bytes) {
return len; return len;
} }
string makeAacConfig(const uint8_t *hex, int length){ string makeAacConfig(const uint8_t *hex, size_t length){
#ifndef ENABLE_MP4 #ifndef ENABLE_MP4
if (!(hex[0] == 0xFF && (hex[1] & 0xF0) == 0xF0)) { if (!(hex[0] == 0xFF && (hex[1] & 0xF0) == 0xF0)) {
return ""; return "";
@ -140,11 +142,11 @@ string makeAacConfig(const uint8_t *hex, int length){
#endif #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 #ifndef ENABLE_MP4
AdtsHeader header; AdtsHeader header;
parseAacConfig(config, 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); dumpAdtsHeader(header, out);
return ADTS_HEADER_LEN; return ADTS_HEADER_LEN;
#else #else

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -17,9 +17,9 @@
namespace mediakit{ namespace mediakit{
string makeAacConfig(const uint8_t *hex, int length); string makeAacConfig(const uint8_t *hex, size_t length);
int getAacFrameLength(const uint8_t *hex, int length); int getAacFrameLength(const uint8_t *hex, size_t length);
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);
bool parseAacConfig(const string &config, int &samplerate, int &channels); bool parseAacConfig(const string &config, int &samplerate, int &channels);
/** /**

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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<FrameImp>::obtainObj(); auto frame = ResourcePoolHelper<FrameImp>::obtainObj();
frame->_codec_id = CodecAAC; frame->_codec_id = CodecAAC;

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -37,7 +37,7 @@ public:
} }
private: private:
void onGetAAC(const char *data, int len, uint32_t stamp); void onGetAAC(const char *data, size_t len, uint32_t stamp);
private: private:
string _aac_cfg; string _aac_cfg;

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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(); auto iLen = frame->size() - frame->prefixSize();
uiStamp %= cycleMS; uiStamp %= cycleMS;
char *ptr = (char *) pcData; auto *ptr = (char *) pcData;
int iSize = iLen; auto iSize = iLen;
while (iSize > 0) { while (iSize > 0) {
if (iSize <= _ui32MtuSize - 20) { if (iSize <= _ui32MtuSize - 20) {
_aucSectionBuf[0] = 0; _aucSectionBuf[0] = 0;
_aucSectionBuf[1] = 16; _aucSectionBuf[1] = 16;
_aucSectionBuf[2] = iLen >> 5; _aucSectionBuf[2] = (iLen >> 5) & 0xFF;
_aucSectionBuf[3] = (iLen & 0x1F) << 3; _aucSectionBuf[3] = ((iLen & 0x1F) << 3) & 0xFF;
memcpy(_aucSectionBuf + 4, ptr, iSize); memcpy(_aucSectionBuf + 4, ptr, iSize);
makeAACRtp(_aucSectionBuf, iSize + 4, true, uiStamp); makeAACRtp(_aucSectionBuf, iSize + 4, true, uiStamp);
break; break;
} }
_aucSectionBuf[0] = 0; _aucSectionBuf[0] = 0;
_aucSectionBuf[1] = 16; _aucSectionBuf[1] = 16;
_aucSectionBuf[2] = (iLen) >> 5; _aucSectionBuf[2] = ((iLen) >> 5) & 0xFF;
_aucSectionBuf[3] = (iLen & 0x1F) << 3; _aucSectionBuf[3] = ((iLen & 0x1F) << 3) & 0xFF;
memcpy(_aucSectionBuf + 4, ptr, _ui32MtuSize - 20); memcpy(_aucSectionBuf + 4, ptr, _ui32MtuSize - 20);
makeAACRtp(_aucSectionBuf, _ui32MtuSize - 16, false, uiStamp); makeAACRtp(_aucSectionBuf, _ui32MtuSize - 16, false, uiStamp);
ptr += (_ui32MtuSize - 20); 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); RtpCodec::inputRtp(makeRtp(getTrackType(), data, len, mark, uiStamp), false);
} }

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -43,9 +43,9 @@ private:
void flushData(); void flushData();
private: private:
FrameImp::Ptr _frame;
string _aac_cfg;
uint32_t _last_dts = 0; uint32_t _last_dts = 0;
string _aac_cfg;
FrameImp::Ptr _frame;
}; };
@ -77,7 +77,7 @@ public:
void inputFrame(const Frame::Ptr &frame) override; void inputFrame(const Frame::Ptr &frame) override;
private: 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: private:
unsigned char _aucSectionBuf[1600]; unsigned char _aucSectionBuf[1600];

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -58,10 +58,10 @@ public:
} }
private: private:
Frame::Ptr _frame;
BufferRaw::Ptr _buffer;
bool _key; bool _key;
bool _config; bool _config;
Frame::Ptr _frame;
BufferRaw::Ptr _buffer;
}; };
Frame::Ptr Frame::getCacheAbleFrame(const Frame::Ptr &frame){ Frame::Ptr Frame::getCacheAbleFrame(const Frame::Ptr &frame){

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -101,7 +101,7 @@ public:
* 2640x00 00 00 01,4 * 2640x00 00 00 01,4
* aac前缀则为7个字节 * aac前缀则为7个字节
*/ */
virtual uint32_t prefixSize() const = 0; virtual size_t prefixSize() const = 0;
/** /**
* *
@ -132,7 +132,7 @@ public:
return (char *)_buffer.data(); return (char *)_buffer.data();
} }
uint32_t size() const override { size_t size() const override {
return _buffer.size(); return _buffer.size();
} }
@ -144,7 +144,7 @@ public:
return _pts ? _pts : _dts; return _pts ? _pts : _dts;
} }
uint32_t prefixSize() const override{ size_t prefixSize() const override{
return _prefix_size; return _prefix_size;
} }
@ -162,10 +162,10 @@ public:
public: public:
CodecId _codec_id = CodecInvalid; CodecId _codec_id = CodecInvalid;
BufferLikeString _buffer;
uint32_t _dts = 0; uint32_t _dts = 0;
uint32_t _pts = 0; uint32_t _pts = 0;
uint32_t _prefix_size = 0; size_t _prefix_size = 0;
BufferLikeString _buffer;
}; };
/** /**
@ -178,7 +178,7 @@ template<typename Parent>
class FrameInternal : public Parent{ class FrameInternal : public Parent{
public: public:
typedef std::shared_ptr<FrameInternal> Ptr; typedef std::shared_ptr<FrameInternal> 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(ptr, size, parent_frame->dts(), parent_frame->pts(), prefix_size) {
_parent_frame = parent_frame; _parent_frame = parent_frame;
} }
@ -301,7 +301,7 @@ public:
/** /**
* *
*/ */
int size() const { size_t size() const {
return _delegates_write.size(); return _delegates_write.size();
} }
private: private:
@ -318,12 +318,12 @@ class FrameFromPtr : public Frame{
public: public:
typedef std::shared_ptr<FrameFromPtr> Ptr; typedef std::shared_ptr<FrameFromPtr> 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) { : FrameFromPtr(ptr, size, dts, pts, prefix_size) {
_codec_id = codec_id; _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; _ptr = ptr;
_size = size; _size = size;
_dts = dts; _dts = dts;
@ -335,7 +335,7 @@ public:
return _ptr; return _ptr;
} }
uint32_t size() const override { size_t size() const override {
return _size; return _size;
} }
@ -347,7 +347,7 @@ public:
return _pts ? _pts : dts(); return _pts ? _pts : dts();
} }
uint32_t prefixSize() const override{ size_t prefixSize() const override{
return _prefix_size; return _prefix_size;
} }
@ -379,10 +379,10 @@ protected:
protected: protected:
char *_ptr; char *_ptr;
uint32_t _size;
uint32_t _dts; uint32_t _dts;
uint32_t _pts = 0; uint32_t _pts = 0;
uint32_t _prefix_size; size_t _size;
size_t _prefix_size;
CodecId _codec_id = CodecInvalid; CodecId _codec_id = CodecInvalid;
}; };
@ -402,7 +402,7 @@ public:
* @param prefix * @param prefix
* @param offset buffer有效数据偏移量 * @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; _buf = buf;
} }
@ -415,7 +415,7 @@ public:
* @param offset buffer有效数据偏移量 * @param offset buffer有效数据偏移量
* @param codec * @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; _buf = buf;
} }

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -15,13 +15,13 @@ using namespace toolkit;
namespace mediakit{ 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_GetBitContext tGetBitBuf;
T_SPS tH264SpsInfo; T_SPS tH264SpsInfo;
memset(&tGetBitBuf,0,sizeof(tGetBitBuf)); memset(&tGetBitBuf,0,sizeof(tGetBitBuf));
memset(&tH264SpsInfo,0,sizeof(tH264SpsInfo)); memset(&tH264SpsInfo,0,sizeof(tH264SpsInfo));
tGetBitBuf.pu8Buf = (uint8_t*)sps + 1; tGetBitBuf.pu8Buf = (uint8_t*)sps + 1;
tGetBitBuf.iBufSize = sps_len - 1; tGetBitBuf.iBufSize = (int)(sps_len - 1);
if(0 != h264DecSeqParameterSet((void *) &tGetBitBuf, &tH264SpsInfo)){ if(0 != h264DecSeqParameterSet((void *) &tGetBitBuf, &tH264SpsInfo)){
return false; return false;
} }
@ -31,11 +31,11 @@ bool getAVCInfo(const char * sps,int sps_len,int &iVideoWidth, int &iVideoHeight
return true; return true;
} }
bool getAVCInfo(const string& strSps,int &iVideoWidth, int &iVideoHeight, float &iVideoFps) { bool getAVCInfo(const string &strSps, int &iVideoWidth, int &iVideoHeight, float &iVideoFps) {
return getAVCInfo(strSps.data(),strSps.size(),iVideoWidth,iVideoHeight,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) { for (auto i = 0; i < len - sublen; ++i) {
if (memcmp(buf + i, subbuf, sublen) == 0) { if (memcmp(buf + i, subbuf, sublen) == 0) {
return buf + i; return buf + i;
@ -44,10 +44,10 @@ const char *memfind(const char *buf, int len, const char *subbuf, int sublen) {
return NULL; return NULL;
} }
void splitH264(const char *ptr, int len, int prefix, const std::function<void(const char *, int, int)> &cb) { void splitH264(const char *ptr, size_t len, size_t prefix, const std::function<void(const char *, size_t , size_t)> &cb) {
auto start = ptr + prefix; auto start = ptr + prefix;
auto end = ptr + len; auto end = ptr + len;
int next_prefix; size_t next_prefix;
while (true) { while (true) {
auto next_start = memfind(start, end - start, "\x00\x00\x01", 3); auto next_start = memfind(start, end - start, "\x00\x00\x01", 3);
if (next_start) { if (next_start) {
@ -74,7 +74,7 @@ void splitH264(const char *ptr, int len, int prefix, const std::function<void(co
} }
} }
int prefixSize(const char *ptr, int len){ size_t prefixSize(const char *ptr, size_t len){
if (len < 4) { if (len < 4) {
return 0; return 0;
} }
@ -96,28 +96,6 @@ int prefixSize(const char *ptr, int len){
return 0; return 0;
} }
#if 0
//splitH264函数测试程序
static onceToken s_token([](){
{
char buf[] = "\x00\x00\x00\x01\x12\x23\x34\x45\x56"
"\x00\x00\x00\x01\x23\x34\x45\x56"
"\x00\x00\x00\x01x34\x45\x56"
"\x00\x00\x01\x12\x23\x34\x45\x56";
splitH264(buf, sizeof(buf) - 1, 4, [](const char *ptr, int len, int prefix) {
cout << prefix << " " << hexdump(ptr, len) << endl;
});
}
{
char buf[] = "\x00\x00\x00\x01\x12\x23\x34\x45\x56";
splitH264(buf, sizeof(buf) - 1, 4, [](const char *ptr, int len, int prefix) {
cout << prefix << " " << hexdump(ptr, len) << endl;
});
}
});
#endif //0
Sdp::Ptr H264Track::getSdp() { Sdp::Ptr H264Track::getSdp() {
if(!ready()){ if(!ready()){
WarnL << getCodecName() << " Track未准备好"; WarnL << getCodecName() << " Track未准备好";

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -19,9 +19,9 @@ using namespace toolkit;
namespace mediakit{ namespace mediakit{
bool getAVCInfo(const string &strSps,int &iVideoWidth, int &iVideoHeight, float &iVideoFps); bool getAVCInfo(const string &strSps,int &iVideoWidth, int &iVideoHeight, float &iVideoFps);
void splitH264(const char *ptr, int len, int prefix, const std::function<void(const char *, int, int)> &cb); void splitH264(const char *ptr, size_t len, size_t prefix, const std::function<void(const char *, size_t, size_t)> &cb);
int prefixSize(const char *ptr, int len); size_t prefixSize(const char *ptr, size_t len);
/** /**
* 264 * 264
*/ */
@ -64,7 +64,7 @@ class H264FrameNoCacheAble : public FrameFromPtr {
public: public:
typedef std::shared_ptr<H264FrameNoCacheAble> Ptr; typedef std::shared_ptr<H264FrameNoCacheAble> 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; _ptr = ptr;
_size = size; _size = size;
_dts = dts; _dts = dts;
@ -183,7 +183,7 @@ public:
int type = H264_TYPE(*((uint8_t *)frame->data() + frame->prefixSize())); int type = H264_TYPE(*((uint8_t *)frame->data() + frame->prefixSize()));
if(type != H264Frame::NAL_B_P && type != H264Frame::NAL_IDR){ if(type != H264Frame::NAL_B_P && type != H264Frame::NAL_IDR){
//非I/B/P帧情况下split一下防止多个帧粘合在一起 //非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<H264FrameInternal>(frame, (char *)ptr, len, prefix); H264FrameInternal::Ptr sub_frame = std::make_shared<H264FrameInternal>(frame, (char *)ptr, len, prefix);
inputFrame_l(sub_frame); inputFrame_l(sub_frame);
}); });
@ -310,14 +310,14 @@ public:
(uint8_t(strSPS[3])); // profile_idc|constraint_setN_flag|level_idc (uint8_t(strSPS[3])); // profile_idc|constraint_setN_flag|level_idc
} }
memset(strTemp, 0, 100); memset(strTemp, 0, 100);
sprintf(strTemp, "%06X", profile_level_id); snprintf(strTemp, sizeof(strTemp), "%06X", profile_level_id);
_printer << strTemp; _printer << strTemp;
_printer << "; sprop-parameter-sets="; _printer << "; sprop-parameter-sets=";
memset(strTemp, 0, 100); 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 << ","; _printer << strTemp << ",";
memset(strTemp, 0, 100); 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 << strTemp << "\r\n";
_printer << "a=control:trackID=" << (int)TrackVideo << "\r\n"; _printer << "a=control:trackID=" << (int)TrackVideo << "\r\n";
} }

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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) { if (pkt->buffer.size() > 9) {
uint32_t iTotalLen = pkt->buffer.size(); auto iTotalLen = pkt->buffer.size();
uint32_t iOffset = 5; size_t iOffset = 5;
uint8_t *cts_ptr = (uint8_t *) (pkt->buffer.data() + 2); 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; int32_t cts = (((cts_ptr[0] << 16) | (cts_ptr[1] << 8) | (cts_ptr[2])) + 0xff800000) ^ 0xff800000;
auto pts = pkt->time_stamp + cts; 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){ if(iLen == 0){
return; return;
} }
@ -213,7 +213,7 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
_lastPacket->type_id = MSG_VIDEO; _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((char *) &size, 4);
_lastPacket->buffer.append(pcData, iLen); _lastPacket->buffer.append(pcData, iLen);
_lastPacket->body_size = _lastPacket->buffer.size(); _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[1]); // profile
rtmpPkt->buffer.push_back(_sps[2]); // compat rtmpPkt->buffer.push_back(_sps[2]); // compat
rtmpPkt->buffer.push_back(_sps[3]); // level 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((char)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)0xe1); // 3 bits reserved + 5 bits number of sps (00001)
//sps //sps
uint16_t size = _sps.size(); uint16_t size = (uint16_t)_sps.size();
size = htons(size); size = htons(size);
rtmpPkt->buffer.append((char *) &size, 2); rtmpPkt->buffer.append((char *) &size, 2);
rtmpPkt->buffer.append(_sps); rtmpPkt->buffer.append(_sps);
//pps //pps
rtmpPkt->buffer.push_back(1); // version rtmpPkt->buffer.push_back(1); // version
size = _pps.size(); size = (uint16_t)_pps.size();
size = htons(size); size = htons(size);
rtmpPkt->buffer.append((char *) &size, 2); rtmpPkt->buffer.append((char *) &size, 2);
rtmpPkt->buffer.append(_pps); rtmpPkt->buffer.append(_pps);

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -40,7 +40,7 @@ public:
} }
protected: 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(); H264Frame::Ptr obtainFrame();
protected: protected:

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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 - 30-31 undefined -
*/ */
const uint8_t *frame = (uint8_t *) rtppack->data() + rtppack->offset; 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_type = *frame & 0x1F;
int nal_suffix = *frame & (~0x1F); int nal_suffix = *frame & (~0x1F);
@ -92,7 +92,7 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) {
bool haveIDR = false; bool haveIDR = false;
auto ptr = frame + 1; auto ptr = frame + 1;
while (true) { while (true) {
int off = ptr - frame; size_t off = ptr - frame;
if (off >= length) { if (off >= length) {
break; break;
} }
@ -198,7 +198,7 @@ void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) {
auto len = frame->size() - frame->prefixSize(); auto len = frame->size() - frame->prefixSize();
auto pts = frame->pts() % cycleMS; auto pts = frame->pts() % cycleMS;
auto nal_type = H264_TYPE(ptr[0]); auto nal_type = H264_TYPE(ptr[0]);
auto payload_size = _ui32MtuSize - 2; size_t payload_size = _ui32MtuSize - 2;
//超过MTU则按照FU-A模式打包 //超过MTU则按照FU-A模式打包
if (len > payload_size + 1) { if (len > payload_size + 1) {
@ -209,7 +209,7 @@ void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) {
unsigned char s_e_r_flags; unsigned char s_e_r_flags;
bool fu_a_start = true; bool fu_a_start = true;
bool mark_bit = false; bool mark_bit = false;
int offset = 1; size_t offset = 1;
while (!mark_bit) { while (!mark_bit) {
if (len <= offset + payload_size) { if (len <= offset + payload_size) {
//FU-A end //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); RtpCodec::inputRtp(makeRtp(getTrackType(), data, len, mark, uiStamp), gop_pos);
} }

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -41,14 +41,16 @@ public:
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return CodecH264; return CodecH264;
} }
private: private:
bool decodeRtp(const RtpPacket::Ptr &rtp); bool decodeRtp(const RtpPacket::Ptr &rtp);
void onGetH264(const H264Frame::Ptr &frame); void onGetH264(const H264Frame::Ptr &frame);
H264Frame::Ptr obtainFrame(); H264Frame::Ptr obtainFrame();
private: private:
int _lastSeq = 0;
H264Frame::Ptr _h264frame; H264Frame::Ptr _h264frame;
DtsGenerator _dts_generator; DtsGenerator _dts_generator;
int _lastSeq = 0;
}; };
/** /**
@ -77,8 +79,9 @@ public:
* @param frame * @param frame
*/ */
void inputFrame(const Frame::Ptr &frame) override; void inputFrame(const Frame::Ptr &frame) override;
private: 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{ }//namespace mediakit{

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -14,7 +14,7 @@
namespace mediakit{ 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_GetBitContext tGetBitBuf;
T_HEVCSPS tH265SpsInfo; T_HEVCSPS tH265SpsInfo;
T_HEVCVPS tH265VpsInfo; 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(&tGetBitBuf,0,sizeof(tGetBitBuf));
memset(&tH265VpsInfo,0,sizeof(tH265VpsInfo)); memset(&tH265VpsInfo,0,sizeof(tH265VpsInfo));
tGetBitBuf.pu8Buf = (uint8_t*)vps+2; tGetBitBuf.pu8Buf = (uint8_t*)vps+2;
tGetBitBuf.iBufSize = vps_len-2; tGetBitBuf.iBufSize = (int)(vps_len-2);
if(0 != h265DecVideoParameterSet((void *) &tGetBitBuf, &tH265VpsInfo)){ if(0 != h265DecVideoParameterSet((void *) &tGetBitBuf, &tH265VpsInfo)){
return false; 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(&tGetBitBuf,0,sizeof(tGetBitBuf));
memset(&tH265SpsInfo,0,sizeof(tH265SpsInfo)); memset(&tH265SpsInfo,0,sizeof(tH265SpsInfo));
tGetBitBuf.pu8Buf = (uint8_t*)sps+2; tGetBitBuf.pu8Buf = (uint8_t*)sps+2;
tGetBitBuf.iBufSize = sps_len-2; tGetBitBuf.iBufSize = (int)(sps_len-2);
if(0 != h265DecSeqParameterSet((void *) &tGetBitBuf, &tH265SpsInfo)){ if(0 != h265DecSeqParameterSet((void *) &tGetBitBuf, &tH265SpsInfo)){
return false; 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) { 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() { Sdp::Ptr H265Track::getSdp() {

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -86,7 +86,7 @@ class H265FrameNoCacheAble : public FrameFromPtr {
public: public:
typedef std::shared_ptr<H265FrameNoCacheAble> Ptr; typedef std::shared_ptr<H265FrameNoCacheAble> 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; _ptr = ptr;
_size = size; _size = size;
_dts = dts; _dts = dts;
@ -197,7 +197,7 @@ public:
void inputFrame(const Frame::Ptr &frame) override{ void inputFrame(const Frame::Ptr &frame) override{
int type = H265_TYPE(*((uint8_t *)frame->data() + frame->prefixSize())); int type = H265_TYPE(*((uint8_t *)frame->data() + frame->prefixSize()));
if(frame->configFrame() || type == H265Frame::NAL_SEI_PREFIX){ 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<H265FrameInternal>(frame, (char*)ptr, len, prefix); H265FrameInternal::Ptr sub_frame = std::make_shared<H265FrameInternal>(frame, (char*)ptr, len, prefix);
inputFrame_l(sub_frame); inputFrame_l(sub_frame);
}); });

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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) { if (pkt->buffer.size() > 9) {
uint32_t iTotalLen = pkt->buffer.size(); auto iTotalLen = pkt->buffer.size();
uint32_t iOffset = 5; size_t iOffset = 5;
uint8_t *cts_ptr = (uint8_t *) (pkt->buffer.data() + 2); 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; int32_t cts = (((cts_ptr[0] << 16) | (cts_ptr[1] << 8) | (cts_ptr[2])) + 0xff800000) ^ 0xff800000;
auto pts = pkt->time_stamp + cts; 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){ if(iLen == 0){
return; return;
} }
@ -196,7 +196,7 @@ void H265RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
_lastPacket->type_id = MSG_VIDEO; _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((char *) &size, 4);
_lastPacket->buffer.append(pcData, iLen); _lastPacket->buffer.append(pcData, iLen);
_lastPacket->body_size = _lastPacket->buffer.size(); _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 vps_sps_pps = string("\x00\x00\x00\x01", 4) + _vps +
string("\x00\x00\x00\x01", 4) + _sps + string("\x00\x00\x00\x01", 4) + _sps +
string("\x00\x00\x00\x01", 4) + _pps; 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]; uint8_t extra_data[1024];
int extra_data_size = mpeg4_hevc_decoder_configuration_record_save(&hevc, extra_data, sizeof(extra_data)); int extra_data_size = mpeg4_hevc_decoder_configuration_record_save(&hevc, extra_data, sizeof(extra_data));
if (extra_data_size == -1) { if (extra_data_size == -1) {

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -40,7 +40,7 @@ public:
} }
protected: 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(); H265Frame::Ptr obtainFrame();
protected: protected:
@ -73,14 +73,16 @@ public:
* config包 * config包
*/ */
void makeConfigPacket() override; void makeConfigPacket() override;
private: private:
void makeVideoConfigPkt(); void makeVideoConfigPkt();
private: private:
bool _gotSpsPps = false;
string _vps; string _vps;
string _sps; string _sps;
string _pps; string _pps;
H265Track::Ptr _track; H265Track::Ptr _track;
bool _gotSpsPps = false;
RtmpPacket::Ptr _lastPacket; RtmpPacket::Ptr _lastPacket;
}; };

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * 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) { bool H265RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) {
const uint8_t *frame = (uint8_t *) rtppack->data() + rtppack->offset; 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]); int nal = H265_TYPE(frame[0]);
if (nal > 50){ if (nal > 50){
@ -154,7 +154,7 @@ void H265RtpEncoder::inputFrame(const Frame::Ptr &frame) {
auto len = frame->size() - frame->prefixSize(); auto len = frame->size() - frame->prefixSize();
auto pts = frame->pts() % cycleMS; auto pts = frame->pts() % cycleMS;
auto nal_type = H265_TYPE(ptr[0]); //获取NALU的5bit 帧类型 auto nal_type = H265_TYPE(ptr[0]); //获取NALU的5bit 帧类型
auto payload_size = _ui32MtuSize - 3; size_t payload_size = _ui32MtuSize - 3;
//超过MTU,按照FU方式打包 //超过MTU,按照FU方式打包
if (len > payload_size + 2) { if (len > payload_size + 2) {
@ -162,7 +162,7 @@ void H265RtpEncoder::inputFrame(const Frame::Ptr &frame) {
unsigned char s_e_flags; unsigned char s_e_flags;
bool fu_start = true; bool fu_start = true;
bool mark_bit = false; bool mark_bit = false;
int offset = 2; size_t offset = 2;
while (!mark_bit) { while (!mark_bit) {
if (len <= offset + payload_size) { if (len <= offset + payload_size) {
//FU end //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)); RtpCodec::inputRtp(makeRtp(getTrackType(),data,len,mark,uiStamp),first_packet && H265Frame::isKeyFrame(nal_type));
} }

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors
@ -42,14 +42,16 @@ public:
CodecId getCodecId() const override{ CodecId getCodecId() const override{
return CodecH265; return CodecH265;
} }
private: private:
bool decodeRtp(const RtpPacket::Ptr &rtp); bool decodeRtp(const RtpPacket::Ptr &rtp);
void onGetH265(const H265Frame::Ptr &frame); void onGetH265(const H265Frame::Ptr &frame);
H265Frame::Ptr obtainFrame(); H265Frame::Ptr obtainFrame();
private: private:
int _lastSeq = 0;
H265Frame::Ptr _h265frame; H265Frame::Ptr _h265frame;
DtsGenerator _dts_generator; DtsGenerator _dts_generator;
int _lastSeq = 0;
}; };
/** /**
@ -79,7 +81,7 @@ public:
*/ */
void inputFrame(const Frame::Ptr &frame) override; void inputFrame(const Frame::Ptr &frame) override;
private: 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{ }//namespace mediakit{

View File

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * 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 * Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors * LICENSE file in the root of the source tree. All contributing project authors

Some files were not shown because too many files have changed in this diff Show More