Skip to content

Commit 9ec9c72

Browse files
authored
fix: use pip from iris to fix renderer issue (#2357) (#2358)
1 parent a4426d0 commit 9ec9c72

File tree

13 files changed

+232
-640
lines changed

13 files changed

+232
-640
lines changed

android/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,13 @@ dependencies {
5858
api fileTree(dir: "libs", include: ["*.jar"])
5959
} else {
6060
// iris dependencies start
61-
api 'io.agora.rtc:iris-rtc:4.5.2-build.1'
61+
api 'io.agora.rtc:iris-rtc:4.5.2.140-build.4'
6262
// iris dependencies end
6363

6464
// native dependencies start
6565
api 'io.agora.rtc:full-sdk:4.5.2'
6666
api 'io.agora.rtc:full-screen-sharing:4.5.2'
6767
// native dependencies end
68-
69-
api 'io.agora.rtc:pip:0.0.3'
7068
}
7169
}
7270

android/src/main/java/io/agora/agora_rtc_ng/AgoraPIPFlutterActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
import java.lang.ref.WeakReference;
1111

12-
import io.agora.pip.AgoraPIPActivityProxy;
13-
import io.agora.pip.AgoraPIPActivityListener;
12+
import io.agora.iris.pip.AgoraPIPActivityProxy;
13+
import io.agora.iris.pip.AgoraPIPActivityListener;
1414

