添加ssrc相关的方法

This commit is contained in:
xia-chu 2021-05-10 17:35:22 +08:00
parent 985fe310b6
commit d4ce5b0091
2 changed files with 23 additions and 0 deletions

View File

@ -1290,6 +1290,9 @@ void RtcMedia::checkValid() const{
CHECK(!proto.empty()); CHECK(!proto.empty());
CHECK(direction != RtpDirection::invalid || type == TrackApplication); CHECK(direction != RtpDirection::invalid || type == TrackApplication);
CHECK(!plan.empty() || type == TrackApplication ); CHECK(!plan.empty() || type == TrackApplication );
}
void RtcMedia::checkValidSSRC() const {
bool send_rtp = (direction == RtpDirection::sendonly || direction == RtpDirection::sendrecv); bool send_rtp = (direction == RtpDirection::sendonly || direction == RtpDirection::sendrecv);
if (rtp_rids.empty() && rtp_ssrc_sim.empty()) { if (rtp_rids.empty() && rtp_ssrc_sim.empty()) {
//非simulcast时检查有没有指定rtp ssrc //非simulcast时检查有没有指定rtp ssrc
@ -1318,6 +1321,12 @@ void RtcSession::checkValid() const{
} }
} }
void RtcSession::checkValidSSRC() const{
for (auto &item : media) {
item.checkValidSSRC();
}
}
const RtcMedia *RtcSession::getMedia(TrackType type) const{ const RtcMedia *RtcSession::getMedia(TrackType type) const{
for(auto &m : media){ for(auto &m : media){
if(m.type == type){ if(m.type == type){
@ -1327,6 +1336,15 @@ const RtcMedia *RtcSession::getMedia(TrackType type) const{
return nullptr; return nullptr;
} }
bool RtcSession::haveSSRC() const {
for (auto &m : media) {
if (!m.rtp_rtx_ssrc.empty()) {
return true;
}
}
return false;
}
bool RtcSession::supportRtcpFb(const string &name, TrackType type) const { bool RtcSession::supportRtcpFb(const string &name, TrackType type) const {
auto media = getMedia(type); auto media = getMedia(type);
if (!media) { if (!media) {

View File

@ -640,6 +640,8 @@ public:
uint32_t sctp_port{0}; uint32_t sctp_port{0};
void checkValid() const; void checkValid() const;
//offer sdp,如果指定了发送rtp,那么应该指定ssrc
void checkValidSSRC() const;
const RtcCodecPlan *getPlan(uint8_t pt) const; const RtcCodecPlan *getPlan(uint8_t pt) const;
const RtcCodecPlan *getPlan(const char *codec) const; const RtcCodecPlan *getPlan(const char *codec) const;
const RtcCodecPlan *getRelatedRtxPlan(uint8_t pt) const; const RtcCodecPlan *getRelatedRtxPlan(uint8_t pt) const;
@ -662,9 +664,12 @@ public:
void loadFrom(const string &sdp, bool check = true); void loadFrom(const string &sdp, bool check = true);
void checkValid() const; void checkValid() const;
//offer sdp,如果指定了发送rtp,那么应该指定ssrc
void checkValidSSRC() const;
string toString() const; string toString() const;
string toRtspSdp() const; string toRtspSdp() const;
const RtcMedia *getMedia(TrackType type) const; const RtcMedia *getMedia(TrackType type) const;
bool haveSSRC() const;
bool supportRtcpFb(const string &name, TrackType type = TrackType::TrackVideo) const; bool supportRtcpFb(const string &name, TrackType type = TrackType::TrackVideo) const;
private: private: