srs/trunk/src/app/srs_app_stream_bridge.hpp
Jason-JP-Yang d887d2b867 Addition Features: Custom Homepage and WHEP player
1. DVR record apply support regex, for usage: please enter
    config file -dvr_apply and start regex with /^xxx$/
2. Add custom homepage for player, enter the url
    localhost:8080/players/homepage.html to access
3. Add WHEP player, enter the url localhost:8080/players/whep_itp.html
4. Convert Files Format from CRLF to LF (Windows to Linux)

* Known Issues:
1. There is a unsmooth swup between hompage and player page, Swup.js
    will be used to fix this issue in the future.
2025-05-13 23:35:28 +08:00

101 lines
2.5 KiB
C++

//
// Copyright (c) 2013-2025 The SRS Authors
//
// SPDX-License-Identifier: MIT
//
#ifndef SRS_APP_STREAM_BRIDGE_HPP
#define SRS_APP_STREAM_BRIDGE_HPP
#include <srs_core.hpp>
#include <srs_kernel_codec.hpp>
#include <srs_core_autofree.hpp>
#include <vector>
class SrsRequest;
class SrsSharedPtrMessage;
class SrsLiveSource;
class SrsRtcSource;
class SrsRtmpFormat;
class SrsMetaCache;
class SrsRtpPacket;
class SrsRtcRtpBuilder;
// A stream bridge is used to convert stream via different protocols, such as bridge for RTMP and RTC. Generally, we use
// frame as message for bridge. A frame is a audio or video frame, such as an I/B/P frame, a general frame for decoder.
// So you must assemble RTP or TS packets to a video frame if WebRTC or SRT.
class ISrsStreamBridge
{
public:
ISrsStreamBridge();
virtual ~ISrsStreamBridge();
public:
virtual srs_error_t initialize(SrsRequest* r) = 0;
virtual srs_error_t on_publish() = 0;
virtual srs_error_t on_frame(SrsSharedPtrMessage* frame) = 0;
virtual void on_unpublish() = 0;
};
// A bridge to feed AV frame to RTMP stream.
class SrsFrameToRtmpBridge : public ISrsStreamBridge
{
private:
SrsSharedPtr<SrsLiveSource> source_;
public:
SrsFrameToRtmpBridge(SrsSharedPtr<SrsLiveSource> source);
virtual ~SrsFrameToRtmpBridge();
public:
srs_error_t initialize(SrsRequest* r);
public:
virtual srs_error_t on_publish();
virtual void on_unpublish();
public:
virtual srs_error_t on_frame(SrsSharedPtrMessage* frame);
};
#ifdef SRS_RTC
// A bridge to covert AV frame to WebRTC stream.
class SrsFrameToRtcBridge : public ISrsStreamBridge
{
private:
SrsSharedPtr<SrsRtcSource> source_;
private:
#if defined(SRS_FFMPEG_FIT)
SrsRtcRtpBuilder* rtp_builder_;
#endif
public:
SrsFrameToRtcBridge(SrsSharedPtr<SrsRtcSource> source);
virtual ~SrsFrameToRtcBridge();
public:
virtual srs_error_t initialize(SrsRequest* r);
virtual srs_error_t on_publish();
virtual void on_unpublish();
virtual srs_error_t on_frame(SrsSharedPtrMessage* frame);
srs_error_t on_rtp(SrsRtpPacket* pkt);
};
#endif
// A bridge chain, a set of bridges.
class SrsCompositeBridge : public ISrsStreamBridge
{
public:
SrsCompositeBridge();
virtual ~SrsCompositeBridge();
public:
srs_error_t initialize(SrsRequest* r);
public:
virtual srs_error_t on_publish();
virtual void on_unpublish();
public:
virtual srs_error_t on_frame(SrsSharedPtrMessage* frame);
public:
SrsCompositeBridge* append(ISrsStreamBridge* bridge);
private:
std::vector<ISrsStreamBridge*> bridges_;
};
#endif