mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
substitute all TAB with 4spaces.
This commit is contained in:
parent
e5770b10b1
commit
c85dde7f3f
64 changed files with 14105 additions and 14105 deletions
File diff suppressed because it is too large
Load diff
|
@ -43,29 +43,29 @@ class __SrsAmf0ObjectEOF;
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
// amf0 codec
|
||||
// 1. SrsAmf0Any: read any from stream
|
||||
// SrsAmf0Any* pany = NULL;
|
||||
// if ((ret = srs_amf0_read_any(stream, &pany)) != ERROR_SUCCESS) {
|
||||
// return ret;
|
||||
// }
|
||||
// srs_assert(pany); // if success, always valid object.
|
||||
// SrsAmf0Any* pany = NULL;
|
||||
// if ((ret = srs_amf0_read_any(stream, &pany)) != ERROR_SUCCESS) {
|
||||
// return ret;
|
||||
// }
|
||||
// srs_assert(pany); // if success, always valid object.
|
||||
// 2. SrsAmf0Any: convert to specifid type, for instance, string
|
||||
// SrsAmf0Any* pany = ...
|
||||
// if (pany->is_string()) {
|
||||
// string v = pany->to_str();
|
||||
// }
|
||||
// SrsAmf0Any* pany = ...
|
||||
// if (pany->is_string()) {
|
||||
// string v = pany->to_str();
|
||||
// }
|
||||
// 3. SrsAmf0Any: parse specified type to any, for instance, string
|
||||
// SrsAmf0Any* pany = SrsAmf0Any::str("winlin");
|
||||
// SrsAmf0Any* pany = SrsAmf0Any::str("winlin");
|
||||
// 4. SrsAmf0Size: get amf0 instance size
|
||||
// int size = SrsAmf0Size::str("winlin");
|
||||
// int size = SrsAmf0Size::str("winlin");
|
||||
// 5. SrsAmf0Object: create the amf0 object.
|
||||
// SrsAmf0Object* obj = SrsAmf0Any::object();
|
||||
// SrsAmf0Object* obj = SrsAmf0Any::object();
|
||||
// 5. SrsAmf0EcmaArray: create the amf0 ecma array.
|
||||
// SrsAmf0EcmaArray* arr = SrsAmf0Any::ecma_array();
|
||||
// SrsAmf0EcmaArray* arr = SrsAmf0Any::ecma_array();
|
||||
//
|
||||
// please carefully the size and count of amf0 any:
|
||||
// 1. total_size(): the total memory size the object wrote to buffer.
|
||||
// 2. count(): the total element count of object, for instance, the properties
|
||||
// of amf0 object, used for key_at/value_at loop.
|
||||
// of amf0 object, used for key_at/value_at loop.
|
||||
//
|
||||
// for detail usage, see interfaces of each object.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -76,73 +76,73 @@ class __SrsAmf0ObjectEOF;
|
|||
* any amf0 value.
|
||||
* 2.1 Types Overview
|
||||
* value-type = number-type | boolean-type | string-type | object-type
|
||||
* | null-marker | undefined-marker | reference-type | ecma-array-type
|
||||
* | strict-array-type | date-type | long-string-type | xml-document-type
|
||||
* | typed-object-type
|
||||
* | null-marker | undefined-marker | reference-type | ecma-array-type
|
||||
* | strict-array-type | date-type | long-string-type | xml-document-type
|
||||
* | typed-object-type
|
||||
*/
|
||||
class SrsAmf0Any
|
||||
{
|
||||
public:
|
||||
char marker;
|
||||
char marker;
|
||||
public:
|
||||
SrsAmf0Any();
|
||||
virtual ~SrsAmf0Any();
|
||||
SrsAmf0Any();
|
||||
virtual ~SrsAmf0Any();
|
||||
public:
|
||||
virtual bool is_string();
|
||||
virtual bool is_boolean();
|
||||
virtual bool is_number();
|
||||
virtual bool is_null();
|
||||
virtual bool is_undefined();
|
||||
virtual bool is_object();
|
||||
virtual bool is_object_eof();
|
||||
virtual bool is_ecma_array();
|
||||
virtual bool is_string();
|
||||
virtual bool is_boolean();
|
||||
virtual bool is_number();
|
||||
virtual bool is_null();
|
||||
virtual bool is_undefined();
|
||||
virtual bool is_object();
|
||||
virtual bool is_object_eof();
|
||||
virtual bool is_ecma_array();
|
||||
public:
|
||||
/**
|
||||
* get the string of any when is_string() indicates true.
|
||||
* user must ensure the type is a string, or assert failed.
|
||||
*/
|
||||
virtual std::string to_str();
|
||||
/**
|
||||
* get the boolean of any when is_boolean() indicates true.
|
||||
* user must ensure the type is a boolean, or assert failed.
|
||||
*/
|
||||
virtual bool to_boolean();
|
||||
/**
|
||||
* get the number of any when is_number() indicates true.
|
||||
* user must ensure the type is a number, or assert failed.
|
||||
*/
|
||||
virtual double to_number();
|
||||
/**
|
||||
* get the object of any when is_object() indicates true.
|
||||
* user must ensure the type is a object, or assert failed.
|
||||
*/
|
||||
virtual SrsAmf0Object* to_object();
|
||||
/**
|
||||
* get the ecma array of any when is_ecma_array() indicates true.
|
||||
* user must ensure the type is a ecma array, or assert failed.
|
||||
*/
|
||||
virtual SrsAmf0EcmaArray* to_ecma_array();
|
||||
/**
|
||||
* get the string of any when is_string() indicates true.
|
||||
* user must ensure the type is a string, or assert failed.
|
||||
*/
|
||||
virtual std::string to_str();
|
||||
/**
|
||||
* get the boolean of any when is_boolean() indicates true.
|
||||
* user must ensure the type is a boolean, or assert failed.
|
||||
*/
|
||||
virtual bool to_boolean();
|
||||
/**
|
||||
* get the number of any when is_number() indicates true.
|
||||
* user must ensure the type is a number, or assert failed.
|
||||
*/
|
||||
virtual double to_number();
|
||||
/**
|
||||
* get the object of any when is_object() indicates true.
|
||||
* user must ensure the type is a object, or assert failed.
|
||||
*/
|
||||
virtual SrsAmf0Object* to_object();
|
||||
/**
|
||||
* get the ecma array of any when is_ecma_array() indicates true.
|
||||
* user must ensure the type is a ecma array, or assert failed.
|
||||
*/
|
||||
virtual SrsAmf0EcmaArray* to_ecma_array();
|
||||
public:
|
||||
/**
|
||||
* get the size of amf0 any, including the marker size.
|
||||
*/
|
||||
virtual int total_size() = 0;
|
||||
/**
|
||||
* read elem from stream
|
||||
*/
|
||||
virtual int read(SrsStream* stream) = 0;
|
||||
virtual int write(SrsStream* stream) = 0;
|
||||
/**
|
||||
* get the size of amf0 any, including the marker size.
|
||||
*/
|
||||
virtual int total_size() = 0;
|
||||
/**
|
||||
* read elem from stream
|
||||
*/
|
||||
virtual int read(SrsStream* stream) = 0;
|
||||
virtual int write(SrsStream* stream) = 0;
|
||||
public:
|
||||
static SrsAmf0Any* str(const char* value = NULL);
|
||||
static SrsAmf0Any* boolean(bool value = false);
|
||||
static SrsAmf0Any* number(double value = 0.0);
|
||||
static SrsAmf0Any* null();
|
||||
static SrsAmf0Any* undefined();
|
||||
static SrsAmf0Object* object();
|
||||
static SrsAmf0Any* object_eof();
|
||||
static SrsAmf0EcmaArray* ecma_array();
|
||||
static SrsAmf0Any* str(const char* value = NULL);
|
||||
static SrsAmf0Any* boolean(bool value = false);
|
||||
static SrsAmf0Any* number(double value = 0.0);
|
||||
static SrsAmf0Any* null();
|
||||
static SrsAmf0Any* undefined();
|
||||
static SrsAmf0Object* object();
|
||||
static SrsAmf0Any* object_eof();
|
||||
static SrsAmf0EcmaArray* ecma_array();
|
||||
public:
|
||||
static int discovery(SrsStream* stream, SrsAmf0Any** ppvalue);
|
||||
static int discovery(SrsStream* stream, SrsAmf0Any** ppvalue);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -153,33 +153,33 @@ public:
|
|||
class SrsAmf0Object : public SrsAmf0Any
|
||||
{
|
||||
private:
|
||||
__SrsUnSortedHashtable* properties;
|
||||
__SrsAmf0ObjectEOF* eof;
|
||||
__SrsUnSortedHashtable* properties;
|
||||
__SrsAmf0ObjectEOF* eof;
|
||||
|
||||
private:
|
||||
// use SrsAmf0Any::object() to create it.
|
||||
friend class SrsAmf0Any;
|
||||
SrsAmf0Object();
|
||||
// use SrsAmf0Any::object() to create it.
|
||||
friend class SrsAmf0Any;
|
||||
SrsAmf0Object();
|
||||
public:
|
||||
virtual ~SrsAmf0Object();
|
||||
virtual ~SrsAmf0Object();
|
||||
|
||||
public:
|
||||
virtual int total_size();
|
||||
virtual int read(SrsStream* stream);
|
||||
virtual int write(SrsStream* stream);
|
||||
|
||||
virtual int total_size();
|
||||
virtual int read(SrsStream* stream);
|
||||
virtual int write(SrsStream* stream);
|
||||
|
||||
public:
|
||||
virtual int count();
|
||||
// @remark: max index is count().
|
||||
virtual std::string key_at(int index);
|
||||
// @remark: max index is count().
|
||||
virtual SrsAmf0Any* value_at(int index);
|
||||
|
||||
virtual int count();
|
||||
// @remark: max index is count().
|
||||
virtual std::string key_at(int index);
|
||||
// @remark: max index is count().
|
||||
virtual SrsAmf0Any* value_at(int index);
|
||||
|
||||
public:
|
||||
virtual void set(std::string key, SrsAmf0Any* value);
|
||||
virtual SrsAmf0Any* get_property(std::string name);
|
||||
virtual SrsAmf0Any* ensure_property_string(std::string name);
|
||||
virtual SrsAmf0Any* ensure_property_number(std::string name);
|
||||
virtual void set(std::string key, SrsAmf0Any* value);
|
||||
virtual SrsAmf0Any* get_property(std::string name);
|
||||
virtual SrsAmf0Any* ensure_property_string(std::string name);
|
||||
virtual SrsAmf0Any* ensure_property_number(std::string name);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -191,35 +191,35 @@ public:
|
|||
class SrsAmf0EcmaArray : public SrsAmf0Any
|
||||
{
|
||||
private:
|
||||
__SrsUnSortedHashtable* properties;
|
||||
__SrsAmf0ObjectEOF* eof;
|
||||
int32_t _count;
|
||||
__SrsUnSortedHashtable* properties;
|
||||
__SrsAmf0ObjectEOF* eof;
|
||||
int32_t _count;
|
||||
|
||||
private:
|
||||
// use SrsAmf0Any::ecma_array() to create it.
|
||||
friend class SrsAmf0Any;
|
||||
SrsAmf0EcmaArray();
|
||||
// use SrsAmf0Any::ecma_array() to create it.
|
||||
friend class SrsAmf0Any;
|
||||
SrsAmf0EcmaArray();
|
||||
public:
|
||||
virtual ~SrsAmf0EcmaArray();
|
||||
virtual ~SrsAmf0EcmaArray();
|
||||
|
||||
public:
|
||||
virtual int total_size();
|
||||
virtual int read(SrsStream* stream);
|
||||
virtual int write(SrsStream* stream);
|
||||
|
||||
virtual int total_size();
|
||||
virtual int read(SrsStream* stream);
|
||||
virtual int write(SrsStream* stream);
|
||||
|
||||
public:
|
||||
virtual void clear();
|
||||
virtual int count();
|
||||
// @remark: max index is count().
|
||||
virtual std::string key_at(int index);
|
||||
// @remark: max index is count().
|
||||
virtual SrsAmf0Any* value_at(int index);
|
||||
virtual void clear();
|
||||
virtual int count();
|
||||
// @remark: max index is count().
|
||||
virtual std::string key_at(int index);
|
||||
// @remark: max index is count().
|
||||
virtual SrsAmf0Any* value_at(int index);
|
||||
|
||||
public:
|
||||
virtual void set(std::string key, SrsAmf0Any* value);
|
||||
virtual SrsAmf0Any* get_property(std::string name);
|
||||
virtual SrsAmf0Any* ensure_property_string(std::string name);
|
||||
virtual SrsAmf0Any* ensure_property_number(std::string name);
|
||||
virtual void set(std::string key, SrsAmf0Any* value);
|
||||
virtual SrsAmf0Any* get_property(std::string name);
|
||||
virtual SrsAmf0Any* ensure_property_string(std::string name);
|
||||
virtual SrsAmf0Any* ensure_property_number(std::string name);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -228,22 +228,22 @@ public:
|
|||
class SrsAmf0Size
|
||||
{
|
||||
public:
|
||||
static int utf8(std::string value);
|
||||
static int str(std::string value);
|
||||
static int number();
|
||||
static int null();
|
||||
static int undefined();
|
||||
static int boolean();
|
||||
static int object(SrsAmf0Object* obj);
|
||||
static int object_eof();
|
||||
static int ecma_array(SrsAmf0EcmaArray* arr);
|
||||
static int any(SrsAmf0Any* o);
|
||||
static int utf8(std::string value);
|
||||
static int str(std::string value);
|
||||
static int number();
|
||||
static int null();
|
||||
static int undefined();
|
||||
static int boolean();
|
||||
static int object(SrsAmf0Object* obj);
|
||||
static int object_eof();
|
||||
static int ecma_array(SrsAmf0EcmaArray* arr);
|
||||
static int any(SrsAmf0Any* o);
|
||||
};
|
||||
|
||||
/**
|
||||
* read anything from stream.
|
||||
* @param ppvalue, the output amf0 any elem.
|
||||
* NULL if error; otherwise, never NULL and user must free it.
|
||||
* NULL if error; otherwise, never NULL and user must free it.
|
||||
*/
|
||||
extern int srs_amf0_read_any(SrsStream* stream, SrsAmf0Any** ppvalue);
|
||||
|
||||
|
@ -259,7 +259,7 @@ extern int srs_amf0_write_string(SrsStream* stream, std::string value);
|
|||
* read amf0 boolean from stream.
|
||||
* 2.4 String Type
|
||||
* boolean-type = boolean-marker U8
|
||||
* 0 is false, <> 0 is true
|
||||
* 0 is false, <> 0 is true
|
||||
*/
|
||||
extern int srs_amf0_read_boolean(SrsStream* stream, bool& value);
|
||||
extern int srs_amf0_write_boolean(SrsStream* stream, bool value);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -39,17 +39,17 @@ class SrsComplexHandshake;
|
|||
class SrsSimpleHandshake
|
||||
{
|
||||
public:
|
||||
SrsSimpleHandshake();
|
||||
virtual ~SrsSimpleHandshake();
|
||||
SrsSimpleHandshake();
|
||||
virtual ~SrsSimpleHandshake();
|
||||
public:
|
||||
/**
|
||||
* simple handshake.
|
||||
* @param complex_hs, try complex handshake first,
|
||||
* if NULL, use simple handshake.
|
||||
* if failed, rollback to simple handshake.
|
||||
*/
|
||||
virtual int handshake_with_client(ISrsProtocolReaderWriter* io, SrsComplexHandshake* complex_hs);
|
||||
virtual int handshake_with_server(ISrsProtocolReaderWriter* io, SrsComplexHandshake* complex_hs);
|
||||
/**
|
||||
* simple handshake.
|
||||
* @param complex_hs, try complex handshake first,
|
||||
* if NULL, use simple handshake.
|
||||
* if failed, rollback to simple handshake.
|
||||
*/
|
||||
virtual int handshake_with_client(ISrsProtocolReaderWriter* io, SrsComplexHandshake* complex_hs);
|
||||
virtual int handshake_with_server(ISrsProtocolReaderWriter* io, SrsComplexHandshake* complex_hs);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -60,20 +60,20 @@ public:
|
|||
class SrsComplexHandshake
|
||||
{
|
||||
public:
|
||||
SrsComplexHandshake();
|
||||
virtual ~SrsComplexHandshake();
|
||||
SrsComplexHandshake();
|
||||
virtual ~SrsComplexHandshake();
|
||||
public:
|
||||
/**
|
||||
* complex hanshake.
|
||||
* @_c1, size of c1 must be 1536.
|
||||
* @remark, user must free the c1.
|
||||
* @return user must:
|
||||
* continue connect app if success,
|
||||
* try simple handshake if error is ERROR_RTMP_TRY_SIMPLE_HS,
|
||||
* otherwise, disconnect
|
||||
*/
|
||||
virtual int handshake_with_client(ISrsProtocolReaderWriter* io, char* _c1);
|
||||
virtual int handshake_with_server(ISrsProtocolReaderWriter* io);
|
||||
/**
|
||||
* complex hanshake.
|
||||
* @_c1, size of c1 must be 1536.
|
||||
* @remark, user must free the c1.
|
||||
* @return user must:
|
||||
* continue connect app if success,
|
||||
* try simple handshake if error is ERROR_RTMP_TRY_SIMPLE_HS,
|
||||
* otherwise, disconnect
|
||||
*/
|
||||
virtual int handshake_with_client(ISrsProtocolReaderWriter* io, char* _c1);
|
||||
virtual int handshake_with_server(ISrsProtocolReaderWriter* io);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -40,14 +40,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
class ISrsProtocolReader : public ISrsBufferReader
|
||||
{
|
||||
public:
|
||||
ISrsProtocolReader();
|
||||
virtual ~ISrsProtocolReader();
|
||||
ISrsProtocolReader();
|
||||
virtual ~ISrsProtocolReader();
|
||||
// for protocol
|
||||
public:
|
||||
virtual void set_recv_timeout(int64_t timeout_us) = 0;
|
||||
virtual int64_t get_recv_timeout() = 0;
|
||||
virtual int64_t get_recv_bytes() = 0;
|
||||
virtual int get_recv_kbps() = 0;
|
||||
virtual void set_recv_timeout(int64_t timeout_us) = 0;
|
||||
virtual int64_t get_recv_timeout() = 0;
|
||||
virtual int64_t get_recv_bytes() = 0;
|
||||
virtual int get_recv_kbps() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -56,28 +56,28 @@ public:
|
|||
class ISrsProtocolWriter
|
||||
{
|
||||
public:
|
||||
ISrsProtocolWriter();
|
||||
virtual ~ISrsProtocolWriter();
|
||||
ISrsProtocolWriter();
|
||||
virtual ~ISrsProtocolWriter();
|
||||
// for protocol
|
||||
public:
|
||||
virtual void set_send_timeout(int64_t timeout_us) = 0;
|
||||
virtual int64_t get_send_timeout() = 0;
|
||||
virtual int64_t get_send_bytes() = 0;
|
||||
virtual int get_send_kbps() = 0;
|
||||
virtual void set_send_timeout(int64_t timeout_us) = 0;
|
||||
virtual int64_t get_send_timeout() = 0;
|
||||
virtual int64_t get_send_bytes() = 0;
|
||||
virtual int get_send_kbps() = 0;
|
||||
virtual int writev(const iovec *iov, int iov_size, ssize_t* nwrite) = 0;
|
||||
};
|
||||
|
||||
class ISrsProtocolReaderWriter : public ISrsProtocolReader, public ISrsProtocolWriter
|
||||
{
|
||||
public:
|
||||
ISrsProtocolReaderWriter();
|
||||
virtual ~ISrsProtocolReaderWriter();
|
||||
ISrsProtocolReaderWriter();
|
||||
virtual ~ISrsProtocolReaderWriter();
|
||||
// for protocol
|
||||
public:
|
||||
/**
|
||||
* whether the specified timeout_us is never timeout.
|
||||
*/
|
||||
virtual bool is_never_timeout(int64_t timeout_us) = 0;
|
||||
/**
|
||||
* whether the specified timeout_us is never timeout.
|
||||
*/
|
||||
virtual bool is_never_timeout(int64_t timeout_us) = 0;
|
||||
// for handshake.
|
||||
public:
|
||||
virtual int read_fully(const void* buf, size_t size, ssize_t* nread) = 0;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -48,41 +48,41 @@ class SrsPlayPacket;
|
|||
*/
|
||||
struct SrsRequest
|
||||
{
|
||||
/**
|
||||
* tcUrl: rtmp://request_vhost:port/app/stream
|
||||
* support pass vhost in query string, such as:
|
||||
* rtmp://ip:port/app?vhost=request_vhost/stream
|
||||
* rtmp://ip:port/app...vhost...request_vhost/stream
|
||||
*/
|
||||
std::string tcUrl;
|
||||
std::string pageUrl;
|
||||
std::string swfUrl;
|
||||
double objectEncoding;
|
||||
|
||||
std::string schema;
|
||||
std::string vhost;
|
||||
std::string port;
|
||||
std::string app;
|
||||
std::string stream;
|
||||
|
||||
SrsRequest();
|
||||
virtual ~SrsRequest();
|
||||
/**
|
||||
* tcUrl: rtmp://request_vhost:port/app/stream
|
||||
* support pass vhost in query string, such as:
|
||||
* rtmp://ip:port/app?vhost=request_vhost/stream
|
||||
* rtmp://ip:port/app...vhost...request_vhost/stream
|
||||
*/
|
||||
std::string tcUrl;
|
||||
std::string pageUrl;
|
||||
std::string swfUrl;
|
||||
double objectEncoding;
|
||||
|
||||
std::string schema;
|
||||
std::string vhost;
|
||||
std::string port;
|
||||
std::string app;
|
||||
std::string stream;
|
||||
|
||||
SrsRequest();
|
||||
virtual ~SrsRequest();
|
||||
|
||||
/**
|
||||
* deep copy the request, for source to use it to support reload,
|
||||
* for when initialize the source, the request is valid,
|
||||
* when reload it, the request maybe invalid, so need to copy it.
|
||||
*/
|
||||
virtual SrsRequest* copy();
|
||||
|
||||
/**
|
||||
* disconvery vhost/app from tcUrl.
|
||||
*/
|
||||
virtual int discovery_app();
|
||||
virtual std::string get_stream_url();
|
||||
virtual void strip();
|
||||
/**
|
||||
* deep copy the request, for source to use it to support reload,
|
||||
* for when initialize the source, the request is valid,
|
||||
* when reload it, the request maybe invalid, so need to copy it.
|
||||
*/
|
||||
virtual SrsRequest* copy();
|
||||
|
||||
/**
|
||||
* disconvery vhost/app from tcUrl.
|
||||
*/
|
||||
virtual int discovery_app();
|
||||
virtual std::string get_stream_url();
|
||||
virtual void strip();
|
||||
private:
|
||||
std::string& trim(std::string& str, std::string chs);
|
||||
std::string& trim(std::string& str, std::string chs);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -90,10 +90,10 @@ private:
|
|||
*/
|
||||
struct SrsResponse
|
||||
{
|
||||
int stream_id;
|
||||
|
||||
SrsResponse();
|
||||
virtual ~SrsResponse();
|
||||
int stream_id;
|
||||
|
||||
SrsResponse();
|
||||
virtual ~SrsResponse();
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -101,10 +101,10 @@ struct SrsResponse
|
|||
*/
|
||||
enum SrsClientType
|
||||
{
|
||||
SrsClientUnknown,
|
||||
SrsClientPlay,
|
||||
SrsClientFMLEPublish,
|
||||
SrsClientFlashPublish,
|
||||
SrsClientUnknown,
|
||||
SrsClientPlay,
|
||||
SrsClientFMLEPublish,
|
||||
SrsClientFlashPublish,
|
||||
};
|
||||
std::string srs_client_type_string(SrsClientType type);
|
||||
|
||||
|
@ -114,36 +114,36 @@ std::string srs_client_type_string(SrsClientType type);
|
|||
class SrsRtmpClient
|
||||
{
|
||||
protected:
|
||||
SrsProtocol* protocol;
|
||||
ISrsProtocolReaderWriter* io;
|
||||
SrsProtocol* protocol;
|
||||
ISrsProtocolReaderWriter* io;
|
||||
public:
|
||||
SrsRtmpClient(ISrsProtocolReaderWriter* skt);
|
||||
virtual ~SrsRtmpClient();
|
||||
SrsRtmpClient(ISrsProtocolReaderWriter* skt);
|
||||
virtual ~SrsRtmpClient();
|
||||
public:
|
||||
virtual void set_recv_timeout(int64_t timeout_us);
|
||||
virtual void set_send_timeout(int64_t timeout_us);
|
||||
virtual int64_t get_recv_bytes();
|
||||
virtual int64_t get_send_bytes();
|
||||
virtual int get_recv_kbps();
|
||||
virtual int get_send_kbps();
|
||||
virtual int recv_message(SrsCommonMessage** pmsg);
|
||||
virtual int send_message(ISrsMessage* msg);
|
||||
virtual void set_recv_timeout(int64_t timeout_us);
|
||||
virtual void set_send_timeout(int64_t timeout_us);
|
||||
virtual int64_t get_recv_bytes();
|
||||
virtual int64_t get_send_bytes();
|
||||
virtual int get_recv_kbps();
|
||||
virtual int get_send_kbps();
|
||||
virtual int recv_message(SrsCommonMessage** pmsg);
|
||||
virtual int send_message(ISrsMessage* msg);
|
||||
public:
|
||||
// try complex, then simple handshake.
|
||||
virtual int handshake();
|
||||
// only use simple handshake
|
||||
virtual int simple_handshake();
|
||||
// only use complex handshake
|
||||
virtual int complex_handshake();
|
||||
virtual int connect_app(std::string app, std::string tc_url);
|
||||
virtual int create_stream(int& stream_id);
|
||||
virtual int play(std::string stream, int stream_id);
|
||||
// flash publish schema:
|
||||
// connect-app => create-stream => flash-publish
|
||||
virtual int publish(std::string stream, int stream_id);
|
||||
// FMLE publish schema:
|
||||
// connect-app => FMLE publish
|
||||
virtual int fmle_publish(std::string stream, int& stream_id);
|
||||
// try complex, then simple handshake.
|
||||
virtual int handshake();
|
||||
// only use simple handshake
|
||||
virtual int simple_handshake();
|
||||
// only use complex handshake
|
||||
virtual int complex_handshake();
|
||||
virtual int connect_app(std::string app, std::string tc_url);
|
||||
virtual int create_stream(int& stream_id);
|
||||
virtual int play(std::string stream, int stream_id);
|
||||
// flash publish schema:
|
||||
// connect-app => create-stream => flash-publish
|
||||
virtual int publish(std::string stream, int stream_id);
|
||||
// FMLE publish schema:
|
||||
// connect-app => FMLE publish
|
||||
virtual int fmle_publish(std::string stream, int& stream_id);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -155,93 +155,93 @@ public:
|
|||
class SrsRtmpServer
|
||||
{
|
||||
private:
|
||||
SrsProtocol* protocol;
|
||||
ISrsProtocolReaderWriter* io;
|
||||
SrsProtocol* protocol;
|
||||
ISrsProtocolReaderWriter* io;
|
||||
public:
|
||||
SrsRtmpServer(ISrsProtocolReaderWriter* skt);
|
||||
virtual ~SrsRtmpServer();
|
||||
SrsRtmpServer(ISrsProtocolReaderWriter* skt);
|
||||
virtual ~SrsRtmpServer();
|
||||
public:
|
||||
virtual SrsProtocol* get_protocol();
|
||||
virtual void set_recv_timeout(int64_t timeout_us);
|
||||
virtual int64_t get_recv_timeout();
|
||||
virtual void set_send_timeout(int64_t timeout_us);
|
||||
virtual int64_t get_send_timeout();
|
||||
virtual int64_t get_recv_bytes();
|
||||
virtual int64_t get_send_bytes();
|
||||
virtual int get_recv_kbps();
|
||||
virtual int get_send_kbps();
|
||||
virtual int recv_message(SrsCommonMessage** pmsg);
|
||||
virtual int send_message(ISrsMessage* msg);
|
||||
virtual SrsProtocol* get_protocol();
|
||||
virtual void set_recv_timeout(int64_t timeout_us);
|
||||
virtual int64_t get_recv_timeout();
|
||||
virtual void set_send_timeout(int64_t timeout_us);
|
||||
virtual int64_t get_send_timeout();
|
||||
virtual int64_t get_recv_bytes();
|
||||
virtual int64_t get_send_bytes();
|
||||
virtual int get_recv_kbps();
|
||||
virtual int get_send_kbps();
|
||||
virtual int recv_message(SrsCommonMessage** pmsg);
|
||||
virtual int send_message(ISrsMessage* msg);
|
||||
public:
|
||||
virtual int handshake();
|
||||
virtual int connect_app(SrsRequest* req);
|
||||
virtual int set_window_ack_size(int ack_size);
|
||||
/**
|
||||
* @type: The sender can mark this message hard (0), soft (1), or dynamic (2)
|
||||
* using the Limit type field.
|
||||
*/
|
||||
virtual int set_peer_bandwidth(int bandwidth, int type);
|
||||
/**
|
||||
* @param server_ip the ip of server.
|
||||
*/
|
||||
virtual int handshake();
|
||||
virtual int connect_app(SrsRequest* req);
|
||||
virtual int set_window_ack_size(int ack_size);
|
||||
/**
|
||||
* @type: The sender can mark this message hard (0), soft (1), or dynamic (2)
|
||||
* using the Limit type field.
|
||||
*/
|
||||
virtual int set_peer_bandwidth(int bandwidth, int type);
|
||||
/**
|
||||
* @param server_ip the ip of server.
|
||||
*/
|
||||
virtual int response_connect_app(SrsRequest* req, const char* server_ip = NULL);
|
||||
virtual void response_connect_reject(SrsRequest* req, const char* desc);
|
||||
virtual int on_bw_done();
|
||||
/**
|
||||
* recv some message to identify the client.
|
||||
* @stream_id, client will createStream to play or publish by flash,
|
||||
* the stream_id used to response the createStream request.
|
||||
* @type, output the client type.
|
||||
*/
|
||||
virtual int identify_client(int stream_id, SrsClientType& type, std::string& stream_name);
|
||||
/**
|
||||
* set the chunk size when client type identified.
|
||||
*/
|
||||
virtual int set_chunk_size(int chunk_size);
|
||||
/**
|
||||
* when client type is play, response with packets:
|
||||
* StreamBegin,
|
||||
* onStatus(NetStream.Play.Reset), onStatus(NetStream.Play.Start).,
|
||||
* |RtmpSampleAccess(false, false),
|
||||
* onStatus(NetStream.Data.Start).
|
||||
*/
|
||||
virtual int start_play(int stream_id);
|
||||
/**
|
||||
* when client(type is play) send pause message,
|
||||
* if is_pause, response the following packets:
|
||||
* onStatus(NetStream.Pause.Notify)
|
||||
* StreamEOF
|
||||
* if not is_pause, response the following packets:
|
||||
* onStatus(NetStream.Unpause.Notify)
|
||||
* StreamBegin
|
||||
*/
|
||||
virtual int on_play_client_pause(int stream_id, bool is_pause);
|
||||
/**
|
||||
* when client type is publish, response with packets:
|
||||
* releaseStream response
|
||||
* FCPublish
|
||||
* FCPublish response
|
||||
* createStream response
|
||||
* onFCPublish(NetStream.Publish.Start)
|
||||
* onStatus(NetStream.Publish.Start)
|
||||
*/
|
||||
virtual int start_fmle_publish(int stream_id);
|
||||
/**
|
||||
* process the FMLE unpublish event.
|
||||
* @unpublish_tid the unpublish request transaction id.
|
||||
*/
|
||||
virtual int fmle_unpublish(int stream_id, double unpublish_tid);
|
||||
/**
|
||||
* when client type is publish, response with packets:
|
||||
* onStatus(NetStream.Publish.Start)
|
||||
*/
|
||||
virtual int start_flash_publish(int stream_id);
|
||||
virtual int on_bw_done();
|
||||
/**
|
||||
* recv some message to identify the client.
|
||||
* @stream_id, client will createStream to play or publish by flash,
|
||||
* the stream_id used to response the createStream request.
|
||||
* @type, output the client type.
|
||||
*/
|
||||
virtual int identify_client(int stream_id, SrsClientType& type, std::string& stream_name);
|
||||
/**
|
||||
* set the chunk size when client type identified.
|
||||
*/
|
||||
virtual int set_chunk_size(int chunk_size);
|
||||
/**
|
||||
* when client type is play, response with packets:
|
||||
* StreamBegin,
|
||||
* onStatus(NetStream.Play.Reset), onStatus(NetStream.Play.Start).,
|
||||
* |RtmpSampleAccess(false, false),
|
||||
* onStatus(NetStream.Data.Start).
|
||||
*/
|
||||
virtual int start_play(int stream_id);
|
||||
/**
|
||||
* when client(type is play) send pause message,
|
||||
* if is_pause, response the following packets:
|
||||
* onStatus(NetStream.Pause.Notify)
|
||||
* StreamEOF
|
||||
* if not is_pause, response the following packets:
|
||||
* onStatus(NetStream.Unpause.Notify)
|
||||
* StreamBegin
|
||||
*/
|
||||
virtual int on_play_client_pause(int stream_id, bool is_pause);
|
||||
/**
|
||||
* when client type is publish, response with packets:
|
||||
* releaseStream response
|
||||
* FCPublish
|
||||
* FCPublish response
|
||||
* createStream response
|
||||
* onFCPublish(NetStream.Publish.Start)
|
||||
* onStatus(NetStream.Publish.Start)
|
||||
*/
|
||||
virtual int start_fmle_publish(int stream_id);
|
||||
/**
|
||||
* process the FMLE unpublish event.
|
||||
* @unpublish_tid the unpublish request transaction id.
|
||||
*/
|
||||
virtual int fmle_unpublish(int stream_id, double unpublish_tid);
|
||||
/**
|
||||
* when client type is publish, response with packets:
|
||||
* onStatus(NetStream.Publish.Start)
|
||||
*/
|
||||
virtual int start_flash_publish(int stream_id);
|
||||
private:
|
||||
virtual int identify_create_stream_client(SrsCreateStreamPacket* req, int stream_id, SrsClientType& type, std::string& stream_name);
|
||||
virtual int identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsClientType& type, std::string& stream_name);
|
||||
virtual int identify_flash_publish_client(SrsPublishPacket* req, SrsClientType& type, std::string& stream_name);
|
||||
virtual int identify_create_stream_client(SrsCreateStreamPacket* req, int stream_id, SrsClientType& type, std::string& stream_name);
|
||||
virtual int identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsClientType& type, std::string& stream_name);
|
||||
virtual int identify_flash_publish_client(SrsPublishPacket* req, SrsClientType& type, std::string& stream_name);
|
||||
private:
|
||||
virtual int identify_play_client(SrsPlayPacket* req, SrsClientType& type, std::string& stream_name);
|
||||
virtual int identify_play_client(SrsPlayPacket* req, SrsClientType& type, std::string& stream_name);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -25,24 +25,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
void srs_vhost_resolve(std::string& vhost, std::string& app)
|
||||
{
|
||||
app = srs_replace(app, "...", "?");
|
||||
|
||||
size_t pos = 0;
|
||||
if ((pos = app.find("?")) == std::string::npos) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string query = app.substr(pos + 1);
|
||||
app = app.substr(0, pos);
|
||||
|
||||
if ((pos = query.find("vhost?")) != std::string::npos
|
||||
|| (pos = query.find("vhost=")) != std::string::npos
|
||||
|| (pos = query.find("Vhost?")) != std::string::npos
|
||||
|| (pos = query.find("Vhost=")) != std::string::npos
|
||||
) {
|
||||
query = query.substr(pos + 6);
|
||||
if (!query.empty()) {
|
||||
vhost = query;
|
||||
}
|
||||
}
|
||||
app = srs_replace(app, "...", "?");
|
||||
|
||||
size_t pos = 0;
|
||||
if ((pos = app.find("?")) == std::string::npos) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string query = app.substr(pos + 1);
|
||||
app = app.substr(0, pos);
|
||||
|
||||
if ((pos = query.find("vhost?")) != std::string::npos
|
||||
|| (pos = query.find("vhost=")) != std::string::npos
|
||||
|| (pos = query.find("Vhost?")) != std::string::npos
|
||||
|| (pos = query.find("Vhost=")) != std::string::npos
|
||||
) {
|
||||
query = query.substr(pos + 6);
|
||||
if (!query.empty()) {
|
||||
vhost = query;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
// resolve the vhost in query string
|
||||
// @param app, may contains the vhost in query string format:
|
||||
// app?vhost=request_vhost
|
||||
// app...vhost...request_vhost
|
||||
// app?vhost=request_vhost
|
||||
// app...vhost...request_vhost
|
||||
extern void srs_vhost_resolve(std::string& vhost, std::string& app);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue