Blame view

trunk/src/core/srs_core_client.hpp 2.5 KB
winlin authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/*
The MIT License (MIT)

Copyright (c) 2013 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>
34
#include <srs_core_reload.hpp>
winlin authored
35 36 37 38 39 40 41 42

class SrsRtmp;
class SrsRequest;
class SrsResponse;
class SrsSource;
class SrsRefer;
class SrsConsumer;
class SrsCommonMessage;
winlin authored
43 44 45
#ifdef SRS_HTTP	
class SrsHttpHooks;
#endif
winlin authored
46 47 48 49

/**
* the client provides the main logic control for RTMP clients.
*/
50
class SrsClient : public SrsConnection, public ISrsReloadHandler
winlin authored
51 52 53 54 55 56 57
{
private:
	char* ip;
	SrsRequest* req;
	SrsResponse* res;
	SrsRtmp* rtmp;
	SrsRefer* refer;
winlin authored
58 59 60
#ifdef SRS_HTTP	
	SrsHttpHooks* http_hooks;
#endif
winlin authored
61 62 63 64 65
public:
	SrsClient(SrsServer* srs_server, st_netfd_t client_stfd);
	virtual ~SrsClient();
protected:
	virtual int do_cycle();
66 67
// interface ISrsReloadHandler
public:
winlin authored
68
	virtual int on_reload_vhost_removed(std::string vhost);
winlin authored
69
private:
70 71
	// when valid and connected to vhost/app, service the client.
	virtual int service_cycle();
winlin authored
72 73 74
	virtual int check_vhost();
	virtual int playing(SrsSource* source);
	virtual int publish(SrsSource* source, bool is_fmle);
75
	virtual int process_publish_message(SrsSource* source, SrsCommonMessage* msg, bool is_fmle);
winlin authored
76 77
	virtual int get_peer_ip();
	virtual int process_play_control_msg(SrsConsumer* consumer, SrsCommonMessage* msg);
78 79 80 81 82 83 84
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();
winlin authored
85 86
};
winlin authored
87
#endif