Skip to content

Commit df1e78f

Browse files
authored
Merge pull request #464 from AgoraIO/dev/4.6.2
Dev/4.6.2
2 parents 1d81ec6 + ce3f4e2 commit df1e78f

File tree

182 files changed

+21621
-12157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+21621
-12157
lines changed

Android/APIExample-Audio/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ android.nonFinalResIds=false
2323
# read enable simple filter section on README first before set this flag to TRUE
2424
simpleFilter = false
2525

26-
rtc_sdk_version = 4.6.0
26+
rtc_sdk_version = 4.6.2

Android/APIExample-Compose/app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
android:exported="true"
2929
android:label="@string/app_name"
3030
android:theme="@style/Theme.APIExampleCompose"
31+
android:supportsPictureInPicture="true"
32+
android:screenOrientation="portrait"
3133
android:configChanges="screenSize|screenLayout|orientation|smallestScreenSize">
3234
<intent-filter>
3335
<action android:name="android.intent.action.MAIN" />
@@ -36,12 +38,14 @@
3638
</intent-filter>
3739
</activity>
3840

41+
<!--
3942
<activity
4043
android:name=".samples.PictureInPictureActivity"
4144
android:supportsPictureInPicture="true"
4245
android:launchMode="singleTask"
4346
android:configChanges="screenSize|screenLayout|orientation|smallestScreenSize"/>
47+
-->
4448

45-
</application>
49+
</application>
4650

4751
</manifest>

Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/NavGraph.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.agora.api.example.compose
22

