Skip to content

Commit eea4112

Browse files
author
xianing
committed
Merge branch 'staging' of ssh://git.agoralab.co/aduc/api-examples into staging
2 parents e77241d + a53d74f commit eea4112

File tree

34 files changed

+9451
-3881
lines changed

34 files changed

+9451
-3881
lines changed

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/SuperResolution.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class SuperResolution extends BaseFragment implements View.OnClickListene
5050
private static final String TAG = SuperResolution.class.getSimpleName();
5151

5252
private FrameLayout fl_local, fl_remote;
53-
private Button join, btnSuperResolution;
53+
private Button join, btnSuperResolution, switchCamera;
5454
private EditText et_channel;
5555
private RtcEngine engine;
5656
private int myUid;
@@ -73,9 +73,12 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
7373
join = view.findViewById(R.id.btn_join);
7474
btnSuperResolution = view.findViewById(R.id.btn_super_resolution);
7575
btnSuperResolution.setEnabled(false);
76+
switchCamera = view.findViewById(R.id.btn_switch);
77+
switchCamera.setEnabled(false);
7678
et_channel = view.findViewById(R.id.et_channel);
7779
view.findViewById(R.id.btn_join).setOnClickListener(this);
7880
view.findViewById(R.id.btn_super_resolution).setOnClickListener(this);
81+
view.findViewById(R.id.btn_switch).setOnClickListener(this);
7982
fl_local = view.findViewById(R.id.fl_local);
8083
fl_remote = view.findViewById(R.id.fl_remote);
8184
}
@@ -172,7 +175,13 @@ public void onClick(View v)
172175
}
173176
}
174177
else if(v.getId() == R.id.btn_super_resolution){
175-
engine.enableRemoteSuperResolution(remoteUid, !enableSuperResolution);
178+
int ret = engine.enableRemoteSuperResolution(remoteUid, !enableSuperResolution);
179+
if(ret!=0){
180+
Log.w(TAG, String.format("onWarning code %d ", ret));
181+
}
182+
}
183+
else if(v.getId() == R.id.btn_switch){
184+
engine.switchCamera();
176185
}
177186
}
178187

@@ -259,6 +268,7 @@ private void joinChannel(String channelId)
259268
public void onWarning(int warn)
260269
{
261270
Log.w(TAG, String.format("onWarning code %d message %s", warn, RtcEngine.getErrorDescription(warn)));
271+
showAlert(String.format("onWarning code %d message %s", warn, RtcEngine.getErrorDescription(warn)));
262272
}
263273

264274
/**Reports an error during SDK runtime.
@@ -421,6 +431,7 @@ public void onUserJoined(int uid, int elapsed)
421431
engine.setupRemoteVideo(new VideoCanvas(surfaceView, RENDER_MODE_HIDDEN, uid));
422432
remoteUid = uid;
423433
btnSuperResolution.setEnabled(true);
434+
switchCamera.setEnabled(true);
424435
});
425436
}
426437

@@ -447,6 +458,7 @@ public void run() {
447458
remove the SurfaceView from its parent*/
448459
engine.setupRemoteVideo(new VideoCanvas(null, RENDER_MODE_HIDDEN, uid));
449460
btnSuperResolution.setEnabled(false);
461+
switchCamera.setEnabled(false);
450462
}
451463
});
452464
}

Android/APIExample/app/src/main/res/layout/fragment_super_resolution.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,22 @@
4545
android:enabled="false"/>
4646
</LinearLayout>
4747

48+
49+
<LinearLayout
50+
android:layout_width="wrap_content"
51+
android:layout_height="40dp"
52+
android:layout_marginBottom="102dp"
53+
android:layout_marginEnd="16dp"
54+
android:layout_alignParentEnd="true"
55+
android:layout_alignParentBottom="true">
56+
<androidx.appcompat.widget.AppCompatButton
57+
android:id="@+id/btn_switch"
58+
android:layout_width="wrap_content"
59+
android:layout_height="wrap_content"
60+
android:text="@string/switch_camera"
61+
android:enabled="false"/>
62+
</LinearLayout>
63+
4864
<LinearLayout
4965
android:id="@+id/ll_join"
5066
android:layout_width="match_parent"

