1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00
srs/trunk/src/app/srs_app_forward.hpp

104 lines
3.1 KiB
C++
Raw Normal View History

2017-03-25 09:21:39 +00:00
/**
* The MIT License (MIT)
*
2019-01-01 13:37:28 +00:00
* Copyright (c) 2013-2019 Winlin
2017-03-25 09:21:39 +00:00
*
* 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.
*/
2013-11-29 14:21:31 +00:00
#ifndef SRS_APP_FORWARD_HPP
#define SRS_APP_FORWARD_HPP
2013-11-29 14:21:31 +00:00
#include <srs_core.hpp>
#include <string>
#include <srs_app_st.hpp>
#include <srs_app_thread.hpp>
2013-11-29 14:21:31 +00:00
class ISrsProtocolReadWriter;
class SrsSharedPtrMessage;
2013-11-29 14:21:31 +00:00
class SrsOnMetaDataPacket;
2013-12-15 10:25:55 +00:00
class SrsMessageQueue;
class SrsRtmpJitter;
2013-11-29 14:21:31 +00:00
class SrsRtmpClient;
class SrsRequest;
class SrsSource;
class SrsOriginHub;
2014-05-12 09:27:50 +00:00
class SrsKbps;
class SrsSimpleRtmpClient;
2013-11-29 14:21:31 +00:00
/**
2017-03-25 09:21:39 +00:00
* forward the stream to other servers.
*/
2014-07-26 12:17:03 +00:00
// TODO: FIXME: refine the error log, comments it.
class SrsForwarder : public ISrsCoroutineHandler
2013-11-29 14:21:31 +00:00
{
private:
// the ep to forward, server[:port].
std::string ep_forward;
SrsRequest* req;
2013-11-29 14:21:31 +00:00
private:
SrsCoroutine* trd;
2013-11-29 14:21:31 +00:00
private:
SrsOriginHub* hub;
SrsSimpleRtmpClient* sdk;
2014-03-18 03:32:58 +00:00
SrsRtmpJitter* jitter;
SrsMessageQueue* queue;
/**
2017-03-25 09:21:39 +00:00
* cache the sequence header for retry when slave is failed.
* @see https://github.com/ossrs/srs/issues/150
*/
SrsSharedPtrMessage* sh_audio;
SrsSharedPtrMessage* sh_video;
2013-11-29 14:21:31 +00:00
public:
SrsForwarder(SrsOriginHub* h);
2014-03-18 03:32:58 +00:00
virtual ~SrsForwarder();
2013-12-15 10:25:55 +00:00
public:
2017-09-23 14:12:33 +00:00
virtual srs_error_t initialize(SrsRequest* r, std::string ep);
virtual void set_queue_size(srs_utime_t queue_size);
2013-11-29 14:21:31 +00:00
public:
2017-09-23 14:12:33 +00:00
virtual srs_error_t on_publish();
2014-03-18 03:32:58 +00:00
virtual void on_unpublish();
/**
2017-03-25 09:21:39 +00:00
* forward the audio packet.
* @param shared_metadata, directly ptr, copy it if need to save it.
*/
2017-09-23 14:12:33 +00:00
virtual srs_error_t on_meta_data(SrsSharedPtrMessage* shared_metadata);
/**
2017-03-25 09:21:39 +00:00
* forward the audio packet.
* @param shared_audio, directly ptr, copy it if need to save it.
*/
2017-09-23 14:12:33 +00:00
virtual srs_error_t on_audio(SrsSharedPtrMessage* shared_audio);
/**
2017-03-25 09:21:39 +00:00
* forward the video packet.
* @param shared_video, directly ptr, copy it if need to save it.
*/
2017-09-23 14:12:33 +00:00
virtual srs_error_t on_video(SrsSharedPtrMessage* shared_video);
2015-05-23 01:49:15 +00:00
// interface ISrsReusableThread2Handler.
public:
virtual srs_error_t cycle();
private:
virtual srs_error_t do_cycle();
2013-11-29 14:21:31 +00:00
private:
2017-09-23 14:12:33 +00:00
virtual srs_error_t forward();
2013-11-29 14:21:31 +00:00
};
#endif
2014-08-02 14:18:39 +00:00