mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Update srs-librtmp, set errno to ret when failed.
This commit is contained in:
parent
72c4ae4a8c
commit
011b693235
2 changed files with 41 additions and 4 deletions
|
@ -557,7 +557,9 @@ srs_rtmp_t srs_rtmp_create(const char* url)
|
|||
context->skt = new SimpleSocketStream();
|
||||
|
||||
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);
|
||||
return NULL;
|
||||
|
@ -1540,6 +1542,9 @@ srs_mp4_t srs_mp4_open_read(const char* file)
|
|||
Mp4Context* mp4 = new Mp4Context();
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -1672,11 +1677,17 @@ srs_flv_t srs_flv_open_read(const char* file)
|
|||
FlvContext* flv = new FlvContext();
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -1691,11 +1702,17 @@ srs_flv_t srs_flv_open_write(const char* file)
|
|||
FlvContext* flv = new FlvContext();
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -2695,7 +2712,11 @@ srs_rtmp_t srs_rtmp_create2(const char* url)
|
|||
srs_freep(context->skt);
|
||||
context->skt = new SimpleSocketStream();
|
||||
|
||||
if (context->skt->create_socket(context) != ERROR_SUCCESS) {
|
||||
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);
|
||||
return NULL;
|
||||
|
|
|
@ -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.
|
||||
* @return a rtmp handler, or NULL if error occured, and errno set to srs error code.
|
||||
*/
|
||||
extern srs_rtmp_t srs_rtmp_create(const char* url);
|
||||
/**
|
||||
|
@ -551,8 +551,14 @@ typedef struct {
|
|||
// The output sample data, user must free it by srs_mp4_free_sample.
|
||||
uint8_t* sample;
|
||||
} srs_mp4_sample_t;
|
||||
/* Open mp4 file for muxer(write) or demuxer(read). */
|
||||
/**
|
||||
* Open mp4 file for muxer(write) or demuxer(read).
|
||||
* @return A MP4 demuxer, NULL if failed, and errno set to srs error code.
|
||||
*/
|
||||
extern srs_mp4_t srs_mp4_open_read(const char* file);
|
||||
/**
|
||||
* Close the MP4 demuxer.
|
||||
*/
|
||||
extern void srs_mp4_close(srs_mp4_t mp4);
|
||||
/**
|
||||
* Initialize mp4 demuxer in non-seek mode.
|
||||
|
@ -592,9 +598,19 @@ extern srs_bool srs_mp4_is_eof(int error_code);
|
|||
**************************************************************
|
||||
*************************************************************/
|
||||
typedef void* srs_flv_t;
|
||||
/* open flv file for both read/write. */
|
||||
/**
|
||||
* Open FLV file in demux mode.
|
||||
* @return A FLV demuxer, NULL if failed, and errno set to srs error code.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
extern srs_flv_t srs_flv_open_write(const char* file);
|
||||
/**
|
||||
* Close the FLV demuxer or muxer.
|
||||
*/
|
||||
extern void srs_flv_close(srs_flv_t flv);
|
||||
/**
|
||||
* read the flv header. 9bytes header.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue