mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
parent
37c84eccc0
commit
602a478e1b
12 changed files with 133 additions and 28 deletions
|
@ -46,7 +46,9 @@ using namespace std;
|
|||
#include <srs_protocol_amf0.hpp>
|
||||
#include <srs_protocol_utility.hpp>
|
||||
#include <srs_app_coworkers.hpp>
|
||||
#ifdef SRS_AUTO_RTC
|
||||
#include <srs_app_rtc_conn.hpp>
|
||||
#endif
|
||||
|
||||
srs_error_t srs_api_response_jsonp(ISrsHttpResponseWriter* w, string callback, string data)
|
||||
{
|
||||
|
@ -781,6 +783,7 @@ srs_error_t SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa
|
|||
return srs_api_response(w, r, obj->dumps());
|
||||
}
|
||||
|
||||
#ifdef SRS_AUTO_RTC
|
||||
SrsGoApiSdp::SrsGoApiSdp(SrsRtcServer* rtc_svr)
|
||||
{
|
||||
rtc_server = rtc_svr;
|
||||
|
@ -907,6 +910,7 @@ srs_error_t SrsGoApiSdp::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessag
|
|||
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
SrsGoApiClients::SrsGoApiClients()
|
||||
{
|
||||
|
|
|
@ -166,6 +166,7 @@ public:
|
|||
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
||||
};
|
||||
|
||||
#ifdef SRS_AUTO_RTC
|
||||
class SrsGoApiSdp : public ISrsHttpHandler
|
||||
{
|
||||
private:
|
||||
|
@ -178,6 +179,7 @@ public:
|
|||
private:
|
||||
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, SrsJsonObject* res);
|
||||
};
|
||||
#endif
|
||||
|
||||
class SrsGoApiClients : public ISrsHttpHandler
|
||||
{
|
||||
|
|
|
@ -33,7 +33,6 @@ using namespace std;
|
|||
#include <srs_kernel_codec.hpp>
|
||||
#include <srs_kernel_rtp.hpp>
|
||||
#include <srs_app_hls.hpp>
|
||||
#include <srs_app_rtc.hpp>
|
||||
#include <srs_app_forward.hpp>
|
||||
#include <srs_app_config.hpp>
|
||||
#include <srs_app_encoder.hpp>
|
||||
|
@ -51,6 +50,9 @@ using namespace std;
|
|||
#include <srs_app_ng_exec.hpp>
|
||||
#include <srs_app_dash.hpp>
|
||||
#include <srs_protocol_format.hpp>
|
||||
#ifdef SRS_AUTO_RTC
|
||||
#include <srs_app_rtc.hpp>
|
||||
#endif
|
||||
|
||||
#define CONST_MAX_JITTER_MS 250
|
||||
#define CONST_MAX_JITTER_MS_NEG -250
|
||||
|
@ -816,6 +818,7 @@ SrsSharedPtrMessage* SrsMixQueue::pop()
|
|||
return msg;
|
||||
}
|
||||
|
||||
#ifdef SRS_AUTO_RTC
|
||||
SrsRtpPacketQueue::SrsRtpPacketQueue()
|
||||
{
|
||||
}
|
||||
|
@ -864,6 +867,7 @@ SrsRtpSharedPacket* SrsRtpPacketQueue::find(const uint16_t& sequence)
|
|||
|
||||
return pkt;
|
||||
}
|
||||
#endif
|
||||
|
||||
SrsOriginHub::SrsOriginHub()
|
||||
{
|
||||
|
@ -875,7 +879,9 @@ SrsOriginHub::SrsOriginHub()
|
|||
dash = new SrsDash();
|
||||
dvr = new SrsDvr();
|
||||
encoder = new SrsEncoder();
|
||||
#ifdef SRS_AUTO_RTC
|
||||
rtc = new SrsRtc();
|
||||
#endif
|
||||
#ifdef SRS_AUTO_HDS
|
||||
hds = new SrsHds();
|
||||
#endif
|
||||
|
@ -919,10 +925,12 @@ srs_error_t SrsOriginHub::initialize(SrsSource* s, SrsRequest* r)
|
|||
if ((err = format->initialize()) != srs_success) {
|
||||
return srs_error_wrap(err, "format initialize");
|
||||
}
|
||||
|
||||
|
||||
#ifdef SRS_AUTO_RTC
|
||||
if ((err = rtc->initialize(this, req)) != srs_success) {
|
||||
return srs_error_wrap(err, "rtc initialize");
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((err = hls->initialize(this, req)) != srs_success) {
|
||||
return srs_error_wrap(err, "hls initialize");
|
||||
|
@ -1022,11 +1030,13 @@ srs_error_t SrsOriginHub::on_audio(SrsSharedPtrMessage* shared_audio)
|
|||
srs_flv_srates[c->sound_rate]);
|
||||
}
|
||||
|
||||
#ifdef SRS_AUTO_RTC
|
||||
if ((err = rtc->on_audio(msg, format)) != srs_success) {
|
||||
srs_warn("rtc: ignore audio error %s", srs_error_desc(err).c_str());
|
||||
srs_error_reset(err);
|
||||
rtc->on_unpublish();
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((err = hls->on_audio(msg, format)) != srs_success) {
|
||||
// apply the error strategy for hls.
|
||||
|
@ -1121,6 +1131,7 @@ srs_error_t SrsOriginHub::on_video(SrsSharedPtrMessage* shared_video, bool is_se
|
|||
return err;
|
||||
}
|
||||
|
||||
#ifdef SRS_AUTO_RTC
|
||||
// Parse RTMP message to RTP packets, in FU-A if too large.
|
||||
if ((err = rtc->on_video(msg, format)) != srs_success) {
|
||||
// TODO: We should support more strategies.
|
||||
|
@ -1132,6 +1143,7 @@ srs_error_t SrsOriginHub::on_video(SrsSharedPtrMessage* shared_video, bool is_se
|
|||
// TODO: FIXME: Refactor to move to rtp?
|
||||
// Save the RTP packets for find_rtp_packet() to rtx or restore it.
|
||||
source->rtp_queue->push(msg->rtp_packets);
|
||||
#endif
|
||||
|
||||
if ((err = hls->on_video(msg, format)) != srs_success) {
|
||||
// TODO: We should support more strategies.
|
||||
|
@ -1200,10 +1212,12 @@ srs_error_t SrsOriginHub::on_publish()
|
|||
if ((err = encoder->on_publish(req)) != srs_success) {
|
||||
return srs_error_wrap(err, "encoder publish");
|
||||
}
|
||||
|
||||
|
||||
#ifdef SRS_AUTO_RTC
|
||||
if ((err = rtc->on_publish()) != srs_success) {
|
||||
return srs_error_wrap(err, "rtc publish");
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((err = hls->on_publish()) != srs_success) {
|
||||
return srs_error_wrap(err, "hls publish");
|
||||
|
@ -1242,7 +1256,9 @@ void SrsOriginHub::on_unpublish()
|
|||
destroy_forwarders();
|
||||
|
||||
encoder->on_unpublish();
|
||||
#ifdef SRS_AUTO_RTC
|
||||
rtc->on_unpublish();
|
||||
#endif
|
||||
hls->on_unpublish();
|
||||
dash->on_unpublish();
|
||||
dvr->on_unpublish();
|
||||
|
@ -1904,7 +1920,9 @@ SrsSource::SrsSource()
|
|||
jitter_algorithm = SrsRtmpJitterAlgorithmOFF;
|
||||
mix_correct = false;
|
||||
mix_queue = new SrsMixQueue();
|
||||
#ifdef SRS_AUTO_RTC
|
||||
rtp_queue = new SrsRtpPacketQueue();
|
||||
#endif
|
||||
|
||||
_can_publish = true;
|
||||
_pre_source_id = _source_id = -1;
|
||||
|
@ -1934,7 +1952,9 @@ SrsSource::~SrsSource()
|
|||
srs_freep(hub);
|
||||
srs_freep(meta);
|
||||
srs_freep(mix_queue);
|
||||
#ifdef SRS_AUTO_RTC
|
||||
srs_freep(rtp_queue);
|
||||
#endif
|
||||
|
||||
srs_freep(play_edge);
|
||||
srs_freep(publish_edge);
|
||||
|
@ -2692,7 +2712,9 @@ string SrsSource::get_curr_origin()
|
|||
return play_edge->get_curr_origin();
|
||||
}
|
||||
|
||||
#ifdef SRS_AUTO_RTC
|
||||
SrsRtpSharedPacket* SrsSource::find_rtp_packet(const uint16_t& seq)
|
||||
{
|
||||
return rtp_queue->find(seq);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -325,6 +325,7 @@ public:
|
|||
virtual SrsSharedPtrMessage* pop();
|
||||
};
|
||||
|
||||
#ifdef SRS_AUTO_RTC
|
||||
// To find the RTP packet for RTX or restore.
|
||||
class SrsRtpPacketQueue
|
||||
{
|
||||
|
@ -347,6 +348,7 @@ public:
|
|||
void insert(const uint16_t& sequence, SrsRtpSharedPacket* pkt);
|
||||
SrsRtpSharedPacket* find(const uint16_t& sequence);
|
||||
};
|
||||
#endif
|
||||
|
||||
// The hub for origin is a collection of utilities for origin only,
|
||||
// For example, DVR, HLS, Forward and Transcode are only available for origin,
|
||||
|
@ -360,8 +362,10 @@ private:
|
|||
private:
|
||||
// The format, codec information.
|
||||
SrsRtmpFormat* format;
|
||||
#ifdef SRS_AUTO_RTC
|
||||
// rtc handler
|
||||
SrsRtc* rtc;
|
||||
#endif
|
||||
// hls handler.
|
||||
SrsHls* hls;
|
||||
// The DASH encoder.
|
||||
|
@ -534,8 +538,10 @@ private:
|
|||
bool mix_correct;
|
||||
// The mix queue to implements the mix correct algorithm.
|
||||
SrsMixQueue* mix_queue;
|
||||
#ifdef SRS_AUTO_RTC
|
||||
// rtp packet queue
|
||||
SrsRtpPacketQueue* rtp_queue;
|
||||
#endif
|
||||
// For play, whether enabled atc.
|
||||
// The atc(use absolute time and donot adjust time),
|
||||
// directly use msg time and donot adjust if atc is true,
|
||||
|
@ -625,8 +631,10 @@ public:
|
|||
public:
|
||||
virtual std::string get_curr_origin();
|
||||
public:
|
||||
#ifdef SRS_AUTO_RTC
|
||||
// Find rtp packet by sequence
|
||||
SrsRtpSharedPacket* find_rtp_packet(const uint16_t& seq);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,11 +36,13 @@ using namespace std;
|
|||
#include <srs_kernel_error.hpp>
|
||||
#include <srs_kernel_buffer.hpp>
|
||||
#include <srs_kernel_file.hpp>
|
||||
#include <srs_kernel_rtp.hpp>
|
||||
#include <srs_kernel_codec.hpp>
|
||||
#include <srs_kernel_utility.hpp>
|
||||
#include <srs_core_mem_watch.hpp>
|
||||
#include <srs_core_autofree.hpp>
|
||||
#ifdef SRS_AUTO_RTC
|
||||
#include <srs_kernel_rtp.hpp>
|
||||
#endif
|
||||
|
||||
SrsMessageHeader::SrsMessageHeader()
|
||||
{
|
||||
|
@ -230,9 +232,11 @@ SrsSharedPtrMessage::~SrsSharedPtrMessage()
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef SRS_AUTO_RTC
|
||||
for (int i = 0; i < (int)rtp_packets.size(); ++i) {
|
||||
srs_freep(rtp_packets[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
srs_error_t SrsSharedPtrMessage::create(SrsCommonMessage* msg)
|
||||
|
@ -351,17 +355,21 @@ SrsSharedPtrMessage* SrsSharedPtrMessage::copy()
|
|||
copy->payload = ptr->payload;
|
||||
copy->size = ptr->size;
|
||||
|
||||
#ifdef SRS_AUTO_RTC
|
||||
for (int i = 0; i < (int)rtp_packets.size(); ++i) {
|
||||
copy->rtp_packets.push_back(rtp_packets[i]->copy());
|
||||
}
|
||||
#endif
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
#ifdef SRS_AUTO_RTC
|
||||
void SrsSharedPtrMessage::set_rtp_packets(const std::vector<SrsRtpSharedPacket*>& pkts)
|
||||
{
|
||||
rtp_packets = pkts;
|
||||
}
|
||||
#endif
|
||||
|
||||
SrsFlvTransmuxer::SrsFlvTransmuxer()
|
||||
{
|
||||
|
|
|
@ -288,7 +288,10 @@ public:
|
|||
// video/audio packet use raw bytes, no video/audio packet.
|
||||
char* payload;
|
||||
|
||||
#ifdef SRS_AUTO_RTC
|
||||
std::vector<SrsRtpSharedPacket*> rtp_packets;
|
||||
#endif
|
||||
|
||||
private:
|
||||
class SrsSharedPtrPayload
|
||||
{
|
||||
|
@ -344,7 +347,9 @@ public:
|
|||
// @remark, assert object is created.
|
||||
virtual SrsSharedPtrMessage* copy();
|
||||
public:
|
||||
#ifdef SRS_AUTO_RTC
|
||||
virtual void set_rtp_packets(const std::vector<SrsRtpSharedPacket*>& pkts);
|
||||
#endif
|
||||
};
|
||||
|
||||
// Transmux RTMP packets to FLV stream.
|
||||
|
|
|
@ -50,7 +50,9 @@ using namespace std;
|
|||
#include <srs_core_autofree.hpp>
|
||||
#include <srs_kernel_file.hpp>
|
||||
#include <srs_app_hybrid.hpp>
|
||||
#ifdef SRS_AUTO_RTC
|
||||
#include <srs_app_rtc_conn.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef SRS_AUTO_SRT
|
||||
#include <srt_server.hpp>
|
||||
|
@ -449,7 +451,9 @@ srs_error_t run_hybrid_server()
|
|||
_srs_hybrid->register_server(new SrtServerAdapter());
|
||||
#endif
|
||||
|
||||
#ifdef SRS_AUTO_RTC
|
||||
_srs_hybrid->register_server(new RtcServerAdapter());
|
||||
#endif
|
||||
|
||||
// Do some system initialize.
|
||||
if ((err = _srs_hybrid->initialize()) != srs_success) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue