From 366d6bcb82a3448aed33d1e93d2734721a823897 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 13 May 2017 21:47:20 +0800 Subject: [PATCH] Refine code --- trunk/src/kernel/srs_kernel_mp4.cpp | 3 +++ trunk/src/libs/srs_librtmp.hpp | 10 +++++----- trunk/src/main/srs_main_ingest_hls.cpp | 2 +- trunk/src/main/srs_main_mp4_parser.cpp | 25 +++++++++++++++++++++++++ trunk/src/protocol/srs_rtmp_stack.cpp | 2 +- trunk/src/protocol/srs_rtmp_stack.hpp | 4 ++-- trunk/src/service/srs_service_log.hpp | 7 ++++--- 7 files changed, 41 insertions(+), 12 deletions(-) diff --git a/trunk/src/kernel/srs_kernel_mp4.cpp b/trunk/src/kernel/srs_kernel_mp4.cpp index 00a3a83dc..6ef90e186 100644 --- a/trunk/src/kernel/srs_kernel_mp4.cpp +++ b/trunk/src/kernel/srs_kernel_mp4.cpp @@ -4326,6 +4326,9 @@ int SrsMp4Decoder::do_load_next_box(SrsMp4Box** ppbox, uint32_t required_box_typ ret = box->decode(buffer); } + // Skip the box from stream, move stream to next box. + // For mdat box, skip the content in stream or underylayer reader. + // For other boxes, skip it from stream because we already decoded it or ignore it. if (ret == ERROR_SUCCESS) { ret = br->skip(box, stream); } diff --git a/trunk/src/libs/srs_librtmp.hpp b/trunk/src/libs/srs_librtmp.hpp index 492335a28..231db1ff2 100644 --- a/trunk/src/libs/srs_librtmp.hpp +++ b/trunk/src/libs/srs_librtmp.hpp @@ -203,9 +203,9 @@ extern "C"{ /** * Retrieve server ip from RTMP handler. - * @Param ip A NULL terminated string specifies the server ip. - * @Param pid An int specifies the PID of server. -1 is no PID information. - * @Param cid An int specifies the CID of connection. -1 is no CID information. + * @param ip A NULL terminated string specifies the server ip. + * @param pid An int specifies the PID of server. -1 is no PID information. + * @param cid An int specifies the CID of connection. -1 is no CID information. * @remark For SRS, ip/pid/cid is the UUID of a client. For other server, these values maybe unknown. * @remark When connected to server by srs_rtmp_connect_app, the information is ready to be retrieved. * @return 0, success; otherswise, failed. @@ -214,7 +214,7 @@ extern "C"{ /** * Retrieve server signature from RTMP handler. - * @Param sig A NULL terminated string specifies the server signature. + * @param sig A NULL terminated string specifies the server signature. * @remark When connected to server by srs_rtmp_connect_app, the information is ready to be retrieved. * @return 0, success; otherswise, failed. */ @@ -299,7 +299,7 @@ extern "C"{ * @return 0, success; otherswise, failed. */ extern int srs_rtmp_read_packet(srs_rtmp_t rtmp, char* type, uint32_t* timestamp, char** data, int* size); - // @Param data User should never free it anymore. + // @param data User should never free it anymore. extern int srs_rtmp_write_packet(srs_rtmp_t rtmp, char type, uint32_t timestamp, char* data, int size); /** diff --git a/trunk/src/main/srs_main_ingest_hls.cpp b/trunk/src/main/srs_main_ingest_hls.cpp index 86a63a377..11759fe0f 100644 --- a/trunk/src/main/srs_main_ingest_hls.cpp +++ b/trunk/src/main/srs_main_ingest_hls.cpp @@ -64,7 +64,7 @@ int main(int argc, char** argv) // directly failed when compile limited. #if defined(SRS_AUTO_GPERF_MP) || defined(SRS_AUTO_GPERF_MP) \ -|| defined(SRS_AUTO_GPERF_MC) || defined(SRS_AUTO_GPERF_MP) + || defined(SRS_AUTO_GPERF_MC) || defined(SRS_AUTO_GPERF_MP) srs_error("donot support gmc/gmp/gcp/gprof"); exit(-1); #endif diff --git a/trunk/src/main/srs_main_mp4_parser.cpp b/trunk/src/main/srs_main_mp4_parser.cpp index 9abcf2617..bdb481fbe 100644 --- a/trunk/src/main/srs_main_mp4_parser.cpp +++ b/trunk/src/main/srs_main_mp4_parser.cpp @@ -26,12 +26,37 @@ #include #include +#include +#include +#include +using namespace std; + // @global log and context. ISrsLog* _srs_log = new SrsConsoleLog(SrsLogLevelTrace, false); ISrsThreadContext* _srs_context = new SrsThreadContext(); +void help(char** argv) +{ + printf("Usage: %s \n" + " mp4_file The MP4 file path to parse.\n" + "For example:\n" + " %s doc/source.200kbps.768x320.mp4\n", + argv[0], argv[0]); + + exit(0); +} + int main(int argc, char** argv) { + printf("SRS MP4 parser/%d.%d.%d, show the mp4 boxes structure.\n", + VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION); + + if (argc < 2) { + help(argv); + } + string mp4_file = argv[1]; + srs_trace("Parse MP4 file %s", mp4_file.c_str()); + return 0; } diff --git a/trunk/src/protocol/srs_rtmp_stack.cpp b/trunk/src/protocol/srs_rtmp_stack.cpp index 2a6c539fc..de78e2ccf 100644 --- a/trunk/src/protocol/srs_rtmp_stack.cpp +++ b/trunk/src/protocol/srs_rtmp_stack.cpp @@ -2767,7 +2767,7 @@ int SrsRtmpServer::identify_client(int stream_id, SrsRtmpConnType& type, string& } // For encoder of Haivision, it always send a _checkbw call message. - // @Remark the next message is createStream, so we continue to identify it. + // @remark the next message is createStream, so we continue to identify it. // @see https://github.com/ossrs/srs/issues/844 if (call->command_name == "_checkbw") { srs_info("Haivision encoder identified."); diff --git a/trunk/src/protocol/srs_rtmp_stack.hpp b/trunk/src/protocol/srs_rtmp_stack.hpp index f005476c4..73a78dc00 100644 --- a/trunk/src/protocol/srs_rtmp_stack.hpp +++ b/trunk/src/protocol/srs_rtmp_stack.hpp @@ -726,8 +726,8 @@ public: * @param app, The app to connect at, for example, live. * @param tcUrl, The tcUrl to connect at, for example, rtmp://ossrs.net/live. * @param req, the optional req object, use the swfUrl/pageUrl if specified. NULL to ignore. - * @Param dsu, Whether debug SRS upnode. For edge, set to true to send its info to upnode. - * @Param si, The server information, retrieve from response of connect app request. NULL to ignore. + * @param dsu, Whether debug SRS upnode. For edge, set to true to send its info to upnode. + * @param si, The server information, retrieve from response of connect app request. NULL to ignore. */ virtual int connect_app(std::string app, std::string tcUrl, SrsRequest* r, bool dsu, SrsServerInfo* si); /** diff --git a/trunk/src/service/srs_service_log.hpp b/trunk/src/service/srs_service_log.hpp index 22108ddba..97376402d 100644 --- a/trunk/src/service/srs_service_log.hpp +++ b/trunk/src/service/srs_service_log.hpp @@ -76,9 +76,10 @@ public: /** * Generate the log header. - * @Param dangerous Whether log is warning or error, log the errno if true. - * @Param utc Whether use UTC time format in the log header. - * @Param psize Output the actual header size. + * @param dangerous Whether log is warning or error, log the errno if true. + * @param utc Whether use UTC time format in the log header. + * @param psize Output the actual header size. + * @remark It's a internal API. */ bool srs_log_header(char* buffer, int size, bool utc, bool dangerous, const char* tag, int cid, const char* level, int* psize);