Skip to content

Commit 7e3978f

Browse files
authored
Merge pull request #48 from AgoraIO-Community/dev/refactor1
Dev/refactor1
2 parents 149a781 + 366386c commit 7e3978f

Some content is hidden

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

45 files changed

+9152
-2002
lines changed

Agora_Unity_WebGL.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@
268268
</Reference>
269269
</ItemGroup>
270270
<ItemGroup>
271+
<Compile Include="Assets\AgoraEngine\Demo\AudioVideoStateControl.cs" />
271272
<Compile Include="Assets\AgoraEngine\Demo\ButtonHandler.cs" />
272273
<Compile Include="Assets\AgoraEngine\Demo\TestHelloUnityVideo.cs" />
273274
<Compile Include="Assets\AgoraEngine\Demo\TestHome.cs" />
@@ -296,9 +297,9 @@
296297
<Compile Include="Assets\AgoraEngine\Utils\TokenClient.cs" />
297298
<Compile Include="Assets\AgoraEngine\Utils\TokenRequestHelper.cs" />
298299
<Compile Include="Assets\API-Example\app-screenshare-sample\AgoraScreenShare.cs" />
300+
<Compile Include="Assets\API-Example\datastream-sample\TestDataStream.cs" />
299301
<Compile Include="Assets\API-Example\desktop-screenshare-sample\WebScreenShare.cs" />
300302
<Compile Include="Assets\API-Example\geo-area-sample\HelloVideoAgora2.cs" />
301-
<Compile Include="Assets\API-Example\multi-channel-sample\AgoraMultiChannel.cs" />
302303
<Compile Include="Assets\API-Example\multi-channel-sample\Scripts\AgoraChannelPanel.cs" />
303304
<Compile Include="Assets\API-Example\multi-channel-sample\Scripts\MultiChannelSceneCtrl.cs" />
304305
<Compile Include="Assets\API-Example\rtmp-streaming-sample\RtmpStreaming.cs" />
@@ -307,6 +308,8 @@
307308
<Compile Include="Assets\API-Example\tools\ToggleStateButton.cs" />
308309
<Compile Include="Assets\API-Example\tools\UIElementDragger.cs" />
309310
<Compile Include="Assets\API-Example\video-encoder-configuration\video_encoder_configuration.cs" />
311+
<Compile Include="Assets\FunctionalTest\JoinMultipleChannel\AgoraMultiChannel.cs" />
312+
<Compile Include="Assets\FunctionalTest\Respawn\TestVideoRespawn.cs" />
310313
</ItemGroup>
311314
<ItemGroup>
312315
<None Include="Assets\AgoraEngine\Plugins\Android\AgoraRtcEngineKit.plugin\AndroidManifest.xml" />

Assets/API-Example/app-screenshare-sample/AgoraScreenShare.cs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using UnityEngine.UI;
55
using agora_utilities;
66

7-
public class AgoraScreenShare : MonoBehaviour
7+
public class AgoraScreenShare : MonoBehaviour
88
{
99

1010
[SerializeField]
@@ -19,27 +19,27 @@ public class AgoraScreenShare : MonoBehaviour
1919
[SerializeField]
2020
Toggle ScreenToggle;
2121

22-
public Text logText;
22+
public Text logText;
2323
private Logger logger;
24-
public IRtcEngine mRtcEngine = null;
25-
private const float Offset = 100;
26-
private Texture2D mTexture;
27-
private Rect mRect;
24+
public IRtcEngine mRtcEngine = null;
25+
private const float Offset = 100;
26+
private Texture2D mTexture;
27+
private Rect mRect;
2828
public RawImage rawImage;
2929
public RawImage textureImage;
30-
public Vector2 cameraSize = new Vector2(640, 480);
31-
public int cameraFPS = 15;
30+
public Vector2 cameraSize = new Vector2(640, 480);
31+
public int cameraFPS = 15;
3232
bool running = false;
3333
int timestamp = 0;
3434
bool _sharingImage = false;
3535

3636
// Use this for initialization
37-
void Start ()
38-
{
37+
void Start()
38+
{
3939
bool appReady = CheckAppId();
4040
if (!appReady) return;
4141

42-
InitEngine();
42+
InitEngine();
4343
InitTexture();
4444

4545
#if !UNITY_WEBGL || UNITY_EDITOR
@@ -86,7 +86,7 @@ public void WebShareScreen()
8686
mRtcEngine.StartScreenCaptureForWeb();
8787
}
8888

89-
89+
9090
// On Native only, after stopping screenshare, you need to choose the
9191
// external source mode again before joining the channel.
9292
// On Web, it is preferred to enable external source while in the channel
@@ -128,8 +128,8 @@ void HandleToggleValueChange(bool isScreenOn)
128128
minBitrate = 1,
129129
orientationMode = ORIENTATION_MODE.ORIENTATION_MODE_ADAPTIVE,
130130
degradationPreference = DEGRADATION_PREFERENCE.MAINTAIN_FRAMERATE,
131-
mirrorMode = VIDEO_MIRROR_MODE_TYPE.VIDEO_MIRROR_MODE_DISABLED
132-
// note: mirrorMode is not effective for WebGL
131+
mirrorMode = VIDEO_MIRROR_MODE_TYPE.VIDEO_MIRROR_MODE_DISABLED
132+
// note: mirrorMode is not effective for WebGL
133133
};
134134
mRtcEngine.SetVideoEncoderConfiguration(config);
135135

@@ -199,18 +199,18 @@ void StopSharing()
199199
}
200200

