mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Refine code
This commit is contained in:
parent
ec2535b183
commit
1615c3df6c
4 changed files with 131 additions and 6 deletions
|
@ -86,9 +86,12 @@ enum SrsRtpExtensionType
|
|||
{
|
||||
kRtpExtensionNone,
|
||||
kRtpExtensionTransportSequenceNumber,
|
||||
kRtpExtensionAudioLevel,
|
||||
kRtpExtensionNumberOfExtensions // Must be the last entity in the enum.
|
||||
};
|
||||
|
||||
const std::string kAudioLevelUri = "urn:ietf:params:rtp-hdrext:ssrc-audio-level";
|
||||
|
||||
struct SrsExtensionInfo
|
||||
{
|
||||
SrsRtpExtensionType type;
|
||||
|
@ -96,7 +99,8 @@ struct SrsExtensionInfo
|
|||
};
|
||||
|
||||
const SrsExtensionInfo kExtensions[] = {
|
||||
{kRtpExtensionTransportSequenceNumber, std::string("http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01")}
|
||||
{kRtpExtensionTransportSequenceNumber, std::string("http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01")},
|
||||
{kRtpExtensionAudioLevel, kAudioLevelUri},
|
||||
};
|
||||
|
||||
class SrsRtpExtensionTypes
|
||||
|
@ -138,12 +142,34 @@ public:
|
|||
virtual uint64_t nb_bytes();
|
||||
};
|
||||
|
||||
class SrsRtpExtensionOneByte : public ISrsCodec
|
||||
{
|
||||
bool has_ext_;
|
||||
int id_;
|
||||
uint8_t value_;
|
||||
public:
|
||||
SrsRtpExtensionOneByte();
|
||||
virtual ~SrsRtpExtensionOneByte() {}
|
||||
|
||||
bool exists() { return has_ext_; }
|
||||
int get_id() { return id_; }
|
||||
uint8_t get_value() { return value_; }
|
||||
void set_id(int id);
|
||||
void set_value(uint8_t value);
|
||||
public:
|
||||
// ISrsCodec
|
||||
virtual srs_error_t decode(SrsBuffer* buf);
|
||||
virtual srs_error_t encode(SrsBuffer* buf);
|
||||
virtual uint64_t nb_bytes() { return 2; };
|
||||
};
|
||||
|
||||
class SrsRtpExtensions : public ISrsCodec
|
||||
{
|
||||
private:
|
||||
bool has_ext_;
|
||||
SrsRtpExtensionTypes types_;
|
||||
SrsRtpExtensionTwcc twcc_;
|
||||
SrsRtpExtensionOneByte audio_level_;
|
||||
public:
|
||||
SrsRtpExtensions();
|
||||
virtual ~SrsRtpExtensions();
|
||||
|
@ -152,6 +178,8 @@ public:
|
|||
void set_types_(const SrsRtpExtensionTypes* types);
|
||||
srs_error_t get_twcc_sequence_number(uint16_t& twcc_sn);
|
||||
srs_error_t set_twcc_sequence_number(uint8_t id, uint16_t sn);
|
||||
srs_error_t get_audio_level(uint8_t& level);
|
||||
srs_error_t set_audio_level(int id, uint8_t level);
|
||||
|
||||
// ISrsCodec
|
||||
public:
|
||||
|
@ -257,7 +285,7 @@ public:
|
|||
// Whether the packet is Audio packet.
|
||||
bool is_audio();
|
||||
// Copy the RTP packet.
|
||||
SrsRtpPacket2* copy();
|
||||
virtual SrsRtpPacket2* copy();
|
||||
// Set RTP header extensions for encoding or decoding header extension
|
||||
void set_extension_types(const SrsRtpExtensionTypes* v);
|
||||
// interface ISrsEncoder
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue