1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-24 06:54:22 +00:00
srs/trunk/src/app/srs_app_rtc_source.hpp

624 lines
19 KiB
C++
Raw Normal View History

2020-05-12 05:19:31 +00:00
/**
* The MIT License (MIT)
*
* Copyright (c) 2013-2020 John
*
* 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_RTC_SOURCE_HPP
#define SRS_APP_RTC_SOURCE_HPP
#include <srs_core.hpp>
#include <vector>
#include <map>
2020-07-15 05:11:35 +00:00
#include <inttypes.h>
#include <vector>
#include <string>
#include <map>
2020-05-12 05:19:31 +00:00
2020-07-15 05:11:35 +00:00
#include <srs_app_rtc_sdp.hpp>
2020-05-12 05:19:31 +00:00
#include <srs_service_st.hpp>
#include <srs_app_source.hpp>
#include <srs_kernel_rtc_rtp.hpp>
2020-05-12 05:19:31 +00:00
class SrsRequest;
class SrsMetaCache;
class SrsSharedPtrMessage;
class SrsCommonMessage;
class SrsMessageArray;
class SrsRtcStream;
2020-05-12 11:53:21 +00:00
class SrsRtcFromRtmpBridger;
2020-05-13 07:09:36 +00:00
class SrsAudioRecode;
class SrsRtpPacket2;
class SrsSample;
2020-07-15 05:11:35 +00:00
class SrsRtcStreamDescription;
class SrsRtcTrackDescription;
class SrsRtcConnection;
class SrsRtpRingBuffer;
class SrsRtpNackForReceiver;
2020-07-20 06:15:08 +00:00
class SrsJsonObject;
class SrsRtcPlayStreamStatistic;
2020-08-28 04:17:51 +00:00
class SrsErrorPithyPrint;
class SrsRtcDummyBridger;
2020-07-15 05:11:35 +00:00
class SrsNtp
{
public:
uint64_t system_ms_;
uint64_t ntp_;
uint32_t ntp_second_;
uint32_t ntp_fractions_;
public:
SrsNtp();
virtual ~SrsNtp();
public:
static SrsNtp from_time_ms(uint64_t ms);
static SrsNtp to_time_ms(uint64_t ntp);
public:
static uint64_t kMagicNtpFractionalUnit;
};
2020-05-12 05:19:31 +00:00
2020-05-15 00:24:26 +00:00
class SrsRtcConsumer
2020-05-12 05:19:31 +00:00
{
private:
SrsRtcStream* source;
2020-05-13 12:13:25 +00:00
std::vector<SrsRtpPacket2*> queue;
2020-05-12 05:19:31 +00:00
// when source id changed, notice all consumers
bool should_update_source_id;
// The cond wait for mw.
// @see https://github.com/ossrs/srs/issues/251
srs_cond_t mw_wait;
bool mw_waiting;
int mw_min_msgs;
public:
SrsRtcConsumer(SrsRtcStream* s);
2020-05-12 05:19:31 +00:00
virtual ~SrsRtcConsumer();
public:
2020-05-13 12:13:25 +00:00
// When source id changed, notice client to print.
2020-05-12 05:19:31 +00:00
virtual void update_source_id();
2020-05-15 00:24:26 +00:00
// Put RTP packet into queue.
// @note We do not drop packet here, but drop it in sender.
srs_error_t enqueue(SrsRtpPacket2* pkt);
// Get all RTP packets from queue.
2020-05-13 12:13:25 +00:00
virtual srs_error_t dump_packets(std::vector<SrsRtpPacket2*>& pkts);
// Wait for at-least some messages incoming in queue.
virtual void wait(int nb_msgs);
2020-05-12 05:19:31 +00:00
};
class SrsRtcStreamManager
2020-05-13 07:46:49 +00:00
{
private:
srs_mutex_t lock;
std::map<std::string, SrsRtcStream*> pool;
2020-05-13 07:46:49 +00:00
public:
SrsRtcStreamManager();
virtual ~SrsRtcStreamManager();
2020-05-13 07:46:49 +00:00
public:
// create source when fetch from cache failed.
// @param r the client request.
// @param pps the matched source, if success never be NULL.
virtual srs_error_t fetch_or_create(SrsRequest* r, SrsRtcStream** pps);
2020-05-13 07:46:49 +00:00
private:
// Get the exists source, NULL when not exists.
// update the request and return the exists source.
virtual SrsRtcStream* fetch(SrsRequest* r);
2020-05-13 07:46:49 +00:00
};
// Global singleton instance.
extern SrsRtcStreamManager* _srs_rtc_sources;
2020-05-13 07:46:49 +00:00
// A publish stream interface, for source to callback with.
class ISrsRtcPublishStream
2020-06-02 11:00:31 +00:00
{
public:
ISrsRtcPublishStream();
virtual ~ISrsRtcPublishStream();
2020-06-02 11:00:31 +00:00
public:
// Request keyframe(PLI) from publisher, for fresh consumer.
2020-07-15 05:11:35 +00:00
virtual void request_keyframe(uint32_t ssrc) = 0;
};
class ISrsRtcStreamEventHandler
{
public:
ISrsRtcStreamEventHandler();
virtual ~ISrsRtcStreamEventHandler();
public:
// stream unpublish, sync API.
virtual void on_unpublish() = 0;
// no player subscribe this stream, sync API
virtual void on_consumers_finished() = 0;
2020-06-02 11:00:31 +00:00
};
// A Source is a stream, to publish and to play with, binding to SrsRtcPublishStream and SrsRtcPlayStream.
class SrsRtcStream
2020-05-12 05:19:31 +00:00
{
private:
// For publish, it's the publish client id.
// For edge, it's the edge ingest id.
// when source id changed, for example, the edge reconnect,
// invoke the on_source_id_changed() to let all clients know.
SrsContextId _source_id;
2020-05-12 05:19:31 +00:00
// previous source id.
SrsContextId _pre_source_id;
2020-05-12 05:19:31 +00:00
SrsRequest* req;
ISrsRtcPublishStream* publish_stream_;
2020-05-12 11:53:21 +00:00
// Transmux RTMP to RTC.
SrsRtcDummyBridger* bridger_;
2020-07-15 05:11:35 +00:00
// Steam description for this steam.
SrsRtcStreamDescription* stream_desc_;
2020-05-12 05:19:31 +00:00
private:
// To delivery stream to clients.
std::vector<SrsRtcConsumer*> consumers;
// Whether stream is created, that is, SDP is done.
bool is_created_;
// Whether stream is delivering data, that is, DTLS is done.
bool is_delivering_packets_;
// Notify stream event to event handler
std::vector<ISrsRtcStreamEventHandler*> event_handlers_;
2020-05-12 05:19:31 +00:00
public:
SrsRtcStream();
virtual ~SrsRtcStream();
2020-05-12 05:19:31 +00:00
public:
virtual srs_error_t initialize(SrsRequest* r);
// Update the authentication information in request.
virtual void update_auth(SrsRequest* r);
// The source id changed.
virtual srs_error_t on_source_id_changed(SrsContextId id);
2020-05-12 05:19:31 +00:00
// Get current source id.
virtual SrsContextId source_id();
virtual SrsContextId pre_source_id();
2020-05-12 11:53:21 +00:00
// Get the bridger.
ISrsSourceBridger* bridger();
2020-05-12 05:19:31 +00:00
public:
// Create consumer
// @param consumer, output the create consumer.
2020-05-13 12:13:25 +00:00
virtual srs_error_t create_consumer(SrsRtcConsumer*& consumer);
2020-05-12 05:19:31 +00:00
// Dumps packets in cache to consumer.
// @param ds, whether dumps the sequence header.
// @param dm, whether dumps the metadata.
// @param dg, whether dumps the gop cache.
virtual srs_error_t consumer_dumps(SrsRtcConsumer* consumer, bool ds = true, bool dm = true, bool dg = true);
virtual void on_consumer_destroy(SrsRtcConsumer* consumer);
2020-08-17 09:47:26 +00:00
// Whether we can publish stream to the source, return false if it exists.
// @remark Note that when SDP is done, we set the stream is not able to publish.
2020-08-17 09:47:26 +00:00
virtual bool can_publish();
// For RTC, the stream is created when SDP is done, and then do DTLS
virtual void set_stream_created();
2020-05-12 05:19:31 +00:00
// When start publish stream.
virtual srs_error_t on_publish();
// When stop publish stream.
virtual void on_unpublish();
public:
// For event handler
void subscribe(ISrsRtcStreamEventHandler* h);
void unsubscribe(ISrsRtcStreamEventHandler* h);
2020-05-12 05:19:31 +00:00
public:
// Get and set the publisher, passed to consumer to process requests such as PLI.
ISrsRtcPublishStream* publish_stream();
void set_publish_stream(ISrsRtcPublishStream* v);
// Consume the shared RTP packet, user must free it.
srs_error_t on_rtp(SrsRtpPacket2* pkt);
2020-07-15 05:11:35 +00:00
// Set and get stream description for souce
bool has_stream_desc();
2020-07-15 05:11:35 +00:00
void set_stream_desc(SrsRtcStreamDescription* stream_desc);
std::vector<SrsRtcTrackDescription*> get_track_desc(std::string type, std::string media_type);
2020-05-12 05:19:31 +00:00
};
#ifdef SRS_FFMPEG_FIT
2020-05-12 11:53:21 +00:00
class SrsRtcFromRtmpBridger : public ISrsSourceBridger
{
private:
SrsRequest* req;
SrsRtcStream* source_;
// The format, codec information.
SrsRtmpFormat* format;
2020-05-15 00:19:22 +00:00
// The metadata cache.
SrsMetaCache* meta;
2020-05-13 07:09:36 +00:00
private:
bool discard_aac;
SrsAudioRecode* codec;
2020-05-13 07:15:57 +00:00
bool discard_bframe;
bool merge_nalus;
uint32_t audio_timestamp;
2020-06-16 08:41:04 +00:00
uint16_t audio_sequence;
uint16_t video_sequence;
2020-07-19 02:26:05 +00:00
uint32_t audio_ssrc;
uint32_t video_ssrc;
2020-05-12 11:53:21 +00:00
public:
SrsRtcFromRtmpBridger(SrsRtcStream* source);
2020-05-12 11:53:21 +00:00
virtual ~SrsRtcFromRtmpBridger();
public:
virtual srs_error_t initialize(SrsRequest* r);
2020-05-12 11:53:21 +00:00
virtual srs_error_t on_publish();
2020-05-13 05:42:55 +00:00
virtual void on_unpublish();
virtual srs_error_t on_audio(SrsSharedPtrMessage* msg);
2020-05-13 07:09:36 +00:00
private:
srs_error_t transcode(char* adts_audio, int nn_adts_audio);
srs_error_t package_opus(char* data, int size, SrsRtpPacket2** ppkt);
2020-05-13 07:09:36 +00:00
public:
virtual srs_error_t on_video(SrsSharedPtrMessage* msg);
2020-05-13 07:15:57 +00:00
private:
2020-05-15 00:34:58 +00:00
srs_error_t filter(SrsSharedPtrMessage* msg, SrsFormat* format, bool& has_idr, std::vector<SrsSample*>& samples);
srs_error_t package_stap_a(SrsRtcStream* source, SrsSharedPtrMessage* msg, SrsRtpPacket2** ppkt);
2020-05-15 00:34:58 +00:00
srs_error_t package_nalus(SrsSharedPtrMessage* msg, const std::vector<SrsSample*>& samples, std::vector<SrsRtpPacket2*>& pkts);
srs_error_t package_single_nalu(SrsSharedPtrMessage* msg, SrsSample* sample, std::vector<SrsRtpPacket2*>& pkts);
srs_error_t package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, std::vector<SrsRtpPacket2*>& pkts);
srs_error_t consume_packets(std::vector<SrsRtpPacket2*>& pkts);
2020-05-12 11:53:21 +00:00
};
#endif
class SrsRtcDummyBridger : public ISrsSourceBridger
{
private:
SrsRtcStream* rtc_;
// The optional implementation bridger, ignore if NULL.
ISrsSourceBridger* impl_;
public:
SrsRtcDummyBridger(SrsRtcStream* s);
virtual ~SrsRtcDummyBridger();
public:
virtual srs_error_t on_publish();
virtual srs_error_t on_audio(SrsSharedPtrMessage* audio);
virtual srs_error_t on_video(SrsSharedPtrMessage* video);
virtual void on_unpublish();
public:
// Setup a new implementation bridger, which might be NULL to free previous one.
void setup(ISrsSourceBridger* impl);
};
2020-05-12 11:53:21 +00:00
2020-07-15 05:11:35 +00:00
// TODO: FIXME: Rename it.
class SrsCodecPayload
{
public:
std::string type_;
uint8_t pt_;
// for publish, equals to PT of itself;
// for subscribe, is the PT of publisher;
uint8_t pt_of_publisher_;
2020-07-15 05:11:35 +00:00
std::string name_;
int sample_;
std::vector<std::string> rtcp_fbs_;
public:
SrsCodecPayload();
SrsCodecPayload(uint8_t pt, std::string encode_name, int sample);
virtual ~SrsCodecPayload();
public:
virtual SrsCodecPayload* copy();
virtual SrsMediaPayloadType generate_media_payload_type();
};
// TODO: FIXME: Rename it.
class SrsVideoPayload : public SrsCodecPayload
{
public:
struct H264SpecificParameter
{
std::string profile_level_id;
std::string packetization_mode;
std::string level_asymmerty_allow;
};
H264SpecificParameter h264_param_;
public:
SrsVideoPayload();
SrsVideoPayload(uint8_t pt, std::string encode_name, int sample);
virtual ~SrsVideoPayload();
public:
virtual SrsVideoPayload* copy();
virtual SrsMediaPayloadType generate_media_payload_type();
public:
srs_error_t set_h264_param_desc(std::string fmtp);
};
// TODO: FIXME: Rename it.
class SrsAudioPayload : public SrsCodecPayload
{
struct SrsOpusParameter
{
int minptime;
bool use_inband_fec;
bool usedtx;
2020-08-21 13:14:18 +00:00
SrsOpusParameter() {
minptime = 0;
use_inband_fec = false;
usedtx = false;
}
2020-07-15 05:11:35 +00:00
};
public:
int channel_;
SrsOpusParameter opus_param_;
public:
SrsAudioPayload();
SrsAudioPayload(uint8_t pt, std::string encode_name, int sample, int channel);
virtual ~SrsAudioPayload();
public:
virtual SrsAudioPayload* copy();
virtual SrsMediaPayloadType generate_media_payload_type();
public:
srs_error_t set_opus_param_desc(std::string fmtp);
};
2020-07-20 06:15:08 +00:00
// TODO: FIXME: Rename it.
class SrsRedPayload : public SrsCodecPayload
{
public:
int channel_;
public:
SrsRedPayload();
SrsRedPayload(uint8_t pt, std::string encode_name, int sample, int channel);
virtual ~SrsRedPayload();
public:
virtual SrsRedPayload* copy();
virtual SrsMediaPayloadType generate_media_payload_type();
};
2020-08-06 08:35:33 +00:00
class SrsRtxPayloadDes : public SrsCodecPayload
{
public:
uint8_t apt_;
public:
SrsRtxPayloadDes();
SrsRtxPayloadDes(uint8_t pt, uint8_t apt);
virtual ~SrsRtxPayloadDes();
public:
virtual SrsRtxPayloadDes* copy();
virtual SrsMediaPayloadType generate_media_payload_type();
};
2020-07-15 05:11:35 +00:00
class SrsRtcTrackDescription
{
public:
// type: audio, video
std::string type_;
// track_id
std::string id_;
// ssrc is the primary ssrc for this track,
// if sdp has ssrc-group, it is the first ssrc of the ssrc-group
uint32_t ssrc_;
// rtx ssrc is the second ssrc of "FEC" src-group,
// if no rtx ssrc, rtx_ssrc_ = 0.
uint32_t fec_ssrc_;
// rtx ssrc is the second ssrc of "FID" src-group,
// if no rtx ssrc, rtx_ssrc_ = 0.
uint32_t rtx_ssrc_;
// key: rtp header extension id, value: rtp header extension uri.
std::map<int, std::string> extmaps_;
// Whether this track active. default: active.
bool is_active_;
// direction
std::string direction_;
2020-09-16 11:59:49 +00:00
// mid is used in BOUNDLE
2020-07-15 05:11:35 +00:00
std::string mid_;
2020-07-20 06:15:08 +00:00
// msid_: track stream id
std::string msid_;
2020-07-15 05:11:35 +00:00
// meida payload, such as opus, h264.
SrsCodecPayload* media_;
SrsCodecPayload* red_;
SrsCodecPayload* rtx_;
SrsCodecPayload* ulpfec_;
public:
SrsRtcTrackDescription();
virtual ~SrsRtcTrackDescription();
public:
// whether or not the track has ssrc.
// for example:
// we need check track has the ssrc in the ssrc_group, then add ssrc_group to the track,
bool has_ssrc(uint32_t ssrc);
public:
void add_rtp_extension_desc(int id, std::string uri);
void set_direction(std::string direction);
void set_codec_payload(SrsCodecPayload* payload);
2020-07-16 05:21:55 +00:00
// auxiliary paylod include red, rtx, ulpfec.
2020-07-15 05:11:35 +00:00
void create_auxiliary_payload(const std::vector<SrsMediaPayloadType> payload_types);
void set_rtx_ssrc(uint32_t ssrc);
void set_fec_ssrc(uint32_t ssrc);
void set_mid(std::string mid);
int get_rtp_extension_id(std::string uri);
public:
SrsRtcTrackDescription* copy();
};
class SrsRtcStreamDescription
{
public:
// the id for this stream;
std::string id_;
SrsRtcTrackDescription* audio_track_desc_;
std::vector<SrsRtcTrackDescription*> video_track_descs_;
public:
SrsRtcStreamDescription();
virtual ~SrsRtcStreamDescription();
public:
SrsRtcStreamDescription* copy();
SrsRtcTrackDescription* find_track_description_by_ssrc(uint32_t ssrc);
};
2020-07-26 14:58:22 +00:00
class SrsRtcTrackStatistic
{
public:
// packets received or sent.
uint32_t packets;
// packets received or sent at last statistic time.
uint32_t last_packets;
// bytes received or sent.
uint64_t bytes;
// bytes received or sent at last statistic time.
uint32_t last_bytes;
// nacks received or sent.
uint32_t nacks;
// nacks received or sent at last statistic time.
uint32_t last_nacks;
// padding packets received or sent.
uint32_t padding_packets;
// padding packets received or sent at last statistic time.
uint32_t last_padding_packets;
// padding bytes received or sent.
uint32_t padding_bytes;
// padding bytes received or sent at last statistic time.
uint32_t last_padding_bytes;
// replay packets received or sent.
uint32_t replay_packets;
// replay packets received or sent at last statistic time.
uint32_t last_replay_packets;
// replay bytes received or sent.
uint64_t replay_bytes;
// replay bytes received or sent at last statistic time.
uint64_t last_replay_bytes;
public:
SrsRtcTrackStatistic();
};
2020-07-15 05:11:35 +00:00
class SrsRtcRecvTrack
{
protected:
SrsRtcTrackDescription* track_desc_;
2020-07-26 14:58:22 +00:00
SrsRtcTrackStatistic* statistic_;
2020-07-15 05:11:35 +00:00
SrsRtcConnection* session_;
SrsRtpRingBuffer* rtp_queue_;
SrsRtpNackForReceiver* nack_receiver_;
// send report ntp and received time.
SrsNtp last_sender_report_ntp;
uint64_t last_sender_report_sys_time;
public:
SrsRtcRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* stream_descs, bool is_audio);
virtual ~SrsRtcRecvTrack();
public:
bool has_ssrc(uint32_t ssrc);
2020-09-17 09:15:59 +00:00
uint32_t get_ssrc();
2020-07-15 05:11:35 +00:00
void update_rtt(int rtt);
void update_send_report_time(const SrsNtp& ntp);
srs_error_t send_rtcp_rr();
srs_error_t send_rtcp_xr_rrtr();
bool set_track_status(bool active);
bool get_track_status();
std::string get_track_id();
2020-07-15 05:11:35 +00:00
protected:
srs_error_t on_nack(SrsRtpPacket2* pkt);
public:
2021-02-05 07:52:44 +00:00
virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt, bool nack_enabled) = 0;
2020-09-10 02:50:59 +00:00
virtual srs_error_t check_send_nacks() = 0;
protected:
virtual srs_error_t do_check_send_nacks(uint32_t& timeout_nacks);
2020-07-15 05:11:35 +00:00
};
class SrsRtcAudioRecvTrack : virtual public SrsRtcRecvTrack, virtual public ISrsRtpPacketDecodeHandler
2020-07-15 05:11:35 +00:00
{
public:
SrsRtcAudioRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc);
virtual ~SrsRtcAudioRecvTrack();
public:
virtual void on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload);
2020-07-15 05:11:35 +00:00
public:
2021-02-05 07:52:44 +00:00
virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt, bool nack_enabled);
2020-09-10 02:50:59 +00:00
virtual srs_error_t check_send_nacks();
2020-07-15 05:11:35 +00:00
};
class SrsRtcVideoRecvTrack : virtual public SrsRtcRecvTrack, virtual public ISrsRtpPacketDecodeHandler
2020-07-15 05:11:35 +00:00
{
public:
SrsRtcVideoRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* stream_descs);
virtual ~SrsRtcVideoRecvTrack();
public:
virtual void on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload);
2020-07-15 05:11:35 +00:00
public:
2021-02-05 07:52:44 +00:00
virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt, bool nack_enabled);
2020-09-10 02:50:59 +00:00
virtual srs_error_t check_send_nacks();
2020-07-15 05:11:35 +00:00
};
class SrsRtcSendTrack
{
protected:
// send track description
SrsRtcTrackDescription* track_desc_;
2020-07-26 14:58:22 +00:00
SrsRtcTrackStatistic* statistic_;
2020-08-28 04:17:51 +00:00
protected:
2020-07-26 14:58:22 +00:00
// The owner connection for this track.
2020-07-15 05:11:35 +00:00
SrsRtcConnection* session_;
// NACK ARQ ring buffer.
SrsRtpRingBuffer* rtp_queue_;
2020-08-28 04:17:51 +00:00
private:
// The pithy print for special stage.
SrsErrorPithyPrint* nack_epp;
2020-07-15 05:11:35 +00:00
public:
SrsRtcSendTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc, bool is_audio);
virtual ~SrsRtcSendTrack();
public:
bool has_ssrc(uint32_t ssrc);
SrsRtpPacket2* fetch_rtp_packet(uint16_t seq);
bool set_track_status(bool active);
2020-07-29 14:12:42 +00:00
bool get_track_status();
2020-07-20 06:15:08 +00:00
std::string get_track_id();
2020-07-15 05:11:35 +00:00
public:
virtual srs_error_t on_rtp(SrsRtpPacket2* pkt, SrsRtcPlayStreamStatistic& info) = 0;
virtual srs_error_t on_rtcp(SrsRtpPacket2* pkt) = 0;
virtual srs_error_t on_recv_nack(const std::vector<uint16_t>& lost_seqs, SrsRtcPlayStreamStatistic& info);
2020-07-15 05:11:35 +00:00
};
class SrsRtcAudioSendTrack : public SrsRtcSendTrack
{
public:
SrsRtcAudioSendTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc);
virtual ~SrsRtcAudioSendTrack();
public:
virtual srs_error_t on_rtp(SrsRtpPacket2* pkt, SrsRtcPlayStreamStatistic& info);
2020-07-15 05:11:35 +00:00
virtual srs_error_t on_rtcp(SrsRtpPacket2* pkt);
};
class SrsRtcVideoSendTrack : public SrsRtcSendTrack
{
public:
SrsRtcVideoSendTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc);
virtual ~SrsRtcVideoSendTrack();
public:
virtual srs_error_t on_rtp(SrsRtpPacket2* pkt, SrsRtcPlayStreamStatistic& info);
2020-07-15 05:11:35 +00:00
virtual srs_error_t on_rtcp(SrsRtpPacket2* pkt);
};
2020-07-19 02:26:05 +00:00
class SrsRtcSSRCGenerator
{
private:
static SrsRtcSSRCGenerator* _instance;
private:
uint32_t ssrc_num;
private:
SrsRtcSSRCGenerator();
virtual ~SrsRtcSSRCGenerator();
public:
static SrsRtcSSRCGenerator* instance();
uint32_t generate_ssrc();
};
2020-05-12 05:19:31 +00:00
#endif