Android/APIExample/app/src/main/res/values-zh/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,5 @@
181181
<string name="skin_protect">肤色保护</string>
182182
<string name="item_ScreenShare">屏幕共享</string>
183183
<string name="virtual_background">虚拟背景</string>
184+
<string name="switch_camera">摄像头切换</string>
184185
</resources>

Android/APIExample/app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,5 @@
185185
<string name="skin_protect">Skin Protect</string>
186186
<string name="item_ScreenShare">Screen Share</string>
187187
<string name="virtual_background">Virtual Background</string>
188+
<string name="switch_camera">switch camera</string>
188189
</resources>

Android/APIExample/lib-player-helper/src/main/cpp/include/AgoraBase.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ enum ERROR_CODE_TYPE {
398398
/** 117: The data stream transmission timed out.
399399
*/
400400
ERR_STREAM_MESSAGE_TIMEOUT = 117,
401-
/** 119: Switching roles fail. Please try to rejoin the channel.
401+
/** **DEPRECATED** 119: Deprecated as of v3.6.1. Use CLIENT_ROLE_CHANGE_FAILED_REASON in the \ref agora::rtc::IRtcEngineEventHandler::onClientRoleChangeFailed "onClientRoleChangeFailed" callback instead.
402+
* Switching roles fail. Please try to rejoin the channel.
402403
*/
403404
ERR_SET_CLIENT_ROLE_NOT_AUTHORIZED = 119,
404405
/** 120: Decryption fails. The user may have used a different encryption password to join the channel. Check your settings or try rejoining the channel.

Android/APIExample/lib-player-helper/src/main/cpp/include/IAgoraMediaEngine.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,12 @@ struct ExternalVideoFrame {
664664
/** 16: The video pixel format is I422.
665665
*/
666666
VIDEO_PIXEL_I422 = 16,
667+
/** 17: The video pixel format is GL_TEXTURE_2D.
668+
*/
669+
VIDEO_TEXTURE_2D = 17,
670+
/** 18: The video pixel format is GL_TEXTURE_OES.
671+
*/
672+
VIDEO_TEXTURE_OES = 18,
667673
};
668674

669675
/** The buffer type. See #VIDEO_BUFFER_TYPE

Android/APIExample/lib-player-helper/src/main/cpp/include/IAgoraRtcChannel.h

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ class IChannelEventHandler {
8080
}
8181
/** Occurs when the user role switches in the interactive live streaming. For example, from a host to an audience or vice versa.
8282
83-
This callback notifies the application of a user role switch when the application calls the \ref IChannel::setClientRole "setClientRole" method.
83+
This callback notifies the application of a user role switch when the application calls the \ref IChannel::setClientRole "setClientRole" method, and successfully changed role.
8484
85-
The SDK triggers this callback when the local user switches the user role by calling the \ref IChannel::setClientRole "setClientRole" method after joining the channel.
85+
The SDK triggers this callback when the local user switches the user role by calling the \ref IChannel::setClientRole "setClientRole" method after joining the channel, and successfully changed role.
8686
8787
@param rtcChannel IChannel
8888
@param oldRole Role that the user switches from: #CLIENT_ROLE_TYPE.
@@ -93,6 +93,21 @@ class IChannelEventHandler {
9393
(void)oldRole;
9494
(void)newRole;
9595
}
96+
97+
/** Occurs when the user role switches in the interactive live streaming. For example, from a host to an audience or vice versa.
98+
99+
This callback notifies the application of a user role switch when the application calls the \ref IChannel::setClientRole "setClientRole" method, and failed to change role.
100+
101+
The SDK triggers this callback when the local user switches the user role by calling the \ref IChannel::setClientRole "setClientRole" method after joining the channel, and failed to change role.
102+
@param reason The reason of changing client role failed. See #CLIENT_ROLE_CHANGE_FAILED_REASON.
103+
@param currentRole Current Role that the user holds: #CLIENT_ROLE_TYPE.
104+
*/
105+
virtual void onClientRoleChangeFailed(IChannel* rtcChannel, CLIENT_ROLE_CHANGE_FAILED_REASON reason, CLIENT_ROLE_TYPE currentRole) {
106+
(void)rtcChannel;
107+
(void)reason;
108+
(void)currentRole;
109+
}
110+
96111
/** Occurs when a remote user (`COMMUNICATION`)/ host (`LIVE_BROADCASTING`) joins the channel.
97112
98113
- `COMMUNICATION` profile: This callback notifies the application that another user joins the channel. If other users are already in the channel, the SDK also reports to the application on the existing users.
@@ -569,6 +584,21 @@ class IChannelEventHandler {
569584
(void)state;
570585
(void)reason;
571586
}
587+
588+
/** Occurs when join success after calling \ref IRtcEngine::setLocalAccessPoint "setLocalAccessPoint" or \ref IRtcEngine::setCloudProxy "setCloudProxy"
589+
@param rtcChannel IChannel
590+
@param uid User ID of the user joining the channel.
591+
@param proxyType type of proxy agora sdk connected, proxyType will be NONE_PROXY_TYPE if not connected to proxy(fallback).
592+
@param localProxyIp local proxy ip list. if not join local proxy, it will be "".
593+
@param elapsed Time elapsed (ms) from the user calling the \ref IRtcEngine::joinChannel "joinChannel" method until the SDK triggers this callback.
594+
*/
595+
virtual void onProxyConnected(IChannel* rtcChannel, uid_t uid, PROXY_TYPE proxyType, const char* localProxyIp, int elapsed) {
596+
(void)rtcChannel;
597+
(void)uid;
598+
(void)proxyType;
599+
(void)localProxyIp;
600+
(void)elapsed;
601+
}
572602
};
573603

574604
/** The IChannel class. */
@@ -887,7 +917,7 @@ class IChannel {
887917
* call this method to switch the user role after joining a channel, the SDK automatically does the following:
888918
* - Calls \ref IChannel::muteLocalAudioStream "muteLocalAudioStream" and \ref IChannel::muteLocalVideoStream "muteLocalVideoStream" to
889919
* change the publishing state.
890-
* - Triggers \ref IChannelEventHandler::onClientRoleChanged "onClientRoleChanged" on the local client.
920+
* - Triggers \ref IChannelEventHandler::onClientRoleChanged "onClientRoleChanged" or \ref IChannelEventHandler::onClientRoleChangeFailed "onClientRoleChangeFailed" on the local client in 5s.
891921
* - Triggers \ref IChannelEventHandler::onUserJoined "onUserJoined" or \ref IChannelEventHandler::onUserOffline "onUserOffline" (BECOME_AUDIENCE)
892922
* on the remote client.
893923
*
@@ -920,7 +950,7 @@ class IChannel {
920950
* call this method to switch the user role after joining a channel, the SDK automatically does the following:
921951
* - Calls \ref IChannel::muteLocalAudioStream "muteLocalAudioStream" and \ref IChannel::muteLocalVideoStream "muteLocalVideoStream" to
922952
* change the publishing state.
923-
* - Triggers \ref IChannelEventHandler::onClientRoleChanged "onClientRoleChanged" on the local client.
953+
* - Triggers \ref IChannelEventHandler::onClientRoleChanged "onClientRoleChanged" or \ref IChannelEventHandler::onClientRoleChangeFailed "onClientRoleChangeFailed" on the local client in 5s.
924954
* - Triggers \ref IChannelEventHandler::onUserJoined "onUserJoined" or \ref IChannelEventHandler::onUserOffline "onUserOffline" (BECOME_AUDIENCE)
925955
* on the remote client.
926956
*
@@ -1237,6 +1267,21 @@ class IChannel {
12371267
- < 0: Failure.
12381268
*/
12391269
virtual int setRemoteVideoStreamType(uid_t userId, REMOTE_VIDEO_STREAM_TYPE streamType) = 0;
1270+
/** Turn WIFI acceleration on or off.
1271+
1272+
@note
1273+
- This method is called before and after joining a channel.
1274+
- Users check the WIFI router app for information about acceleration. Therefore, if this interface is invoked, the caller accepts that the caller's name will be displayed to the user in the WIFI router application on behalf of the caller.
1275+
1276+
@param enabled
1277+
- true:Turn WIFI acceleration on.
1278+
- false:Turn WIFI acceleration off.
1279+
1280+
@return
1281+
- 0: Success.
1282+
- < 0: Failure.
1283+
*/
1284+
virtual int enableWirelessAccelerate(bool enabled) = 0;
12401285
/** Sets the default stream type of remote videos.
12411286
12421287
Under limited network conditions, if the publisher has not disabled the dual-stream mode using

0 commit comments

Comments
 (0)