1515
public class AgoraPIPFlutterActivity extends FlutterActivity implements AgoraPIPActivityProxy {
1616
private WeakReference<AgoraPIPActivityListener> mListener;

android/src/main/java/io/agora/agora_rtc_ng/AgoraPIPFlutterFragmentActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
import java.lang.ref.WeakReference;
1111

12-
import io.agora.pip.AgoraPIPActivityProxy;
13-
import io.agora.pip.AgoraPIPActivityListener;
12+
import io.agora.iris.pip.AgoraPIPActivityProxy;
13+
import io.agora.iris.pip.AgoraPIPActivityListener;
1414

1515
public class AgoraPIPFlutterFragmentActivity extends FlutterFragmentActivity implements AgoraPIPActivityProxy {
1616
private WeakReference<AgoraPIPActivityListener> mListener;

android/src/main/java/io/agora/agora_rtc_ng/AgoraRtcNgPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import androidx.annotation.NonNull;
1010
import androidx.annotation.Nullable;
1111

12-
import io.agora.pip.AgoraPIPActivityProxy;
13-
import io.agora.pip.AgoraPIPController;
12+
import io.agora.iris.pip.AgoraPIPActivityProxy;
13+
import io.agora.iris.pip.AgoraPIPController;
1414
import io.flutter.embedding.engine.plugins.FlutterPlugin;
1515
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
1616
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;

docs/integration/Picture-in-Picture.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,6 @@ The Picture-in-Picture (PiP) feature allows you to display video content in a sm
111111
// ... configuration
112112
));
113113
114-
// iOS-specific render type configuration
115-
if (Platform.isIOS) {
116-
// According to [Adopting Picture in Picture in a Custom Player](https://developer.apple.com/documentation/avkit/adopting_picture_in_picture_in_a_custom_player),
117-
// the PiP window only supports `AVPlayerLayer` or `AVSampleBufferDisplayLayer` for rendering video content.
118-
// Therefore, we need to change the internal render type for iOS to use a compatible layer type.
119-
await _engine.setParameters("{\"che.video.render.mode\":22}");
120-
}
121-
122114
// Create PiP controller
123115
_pipController = _engine.createPipController();
124116
```

example/lib/examples/advanced/picture_in_picture/picture_in_picture.dart

Lines changed: 65 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class _State extends State<PictureInPicture> with WidgetsBindingObserver {
3737

3838
double _pipContentRow = 1;
3939
double _pipContentCol = 0;
40+
ClientRoleType _clientRoleType = ClientRoleType.clientRoleBroadcaster;
4041

4142
final Map<int, RtcConnection> _remoteUsers = {};
4243

@@ -280,18 +281,24 @@ class _State extends State<PictureInPicture> with WidgetsBindingObserver {
280281
// - The view property in VideoCanvas will be replaced by the SDK-managed native view.
281282
// - You can customize the rendering of each stream using properties like renderMode and mirrorMode.
282283
videoStreams: [
283-
AgoraPipVideoStream(
284-
connection: RtcConnection(
285-
channelId: _channelIdController.text,
286-
localUid: config.uid,
287-
),
288-
canvas: const VideoCanvas(
289-
uid: 0,
290-
sourceType: VideoSourceType.videoSourceCamera,
291-
setupMode: VideoViewSetupMode.videoViewSetupAdd,
292-
renderMode: RenderModeType.renderModeHidden,
284+
// Only add local video stream if client role is broadcaster
285+
if (_clientRoleType == ClientRoleType.clientRoleBroadcaster)
286+
AgoraPipVideoStream(
287+
connection: RtcConnection(
288+
channelId: _channelIdController.text,
289+
localUid: config.uid,
290+
),
291+
canvas: const VideoCanvas(
292+
uid: 0,
293+
sourceType: VideoSourceType.videoSourceCamera,
294+
setupMode: VideoViewSetupMode.videoViewSetupAdd,
295+
renderMode: RenderModeType.renderModeHidden,
296+
// you should determine the mirror mode based on your use case, like if you are using the front camera,
297+
// you should set the mirror mode to enabled otherwise disabled to get better user experience.
298+
mirrorMode: VideoMirrorModeType.videoMirrorModeEnabled,
299+
),
293300
),
294-
),
301+
// Add all remote video streams
295302
..._remoteUsers.entries.map((entry) => AgoraPipVideoStream(
296303
connection: entry.value,
297304
canvas: VideoCanvas(
@@ -337,11 +344,6 @@ class _State extends State<PictureInPicture> with WidgetsBindingObserver {
337344
appId: config.appId,
338345
));
339346

340-
if (Platform.isIOS) {
341-
// to render video in pip window with sdk, must call this to set the render type
342-
await _engine.setParameters("{\"che.video.render.mode\":22}");
343-
}
344-
345347
_rtcEngineEventHandler = RtcEngineEventHandler(
346348
onError: (ErrorCodeType err, String msg) {
347349
logSink.log('[onError] err: $err, msg: $msg');
@@ -427,8 +429,8 @@ class _State extends State<PictureInPicture> with WidgetsBindingObserver {
427429
token: config.token,
428430
channelId: _channelIdController.text,
429431
uid: config.uid,
430-
options: const ChannelMediaOptions(
431-
clientRoleType: ClientRoleType.clientRoleBroadcaster,
432+
options: ChannelMediaOptions(
433+
clientRoleType: _clientRoleType,
432434
),
433435
);
434436
}
@@ -601,7 +603,48 @@ class _State extends State<PictureInPicture> with WidgetsBindingObserver {
601603
),
602604
],
603605
),
604-
// Second row: Content size and layout
606+
// Second row: Client Role Type
607+
const SizedBox(height: 4),
608+
Row(
609+
children: [
610+
const Text(
611+
'Client Role: ',
612+
style: TextStyle(color: Colors.white),
613+
),
614+
Expanded(
615+
child: Container(
616+
padding: const EdgeInsets.symmetric(horizontal: 8),
617+
decoration: BoxDecoration(
618+
color: Colors.white,
619+
borderRadius: BorderRadius.circular(4),
620+
),
621+
child: DropdownButton<ClientRoleType>(
622+
value: _clientRoleType,
623+
isExpanded: true,
624+
underline: Container(),
625+
items: [
626+
ClientRoleType.clientRoleBroadcaster,
627+
ClientRoleType.clientRoleAudience,
628+
].map((role) => DropdownMenuItem(
629+
value: role,
630+
child: Text(
631+
role.toString().split('.')[1],
632+
style: const TextStyle(fontSize: 12),
633+
),
634+
)).toList(),
635+
onChanged: _isJoined ? null : (value) {
636+
if (value != null) {
637+
setState(() {
638+
_clientRoleType = value;
639+
});
640+
}
641+
},
642+
),
643+
),
644+
),
645+
],
646+
),
647+
// Third row: Content size and layout
605648
const SizedBox(height: 4),
606649
Row(
607650
children: [
@@ -641,7 +684,7 @@ class _State extends State<PictureInPicture> with WidgetsBindingObserver {
641684
]
642685
],
643686
),
644-
// Third row: Row and Column
687+
// Fourth row: Row and Column (iOS only)
645688
if (Platform.isIOS) ...[
646689
const SizedBox(width: 4),
647690
Row(
@@ -685,8 +728,8 @@ class _State extends State<PictureInPicture> with WidgetsBindingObserver {
685728
],
686729
),
687730
],
688-
// Fourth row: Setup PIP + Start PIP + Stop PIP + Dispose PIP
689-
const SizedBox(width: 4),
731+
// Fifth row: Setup PIP + Start PIP + Stop PIP + Dispose PIP
732+
const SizedBox(height: 4),
690733
Row(
691734
children: [
692735
ElevatedButton(

ios/agora_rtc_engine.podspec

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ Pod::Spec.new do |s|
2424
s.vendored_frameworks = 'libs/*.xcframework'
2525
else
2626
# iris dependencies start
27-
s.dependency 'AgoraIrisRTC_iOS', '4.5.2.140-build.2'
27+
s.dependency 'AgoraIrisRTC_iOS', '4.5.2.140-build.4'
2828
# iris dependencies end
2929

3030
# native dependencies start
3131
s.dependency 'AgoraRtcEngine_Special_iOS', '4.5.2.140'
3232
# native dependencies end
33-
34-
s.dependency 'AgoraPIP_iOS', '0.0.2-rc.2'
3533
end
3634

3735
s.platform = :ios, '9.0'

0 commit comments

Comments
 (0)