Skip to content

Commit

Permalink
common: Add function for getting SSRC of media_stream
Browse files Browse the repository at this point in the history
Came across needing to know the local SSRC when trying to separate
media streams from one another.
  • Loading branch information
jrsnen committed May 16, 2022
1 parent 519b535 commit a6f9afc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
2 changes: 2 additions & 0 deletions include/uvgrtp/media_stream.hh
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ namespace uvgrtp {
*/
uvgrtp::rtcp *get_rtcp();

uint32_t get_ssrc() const;

private:
/* Initialize the connection by initializing the socket
* and binding ourselves to specified interface and creating
Expand Down
10 changes: 10 additions & 0 deletions src/media_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,16 @@ uvgrtp::rtcp *uvgrtp::media_stream::get_rtcp()
return rtcp_.get();
}

uint32_t uvgrtp::media_stream::get_ssrc() const
{
if (!initialized_ || rtp_ == nullptr) {
LOG_ERROR("RTP context has not been initialized, please call init before asking ssrc!");
return RTP_NOT_INITIALIZED;
}

return rtp_->get_ssrc();
}

rtp_error_t uvgrtp::media_stream::init_srtp_with_zrtp(int flags, int type, std::shared_ptr<uvgrtp::base_srtp> srtp,
std::shared_ptr<uvgrtp::zrtp> zrtp)
{
Expand Down
12 changes: 6 additions & 6 deletions src/rtp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ uvgrtp::rtp::~rtp()
{
}

uint32_t uvgrtp::rtp::get_ssrc()
uint32_t uvgrtp::rtp::get_ssrc() const
{
return ssrc_;
}

uint16_t uvgrtp::rtp::get_sequence()
uint16_t uvgrtp::rtp::get_sequence() const
{
return seq_;
}
Expand Down Expand Up @@ -127,7 +127,7 @@ void uvgrtp::rtp::set_timestamp(uint64_t timestamp)
timestamp_= timestamp;
}

uint32_t uvgrtp::rtp::get_clock_rate(void)
uint32_t uvgrtp::rtp::get_clock_rate() const
{
return clock_rate_;
}
Expand All @@ -137,12 +137,12 @@ void uvgrtp::rtp::set_payload_size(size_t payload_size)
payload_size_ = payload_size;
}

size_t uvgrtp::rtp::get_payload_size()
size_t uvgrtp::rtp::get_payload_size() const
{
return payload_size_;
}

rtp_format_t uvgrtp::rtp::get_payload()
rtp_format_t uvgrtp::rtp::get_payload() const
{
return (rtp_format_t)fmt_;
}
Expand All @@ -152,7 +152,7 @@ void uvgrtp::rtp::set_pkt_max_delay(size_t delay)
delay_ = delay;
}

size_t uvgrtp::rtp::get_pkt_max_delay()
size_t uvgrtp::rtp::get_pkt_max_delay() const
{
return delay_;
}
Expand Down
12 changes: 6 additions & 6 deletions src/rtp.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ namespace uvgrtp {
rtp(rtp_format_t fmt);
~rtp();

uint32_t get_ssrc();
uint16_t get_sequence();
uint32_t get_clock_rate();
size_t get_payload_size();
size_t get_pkt_max_delay();
rtp_format_t get_payload();
uint32_t get_ssrc() const;
uint16_t get_sequence() const;
uint32_t get_clock_rate() const;
size_t get_payload_size() const;
size_t get_pkt_max_delay() const;
rtp_format_t get_payload() const;

void inc_sent_pkts();
void inc_sequence();
Expand Down

0 comments on commit a6f9afc

Please sign in to comment.