From 5bec6a4fddbeaff38c629b2bddbe6d53e2f8293e Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 1 Mar 2017 12:03:49 +0800 Subject: [PATCH] Refine srs-librtmp --- trunk/src/libs/srs_librtmp.cpp | 7 ------- trunk/src/libs/srs_librtmp.hpp | 15 ++++++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/trunk/src/libs/srs_librtmp.cpp b/trunk/src/libs/srs_librtmp.cpp index 78a9acd145..3d3e32e524 100644 --- a/trunk/src/libs/srs_librtmp.cpp +++ b/trunk/src/libs/srs_librtmp.cpp @@ -558,7 +558,6 @@ srs_rtmp_t srs_rtmp_create(const char* url) if ((ret = context->skt->create_socket(context)) != ERROR_SUCCESS) { srs_human_error("Create socket failed, ret=%d", ret); - errno = ret; // free the context and return NULL srs_freep(context); @@ -1543,7 +1542,6 @@ srs_mp4_t srs_mp4_open_read(const char* file) if ((ret = mp4->reader.open(file)) != ERROR_SUCCESS) { srs_human_error("Open MP4 file failed, ret=%d", ret); - errno = ret; srs_freep(mp4); return NULL; @@ -1678,7 +1676,6 @@ srs_flv_t srs_flv_open_read(const char* file) if ((ret = flv->reader.open(file)) != ERROR_SUCCESS) { srs_human_error("Open FLV file failed, ret=%d", ret); - errno = ret; srs_freep(flv); return NULL; @@ -1686,7 +1683,6 @@ srs_flv_t srs_flv_open_read(const char* file) if ((ret = flv->dec.initialize(&flv->reader)) != ERROR_SUCCESS) { srs_human_error("Initialize FLV demuxer failed, ret=%d", ret); - errno = ret; srs_freep(flv); return NULL; @@ -1703,7 +1699,6 @@ srs_flv_t srs_flv_open_write(const char* file) if ((ret = flv->writer.open(file)) != ERROR_SUCCESS) { srs_human_error("Open FLV file failed, ret=%d", ret); - errno = ret; srs_freep(flv); return NULL; @@ -1711,7 +1706,6 @@ srs_flv_t srs_flv_open_write(const char* file) if ((ret = flv->enc.initialize(&flv->writer)) != ERROR_SUCCESS) { srs_human_error("Initilize FLV muxer failed, ret=%d", ret); - errno = ret; srs_freep(flv); return NULL; @@ -2715,7 +2709,6 @@ srs_rtmp_t srs_rtmp_create2(const char* url) int ret = ERROR_SUCCESS; if ((ret = context->skt->create_socket(context)) != ERROR_SUCCESS) { srs_human_error("Create socket failed, ret=%d", ret); - errno = ret; // free the context and return NULL srs_freep(context); diff --git a/trunk/src/libs/srs_librtmp.hpp b/trunk/src/libs/srs_librtmp.hpp index e1320f9d41..fc71f24c9a 100644 --- a/trunk/src/libs/srs_librtmp.hpp +++ b/trunk/src/libs/srs_librtmp.hpp @@ -128,7 +128,7 @@ typedef void* srs_amf0_t; * @remark default timeout to 30s if not set by srs_rtmp_set_timeout. * @remark default schema to srs_url_schema_normal, use srs_rtmp_set_schema to change it. * - * @return a rtmp handler, or NULL if error occured, and errno set to srs error code. + * @return a rtmp handler, or NULL if error occured. */ extern srs_rtmp_t srs_rtmp_create(const char* url); /** @@ -553,7 +553,7 @@ typedef struct { } srs_mp4_sample_t; /** * Open mp4 file for muxer(write) or demuxer(read). - * @return A MP4 demuxer, NULL if failed, and errno set to srs error code. + * @return A MP4 demuxer, NULL if failed. */ extern srs_mp4_t srs_mp4_open_read(const char* file); /** @@ -600,12 +600,12 @@ extern srs_bool srs_mp4_is_eof(int error_code); typedef void* srs_flv_t; /** * Open FLV file in demux mode. - * @return A FLV demuxer, NULL if failed, and errno set to srs error code. + * @return A FLV demuxer, NULL if failed. */ extern srs_flv_t srs_flv_open_read(const char* file); /** * Open FlV file in mux mode. - * @return A FLV muxer, NULL if failed, and errno set to srs error code. + * @return A FLV muxer, NULL if failed. */ extern srs_flv_t srs_flv_open_write(const char* file); /** @@ -1068,17 +1068,18 @@ extern const char* srs_human_format_time(); #define srs_human_verbose(msg, ...) (void)0 #define srs_human_raw(msg, ...) (void)0 #else + #include #define srs_human_trace(msg, ...) \ fprintf(stdout, "[T][%d][%s] ", getpid(), srs_human_format_time());\ fprintf(stdout, msg, ##__VA_ARGS__); fprintf(stdout, "\n") #define srs_human_warn(msg, ...) \ - fprintf(stdout, "[W][%d][%s] ", getpid(), srs_human_format_time()); \ + fprintf(stdout, "[W][%d][%s][%d] ", getpid(), srs_human_format_time(), errno); \ fprintf(stdout, msg, ##__VA_ARGS__); \ fprintf(stdout, "\n") #define srs_human_error(msg, ...) \ - fprintf(stderr, "[E][%d][%s] ", getpid(), srs_human_format_time());\ + fprintf(stderr, "[E][%d][%s][%d] ", getpid(), srs_human_format_time(), errno);\ fprintf(stderr, msg, ##__VA_ARGS__); \ - fprintf(stderr, "\n") + fprintf(stderr, " (%s)\n", strerror(errno)) #define srs_human_verbose(msg, ...) (void)0 #define srs_human_raw(msg, ...) printf(msg, ##__VA_ARGS__) #endif