201201
void InitEngine()
202-
{
202+
{
203203
mRtcEngine = IRtcEngine.GetEngine(APP_ID);
204-
mRtcEngine.SetLogFile("log.txt");
205-
mRtcEngine.SetChannelProfile(CHANNEL_PROFILE.CHANNEL_PROFILE_LIVE_BROADCASTING);
206-
mRtcEngine.SetClientRole(CLIENT_ROLE_TYPE.CLIENT_ROLE_BROADCASTER);
207-
mRtcEngine.EnableAudio();
208-
mRtcEngine.EnableVideo();
209-
mRtcEngine.EnableVideoObserver();
204+
mRtcEngine.SetLogFile("log.txt");
205+
mRtcEngine.SetChannelProfile(CHANNEL_PROFILE.CHANNEL_PROFILE_LIVE_BROADCASTING);
206+
mRtcEngine.SetClientRole(CLIENT_ROLE_TYPE.CLIENT_ROLE_BROADCASTER);
207+
mRtcEngine.EnableAudio();
208+
mRtcEngine.EnableVideo();
209+
mRtcEngine.EnableVideoObserver();
210210

211211
// Web: calling this before joining creates publish error
212212
// as we publish new created canvas source
213-
//mRtcEngine.SetExternalVideoSource(true, false);
213+
//mRtcEngine.SetExternalVideoSource(true, false);
214214

215215
mRtcEngine.OnJoinChannelSuccess += OnJoinChannelSuccessHandler;
216216
mRtcEngine.OnLeaveChannel += OnLeaveChannelHandler;
@@ -219,16 +219,16 @@ void InitEngine()
219219
mRtcEngine.OnConnectionLost += OnConnectionLostHandler;
220220
mRtcEngine.OnUserJoined += OnUserJoinedHandler;
221221
mRtcEngine.OnUserOffline += OnUserOfflineHandler;
222-
}
222+
}
223223

224-
void JoinChannel()
225-
{
224+
void JoinChannel()
225+
{
226226
int ret = mRtcEngine.JoinChannelByKey(TOKEN, CHANNEL_NAME, "", 0);
227227
// int ret = mRtcEngine.JoinChannel(CHANNEL_NAME, "", 0);
228228
Debug.Log(string.Format("JoinChannel ret: ${0}", ret));
229-
}
229+
}
230230

231-
bool CheckAppId()
231+
bool CheckAppId()
232232
{
233233
logger = new Logger(logText);
234234
return logger.DebugAssert(APP_ID.Length > 10, "<color=red>[STOP] Please fill in your appId in Canvas!!!!</color>");
@@ -268,12 +268,12 @@ void OnSDKWarningHandler(int warn, string msg)
268268
{
269269
logger.UpdateLog(string.Format("OnSDKWarning warn: {0}, msg: {1}", warn, msg));
270270
}
271-
271+
272272
void OnSDKErrorHandler(int error, string msg)
273273
{
274274
logger.UpdateLog(string.Format("OnSDKError error: {0}, msg: {1}", error, msg));
275275
}
276-
276+
277277
void OnConnectionLostHandler()
278278
{
279279
logger.UpdateLog(string.Format("OnConnectionLost "));
@@ -283,8 +283,8 @@ void OnApplicationQuit()
283283
{
284284
if (mRtcEngine != null)
285285
{
286-
mRtcEngine.LeaveChannel();
287-
mRtcEngine.DisableVideoObserver();
286+
mRtcEngine.LeaveChannel();
287+
mRtcEngine.DisableVideoObserver();
288288
IRtcEngine.Destroy();
289289
mRtcEngine = null;
290290
}
@@ -309,7 +309,7 @@ private void makeVideoView(uint uid)
309309
{
310310
return; // reuse
311311
}
312-
312+
313313
// create a GameObject and assign to this new user
314314
VideoSurface videoSurface = makeImageSurface(uid.ToString());
315315
if (!ReferenceEquals(videoSurface, null))
@@ -339,7 +339,7 @@ public VideoSurface makeImageSurface(string goName)
339339
GameObject canvas = GameObject.Find("Canvas");
340340
if (canvas != null)
341341
{
342-
go.transform.parent = canvas.transform;
342+
go.transform.SetParent(canvas.transform);
343343
Debug.Log("add video view");
344344
}
345345
else
@@ -353,7 +353,7 @@ public VideoSurface makeImageSurface(string goName)
353353
Debug.Log("position x " + xPos + " y: " + yPos);
354354
go.transform.localPosition = new Vector3(xPos, yPos, 0f);
355355
//go.transform.localPosition = new Vector3(10, 10, 0f);
356-
go.transform.localScale = new Vector3(3 * 1.6666f, 3f, 1f);
356+
go.transform.localScale = new Vector3(1 * 1.33333f, 1f, 1f);
357357

358358
// configure videoSurface
359359
VideoSurface videoSurface = go.AddComponent<VideoSurface>();

Assets/API-Example/datastream-sample.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)