mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
merge from wenjie, fix the pause bug of jw/flower which actually send closeStream to pause.
This commit is contained in:
parent
4148f5231d
commit
765b0a9c01
8 changed files with 3786 additions and 3637 deletions
1455
trunk/src/core/srs_core_client.cpp
Normal file → Executable file
1455
trunk/src/core/srs_core_client.cpp
Normal file → Executable file
File diff suppressed because it is too large
Load diff
178
trunk/src/core/srs_core_client.hpp
Normal file → Executable file
178
trunk/src/core/srs_core_client.hpp
Normal file → Executable file
|
@ -1,89 +1,91 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRS_CORE_CLIENT_HPP
|
||||
#define SRS_CORE_CLIENT_HPP
|
||||
|
||||
/*
|
||||
#include <srs_core_client.hpp>
|
||||
*/
|
||||
|
||||
#include <srs_core.hpp>
|
||||
|
||||
#include <srs_core_conn.hpp>
|
||||
#include <srs_core_reload.hpp>
|
||||
|
||||
class SrsRtmp;
|
||||
class SrsRequest;
|
||||
class SrsResponse;
|
||||
class SrsSource;
|
||||
class SrsRefer;
|
||||
class SrsConsumer;
|
||||
class SrsCommonMessage;
|
||||
#ifdef SRS_HTTP
|
||||
class SrsHttpHooks;
|
||||
#endif
|
||||
class SrsBandwidth;
|
||||
|
||||
/**
|
||||
* the client provides the main logic control for RTMP clients.
|
||||
*/
|
||||
class SrsClient : public SrsConnection, public ISrsReloadHandler
|
||||
{
|
||||
private:
|
||||
char* ip;
|
||||
SrsRequest* req;
|
||||
SrsResponse* res;
|
||||
SrsRtmp* rtmp;
|
||||
SrsRefer* refer;
|
||||
#ifdef SRS_HTTP
|
||||
SrsHttpHooks* http_hooks;
|
||||
#endif
|
||||
SrsBandwidth* bandwidth;
|
||||
public:
|
||||
SrsClient(SrsServer* srs_server, st_netfd_t client_stfd);
|
||||
virtual ~SrsClient();
|
||||
protected:
|
||||
virtual int do_cycle();
|
||||
// interface ISrsReloadHandler
|
||||
public:
|
||||
virtual int on_reload_vhost_removed(std::string vhost);
|
||||
private:
|
||||
// when valid and connected to vhost/app, service the client.
|
||||
virtual int service_cycle();
|
||||
virtual int check_vhost();
|
||||
virtual int playing(SrsSource* source);
|
||||
virtual int publish(SrsSource* source, bool is_fmle);
|
||||
virtual int process_publish_message(SrsSource* source, SrsCommonMessage* msg, bool is_fmle);
|
||||
virtual int get_peer_ip();
|
||||
virtual int process_play_control_msg(SrsConsumer* consumer, SrsCommonMessage* msg);
|
||||
private:
|
||||
virtual int on_connect();
|
||||
virtual void on_close();
|
||||
virtual int on_publish();
|
||||
virtual void on_unpublish();
|
||||
virtual int on_play();
|
||||
virtual void on_stop();
|
||||
};
|
||||
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRS_CORE_CLIENT_HPP
|
||||
#define SRS_CORE_CLIENT_HPP
|
||||
|
||||
/*
|
||||
#include <srs_core_client.hpp>
|
||||
*/
|
||||
|
||||
#include <srs_core.hpp>
|
||||
|
||||
#include <srs_core_conn.hpp>
|
||||
#include <srs_core_reload.hpp>
|
||||
|
||||
class SrsRtmp;
|
||||
class SrsRequest;
|
||||
class SrsResponse;
|
||||
class SrsSource;
|
||||
class SrsRefer;
|
||||
class SrsConsumer;
|
||||
class SrsCommonMessage;
|
||||
#ifdef SRS_HTTP
|
||||
class SrsHttpHooks;
|
||||
#endif
|
||||
class SrsBandwidth;
|
||||
|
||||
/**
|
||||
* the client provides the main logic control for RTMP clients.
|
||||
*/
|
||||
class SrsClient : public SrsConnection, public ISrsReloadHandler
|
||||
{
|
||||
private:
|
||||
char* ip;
|
||||
SrsRequest* req;
|
||||
SrsResponse* res;
|
||||
SrsRtmp* rtmp;
|
||||
SrsRefer* refer;
|
||||
#ifdef SRS_HTTP
|
||||
SrsHttpHooks* http_hooks;
|
||||
#endif
|
||||
SrsBandwidth* bandwidth;
|
||||
public:
|
||||
SrsClient(SrsServer* srs_server, st_netfd_t client_stfd);
|
||||
virtual ~SrsClient();
|
||||
protected:
|
||||
virtual int do_cycle();
|
||||
// interface ISrsReloadHandler
|
||||
public:
|
||||
virtual int on_reload_vhost_removed(std::string vhost);
|
||||
private:
|
||||
// when valid and connected to vhost/app, service the client.
|
||||
virtual int service_cycle();
|
||||
// stream(play/publish) service cycle, identify client first.
|
||||
virtual int stream_service_cycle();
|
||||
virtual int check_vhost();
|
||||
virtual int playing(SrsSource* source);
|
||||
virtual int publish(SrsSource* source, bool is_fmle);
|
||||
virtual int process_publish_message(SrsSource* source, SrsCommonMessage* msg, bool is_fmle);
|
||||
virtual int get_peer_ip();
|
||||
virtual int process_play_control_msg(SrsConsumer* consumer, SrsCommonMessage* msg);
|
||||
private:
|
||||
virtual int on_connect();
|
||||
virtual void on_close();
|
||||
virtual int on_publish();
|
||||
virtual void on_unpublish();
|
||||
virtual int on_play();
|
||||
virtual void on_stop();
|
||||
};
|
||||
|
||||
#endif
|
53
trunk/src/core/srs_core_error.cpp
Normal file → Executable file
53
trunk/src/core/srs_core_error.cpp
Normal file → Executable file
|
@ -1,24 +1,29 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <srs_core_error.hpp>
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <srs_core_error.hpp>
|
||||
|
||||
bool srs_is_system_control_error(int error_code)
|
||||
{
|
||||
return error_code == ERROR_CONTROL_RTMP_CLOSE;
|
||||
}
|
||||
|
|
308
trunk/src/core/srs_core_error.hpp
Normal file → Executable file
308
trunk/src/core/srs_core_error.hpp
Normal file → Executable file
|
@ -1,150 +1,160 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRS_CORE_ERROR_HPP
|
||||
#define SRS_CORE_ERROR_HPP
|
||||
|
||||
/*
|
||||
#include <srs_core_error.hpp>
|
||||
*/
|
||||
|
||||
#include <srs_core.hpp>
|
||||
|
||||
#define ERROR_SUCCESS 0
|
||||
|
||||
#define ERROR_ST_SET_EPOLL 100
|
||||
#define ERROR_ST_INITIALIZE 101
|
||||
#define ERROR_ST_OPEN_SOCKET 102
|
||||
#define ERROR_ST_CREATE_LISTEN_THREAD 103
|
||||
#define ERROR_ST_CREATE_CYCLE_THREAD 104
|
||||
#define ERROR_ST_CONNECT 105
|
||||
|
||||
#define ERROR_SOCKET_CREATE 200
|
||||
#define ERROR_SOCKET_SETREUSE 201
|
||||
#define ERROR_SOCKET_BIND 202
|
||||
#define ERROR_SOCKET_LISTEN 203
|
||||
#define ERROR_SOCKET_CLOSED 204
|
||||
#define ERROR_SOCKET_GET_PEER_NAME 205
|
||||
#define ERROR_SOCKET_GET_PEER_IP 206
|
||||
#define ERROR_SOCKET_READ 207
|
||||
#define ERROR_SOCKET_READ_FULLY 208
|
||||
#define ERROR_SOCKET_WRITE 209
|
||||
#define ERROR_SOCKET_WAIT 210
|
||||
#define ERROR_SOCKET_TIMEOUT 211
|
||||
#define ERROR_SOCKET_GET_LOCAL_IP 212
|
||||
|
||||
#define ERROR_RTMP_PLAIN_REQUIRED 300
|
||||
#define ERROR_RTMP_CHUNK_START 301
|
||||
#define ERROR_RTMP_MSG_INVLIAD_SIZE 302
|
||||
#define ERROR_RTMP_AMF0_DECODE 303
|
||||
#define ERROR_RTMP_AMF0_INVALID 304
|
||||
#define ERROR_RTMP_REQ_CONNECT 305
|
||||
#define ERROR_RTMP_REQ_TCURL 306
|
||||
#define ERROR_RTMP_MESSAGE_DECODE 307
|
||||
#define ERROR_RTMP_MESSAGE_ENCODE 308
|
||||
#define ERROR_RTMP_AMF0_ENCODE 309
|
||||
#define ERROR_RTMP_CHUNK_SIZE 310
|
||||
#define ERROR_RTMP_TRY_SIMPLE_HS 311
|
||||
#define ERROR_RTMP_CH_SCHEMA 312
|
||||
#define ERROR_RTMP_PACKET_SIZE 313
|
||||
#define ERROR_RTMP_VHOST_NOT_FOUND 314
|
||||
#define ERROR_RTMP_ACCESS_DENIED 315
|
||||
#define ERROR_RTMP_HANDSHAKE 316
|
||||
#define ERROR_RTMP_NO_REQUEST 317
|
||||
|
||||
#define ERROR_SYSTEM_STREAM_INIT 400
|
||||
#define ERROR_SYSTEM_PACKET_INVALID 401
|
||||
#define ERROR_SYSTEM_CLIENT_INVALID 402
|
||||
#define ERROR_SYSTEM_ASSERT_FAILED 403
|
||||
#define ERROR_SYSTEM_SIZE_NEGATIVE 404
|
||||
#define ERROR_SYSTEM_CONFIG_INVALID 405
|
||||
#define ERROR_SYSTEM_CONFIG_DIRECTIVE 406
|
||||
#define ERROR_SYSTEM_CONFIG_BLOCK_START 407
|
||||
#define ERROR_SYSTEM_CONFIG_BLOCK_END 408
|
||||
#define ERROR_SYSTEM_CONFIG_EOF 409
|
||||
#define ERROR_SYSTEM_STREAM_BUSY 410
|
||||
#define ERROR_SYSTEM_IP_INVALID 411
|
||||
#define ERROR_SYSTEM_FORWARD_LOOP 412
|
||||
#define ERROR_SYSTEM_WAITPID 413
|
||||
#define ERROR_SYSTEM_BANDWIDTH_KEY 414
|
||||
#define ERROR_SYSTEM_BANDWIDTH_DENIED 415
|
||||
|
||||
// see librtmp.
|
||||
// failed when open ssl create the dh
|
||||
#define ERROR_OpenSslCreateDH 500
|
||||
// failed when open ssl create the Private key.
|
||||
#define ERROR_OpenSslCreateP 501
|
||||
// when open ssl create G.
|
||||
#define ERROR_OpenSslCreateG 502
|
||||
// when open ssl parse P1024
|
||||
#define ERROR_OpenSslParseP1024 503
|
||||
// when open ssl set G
|
||||
#define ERROR_OpenSslSetG 504
|
||||
// when open ssl generate DHKeys
|
||||
#define ERROR_OpenSslGenerateDHKeys 505
|
||||
// when open ssl share key already computed.
|
||||
#define ERROR_OpenSslShareKeyComputed 506
|
||||
// when open ssl get shared key size.
|
||||
#define ERROR_OpenSslGetSharedKeySize 507
|
||||
// when open ssl get peer public key.
|
||||
#define ERROR_OpenSslGetPeerPublicKey 508
|
||||
// when open ssl compute shared key.
|
||||
#define ERROR_OpenSslComputeSharedKey 509
|
||||
// when open ssl is invalid DH state.
|
||||
#define ERROR_OpenSslInvalidDHState 510
|
||||
// when open ssl copy key
|
||||
#define ERROR_OpenSslCopyKey 511
|
||||
// when open ssl sha256 digest key invalid size.
|
||||
#define ERROR_OpenSslSha256DigestSize 512
|
||||
|
||||
#define ERROR_HLS_METADATA 600
|
||||
#define ERROR_HLS_DECODE_ERROR 601
|
||||
#define ERROR_HLS_CREATE_DIR 602
|
||||
#define ERROR_HLS_OPEN_FAILED 603
|
||||
#define ERROR_HLS_WRITE_FAILED 604
|
||||
#define ERROR_HLS_AAC_FRAME_LENGTH 605
|
||||
#define ERROR_HLS_AVC_SAMPLE_SIZE 606
|
||||
|
||||
#define ERROR_ENCODER_VCODEC 700
|
||||
#define ERROR_ENCODER_OUTPUT 701
|
||||
#define ERROR_ENCODER_ACHANNELS 702
|
||||
#define ERROR_ENCODER_ASAMPLE_RATE 703
|
||||
#define ERROR_ENCODER_ABITRATE 704
|
||||
#define ERROR_ENCODER_ACODEC 705
|
||||
#define ERROR_ENCODER_VPRESET 706
|
||||
#define ERROR_ENCODER_VPROFILE 707
|
||||
#define ERROR_ENCODER_VTHREADS 708
|
||||
#define ERROR_ENCODER_VHEIGHT 709
|
||||
#define ERROR_ENCODER_VWIDTH 710
|
||||
#define ERROR_ENCODER_VFPS 711
|
||||
#define ERROR_ENCODER_VBITRATE 712
|
||||
#define ERROR_ENCODER_FORK 713
|
||||
#define ERROR_ENCODER_LOOP 714
|
||||
#define ERROR_ENCODER_OPEN 715
|
||||
#define ERROR_ENCODER_DUP2 716
|
||||
|
||||
#define ERROR_HTTP_PARSE_URI 800
|
||||
#define ERROR_HTTP_DATA_INVLIAD 801
|
||||
#define ERROR_HTTP_PARSE_HEADER 802
|
||||
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRS_CORE_ERROR_HPP
|
||||
#define SRS_CORE_ERROR_HPP
|
||||
|
||||
/*
|
||||
#include <srs_core_error.hpp>
|
||||
*/
|
||||
|
||||
#include <srs_core.hpp>
|
||||
|
||||
#define ERROR_SUCCESS 0
|
||||
|
||||
#define ERROR_ST_SET_EPOLL 100
|
||||
#define ERROR_ST_INITIALIZE 101
|
||||
#define ERROR_ST_OPEN_SOCKET 102
|
||||
#define ERROR_ST_CREATE_LISTEN_THREAD 103
|
||||
#define ERROR_ST_CREATE_CYCLE_THREAD 104
|
||||
#define ERROR_ST_CONNECT 105
|
||||
|
||||
#define ERROR_SOCKET_CREATE 200
|
||||
#define ERROR_SOCKET_SETREUSE 201
|
||||
#define ERROR_SOCKET_BIND 202
|
||||
#define ERROR_SOCKET_LISTEN 203
|
||||
#define ERROR_SOCKET_CLOSED 204
|
||||
#define ERROR_SOCKET_GET_PEER_NAME 205
|
||||
#define ERROR_SOCKET_GET_PEER_IP 206
|
||||
#define ERROR_SOCKET_READ 207
|
||||
#define ERROR_SOCKET_READ_FULLY 208
|
||||
#define ERROR_SOCKET_WRITE 209
|
||||
#define ERROR_SOCKET_WAIT 210
|
||||
#define ERROR_SOCKET_TIMEOUT 211
|
||||
#define ERROR_SOCKET_GET_LOCAL_IP 212
|
||||
|
||||
#define ERROR_RTMP_PLAIN_REQUIRED 300
|
||||
#define ERROR_RTMP_CHUNK_START 301
|
||||
#define ERROR_RTMP_MSG_INVLIAD_SIZE 302
|
||||
#define ERROR_RTMP_AMF0_DECODE 303
|
||||
#define ERROR_RTMP_AMF0_INVALID 304
|
||||
#define ERROR_RTMP_REQ_CONNECT 305
|
||||
#define ERROR_RTMP_REQ_TCURL 306
|
||||
#define ERROR_RTMP_MESSAGE_DECODE 307
|
||||
#define ERROR_RTMP_MESSAGE_ENCODE 308
|
||||
#define ERROR_RTMP_AMF0_ENCODE 309
|
||||
#define ERROR_RTMP_CHUNK_SIZE 310
|
||||
#define ERROR_RTMP_TRY_SIMPLE_HS 311
|
||||
#define ERROR_RTMP_CH_SCHEMA 312
|
||||
#define ERROR_RTMP_PACKET_SIZE 313
|
||||
#define ERROR_RTMP_VHOST_NOT_FOUND 314
|
||||
#define ERROR_RTMP_ACCESS_DENIED 315
|
||||
#define ERROR_RTMP_HANDSHAKE 316
|
||||
#define ERROR_RTMP_NO_REQUEST 317
|
||||
|
||||
#define ERROR_SYSTEM_STREAM_INIT 400
|
||||
#define ERROR_SYSTEM_PACKET_INVALID 401
|
||||
#define ERROR_SYSTEM_CLIENT_INVALID 402
|
||||
#define ERROR_SYSTEM_ASSERT_FAILED 403
|
||||
#define ERROR_SYSTEM_SIZE_NEGATIVE 404
|
||||
#define ERROR_SYSTEM_CONFIG_INVALID 405
|
||||
#define ERROR_SYSTEM_CONFIG_DIRECTIVE 406
|
||||
#define ERROR_SYSTEM_CONFIG_BLOCK_START 407
|
||||
#define ERROR_SYSTEM_CONFIG_BLOCK_END 408
|
||||
#define ERROR_SYSTEM_CONFIG_EOF 409
|
||||
#define ERROR_SYSTEM_STREAM_BUSY 410
|
||||
#define ERROR_SYSTEM_IP_INVALID 411
|
||||
#define ERROR_SYSTEM_FORWARD_LOOP 412
|
||||
#define ERROR_SYSTEM_WAITPID 413
|
||||
#define ERROR_SYSTEM_BANDWIDTH_KEY 414
|
||||
#define ERROR_SYSTEM_BANDWIDTH_DENIED 415
|
||||
|
||||
// see librtmp.
|
||||
// failed when open ssl create the dh
|
||||
#define ERROR_OpenSslCreateDH 500
|
||||
// failed when open ssl create the Private key.
|
||||
#define ERROR_OpenSslCreateP 501
|
||||
// when open ssl create G.
|
||||
#define ERROR_OpenSslCreateG 502
|
||||
// when open ssl parse P1024
|
||||
#define ERROR_OpenSslParseP1024 503
|
||||
// when open ssl set G
|
||||
#define ERROR_OpenSslSetG 504
|
||||
// when open ssl generate DHKeys
|
||||
#define ERROR_OpenSslGenerateDHKeys 505
|
||||
// when open ssl share key already computed.
|
||||
#define ERROR_OpenSslShareKeyComputed 506
|
||||
// when open ssl get shared key size.
|
||||
#define ERROR_OpenSslGetSharedKeySize 507
|
||||
// when open ssl get peer public key.
|
||||
#define ERROR_OpenSslGetPeerPublicKey 508
|
||||
// when open ssl compute shared key.
|
||||
#define ERROR_OpenSslComputeSharedKey 509
|
||||
// when open ssl is invalid DH state.
|
||||
#define ERROR_OpenSslInvalidDHState 510
|
||||
// when open ssl copy key
|
||||
#define ERROR_OpenSslCopyKey 511
|
||||
// when open ssl sha256 digest key invalid size.
|
||||
#define ERROR_OpenSslSha256DigestSize 512
|
||||
|
||||
#define ERROR_HLS_METADATA 600
|
||||
#define ERROR_HLS_DECODE_ERROR 601
|
||||
#define ERROR_HLS_CREATE_DIR 602
|
||||
#define ERROR_HLS_OPEN_FAILED 603
|
||||
#define ERROR_HLS_WRITE_FAILED 604
|
||||
#define ERROR_HLS_AAC_FRAME_LENGTH 605
|
||||
#define ERROR_HLS_AVC_SAMPLE_SIZE 606
|
||||
|
||||
#define ERROR_ENCODER_VCODEC 700
|
||||
#define ERROR_ENCODER_OUTPUT 701
|
||||
#define ERROR_ENCODER_ACHANNELS 702
|
||||
#define ERROR_ENCODER_ASAMPLE_RATE 703
|
||||
#define ERROR_ENCODER_ABITRATE 704
|
||||
#define ERROR_ENCODER_ACODEC 705
|
||||
#define ERROR_ENCODER_VPRESET 706
|
||||
#define ERROR_ENCODER_VPROFILE 707
|
||||
#define ERROR_ENCODER_VTHREADS 708
|
||||
#define ERROR_ENCODER_VHEIGHT 709
|
||||
#define ERROR_ENCODER_VWIDTH 710
|
||||
#define ERROR_ENCODER_VFPS 711
|
||||
#define ERROR_ENCODER_VBITRATE 712
|
||||
#define ERROR_ENCODER_FORK 713
|
||||
#define ERROR_ENCODER_LOOP 714
|
||||
#define ERROR_ENCODER_OPEN 715
|
||||
#define ERROR_ENCODER_DUP2 716
|
||||
|
||||
#define ERROR_HTTP_PARSE_URI 800
|
||||
#define ERROR_HTTP_DATA_INVLIAD 801
|
||||
#define ERROR_HTTP_PARSE_HEADER 802
|
||||
|
||||
// system control message,
|
||||
// not an error, but special control logic.
|
||||
// sys ctl: rtmp close stream, support replay.
|
||||
#define ERROR_CONTROL_RTMP_CLOSE 900
|
||||
|
||||
/**
|
||||
* whether the error code is an system control error.
|
||||
*/
|
||||
extern bool srs_is_system_control_error(int error_code);
|
||||
|
||||
#endif
|
40
trunk/src/core/srs_core_protocol.cpp
Normal file → Executable file
40
trunk/src/core/srs_core_protocol.cpp
Normal file → Executable file
|
@ -196,6 +196,7 @@ messages.
|
|||
*/
|
||||
#define RTMP_AMF0_COMMAND_CONNECT "connect"
|
||||
#define RTMP_AMF0_COMMAND_CREATE_STREAM "createStream"
|
||||
#define RTMP_AMF0_COMMAND_CLOSE_STREAM "closeStream"
|
||||
#define RTMP_AMF0_COMMAND_PLAY "play"
|
||||
#define RTMP_AMF0_COMMAND_PAUSE "pause"
|
||||
#define RTMP_AMF0_COMMAND_ON_BW_DONE "onBWDone"
|
||||
|
@ -1363,6 +1364,10 @@ int SrsCommonMessage::decode_packet(SrsProtocol* protocol)
|
|||
srs_info("decode the AMF0/AMF3 band width check message.");
|
||||
packet = new SrsBandwidthPacket();
|
||||
return packet->decode(stream);
|
||||
} else if (command == RTMP_AMF0_COMMAND_CLOSE_STREAM) {
|
||||
srs_info("decode the AMF0/AMF3 closeStream message.");
|
||||
packet = new SrsCloseStreamPacket();
|
||||
return packet->decode(stream);
|
||||
}
|
||||
|
||||
// default packet to drop message.
|
||||
|
@ -2064,6 +2069,41 @@ int SrsCreateStreamResPacket::encode_packet(SrsStream* stream)
|
|||
return ret;
|
||||
}
|
||||
|
||||
SrsCloseStreamPacket::SrsCloseStreamPacket()
|
||||
{
|
||||
command_name = RTMP_AMF0_COMMAND_CLOSE_STREAM;
|
||||
transaction_id = 0;
|
||||
command_object = new SrsAmf0Null();
|
||||
}
|
||||
|
||||
SrsCloseStreamPacket::~SrsCloseStreamPacket()
|
||||
{
|
||||
srs_freep(command_object);
|
||||
}
|
||||
|
||||
int SrsCloseStreamPacket::decode(SrsStream* stream)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
if ((ret = srs_amf0_read_string(stream, command_name)) != ERROR_SUCCESS) {
|
||||
srs_error("amf0 decode closeStream command_name failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = srs_amf0_read_number(stream, transaction_id)) != ERROR_SUCCESS) {
|
||||
srs_error("amf0 decode closeStream transaction_id failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = srs_amf0_read_null(stream)) != ERROR_SUCCESS) {
|
||||
srs_error("amf0 decode closeStream command_object failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
srs_info("amf0 decode closeStream packet success");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SrsFMLEStartPacket::SrsFMLEStartPacket()
|
||||
{
|
||||
command_name = RTMP_AMF0_COMMAND_CREATE_STREAM;
|
||||
|
|
2480
trunk/src/core/srs_core_protocol.hpp
Normal file → Executable file
2480
trunk/src/core/srs_core_protocol.hpp
Normal file → Executable file
File diff suppressed because it is too large
Load diff
2446
trunk/src/core/srs_core_rtmp.cpp
Normal file → Executable file
2446
trunk/src/core/srs_core_rtmp.cpp
Normal file → Executable file
File diff suppressed because it is too large
Load diff
463
trunk/src/core/srs_core_rtmp.hpp
Normal file → Executable file
463
trunk/src/core/srs_core_rtmp.hpp
Normal file → Executable file
|
@ -1,231 +1,234 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRS_CORE_RTMP_HPP
|
||||
#define SRS_CORE_RTMP_HPP
|
||||
|
||||
/*
|
||||
#include <srs_core_rtmp.hpp>
|
||||
*/
|
||||
|
||||
#include <srs_core.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
class SrsProtocol;
|
||||
class ISrsMessage;
|
||||
class SrsCommonMessage;
|
||||
class SrsCreateStreamPacket;
|
||||
class SrsFMLEStartPacket;
|
||||
class SrsPublishPacket;
|
||||
class SrsSharedPtrMessage;
|
||||
class SrsOnMetaDataPacket;
|
||||
|
||||
/**
|
||||
* the original request from client.
|
||||
*/
|
||||
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();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
};
|
||||
|
||||
/**
|
||||
* the response to client.
|
||||
*/
|
||||
struct SrsResponse
|
||||
{
|
||||
int stream_id;
|
||||
|
||||
SrsResponse();
|
||||
virtual ~SrsResponse();
|
||||
};
|
||||
|
||||
/**
|
||||
* the rtmp client type.
|
||||
*/
|
||||
enum SrsClientType
|
||||
{
|
||||
SrsClientUnknown,
|
||||
SrsClientPlay,
|
||||
SrsClientFMLEPublish,
|
||||
SrsClientFlashPublish,
|
||||
};
|
||||
|
||||
/**
|
||||
* implements the client role protocol.
|
||||
*/
|
||||
class SrsRtmpClient
|
||||
{
|
||||
protected:
|
||||
SrsProtocol* protocol;
|
||||
st_netfd_t stfd;
|
||||
public:
|
||||
SrsRtmpClient(st_netfd_t _stfd);
|
||||
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);
|
||||
public:
|
||||
virtual int 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);
|
||||
virtual int publish(std::string stream, int stream_id);
|
||||
};
|
||||
|
||||
/**
|
||||
* the rtmp provices rtmp-command-protocol services,
|
||||
* a high level protocol, media stream oriented services,
|
||||
* such as connect to vhost/app, play stream, get audio/video data.
|
||||
*/
|
||||
class SrsRtmp
|
||||
{
|
||||
private:
|
||||
SrsProtocol* protocol;
|
||||
st_netfd_t stfd;
|
||||
public:
|
||||
SrsRtmp(st_netfd_t client_stfd);
|
||||
virtual ~SrsRtmp();
|
||||
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);
|
||||
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 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);
|
||||
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);
|
||||
};
|
||||
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2014 winlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRS_CORE_RTMP_HPP
|
||||
#define SRS_CORE_RTMP_HPP
|
||||
|
||||
/*
|
||||
#include <srs_core_rtmp.hpp>
|
||||
*/
|
||||
|
||||
#include <srs_core.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
class SrsProtocol;
|
||||
class ISrsMessage;
|
||||
class SrsCommonMessage;
|
||||
class SrsCreateStreamPacket;
|
||||
class SrsFMLEStartPacket;
|
||||
class SrsPublishPacket;
|
||||
class SrsSharedPtrMessage;
|
||||
class SrsOnMetaDataPacket;
|
||||
class SrsPlayPacket;
|
||||
|
||||
/**
|
||||
* the original request from client.
|
||||
*/
|
||||
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();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
};
|
||||
|
||||
/**
|
||||
* the response to client.
|
||||
*/
|
||||
struct SrsResponse
|
||||
{
|
||||
int stream_id;
|
||||
|
||||
SrsResponse();
|
||||
virtual ~SrsResponse();
|
||||
};
|
||||
|
||||
/**
|
||||
* the rtmp client type.
|
||||
*/
|
||||
enum SrsClientType
|
||||
{
|
||||
SrsClientUnknown,
|
||||
SrsClientPlay,
|
||||
SrsClientFMLEPublish,
|
||||
SrsClientFlashPublish,
|
||||
};
|
||||
|
||||
/**
|
||||
* implements the client role protocol.
|
||||
*/
|
||||
class SrsRtmpClient
|
||||
{
|
||||
protected:
|
||||
SrsProtocol* protocol;
|
||||
st_netfd_t stfd;
|
||||
public:
|
||||
SrsRtmpClient(st_netfd_t _stfd);
|
||||
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);
|
||||
public:
|
||||
virtual int 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);
|
||||
virtual int publish(std::string stream, int stream_id);
|
||||
};
|
||||
|
||||
/**
|
||||
* the rtmp provices rtmp-command-protocol services,
|
||||
* a high level protocol, media stream oriented services,
|
||||
* such as connect to vhost/app, play stream, get audio/video data.
|
||||
*/
|
||||
class SrsRtmp
|
||||
{
|
||||
private:
|
||||
SrsProtocol* protocol;
|
||||
st_netfd_t stfd;
|
||||
public:
|
||||
SrsRtmp(st_netfd_t client_stfd);
|
||||
virtual ~SrsRtmp();
|
||||
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);
|
||||
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 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);
|
||||
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);
|
||||
private:
|
||||
virtual int identify_play_client(SrsPlayPacket* req, SrsClientType& type, std::string& stream_name);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue