正在显示
4 个修改的文件
包含
38 行增加
和
5 行删除
| @@ -290,6 +290,11 @@ SimpleSocketStream::~SimpleSocketStream() | @@ -290,6 +290,11 @@ SimpleSocketStream::~SimpleSocketStream() | ||
| 290 | } | 290 | } |
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | +srs_hijack_io_t SimpleSocketStream::hijack_io() | ||
| 294 | +{ | ||
| 295 | + return io; | ||
| 296 | +} | ||
| 297 | + | ||
| 293 | int SimpleSocketStream::create_socket() | 298 | int SimpleSocketStream::create_socket() |
| 294 | { | 299 | { |
| 295 | srs_assert(io); | 300 | srs_assert(io); |
| @@ -50,6 +50,7 @@ public: | @@ -50,6 +50,7 @@ public: | ||
| 50 | SimpleSocketStream(); | 50 | SimpleSocketStream(); |
| 51 | virtual ~SimpleSocketStream(); | 51 | virtual ~SimpleSocketStream(); |
| 52 | public: | 52 | public: |
| 53 | + virtual srs_hijack_io_t hijack_io(); | ||
| 53 | virtual int create_socket(); | 54 | virtual int create_socket(); |
| 54 | virtual int connect(const char* server, int port); | 55 | virtual int connect(const char* server, int port); |
| 55 | // ISrsBufferReader | 56 | // ISrsBufferReader |
| @@ -534,7 +534,10 @@ srs_rtmp_t srs_rtmp_create2(const char* url) | @@ -534,7 +534,10 @@ srs_rtmp_t srs_rtmp_create2(const char* url) | ||
| 534 | 534 | ||
| 535 | void srs_rtmp_destroy(srs_rtmp_t rtmp) | 535 | void srs_rtmp_destroy(srs_rtmp_t rtmp) |
| 536 | { | 536 | { |
| 537 | - srs_assert(rtmp != NULL); | 537 | + if (!rtmp) { |
| 538 | + return; | ||
| 539 | + } | ||
| 540 | + | ||
| 538 | Context* context = (Context*)rtmp; | 541 | Context* context = (Context*)rtmp; |
| 539 | 542 | ||
| 540 | srs_freep(context); | 543 | srs_freep(context); |
| @@ -2424,6 +2427,23 @@ const char* srs_human_format_time() | @@ -2424,6 +2427,23 @@ const char* srs_human_format_time() | ||
| 2424 | return buf; | 2427 | return buf; |
| 2425 | } | 2428 | } |
| 2426 | 2429 | ||
| 2430 | + | ||
| 2431 | +#ifdef SRS_HIJACK_IO | ||
| 2432 | +srs_hijack_io_t srs_hijack_io_get(srs_rtmp_t rtmp) | ||
| 2433 | +{ | ||
| 2434 | + if (!rtmp) { | ||
| 2435 | + return NULL; | ||
| 2436 | + } | ||
| 2437 | + | ||
| 2438 | + Context* context = (Context*)rtmp; | ||
| 2439 | + if (!context->skt) { | ||
| 2440 | + return NULL; | ||
| 2441 | + } | ||
| 2442 | + | ||
| 2443 | + return context->skt->hijack_io(); | ||
| 2444 | +} | ||
| 2445 | +#endif | ||
| 2446 | + | ||
| 2427 | #ifdef __cplusplus | 2447 | #ifdef __cplusplus |
| 2428 | } | 2448 | } |
| 2429 | #endif | 2449 | #endif |
| @@ -107,7 +107,7 @@ extern srs_rtmp_t srs_rtmp_create(const char* url); | @@ -107,7 +107,7 @@ extern srs_rtmp_t srs_rtmp_create(const char* url); | ||
| 107 | extern srs_rtmp_t srs_rtmp_create2(const char* url); | 107 | extern srs_rtmp_t srs_rtmp_create2(const char* url); |
| 108 | /** | 108 | /** |
| 109 | * close and destroy the rtmp stack. | 109 | * close and destroy the rtmp stack. |
| 110 | -* @remark, user should use the rtmp again. | 110 | +* @remark, user should never use the rtmp again. |
| 111 | */ | 111 | */ |
| 112 | extern void srs_rtmp_destroy(srs_rtmp_t rtmp); | 112 | extern void srs_rtmp_destroy(srs_rtmp_t rtmp); |
| 113 | 113 | ||
| @@ -895,15 +895,22 @@ extern const char* srs_human_format_time(); | @@ -895,15 +895,22 @@ extern const char* srs_human_format_time(); | ||
| 895 | *************************************************************/ | 895 | *************************************************************/ |
| 896 | // the void* will convert to your handler for io hijack. | 896 | // the void* will convert to your handler for io hijack. |
| 897 | typedef void* srs_hijack_io_t; | 897 | typedef void* srs_hijack_io_t; |
| 898 | -// define the following macro and functions in your module to hijack the io. | ||
| 899 | -// the example @see https://github.com/winlinvip/st-load | ||
| 900 | -// which use librtmp but use its own io(use st also). | ||
| 901 | #ifdef SRS_HIJACK_IO | 898 | #ifdef SRS_HIJACK_IO |
| 902 | #ifndef _WIN32 | 899 | #ifndef _WIN32 |
| 903 | // for iovec. | 900 | // for iovec. |
| 904 | #include <sys/uio.h> | 901 | #include <sys/uio.h> |
| 905 | #endif | 902 | #endif |
| 906 | /** | 903 | /** |
| 904 | + * get the hijack io object in rtmp protocol sdk. | ||
| 905 | + * @remark, user should never provides this method, srs-librtmp provides it. | ||
| 906 | + */ | ||
| 907 | + extern srs_hijack_io_t srs_hijack_io_get(srs_rtmp_t rtmp); | ||
| 908 | +#endif | ||
| 909 | +// define the following macro and functions in your module to hijack the io. | ||
| 910 | +// the example @see https://github.com/winlinvip/st-load | ||
| 911 | +// which use librtmp but use its own io(use st also). | ||
| 912 | +#ifdef SRS_HIJACK_IO | ||
| 913 | + /** | ||
| 907 | * create hijack. | 914 | * create hijack. |
| 908 | * @return NULL for error; otherwise, ok. | 915 | * @return NULL for error; otherwise, ok. |
| 909 | */ | 916 | */ |
-
请 注册 或 登录 后发表评论