mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-22 23:25:33 +00:00
Rename RtcpSRReporter to RtcpSrReporter for naming consistency
This commit is contained in:
@ -60,7 +60,7 @@ int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||
using namespace std;
|
||||
using namespace rtc;
|
||||
|
||||
ClientTrackData::ClientTrackData(shared_ptr<Track> track, shared_ptr<RtcpSRReporter> sender) {
|
||||
ClientTrackData::ClientTrackData(shared_ptr<Track> track, shared_ptr<RtcpSrReporter> sender) {
|
||||
this->track = track;
|
||||
this->sender = sender;
|
||||
}
|
||||
|
@ -23,9 +23,9 @@
|
||||
|
||||
struct ClientTrackData {
|
||||
std::shared_ptr<rtc::Track> track;
|
||||
std::shared_ptr<rtc::RtcpSRReporter> sender;
|
||||
std::shared_ptr<rtc::RtcpSrReporter> sender;
|
||||
|
||||
ClientTrackData(std::shared_ptr<rtc::Track> track, std::shared_ptr<rtc::RtcpSRReporter> sender);
|
||||
ClientTrackData(std::shared_ptr<rtc::Track> track, std::shared_ptr<rtc::RtcpSrReporter> sender);
|
||||
};
|
||||
|
||||
struct Client {
|
||||
|
@ -223,7 +223,7 @@ shared_ptr<ClientTrackData> addVideo(const shared_ptr<PeerConnection> pc, const
|
||||
// create H264 handler
|
||||
shared_ptr<H264PacketizationHandler> h264Handler(new H264PacketizationHandler(packetizer));
|
||||
// add RTCP SR handler
|
||||
auto srReporter = make_shared<RtcpSRReporter>(rtpConfig);
|
||||
auto srReporter = make_shared<RtcpSrReporter>(rtpConfig);
|
||||
h264Handler->addToChain(srReporter);
|
||||
// add RTCP NACK handler
|
||||
auto nackResponder = make_shared<RtcpNackResponder>();
|
||||
@ -247,7 +247,7 @@ shared_ptr<ClientTrackData> addAudio(const shared_ptr<PeerConnection> pc, const
|
||||
// create opus handler
|
||||
auto opusHandler = make_shared<OpusPacketizationHandler>(packetizer);
|
||||
// add RTCP SR handler
|
||||
auto srReporter = make_shared<RtcpSRReporter>(rtpConfig);
|
||||
auto srReporter = make_shared<RtcpSrReporter>(rtpConfig);
|
||||
opusHandler->addToChain(srReporter);
|
||||
// add RTCP NACK handler
|
||||
auto nackResponder = make_shared<RtcpNackResponder>();
|
||||
|
@ -240,9 +240,9 @@ RTC_EXPORT int rtcSetH264PacketizationHandler(int tr, uint32_t ssrc, const char
|
||||
/// @param _timestamp Timestamp
|
||||
RTC_EXPORT int rtcSetOpusPacketizationHandler(int tr, uint32_t ssrc, const char * cname, uint8_t payloadType, uint32_t clockRate, uint16_t _sequenceNumber, uint32_t _timestamp);
|
||||
|
||||
/// Chain RtcpSRReporter to handler chain for given track
|
||||
/// Chain RtcpSrReporter to handler chain for given track
|
||||
/// @param tr Track id
|
||||
int rtcChainRtcpSRReporter(int tr);
|
||||
int rtcChainRtcpSrReporter(int tr);
|
||||
|
||||
/// Chain RtcpNackResponder to handler chain for given track
|
||||
/// @param tr Track id
|
||||
@ -291,9 +291,9 @@ int rtcSetTrackRTPTimestamp(int id, uint32_t timestamp);
|
||||
/// @param timestamp Pointer for result
|
||||
int rtcGetPreviousTrackSenderReportTimestamp(int id, uint32_t * timestamp);
|
||||
|
||||
/// Set `NeedsToReport` flag in RtcpSenderReporter handler identified by given track id
|
||||
/// Set `NeedsToReport` flag in RtcpSrReporter handler identified by given track id
|
||||
/// @param id Track id
|
||||
int rtcSetNeedsToSendRTCPSR(int id);
|
||||
int rtcSetNeedsToSendRtcpSr(int id);
|
||||
|
||||
#endif // RTC_ENABLE_MEDIA
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
namespace rtc {
|
||||
|
||||
class RTC_CPP_EXPORT RtcpSRReporter: public MessageHandlerElement {
|
||||
class RTC_CPP_EXPORT RtcpSrReporter: public MessageHandlerElement {
|
||||
|
||||
bool needsToReport = false;
|
||||
|
||||
@ -48,7 +48,7 @@ public:
|
||||
/// RTP configuration
|
||||
const std::shared_ptr<RtpPacketizationConfig> rtpConfig;
|
||||
|
||||
RtcpSRReporter(std::shared_ptr<RtpPacketizationConfig> rtpConfig);
|
||||
RtcpSrReporter(std::shared_ptr<RtpPacketizationConfig> rtpConfig);
|
||||
|
||||
ChainedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages, std::optional<message_ptr> control) override;
|
||||
|
||||
|
26
src/capi.cpp
26
src/capi.cpp
@ -54,7 +54,7 @@ std::unordered_map<int, shared_ptr<DataChannel>> dataChannelMap;
|
||||
std::unordered_map<int, shared_ptr<Track>> trackMap;
|
||||
#if RTC_ENABLE_MEDIA
|
||||
std::unordered_map<int, shared_ptr<RtcpChainableHandler>> rtcpChainableHandlerMap;
|
||||
std::unordered_map<int, shared_ptr<RtcpSRReporter>> rtcpSenderMap;
|
||||
std::unordered_map<int, shared_ptr<RtcpSrReporter>> rtcpSrReporterMap;
|
||||
std::unordered_map<int, shared_ptr<RtpPacketizationConfig>> rtpConfigMap;
|
||||
#endif
|
||||
#if RTC_ENABLE_WEBSOCKET
|
||||
@ -142,7 +142,7 @@ void eraseTrack(int tr) {
|
||||
if (trackMap.erase(tr) == 0)
|
||||
throw std::invalid_argument("Track ID does not exist");
|
||||
#if RTC_ENABLE_MEDIA
|
||||
rtcpSenderMap.erase(tr);
|
||||
rtcpSrReporterMap.erase(tr);
|
||||
rtcpChainableHandlerMap.erase(tr);
|
||||
rtpConfigMap.erase(tr);
|
||||
#endif
|
||||
@ -151,18 +151,18 @@ void eraseTrack(int tr) {
|
||||
|
||||
#if RTC_ENABLE_MEDIA
|
||||
|
||||
shared_ptr<RtcpSRReporter> getRTCPSender(int id) {
|
||||
shared_ptr<RtcpSrReporter> getRtcpSrReporter(int id) {
|
||||
std::lock_guard lock(mutex);
|
||||
if (auto it = rtcpSenderMap.find(id); it != rtcpSenderMap.end()) {
|
||||
if (auto it = rtcpSrReporterMap.find(id); it != rtcpSrReporterMap.end()) {
|
||||
return it->second;
|
||||
} else {
|
||||
throw std::invalid_argument("RtcpSRReporter ID does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
void emplaceRTCPSender(shared_ptr<RtcpSRReporter> ptr, int tr) {
|
||||
void emplaceRtcpSrReporter(shared_ptr<RtcpSrReporter> ptr, int tr) {
|
||||
std::lock_guard lock(mutex);
|
||||
rtcpSenderMap.emplace(std::make_pair(tr, ptr));
|
||||
rtcpSrReporterMap.emplace(std::make_pair(tr, ptr));
|
||||
}
|
||||
|
||||
shared_ptr<RtcpChainableHandler> getRTCPChainableHandler(int id) {
|
||||
@ -583,11 +583,11 @@ int rtcSetOpusPacketizationHandler(int tr, uint32_t ssrc, const char *cname, uin
|
||||
});
|
||||
}
|
||||
|
||||
int rtcChainRtcpSRReporter(int tr) {
|
||||
int rtcChainRtcpSrReporter(int tr) {
|
||||
return WRAP({
|
||||
auto config = getRTPConfig(tr);
|
||||
auto reporter = std::make_shared<RtcpSRReporter>(config);
|
||||
emplaceRTCPSender(reporter, tr);
|
||||
auto reporter = std::make_shared<RtcpSrReporter>(config);
|
||||
emplaceRtcpSrReporter(reporter, tr);
|
||||
auto chainableHandler = getRTCPChainableHandler(tr);
|
||||
chainableHandler->addToChain(reporter);
|
||||
});
|
||||
@ -615,7 +615,7 @@ int rtcSetRtpConfigurationStartTime(int id, double startTime_s, bool timeInterva
|
||||
|
||||
int rtcStartRtcpSenderReporterRecording(int id) {
|
||||
return WRAP({
|
||||
auto sender = getRTCPSender(id);
|
||||
auto sender = getRtcpSrReporter(id);
|
||||
sender->startRecording();
|
||||
});
|
||||
}
|
||||
@ -657,14 +657,14 @@ int rtcSetTrackRTPTimestamp(int id, uint32_t timestamp) {
|
||||
|
||||
int rtcGetPreviousTrackSenderReportTimestamp(int id, uint32_t *timestamp) {
|
||||
return WRAP({
|
||||
auto sender = getRTCPSender(id);
|
||||
auto sender = getRtcpSrReporter(id);
|
||||
*timestamp = sender->previousReportedTimestamp;
|
||||
});
|
||||
}
|
||||
|
||||
int rtcSetNeedsToSendRTCPSR(int id) {
|
||||
int rtcSetNeedsToSendRtcpSr(int id) {
|
||||
return WRAP({
|
||||
auto sender = getRTCPSender(id);
|
||||
auto sender = getRtcpSrReporter(id);
|
||||
sender->setNeedsToReport();
|
||||
});
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
namespace rtc {
|
||||
|
||||
ChainedOutgoingProduct RtcpSRReporter::processOutgoingBinaryMessage(ChainedMessagesProduct messages, std::optional<message_ptr> control) {
|
||||
ChainedOutgoingProduct RtcpSrReporter::processOutgoingBinaryMessage(ChainedMessagesProduct messages, std::optional<message_ptr> control) {
|
||||
if (needsToReport) {
|
||||
auto timestamp = rtpConfig->timestamp;
|
||||
auto sr = getSenderReport(timestamp);
|
||||
@ -40,27 +40,27 @@ ChainedOutgoingProduct RtcpSRReporter::processOutgoingBinaryMessage(ChainedMessa
|
||||
return {messages, control};
|
||||
}
|
||||
|
||||
void RtcpSRReporter::startRecording() {
|
||||
void RtcpSrReporter::startRecording() {
|
||||
_previousReportedTimestamp = rtpConfig->timestamp;
|
||||
timeOffset = rtpConfig->startTime_s - rtpConfig->timestampToSeconds(rtpConfig->timestamp);
|
||||
}
|
||||
|
||||
void RtcpSRReporter::addToReport(RTP *rtp, uint32_t rtpSize) {
|
||||
void RtcpSrReporter::addToReport(RTP *rtp, uint32_t rtpSize) {
|
||||
packetCount += 1;
|
||||
assert(!rtp->padding());
|
||||
payloadOctets += rtpSize - rtp->getSize();
|
||||
}
|
||||
|
||||
RtcpSRReporter::RtcpSRReporter(std::shared_ptr<RtpPacketizationConfig> rtpConfig)
|
||||
RtcpSrReporter::RtcpSrReporter(std::shared_ptr<RtpPacketizationConfig> rtpConfig)
|
||||
: MessageHandlerElement(), rtpConfig(rtpConfig) {}
|
||||
|
||||
uint64_t RtcpSRReporter::secondsToNTP(double seconds) {
|
||||
uint64_t RtcpSrReporter::secondsToNTP(double seconds) {
|
||||
return std::round(seconds * double(uint64_t(1) << 32));
|
||||
}
|
||||
|
||||
void RtcpSRReporter::setNeedsToReport() { needsToReport = true; }
|
||||
void RtcpSrReporter::setNeedsToReport() { needsToReport = true; }
|
||||
|
||||
message_ptr RtcpSRReporter::getSenderReport(uint32_t timestamp) {
|
||||
message_ptr RtcpSrReporter::getSenderReport(uint32_t timestamp) {
|
||||
auto srSize = RTCP_SR::size(0);
|
||||
auto msg = make_message(srSize + RTCP_SDES::size({{uint8_t(rtpConfig->cname.size())}}),
|
||||
Message::Type::Control);
|
||||
|
Reference in New Issue
Block a user