Skip to content

Commit

Permalink
Mofidy x-google* from cpp code to html
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhihong committed Dec 15, 2021
1 parent a38ad9b commit ca7feaa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
25 changes: 21 additions & 4 deletions trunk/research/players/js/srs.sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function SrsRtcPublisherAsync() {
var conf = self.__internal.prepareUrl(url);
const parameter = QueryParameterByName('numberOfSimulcastLayers', conf.streamUrl);
const numberOfSimulcastLayers = parseInt(parameter)
var forceSetBitrate = false
if (numberOfSimulcastLayers > 1) {
self.constraints.video = {
wіdth: 1280, height: 720
Expand All @@ -56,6 +57,7 @@ function SrsRtcPublisherAsync() {
self.constraints.video = {
wіdth: 1280, height: 720
}
forceSetBitrate = true;
console.log('kSimulcastApiVersionSpecCompliant')
}

Expand Down Expand Up @@ -110,9 +112,24 @@ function SrsRtcPublisherAsync() {
reject(reason);
});
});
await self.pc.setRemoteDescription(
new RTCSessionDescription({type: 'answer', sdp: session.sdp})
);


if (forceSetBitrate) {
var arr = session.sdp.split('\r\n');
arr.forEach((str, i) => {
// TODO: FIXME: adapter to different browers.
if (/^a=fmtp:\d*/.test(str)) {
arr[i] = str + ';x-google-min-bitrate=5000;x-google-max-bitrate=8000;x-google-start-bitrate=6000';
}
});
await self.pc.setRemoteDescription(
new RTCSessionDescription({type: 'answer', sdp: arr.join('\r\n')})
);
} else {
await self.pc.setRemoteDescription(
new RTCSessionDescription({type: 'answer', sdp: session.sdp})
);
}
session.simulator = conf.schema + '//' + conf.urlObject.server + ':' + conf.port + '/rtc/v1/nack/';

return session;
Expand Down Expand Up @@ -637,4 +654,4 @@ function QueryParameterByName(name, url) {
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
}
3 changes: 0 additions & 3 deletions trunk/src/app/srs_app_rtc_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3224,9 +3224,6 @@ srs_error_t SrsRtcConnection::generate_publish_local_sdp(SrsRequest* req, SrsSdp
}

SrsVideoPayload* payload = (SrsVideoPayload*)video_track->media_;
if (srs_string_contains(req->param,"?numberOfSimulcastLayers=spec3")) {
payload->h264_param_.x_google_bitrate = "x-google-min-bitrate=5000;x-google-max-bitrate=8000;x-google-start-bitrate=6000";
}
local_media_desc.payload_types_.push_back(payload->generate_media_payload_type());

if (video_track->red_) {
Expand Down
3 changes: 0 additions & 3 deletions trunk/src/app/srs_app_rtc_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1865,9 +1865,6 @@ SrsMediaPayloadType SrsVideoPayload::generate_media_payload_type()
if (!h264_param_.packetization_mode.empty()) {
format_specific_param << ";packetization-mode=" << h264_param_.packetization_mode;
}
if (!h264_param_.x_google_bitrate.empty()) {
format_specific_param << ";" << h264_param_.x_google_bitrate;
}
if (!h264_param_.profile_level_id.empty()) {
format_specific_param << ";profile-level-id=" << h264_param_.profile_level_id;
}
Expand Down

0 comments on commit ca7feaa

Please sign in to comment.