3+
import android.util.Log
34
import androidx.compose.runtime.Composable
45
import androidx.navigation.NavType
56
import androidx.navigation.compose.NavHost
@@ -9,6 +10,7 @@ import androidx.navigation.navArgument
910
import io.agora.api.example.compose.model.Component
1011
import io.agora.api.example.compose.model.Components
1112
import io.agora.api.example.compose.model.Example
13+
import io.agora.api.example.compose.samples.cleanupPictureInPictureState
1214
import io.agora.api.example.compose.ui.example.Example
1315
import io.agora.api.example.compose.ui.home.Home
1416
import io.agora.api.example.compose.ui.settings.Settings
@@ -48,7 +50,15 @@ fun NavGraph() {
4850
val example = component.examples[exampleIndex]
4951
Example(
5052
example = example,
51-
onBackClick = { navController.popBackStack() },
53+
onBackClick = {
54+
Log.d("PiPDebug", "NavGraph: onBackClick called for example: ${example.name}")
55+
// Special handling for PictureInPicture example
56+
if (example.name == R.string.example_pictureinpicture) {
57+
Log.d("PiPDebug", "NavGraph: Cleaning up PictureInPicture state")
58+
cleanupPictureInPictureState()
59+
}
60+
navController.popBackStack()
61+
},
5262
)
5363
}
5464
}

Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/model/Examples.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import io.agora.api.example.compose.samples.MediaPlayer
2020
import io.agora.api.example.compose.samples.MediaRecorder
2121
import io.agora.api.example.compose.samples.OriginAudioData
2222
import io.agora.api.example.compose.samples.OriginVideoData
23-
import io.agora.api.example.compose.samples.PictureInPictureEntrance
23+
import io.agora.api.example.compose.samples.PictureInPicture
2424
import io.agora.api.example.compose.samples.PlayAudioFiles
2525
import io.agora.api.example.compose.samples.PreCallTest
2626
import io.agora.api.example.compose.samples.RTMPStreaming
@@ -54,7 +54,7 @@ val AdvanceExampleList = listOf(
5454
Example(R.string.example_originvideodata) { OriginVideoData() },
5555
Example(R.string.example_customvideosource) { CustomVideoSource() },
5656
Example(R.string.example_customvideorender) { CustomVideoRender() },
57-
Example(R.string.example_pictureinpicture) { PictureInPictureEntrance(it) },
57+
Example(R.string.example_pictureinpicture) { PictureInPicture() },
5858
Example(R.string.example_joinmultichannel) { JoinMultiChannel() },
5959
Example(R.string.example_channelencryption) { ChannelEncryption() },
6060
Example(R.string.example_playaudiofiles) { PlayAudioFiles() },

Android/APIExample-Compose/app/src/main/java/io/agora/api/example/compose/samples/LiveStreaming.kt

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.agora.api.example.compose.samples
22

3+
import android.util.Log
34
import android.widget.Toast
45
import androidx.activity.compose.rememberLauncherForActivityResult
56
import androidx.activity.result.contract.ActivityResultContracts
@@ -57,6 +58,17 @@ import io.agora.rtc2.video.VideoEncoderConfiguration
5758
import io.agora.rtc2.video.VideoEncoderConfiguration.AdvanceOptions
5859
import io.agora.rtc2.video.WatermarkOptions
5960

61+
private const val TAG = "LiveStreaming"
62+
63+
private fun getVideoScenarioName(scenario: Constants.VideoScenario): String {
64+
return when (scenario) {
65+
Constants.VideoScenario.APPLICATION_SCENARIO_GENERAL -> "General"
66+
Constants.VideoScenario.APPLICATION_SCENARIO_MEETING -> "Meeting"
67+
Constants.VideoScenario.APPLICATION_SCENARIO_1V1 -> "1V1"
68+
Constants.VideoScenario.APPLICATION_SCENARIO_LIVESHOW -> "Live Show"
69+
}
70+
}
71+
6072
@Composable
6173
fun LiveStreaming() {
6274
val context = LocalContext.current
@@ -70,6 +82,9 @@ fun LiveStreaming() {
7082
var localStats by remember { mutableStateOf(VideoStatsInfo()) }
7183
var remoteStats by remember { mutableStateOf(VideoStatsInfo()) }
7284
var clientRole by remember { mutableStateOf(Constants.CLIENT_ROLE_AUDIENCE) }
85+
val settingsValues = remember { mutableStateMapOf<String, Any>().apply {
86+
put("videoScenario", Constants.VideoScenario.APPLICATION_SCENARIO_LIVESHOW)
87+
} }
7388

7489
val rtcEngine = remember {
7590
RtcEngine.create(RtcEngineConfig().apply {
@@ -177,6 +192,10 @@ fun LiveStreaming() {
177192
), 100, 15
178193
)
179194
)
195+
// Set default video scenario
196+
val defaultScenario = Constants.VideoScenario.APPLICATION_SCENARIO_LIVESHOW
197+
val ret = setVideoScenario(defaultScenario)
198+
Log.d(TAG, "onItemSelected: setVideoScenario " + getVideoScenarioName(defaultScenario) + " ret=" + ret)
180199
}
181200
}
182201
DisposableEffect(lifecycleOwner) {
@@ -192,6 +211,11 @@ fun LiveStreaming() {
192211
if (allGranted) {
193212
// Permission is granted
194213
Toast.makeText(context, R.string.permission_granted, Toast.LENGTH_LONG).show()
214+
// Set video scenario before joining channel
215+
val scenario = settingsValues["videoScenario"] as? Constants.VideoScenario
216+
?: Constants.VideoScenario.APPLICATION_SCENARIO_LIVESHOW
217+
val ret = rtcEngine.setVideoScenario(scenario)
218+
Log.d(TAG, "onItemSelected: setVideoScenario " + getVideoScenarioName(scenario) + " ret=" + ret)
195219
val mediaOptions = ChannelMediaOptions()
196220
mediaOptions.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING
197221
mediaOptions.clientRoleType = clientRole
@@ -214,6 +238,7 @@ fun LiveStreaming() {
214238
localStats = localStats,
215239
remoteStats = remoteStats,
216240
localLarge = localLarge,
241+
settingsValues = settingsValues,
217242
onSwitch = {
218243
localLarge = !localLarge
219244
},
@@ -248,12 +273,12 @@ private fun LiveStreamingView(
248273
localLarge: Boolean = true,
249274
localStats: VideoStatsInfo = VideoStatsInfo(),
250275
remoteStats: VideoStatsInfo = VideoStatsInfo(),
276+
settingsValues: MutableMap<String, Any> = mutableMapOf(),
251277
onSwitch: () -> Unit = {},
252278
onJoinClick: (String) -> Unit,
253279
onLeaveClick: () -> Unit
254280
) {
255281
var openSettingSheet by rememberSaveable { mutableStateOf(false) }
256-
val settingsValues = remember { mutableStateMapOf<String, Any>() }
257282

258283
Box {
259284
Column {
@@ -349,9 +374,17 @@ private fun LiveStreamingView(
349374
rtcEngine = rtcEngine,
350375
role = clientRole,
351376
remoteUid = remoteUid,
377+
isJoined = isJoined,
352378
values = settingsValues,
353379
onValueChanged = { key, value ->
354380
settingsValues[key] = value
381+
// Update video scenario immediately if not joined
382+
if (key == "videoScenario" && !isJoined) {
383+
val scenario = value as? Constants.VideoScenario
384+
?: Constants.VideoScenario.APPLICATION_SCENARIO_LIVESHOW
385+
val ret = rtcEngine?.setVideoScenario(scenario) ?: -1
386+
Log.d(TAG, "onItemSelected: setVideoScenario " + getVideoScenarioName(scenario) + " ret=" + ret)
387+
}
355388
}
356389
)
357390
}
@@ -387,15 +420,34 @@ private fun LiveStreamingSettingView(
387420
rtcEngine: RtcEngine? = null,
388421
role: Int = Constants.CLIENT_ROLE_AUDIENCE,
389422
remoteUid: Int = 0,
423+
isJoined: Boolean = false,
390424
values: Map<String, Any> = emptyMap(),
391425
onValueChanged: (String, Any) -> Unit = { _, _ -> }
392426
) {
393427
val context = LocalContext.current
428+
val videoScenario = values["videoScenario"] as? Constants.VideoScenario
429+
?: Constants.VideoScenario.APPLICATION_SCENARIO_LIVESHOW
394430

395431
Column(
396432
modifier = modifier,
397433
horizontalAlignment = Alignment.CenterHorizontally
398434
) {
435+
// Video Scenario selection - must be set before joining channel
436+
DropdownMenuRaw(
437+
title = stringResource(id = R.string.video_scenario),
438+
options = listOf(
439+
stringResource(id = R.string.video_scenario_general) to Constants.VideoScenario.APPLICATION_SCENARIO_GENERAL,
440+
stringResource(id = R.string.video_scenario_meeting) to Constants.VideoScenario.APPLICATION_SCENARIO_MEETING,
441+
stringResource(id = R.string.video_scenario_1v1) to Constants.VideoScenario.APPLICATION_SCENARIO_1V1,
442+
stringResource(id = R.string.video_scenario_liveshow) to Constants.VideoScenario.APPLICATION_SCENARIO_LIVESHOW,
443+
),
444+
selectedValue = videoScenario,
445+
enable = !isJoined,
446+
onSelected = { _, option ->
447+
onValueChanged("videoScenario", option.second)
448+
}
449+
)
450+
Divider(modifier = Modifier.padding(horizontal = 16.dp))
399451
if (role == Constants.CLIENT_ROLE_AUDIENCE) {
400452
SwitchRaw(
401453
title = stringResource(id = R.string.open_low_latency_live),

0 commit comments

Comments
 (0)