Blame view

trunk/src/app/srs_app_forward.hpp 2.4 KB
winlin authored
1 2 3
/*
The MIT License (MIT)
4
Copyright (c) 2013-2014 winlin
winlin authored
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

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.
*/
24 25
#ifndef SRS_APP_FORWARD_HPP
#define SRS_APP_FORWARD_HPP
winlin authored
26 27

/*
28
#include <srs_app_forward.hpp>
winlin authored
29 30 31 32 33
*/
#include <srs_core.hpp>

#include <string>
34 35
#include <srs_app_st.hpp>
#include <srs_app_thread.hpp>
winlin authored
36
37
class ISrsProtocolReaderWriter;
38
class SrsSharedPtrMessage;
winlin authored
39
class SrsOnMetaDataPacket;
winlin authored
40
class SrsMessageQueue;
41
class SrsRtmpJitter;
winlin authored
42
class SrsRtmpClient;
43
class SrsRequest;
44
class SrsSource;
winlin authored
45 46 47 48

/**
* forward the stream to other servers.
*/
49
class SrsForwarder : public ISrsThreadHandler
winlin authored
50 51
{
private:
52 53 54 55 56 57
    std::string app;
    std::string tc_url;
    std::string stream_name;
    int stream_id;
    std::string server;
    int port;
winlin authored
58
private:
59 60
    st_netfd_t stfd;
    SrsThread* pthread;
winlin authored
61
private:
62 63 64 65 66
    SrsSource* source;
    ISrsProtocolReaderWriter* io;
    SrsRtmpClient* client;
    SrsRtmpJitter* jitter;
    SrsMessageQueue* queue;
winlin authored
67
public:
68 69
    SrsForwarder(SrsSource* _source);
    virtual ~SrsForwarder();
winlin authored
70
public:
71
    virtual void set_queue_size(double queue_size);
winlin authored
72
public:
73 74
    virtual int on_publish(SrsRequest* req, std::string forward_server);
    virtual void on_unpublish();
75 76 77
    virtual int on_meta_data(SrsSharedPtrMessage* metadata);
    virtual int on_audio(SrsSharedPtrMessage* msg);
    virtual int on_video(SrsSharedPtrMessage* msg);
78 79
// interface ISrsThreadHandler.
public:
80
    virtual int cycle();
winlin authored
81
private:
82 83 84
    virtual void close_underlayer_socket();
    virtual int connect_server();
    virtual int forward();
winlin authored
85 86 87
};

#endif