mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine the srs-librtmp, add hijack get the object.
This commit is contained in:
parent
a94dbecdc4
commit
b28dc7364e
4 changed files with 38 additions and 5 deletions
|
@ -290,6 +290,11 @@ SimpleSocketStream::~SimpleSocketStream()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
srs_hijack_io_t SimpleSocketStream::hijack_io()
|
||||||
|
{
|
||||||
|
return io;
|
||||||
|
}
|
||||||
|
|
||||||
int SimpleSocketStream::create_socket()
|
int SimpleSocketStream::create_socket()
|
||||||
{
|
{
|
||||||
srs_assert(io);
|
srs_assert(io);
|
||||||
|
|
|
@ -50,6 +50,7 @@ public:
|
||||||
SimpleSocketStream();
|
SimpleSocketStream();
|
||||||
virtual ~SimpleSocketStream();
|
virtual ~SimpleSocketStream();
|
||||||
public:
|
public:
|
||||||
|
virtual srs_hijack_io_t hijack_io();
|
||||||
virtual int create_socket();
|
virtual int create_socket();
|
||||||
virtual int connect(const char* server, int port);
|
virtual int connect(const char* server, int port);
|
||||||
// ISrsBufferReader
|
// ISrsBufferReader
|
||||||
|
|
|
@ -534,7 +534,10 @@ srs_rtmp_t srs_rtmp_create2(const char* url)
|
||||||
|
|
||||||
void srs_rtmp_destroy(srs_rtmp_t rtmp)
|
void srs_rtmp_destroy(srs_rtmp_t rtmp)
|
||||||
{
|
{
|
||||||
srs_assert(rtmp != NULL);
|
if (!rtmp) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Context* context = (Context*)rtmp;
|
Context* context = (Context*)rtmp;
|
||||||
|
|
||||||
srs_freep(context);
|
srs_freep(context);
|
||||||
|
@ -2424,6 +2427,23 @@ const char* srs_human_format_time()
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SRS_HIJACK_IO
|
||||||
|
srs_hijack_io_t srs_hijack_io_get(srs_rtmp_t rtmp)
|
||||||
|
{
|
||||||
|
if (!rtmp) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Context* context = (Context*)rtmp;
|
||||||
|
if (!context->skt) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return context->skt->hijack_io();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -107,7 +107,7 @@ extern srs_rtmp_t srs_rtmp_create(const char* url);
|
||||||
extern srs_rtmp_t srs_rtmp_create2(const char* url);
|
extern srs_rtmp_t srs_rtmp_create2(const char* url);
|
||||||
/**
|
/**
|
||||||
* close and destroy the rtmp stack.
|
* close and destroy the rtmp stack.
|
||||||
* @remark, user should use the rtmp again.
|
* @remark, user should never use the rtmp again.
|
||||||
*/
|
*/
|
||||||
extern void srs_rtmp_destroy(srs_rtmp_t rtmp);
|
extern void srs_rtmp_destroy(srs_rtmp_t rtmp);
|
||||||
|
|
||||||
|
@ -895,14 +895,21 @@ extern const char* srs_human_format_time();
|
||||||
*************************************************************/
|
*************************************************************/
|
||||||
// the void* will convert to your handler for io hijack.
|
// the void* will convert to your handler for io hijack.
|
||||||
typedef void* srs_hijack_io_t;
|
typedef void* srs_hijack_io_t;
|
||||||
// define the following macro and functions in your module to hijack the io.
|
|
||||||
// the example @see https://github.com/winlinvip/st-load
|
|
||||||
// which use librtmp but use its own io(use st also).
|
|
||||||
#ifdef SRS_HIJACK_IO
|
#ifdef SRS_HIJACK_IO
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
// for iovec.
|
// for iovec.
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#endif
|
#endif
|
||||||
|
/**
|
||||||
|
* get the hijack io object in rtmp protocol sdk.
|
||||||
|
* @remark, user should never provides this method, srs-librtmp provides it.
|
||||||
|
*/
|
||||||
|
extern srs_hijack_io_t srs_hijack_io_get(srs_rtmp_t rtmp);
|
||||||
|
#endif
|
||||||
|
// define the following macro and functions in your module to hijack the io.
|
||||||
|
// the example @see https://github.com/winlinvip/st-load
|
||||||
|
// which use librtmp but use its own io(use st also).
|
||||||
|
#ifdef SRS_HIJACK_IO
|
||||||
/**
|
/**
|
||||||
* create hijack.
|
* create hijack.
|
||||||
* @return NULL for error; otherwise, ok.
|
* @return NULL for error; otherwise, ok.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue