|
@@ -173,19 +173,18 @@ public class AgoraVideoAudioManager : SingletonMono<AgoraVideoAudioManager>
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ VideoEncoderConfiguration config = new VideoEncoderConfiguration();
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
RtcEngine.SetChannelProfile(CHANNEL_PROFILE_TYPE.CHANNEL_PROFILE_COMMUNICATION);
|
|
|
RtcEngine.SetClientRole(CLIENT_ROLE_TYPE.CLIENT_ROLE_BROADCASTER);
|
|
|
|
|
|
SenderOptions s = new SenderOptions();
|
|
|
- s.targetBitrate = 1000;
|
|
|
RtcEngine.SetExternalVideoSource(true, true, EXTERNAL_VIDEO_SOURCE_TYPE.VIDEO_FRAME,s);
|
|
|
- RtcEngine.SetRemoteDefaultVideoStreamType(VIDEO_STREAM_TYPE.VIDEO_STREAM_LOW);
|
|
|
+
|
|
|
if (DeviceType.type == "DreamGlass")
|
|
|
RtcEngine.SetAudioProfile(0, AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_GAME_STREAMING);
|
|
|
|
|
@@ -199,7 +198,6 @@ public class AgoraVideoAudioManager : SingletonMono<AgoraVideoAudioManager>
|
|
|
EnableLoacalAudio(CustomInfo.isSendAudio);
|
|
|
EnableLocalVideo(CustomInfo.isSendVideo);
|
|
|
isSendVideo = CustomInfo.isSendVideo;
|
|
|
- StartCoroutine(RenderTexturesScreenCapture());
|
|
|
}
|
|
|
|
|
|
public void OpenAgoraAudio()
|
|
@@ -224,7 +222,7 @@ public class AgoraVideoAudioManager : SingletonMono<AgoraVideoAudioManager>
|
|
|
screenShot = new Texture2D(CustomInfo.mWidth, CustomInfo.mHight, TextureFormat.RGBA32, false);
|
|
|
StartCoroutine(GetRenederFPS());
|
|
|
}
|
|
|
- while (true)
|
|
|
+ while (screenShot!=null)
|
|
|
{
|
|
|
|
|
|
|
|
@@ -258,26 +256,30 @@ public class AgoraVideoAudioManager : SingletonMono<AgoraVideoAudioManager>
|
|
|
byte[] bts;
|
|
|
IEnumerator GetRenederFPS()
|
|
|
{
|
|
|
- while (true)
|
|
|
+ while (screenShot != null)
|
|
|
{
|
|
|
- var req = AsyncGPUReadback.Request(RemoteRtc.Instance.cam2.activeTexture);
|
|
|
+ var req = AsyncGPUReadback.Request(RemoteRtc.Instance.cam2.targetTexture);
|
|
|
yield return new WaitUntil(() => req.done);
|
|
|
- if (!req.hasError)
|
|
|
+ if(screenShot!=null)
|
|
|
{
|
|
|
|
|
|
- if (bts == null)
|
|
|
+ if (!req.hasError)
|
|
|
{
|
|
|
- bts = new byte[req.layerDataSize];
|
|
|
+
|
|
|
+ if (bts == null)
|
|
|
+ {
|
|
|
+ bts = new byte[req.layerDataSize];
|
|
|
+ }
|
|
|
+ req.GetData<byte>().CopyTo(bts);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Debug.LogError("Error AsyncGPUReadbackRequest.hasError");
|
|
|
}
|
|
|
- req.GetData<byte>().CopyTo(bts);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Debug.LogError("Error AsyncGPUReadbackRequest.hasError");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -292,6 +294,7 @@ public class AgoraVideoAudioManager : SingletonMono<AgoraVideoAudioManager>
|
|
|
|
|
|
public void LeaveChannel()
|
|
|
{
|
|
|
+ cameraStop();
|
|
|
Debug.Log("LeaveChannel ");
|
|
|
int msg = RtcEngine.LeaveChannel();
|
|
|
switch (msg)
|
|
@@ -342,7 +345,12 @@ public class AgoraVideoAudioManager : SingletonMono<AgoraVideoAudioManager>
|
|
|
Debug.Log(" AddPeeridUid " + peerid + " " + uid);
|
|
|
|
|
|
if (dicPeeridAndUid.ContainsKey(peerid))
|
|
|
+ {
|
|
|
+ dicPeeridAndUid[peerid] = uid;
|
|
|
+
|
|
|
return;
|
|
|
+
|
|
|
+ }
|
|
|
dicPeeridAndUid.Add(peerid, uid);
|
|
|
}
|
|
|
|
|
@@ -352,7 +360,11 @@ public class AgoraVideoAudioManager : SingletonMono<AgoraVideoAudioManager>
|
|
|
Debug.Log(" AddPeeridUid " + peerid + " " + uid);
|
|
|
|
|
|
if (dicPeeridAndUid.ContainsKey(peerid))
|
|
|
+ {
|
|
|
+
|
|
|
+ dicPeeridAndUid[peerid] = uid;
|
|
|
return;
|
|
|
+ }
|
|
|
dicPeeridAndUid.Add(peerid, uid);
|
|
|
}
|
|
|
|
|
@@ -368,7 +380,10 @@ public class AgoraVideoAudioManager : SingletonMono<AgoraVideoAudioManager>
|
|
|
for (int i = 0; i < listCustomPeer.Count; i++)
|
|
|
{
|
|
|
if (listCustomPeer[i].peerId == peerid)
|
|
|
+ {
|
|
|
listCustomPeer.RemoveAt(i);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -461,9 +476,39 @@ public class AgoraVideoAudioManager : SingletonMono<AgoraVideoAudioManager>
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+ public void cameraStart()
|
|
|
+ {
|
|
|
+ if (rc == null)
|
|
|
+ {
|
|
|
+ if (RemoteRtc.Instance.cam2.targetTexture != null)
|
|
|
+ RemoteRtc.Instance.cam2.targetTexture.Release();
|
|
|
+ RemoteRtc.Instance.cam2.targetTexture = new RenderTexture(CustomInfo.mWidth, CustomInfo.mHight, 1);
|
|
|
+ StartCoroutine(RenderTexturesScreenCapture());
|
|
|
+ XRRGBCamera.Instance.playCamera(CustomInfo.mWidth, CustomInfo.mHight);
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void cameraStop()
|
|
|
+ {
|
|
|
+ XRRGBCamera.Instance.stopCamera();
|
|
|
+ if (screenShot != null)
|
|
|
+ Destroy(screenShot);
|
|
|
+ screenShot = null;
|
|
|
+ rc = null;
|
|
|
+ bts = null;
|
|
|
+ }
|
|
|
+ Coroutine rc;
|
|
|
public void EnableLocalVideo(bool isVideo)
|
|
|
{
|
|
|
+ if(isVideo)
|
|
|
+ {
|
|
|
+ cameraStart();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cameraStop();
|
|
|
+ }
|
|
|
+
|
|
|
int msg = RtcEngine.MuteLocalVideoStream(!isVideo);
|
|
|
|
|
|
|
|
@@ -479,10 +524,13 @@ public class AgoraVideoAudioManager : SingletonMono<AgoraVideoAudioManager>
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- public void MuteRemoteAudioStream(string uid, bool isAudio)
|
|
|
+ public void MuteRemoteAudioStream(string peerid, bool isAudio)
|
|
|
{
|
|
|
-
|
|
|
- int msg = RtcEngine.MuteRemoteAudioStream(StringToUint(uid) , !isAudio);
|
|
|
+
|
|
|
+ Debug.Log(peerid);
|
|
|
+ if (!dicPeeridAndUid.ContainsKey(peerid))
|
|
|
+ return;
|
|
|
+ int msg = RtcEngine.MuteRemoteAudioStream(dicPeeridAndUid[peerid], !isAudio);
|
|
|
|
|
|
switch (msg)
|
|
|
{
|
|
@@ -615,7 +663,26 @@ public class AgoraVideoAudioManager : SingletonMono<AgoraVideoAudioManager>
|
|
|
Debug.Log(listCustomPeer[i].peerId);
|
|
|
if (dicPeeridAndUid[listCustomPeer[i].peerId] == uid)
|
|
|
{
|
|
|
- Debug.Log("RemoteAudioStateChanged " + 2);
|
|
|
+ switch (state)
|
|
|
+ {
|
|
|
+ case REMOTE_AUDIO_STATE.REMOTE_AUDIO_STATE_STOPPED:
|
|
|
+
|
|
|
+ break;
|
|
|
+ case REMOTE_AUDIO_STATE.REMOTE_AUDIO_STATE_STARTING:
|
|
|
+ listCustomPeer[i].isAudio = true;
|
|
|
+ break;
|
|
|
+ case REMOTE_AUDIO_STATE.REMOTE_AUDIO_STATE_DECODING:
|
|
|
+ listCustomPeer[i].isCloseAudio = false;
|
|
|
+ break;
|
|
|
+ case REMOTE_AUDIO_STATE.REMOTE_AUDIO_STATE_FROZEN:
|
|
|
+ break;
|
|
|
+ case REMOTE_AUDIO_STATE.REMOTE_AUDIO_STATE_FAILED:
|
|
|
+
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ Debug.Log("RemoteAudioStateChanged " + reason);
|
|
|
switch (reason)
|
|
|
{
|
|
|
case REMOTE_AUDIO_STATE_REASON.REMOTE_AUDIO_REASON_INTERNAL:
|