2015-02-15 13:28:31 +00:00
|
|
|
/*
|
|
|
|
The MIT License (MIT)
|
|
|
|
|
|
|
|
Copyright (c) 2013-2015 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_APP_RTSP_HPP
|
|
|
|
#define SRS_APP_RTSP_HPP
|
|
|
|
|
|
|
|
/*
|
|
|
|
#include <srs_app_rtsp.hpp>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <srs_core.hpp>
|
|
|
|
|
|
|
|
#include <string>
|
2015-02-16 06:05:01 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <srs_app_st.hpp>
|
|
|
|
#include <srs_app_thread.hpp>
|
2015-02-15 13:28:31 +00:00
|
|
|
|
|
|
|
#ifdef SRS_AUTO_STREAM_CASTER
|
|
|
|
|
|
|
|
class SrsConfDirective;
|
2015-02-16 06:05:01 +00:00
|
|
|
class SrsStSocket;
|
|
|
|
class SrsRtspStack;
|
|
|
|
class SrsRtspCaster;
|
2015-02-15 13:28:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the handler for rtsp handler.
|
|
|
|
*/
|
|
|
|
class ISrsRtspHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ISrsRtspHandler();
|
|
|
|
virtual ~ISrsRtspHandler();
|
2015-02-16 06:05:01 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* serve the rtsp connection.
|
|
|
|
*/
|
|
|
|
virtual int serve_client(st_netfd_t stfd) = 0;
|
2015-02-15 13:28:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2015-02-16 06:05:01 +00:00
|
|
|
* the rtsp connection serve the fd.
|
2015-02-15 13:28:31 +00:00
|
|
|
*/
|
2015-02-16 06:05:01 +00:00
|
|
|
class SrsRtspConn : public ISrsThreadHandler
|
2015-02-15 13:28:31 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::string output;
|
2015-02-16 06:05:01 +00:00
|
|
|
st_netfd_t stfd;
|
|
|
|
SrsStSocket* skt;
|
|
|
|
SrsRtspStack* rtsp;
|
|
|
|
SrsRtspCaster* caster;
|
|
|
|
SrsThread* trd;
|
2015-02-15 13:28:31 +00:00
|
|
|
public:
|
2015-02-16 06:05:01 +00:00
|
|
|
SrsRtspConn(SrsRtspCaster* c, st_netfd_t fd, std::string o);
|
2015-02-15 13:28:31 +00:00
|
|
|
virtual ~SrsRtspConn();
|
2015-02-16 06:05:01 +00:00
|
|
|
public:
|
|
|
|
virtual int serve();
|
|
|
|
private:
|
|
|
|
virtual int do_cycle();
|
|
|
|
// interface ISrsThreadHandler
|
|
|
|
public:
|
|
|
|
virtual int cycle();
|
|
|
|
virtual void on_thread_stop();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the caster for rtsp.
|
|
|
|
*/
|
|
|
|
class SrsRtspCaster : public ISrsRtspHandler
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::string output;
|
|
|
|
std::vector<SrsRtspConn*> clients;
|
|
|
|
public:
|
|
|
|
SrsRtspCaster(SrsConfDirective* c);
|
|
|
|
virtual ~SrsRtspCaster();
|
|
|
|
public:
|
|
|
|
virtual int serve_client(st_netfd_t stfd);
|
|
|
|
// internal methods.
|
|
|
|
public:
|
|
|
|
virtual void remove(SrsRtspConn* conn);
|
2015-02-15 13:28:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|