mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Fix the bug for RTC publisher
This commit is contained in:
parent
bb9367f88a
commit
70a81b3970
4 changed files with 33 additions and 6 deletions
|
@ -841,7 +841,7 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
|
|||
|
||||
SrsJsonAny* json = SrsJsonAny::loads(req_json);
|
||||
if (!json || !json->is_object()) {
|
||||
return srs_error_wrap(err, "not json");
|
||||
return srs_error_new(ERROR_RTC_API_BODY, "invalid body %s", req_json.c_str());
|
||||
}
|
||||
|
||||
req = json->to_object();
|
||||
|
@ -1021,7 +1021,6 @@ srs_error_t SrsGoApiRtcPlay::exchange_sdp(const std::string& app, const std::str
|
|||
if (local_media_desc.payload_types_.empty()) {
|
||||
return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "no found valid opus payload type");
|
||||
}
|
||||
|
||||
} else if (remote_media_desc.is_video()) {
|
||||
std::deque<SrsMediaPayloadType> backup_payloads;
|
||||
std::vector<SrsMediaPayloadType> payloads = remote_media_desc.find_media_with_encoding_name("H264");
|
||||
|
@ -1086,7 +1085,7 @@ srs_error_t SrsGoApiRtcPlay::exchange_sdp(const std::string& app, const std::str
|
|||
local_media_desc.rtcp_mux_ = true;
|
||||
local_media_desc.rtcp_rsize_ = true;
|
||||
|
||||
if (local_media_desc.recvonly_ || local_media_desc.sendrecv_) {
|
||||
if (local_media_desc.sendonly_ || local_media_desc.sendrecv_) {
|
||||
SrsSSRCInfo ssrc_info;
|
||||
ssrc_info.ssrc_ = ++ssrc_num;
|
||||
// TODO:use formated cname
|
||||
|
@ -1152,7 +1151,7 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter* w, ISrsHtt
|
|||
|
||||
SrsJsonAny* json = SrsJsonAny::loads(req_json);
|
||||
if (!json || !json->is_object()) {
|
||||
return srs_error_wrap(err, "not json");
|
||||
return srs_error_new(ERROR_RTC_API_BODY, "invalid body %s", req_json.c_str());
|
||||
}
|
||||
|
||||
req = json->to_object();
|
||||
|
|
|
@ -1578,6 +1578,11 @@ srs_error_t SrsRtcPublisher::on_rtp(SrsUdpMuxSocket* skt, char* buf, int nb_buf)
|
|||
|
||||
void SrsRtcPublisher::check_send_nacks(SrsRtpQueue* rtp_queue, uint32_t ssrc, SrsUdpMuxSocket* skt)
|
||||
{
|
||||
// If DTLS is not OK, drop all messages.
|
||||
if (!rtc_session->dtls_session) {
|
||||
return;
|
||||
}
|
||||
|
||||
vector<uint16_t> nack_seqs;
|
||||
rtp_queue->nack_.get_nack_seqs(nack_seqs);
|
||||
vector<uint16_t>::iterator iter = nack_seqs.begin();
|
||||
|
@ -1605,6 +1610,7 @@ void SrsRtcPublisher::check_send_nacks(SrsRtpQueue* rtp_queue, uint32_t ssrc, Sr
|
|||
|
||||
// FIXME: Merge nack rtcp into one packets.
|
||||
if (rtc_session->dtls_session->protect_rtcp(protected_buf, stream.data(), nb_protected_buf) == srs_success) {
|
||||
// TODO: FIXME: Check error.
|
||||
skt->sendto(protected_buf, nb_protected_buf, 0);
|
||||
}
|
||||
|
||||
|
@ -1769,6 +1775,11 @@ srs_error_t SrsRtcPublisher::send_rtcp_rr(SrsUdpMuxSocket* skt, uint32_t ssrc, S
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// If DTLS is not OK, drop all messages.
|
||||
if (!rtc_session->dtls_session) {
|
||||
return err;
|
||||
}
|
||||
|
||||
char buf[kRtpPacketSize];
|
||||
SrsBuffer stream(buf, sizeof(buf));
|
||||
stream.write_1bytes(0x81);
|
||||
|
@ -1810,6 +1821,7 @@ srs_error_t SrsRtcPublisher::send_rtcp_rr(SrsUdpMuxSocket* skt, uint32_t ssrc, S
|
|||
return srs_error_wrap(err, "protect rtcp rr");
|
||||
}
|
||||
|
||||
// TDOO: FIXME: Check error.
|
||||
skt->sendto(protected_buf, nb_protected_buf, 0);
|
||||
return err;
|
||||
}
|
||||
|
@ -1817,6 +1829,12 @@ srs_error_t SrsRtcPublisher::send_rtcp_rr(SrsUdpMuxSocket* skt, uint32_t ssrc, S
|
|||
srs_error_t SrsRtcPublisher::send_rtcp_xr_rrtr(SrsUdpMuxSocket* skt, uint32_t ssrc)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// If DTLS is not OK, drop all messages.
|
||||
if (!rtc_session->dtls_session) {
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
@see: http://www.rfc-editor.org/rfc/rfc3611.html#section-2
|
||||
|
||||
|
@ -1863,6 +1881,7 @@ srs_error_t SrsRtcPublisher::send_rtcp_xr_rrtr(SrsUdpMuxSocket* skt, uint32_t ss
|
|||
return srs_error_wrap(err, "protect rtcp xr");
|
||||
}
|
||||
|
||||
// TDOO: FIXME: Check error.
|
||||
skt->sendto(protected_buf, nb_protected_buf, 0);
|
||||
|
||||
return err;
|
||||
|
@ -1872,6 +1891,11 @@ srs_error_t SrsRtcPublisher::send_rtcp_fb_pli(SrsUdpMuxSocket* skt, uint32_t ssr
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// If DTLS is not OK, drop all messages.
|
||||
if (!rtc_session->dtls_session) {
|
||||
return err;
|
||||
}
|
||||
|
||||
char buf[kRtpPacketSize];
|
||||
SrsBuffer stream(buf, sizeof(buf));
|
||||
stream.write_1bytes(0x81);
|
||||
|
@ -1888,6 +1912,7 @@ srs_error_t SrsRtcPublisher::send_rtcp_fb_pli(SrsUdpMuxSocket* skt, uint32_t ssr
|
|||
return srs_error_wrap(err, "protect rtcp psfb pli");
|
||||
}
|
||||
|
||||
// TDOO: FIXME: Check error.
|
||||
skt->sendto(protected_buf, nb_protected_buf, 0);
|
||||
|
||||
return err;
|
||||
|
@ -2123,6 +2148,7 @@ SrsRtcSession::SrsRtcSession(SrsRtcServer* rtc_svr, const SrsRequest& req, const
|
|||
rtc_server = rtc_svr;
|
||||
session_state = INIT;
|
||||
dtls_session = new SrsDtlsSession(this);
|
||||
// TODO: FIXME: Check error.
|
||||
dtls_session->initialize(req);
|
||||
strd = NULL;
|
||||
|
||||
|
@ -2344,6 +2370,7 @@ srs_error_t SrsRtcSession::on_rtcp_feedback(char* buf, int nb_buf, SrsUdpMuxSock
|
|||
|
||||
srs_verbose("resend pkt sequence=%u", resend_pkts[i]->rtp_header.get_sequence());
|
||||
|
||||
// TODO: FIXME: Check error.
|
||||
dtls_session->protect_rtp(protected_buf, resend_pkts[i]->payload, nb_protected_buf);
|
||||
skt->sendto(protected_buf, nb_protected_buf, 0);
|
||||
}
|
||||
|
|
|
@ -226,8 +226,8 @@ srs_error_t SrsMediaPayloadType::encode(std::ostringstream& os)
|
|||
|
||||
if (! format_specific_param_.empty()) {
|
||||
os << "a=fmtp:" << payload_type_ << " " << format_specific_param_
|
||||
// FIXME:test code.
|
||||
<< ";x-google-max-bitrate=6000;x-google-min-bitrate=5100;x-google-start-bitrate=5000"
|
||||
// TODO: FIXME: Remove the test code bellow.
|
||||
// << ";x-google-max-bitrate=6000;x-google-min-bitrate=5100;x-google-start-bitrate=5000"
|
||||
<< kCRLF;
|
||||
}
|
||||
|
||||
|
|
|
@ -347,6 +347,7 @@
|
|||
#define ERROR_RTC_RTCP_CHECK 5016
|
||||
#define ERROR_RTC_SOURCE_CHECK 5017
|
||||
#define ERROR_RTC_SDP_EXCHANGE 5018
|
||||
#define ERROR_RTC_API_BODY 5019
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// GB28181 API error.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue