Skip to content

Commit 3d16f52

Browse files
authored
Update screenshare logic for svc publishing (#487)
* Update screenshare logic for SVC publishing. * Handle SVC compatibility with Safari and Chrome prior to M113. * Update build.gradle * Update build.yaml
1 parent 63e4fa8 commit 3d16f52

File tree

5 files changed

+19
-35
lines changed

5 files changed

+19
-35
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
- uses: actions/checkout@v2
5656
- uses: actions/setup-java@v1
5757
with:
58-
java-version: '12.x'
58+
java-version: '17.x'
5959
- uses: actions/checkout@v2
6060
- uses: subosito/flutter-action@v2
6161
with:

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

2828
android {
29-
compileSdkVersion 33
29+
compileSdkVersion 34
3030

3131
sourceSets {
3232
main.java.srcDirs += 'src/main/kotlin'

lib/src/core/transport.dart

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,31 +209,16 @@ class Transport extends Disposable {
209209
continue;
210210
}
211211

212-
var fmtpFound = false;
213212
for (var fmtp in media['fmtp']) {
214213
if (fmtp['payload'] == codecPayload) {
215214
if (!(fmtp['config'] as String)
216215
.contains('x-google-start-bitrate')) {
217216
fmtp['config'] +=
218217
';x-google-start-bitrate=${(trackbr.maxbr * startBitrateForSVC).toInt()}';
219218
}
220-
if (!(fmtp['config'] as String)
221-
.contains('x-google-max-bitrate')) {
222-
fmtp['config'] += ';x-google-max-bitrate=${trackbr.maxbr}';
223-
}
224-
fmtpFound = true;
225219
break;
226220
}
227221
}
228-
229-
if (!fmtpFound) {
230-
media['fmtp']?.add({
231-
'payload': codecPayload,
232-
'config':
233-
'x-google-start-bitrate=${(trackbr.maxbr * startBitrateForSVC).toInt()};x-google-max-bitrate=${trackbr.maxbr}',
234-
});
235-
}
236-
237222
continue;
238223
}
239224
}

lib/src/participant/local.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ class LocalParticipant extends Participant<LocalTrackPublication> {
166166
}
167167

168168
// vp9 svc with screenshare has problem to encode, always use L1T3 here
169-
if (track.source == TrackSource.screenShareVideo &&
170-
publishOptions.videoCodec.toLowerCase() == 'vp9') {
169+
if (track.source == TrackSource.screenShareVideo) {
171170
publishOptions = publishOptions.copyWith(
172171
scalabilityMode: 'L1T3',
173172
);

lib/src/utils.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -432,23 +432,23 @@ class Utils {
432432

433433
if (scalabilityMode != null && isSVCCodec(options.videoCodec)) {
434434
logger.info('using svc with scalabilityMode ${scalabilityMode}');
435-
436-
//final sm = ScalabilityMode(scalabilityMode);
437-
438-
List<rtc.RTCRtpEncoding> encodings = [videoEncoding.toRTCRtpEncoding()];
439-
/*
440-
if (sm.spatial > 3) {
441-
throw Exception('unsupported scalabilityMode: ${scalabilityMode}');
435+
List<rtc.RTCRtpEncoding> encodings = [];
436+
if (lkPlatformIs(PlatformType.web) &&
437+
(lkBrowser() == BrowserType.safari ||
438+
lkBrowser() == BrowserType.chrome &&
439+
lkBrowserVersion().major < 113)) {
440+
final sm = ScalabilityMode(scalabilityMode);
441+
for (var i = 0; i < sm.spatial; i += 1) {
442+
// in legacy SVC, scaleResolutionDownBy cannot be set
443+
encodings.add(rtc.RTCRtpEncoding(
444+
rid: videoRids[2 - i],
445+
maxBitrate: videoEncoding.maxBitrate ~/ math.pow(3, i),
446+
maxFramerate: original.encoding.maxFramerate,
447+
));
448+
}
449+
} else {
450+
encodings.add(videoEncoding.toRTCRtpEncoding());
442451
}
443-
for (int i = 0; i < sm.spatial; i += 1) {
444-
encodings.add(rtc.RTCRtpEncoding(
445-
rid: videoRids[2 - i],
446-
maxBitrate: videoEncoding.maxBitrate ~/ math.pow(3, i),
447-
maxFramerate: videoEncoding.maxFramerate,
448-
scaleResolutionDownBy: null,
449-
numTemporalLayers: sm.temporal.toInt(),
450-
));
451-
}*/
452452
encodings[0].scalabilityMode = scalabilityMode;
453453
logger.fine('encodings $encodings');
454454
return encodings;

0 commit comments

Comments
 (0)