Skip to content

Commit

Permalink
Refine srs-librtmp
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Mar 1, 2017
1 parent 011b693 commit 5bec6a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
7 changes: 0 additions & 7 deletions trunk/src/libs/srs_librtmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1678,15 +1676,13 @@ 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;
}

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;
Expand All @@ -1703,15 +1699,13 @@ 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;
}

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;
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 8 additions & 7 deletions trunk/src/libs/srs_librtmp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/**
Expand Down Expand Up @@ -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);
/**
Expand Down Expand Up @@ -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);
/**
Expand Down Expand Up @@ -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 <string.h>
#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
Expand Down

0 comments on commit 5bec6a4

Please sign in to comment.