mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Support av1 for Chrome M90 enabled it. 4.0.91 (#2324)
* RTC: Support av1 for Chrome M90 enabled it. 4.0.91 * RTC: Show codec for WebRTC publisher
This commit is contained in:
parent
a9d39f6946
commit
e8fe66e3ba
7 changed files with 93 additions and 5 deletions
|
@ -157,6 +157,7 @@ Other important wiki:
|
||||||
|
|
||||||
## V4 changes
|
## V4 changes
|
||||||
|
|
||||||
|
* v4.0, 2021-04-29, RTC: Support av1 for Chrome M90. 4.0.91
|
||||||
* v4.0, 2021-04-24, Change push-RTSP as deprecated feature.
|
* v4.0, 2021-04-24, Change push-RTSP as deprecated feature.
|
||||||
* v4.0, 2021-04-24, Player: Change the default from RTMP to HTTP-FLV.
|
* v4.0, 2021-04-24, Player: Change the default from RTMP to HTTP-FLV.
|
||||||
* v4.0, 2021-04-24, Disable CherryPy by --cherrypy=off. 4.0.90
|
* v4.0, 2021-04-24, Disable CherryPy by --cherrypy=off. 4.0.90
|
||||||
|
|
|
@ -470,3 +470,32 @@ function SrsRtcPlayerAsync() {
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Format the codec of RTCRtpSender, kind(audio/video) is optional filter.
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/Media/Formats/WebRTC_codecs#getting_the_supported_codecs
|
||||||
|
function SrsRtcFormatSenders(senders, kind) {
|
||||||
|
var codecs = [];
|
||||||
|
senders.forEach(function (sender) {
|
||||||
|
sender.getParameters().codecs.forEach(function(c) {
|
||||||
|
if (kind && sender.track.kind !== kind) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c.mimeType.indexOf('/red') > 0 || c.mimeType.indexOf('/rtx') > 0 || c.mimeType.indexOf('/fec') > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var s = '';
|
||||||
|
|
||||||
|
s += c.mimeType.replace('audio/', '').replace('video/', '');
|
||||||
|
s += ', ' + c.clockRate + 'HZ';
|
||||||
|
if (sender.track.kind === "audio") {
|
||||||
|
s += ', channels: ' + c.channels;
|
||||||
|
}
|
||||||
|
s += ', pt: ' + c.payloadType;
|
||||||
|
|
||||||
|
codecs.push(s);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return codecs.join(", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,10 @@
|
||||||
<label></label>
|
<label></label>
|
||||||
SessionID: <span id='sessionid'></span>
|
SessionID: <span id='sessionid'></span>
|
||||||
|
|
||||||
|
<label></label>
|
||||||
|
Audio: <span id='acodecs'></span><br/>
|
||||||
|
Video: <span id='vcodecs'></span>
|
||||||
|
|
||||||
<label></label>
|
<label></label>
|
||||||
Simulator: <a href='#' id='simulator-drop'>Drop</a>
|
Simulator: <a href='#' id='simulator-drop'>Drop</a>
|
||||||
|
|
||||||
|
@ -81,6 +85,14 @@
|
||||||
$('#rtc_media_player').prop('srcObject', event.stream);
|
$('#rtc_media_player').prop('srcObject', event.stream);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/Media/Formats/WebRTC_codecs#getting_the_supported_codecs
|
||||||
|
sdk.pc.onicegatheringstatechange = function (event) {
|
||||||
|
if (sdk.pc.iceGatheringState === "complete") {
|
||||||
|
$('#acodecs').html(SrsRtcFormatSenders(sdk.pc.getSenders(), "audio"));
|
||||||
|
$('#vcodecs').html(SrsRtcFormatSenders(sdk.pc.getSenders(), "video"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// For example:
|
// For example:
|
||||||
// webrtc://r.ossrs.net/live/livestream
|
// webrtc://r.ossrs.net/live/livestream
|
||||||
var url = $("#txt_url").val();
|
var url = $("#txt_url").val();
|
||||||
|
|
|
@ -134,18 +134,20 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
|
||||||
|
|
||||||
// For client to specifies the EIP of server.
|
// For client to specifies the EIP of server.
|
||||||
string eip = r->query_get("eip");
|
string eip = r->query_get("eip");
|
||||||
|
string codec = r->query_get("codec");
|
||||||
// For client to specifies whether encrypt by SRTP.
|
// For client to specifies whether encrypt by SRTP.
|
||||||
string srtp = r->query_get("encrypt");
|
string srtp = r->query_get("encrypt");
|
||||||
string dtls = r->query_get("dtls");
|
string dtls = r->query_get("dtls");
|
||||||
|
|
||||||
srs_trace("RTC play %s, api=%s, clientip=%s, app=%s, stream=%s, offer=%dB, eip=%s, srtp=%s, dtls=%s",
|
srs_trace("RTC play %s, api=%s, clientip=%s, app=%s, stream=%s, offer=%dB, eip=%s, codec=%s, srtp=%s, dtls=%s",
|
||||||
streamurl.c_str(), api.c_str(), clientip.c_str(), app.c_str(), stream_name.c_str(), remote_sdp_str.length(), eip.c_str(),
|
streamurl.c_str(), api.c_str(), clientip.c_str(), app.c_str(), stream_name.c_str(), remote_sdp_str.length(), eip.c_str(),
|
||||||
srtp.c_str(), dtls.c_str()
|
codec.c_str(), srtp.c_str(), dtls.c_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
// The RTC user config object.
|
// The RTC user config object.
|
||||||
SrsRtcUserConfig ruc;
|
SrsRtcUserConfig ruc;
|
||||||
ruc.eip_ = eip;
|
ruc.eip_ = eip;
|
||||||
|
ruc.codec_ = codec;
|
||||||
ruc.publish_ = false;
|
ruc.publish_ = false;
|
||||||
ruc.dtls_ = (dtls != "false");
|
ruc.dtls_ = (dtls != "false");
|
||||||
|
|
||||||
|
@ -500,14 +502,17 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter* w, ISrsHtt
|
||||||
|
|
||||||
// For client to specifies the EIP of server.
|
// For client to specifies the EIP of server.
|
||||||
string eip = r->query_get("eip");
|
string eip = r->query_get("eip");
|
||||||
|
string codec = r->query_get("codec");
|
||||||
|
|
||||||
srs_trace("RTC publish %s, api=%s, clientip=%s, app=%s, stream=%s, offer=%dB, eip=%s",
|
srs_trace("RTC publish %s, api=%s, clientip=%s, app=%s, stream=%s, offer=%dB, eip=%s, codec=%s",
|
||||||
streamurl.c_str(), api.c_str(), clientip.c_str(), app.c_str(), stream_name.c_str(), remote_sdp_str.length(), eip.c_str()
|
streamurl.c_str(), api.c_str(), clientip.c_str(), app.c_str(), stream_name.c_str(), remote_sdp_str.length(), eip.c_str(),
|
||||||
|
codec.c_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
// The RTC user config object.
|
// The RTC user config object.
|
||||||
SrsRtcUserConfig ruc;
|
SrsRtcUserConfig ruc;
|
||||||
ruc.eip_ = eip;
|
ruc.eip_ = eip;
|
||||||
|
ruc.codec_ = codec;
|
||||||
ruc.publish_ = true;
|
ruc.publish_ = true;
|
||||||
ruc.dtls_ = ruc.srtp_ = true;
|
ruc.dtls_ = ruc.srtp_ = true;
|
||||||
|
|
||||||
|
|
|
@ -2771,6 +2771,38 @@ srs_error_t SrsRtcConnection::negotiate_publish_capability(SrsRtcUserConfig* ruc
|
||||||
// Only choose one match opus codec.
|
// Only choose one match opus codec.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (remote_media_desc.is_video() && ruc->codec_ == "av1") {
|
||||||
|
std::vector<SrsMediaPayloadType> payloads = remote_media_desc.find_media_with_encoding_name("AV1X");
|
||||||
|
if (payloads.empty()) {
|
||||||
|
return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "no found valid AV1 payload type");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < (int)payloads.size(); j++) {
|
||||||
|
const SrsMediaPayloadType& payload = payloads.at(j);
|
||||||
|
|
||||||
|
// Generate video payload for av1.
|
||||||
|
SrsVideoPayload* video_payload = new SrsVideoPayload(payload.payload_type_, payload.encoding_name_, payload.clock_rate_);
|
||||||
|
|
||||||
|
// TODO: FIXME: Only support some transport algorithms.
|
||||||
|
for (int k = 0; k < (int)payload.rtcp_fb_.size(); ++k) {
|
||||||
|
const string& rtcp_fb = payload.rtcp_fb_.at(k);
|
||||||
|
|
||||||
|
if (nack_enabled) {
|
||||||
|
if (rtcp_fb == "nack" || rtcp_fb == "nack pli") {
|
||||||
|
video_payload->rtcp_fbs_.push_back(rtcp_fb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (twcc_enabled && remote_twcc_id) {
|
||||||
|
if (rtcp_fb == "transport-cc") {
|
||||||
|
video_payload->rtcp_fbs_.push_back(rtcp_fb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
track_desc->type_ = "video";
|
||||||
|
track_desc->set_codec_payload((SrsCodecPayload*)video_payload);
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else if (remote_media_desc.is_video()) {
|
} else if (remote_media_desc.is_video()) {
|
||||||
std::vector<SrsMediaPayloadType> payloads = remote_media_desc.find_media_with_encoding_name("H264");
|
std::vector<SrsMediaPayloadType> payloads = remote_media_desc.find_media_with_encoding_name("H264");
|
||||||
if (payloads.empty()) {
|
if (payloads.empty()) {
|
||||||
|
@ -3050,6 +3082,14 @@ srs_error_t SrsRtcConnection::negotiate_play_capability(SrsRtcUserConfig* ruc, s
|
||||||
|
|
||||||
remote_payload = payloads.at(0);
|
remote_payload = payloads.at(0);
|
||||||
track_descs = source->get_track_desc("audio", "opus");
|
track_descs = source->get_track_desc("audio", "opus");
|
||||||
|
} else if (remote_media_desc.is_video() && ruc->codec_ == "av1") {
|
||||||
|
std::vector<SrsMediaPayloadType> payloads = remote_media_desc.find_media_with_encoding_name("AV1X");
|
||||||
|
if (payloads.empty()) {
|
||||||
|
return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "no found valid AV1 payload type");
|
||||||
|
}
|
||||||
|
|
||||||
|
remote_payload = payloads.at(0);
|
||||||
|
track_descs = source->get_track_desc("video", "AV1X");
|
||||||
} else if (remote_media_desc.is_video()) {
|
} else if (remote_media_desc.is_video()) {
|
||||||
// TODO: check opus format specific param
|
// TODO: check opus format specific param
|
||||||
vector<SrsMediaPayloadType> payloads = remote_media_desc.find_media_with_encoding_name("H264");
|
vector<SrsMediaPayloadType> payloads = remote_media_desc.find_media_with_encoding_name("H264");
|
||||||
|
|
|
@ -92,6 +92,7 @@ public:
|
||||||
// Original variables from API.
|
// Original variables from API.
|
||||||
SrsSdp remote_sdp_;
|
SrsSdp remote_sdp_;
|
||||||
std::string eip_;
|
std::string eip_;
|
||||||
|
std::string codec_;
|
||||||
|
|
||||||
// Generated data.
|
// Generated data.
|
||||||
SrsRequest* req_;
|
SrsRequest* req_;
|
||||||
|
|
|
@ -26,6 +26,6 @@
|
||||||
|
|
||||||
#define VERSION_MAJOR 4
|
#define VERSION_MAJOR 4
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 90
|
#define VERSION_REVISION 91
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue