Skip to content

Commit 10094fb

Browse files
author
ShanguUncle
committed
fix aduio play and record error
1 parent e994b25 commit 10094fb

7 files changed

Lines changed: 40 additions & 98 deletions

File tree

Assets/UnityChatDemo(Can be deleted)/Scenes/UnityChatDemo_SendMessage.unity

Lines changed: 8 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ Camera:
374374
m_Depth: 0
375375
m_CullingMask:
376376
serializedVersion: 2
377-
m_Bits: 4294966271
377+
m_Bits: 4294967295
378378
m_RenderingPath: -1
379379
m_TargetTexture: {fileID: 0}
380380
m_TargetDisplay: 0
@@ -3808,74 +3808,6 @@ CanvasRenderer:
38083808
m_PrefabParentObject: {fileID: 0}
38093809
m_PrefabInternal: {fileID: 0}
38103810
m_GameObject: {fileID: 523341788}
3811-
--- !u!1 &535887093
3812-
GameObject:
3813-
m_ObjectHideFlags: 0
3814-
m_PrefabParentObject: {fileID: 1565746348981914, guid: 48d512021e38e2245856d414c70e274e,
3815-
type: 2}
3816-
m_PrefabInternal: {fileID: 0}
3817-
serializedVersion: 5
3818-
m_Component:
3819-
- component: {fileID: 535887095}
3820-
- component: {fileID: 535887094}
3821-
m_Layer: 10
3822-
m_Name: CaptureCamera
3823-
m_TagString: Untagged
3824-
m_Icon: {fileID: 0}
3825-
m_NavMeshLayer: 0
3826-
m_StaticEditorFlags: 0
3827-
m_IsActive: 1
3828-
--- !u!20 &535887094
3829-
Camera:
3830-
m_ObjectHideFlags: 0
3831-
m_PrefabParentObject: {fileID: 20761546725244870, guid: 48d512021e38e2245856d414c70e274e,
3832-
type: 2}
3833-
m_PrefabInternal: {fileID: 0}
3834-
m_GameObject: {fileID: 535887093}
3835-
m_Enabled: 0
3836-
serializedVersion: 2
3837-
m_ClearFlags: 2
3838-
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
3839-
m_NormalizedViewPortRect:
3840-
serializedVersion: 2
3841-
x: 0
3842-
y: 0
3843-
width: 1
3844-
height: 1
3845-
near clip plane: 0.01
3846-
far clip plane: 100
3847-
field of view: 60
3848-
orthographic: 0
3849-
orthographic size: 5
3850-
m_Depth: 0
3851-
m_CullingMask:
3852-
serializedVersion: 2
3853-
m_Bits: 1280
3854-
m_RenderingPath: -1
3855-
m_TargetTexture: {fileID: 0}
3856-
m_TargetDisplay: 0
3857-
m_TargetEye: 3
3858-
m_HDR: 0
3859-
m_AllowMSAA: 0
3860-
m_AllowDynamicResolution: 0
3861-
m_ForceIntoRT: 0
3862-
m_OcclusionCulling: 1
3863-
m_StereoConvergence: 0
3864-
m_StereoSeparation: 0
3865-
--- !u!4 &535887095
3866-
Transform:
3867-
m_ObjectHideFlags: 0
3868-
m_PrefabParentObject: {fileID: 4148342547608750, guid: 48d512021e38e2245856d414c70e274e,
3869-
type: 2}
3870-
m_PrefabInternal: {fileID: 0}
3871-
m_GameObject: {fileID: 535887093}
3872-
m_LocalRotation: {x: 0.10342088, y: -0, z: -0, w: 0.9946377}
3873-
m_LocalPosition: {x: -0.409, y: 1.01, z: -2.94}
3874-
m_LocalScale: {x: 1, y: 1, z: 1}
3875-
m_Children: []
3876-
m_Father: {fileID: 1468329509}
3877-
m_RootOrder: 1
3878-
m_LocalEulerAnglesHint: {x: 11.872001, y: 0, z: 0}
38793811
--- !u!1 &579700496
38803812
GameObject:
38813813
m_ObjectHideFlags: 0
@@ -7091,7 +7023,7 @@ RectTransform:
70917023
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
70927024
m_AnchorMin: {x: 0, y: 1}
70937025
m_AnchorMax: {x: 1, y: 1}
7094-
m_AnchoredPosition: {x: 0, y: 0.000057185243}
7026+
m_AnchoredPosition: {x: 0, y: 0.00006645337}
70957027
m_SizeDelta: {x: 0, y: 439.7}
70967028
m_Pivot: {x: 0, y: 1}
70977029
--- !u!114 &1080824776
@@ -9738,7 +9670,6 @@ Transform:
97389670
m_LocalScale: {x: 1, y: 1, z: 1}
97399671
m_Children:
97409672
- {fileID: 1869994738}
9741-
- {fileID: 535887095}
97429673
- {fileID: 2102343039}
97439674
m_Father: {fileID: 0}
97449675
m_RootOrder: 8
@@ -12300,14 +12231,15 @@ MonoBehaviour:
1230012231
m_Name:
1230112232
m_EditorClassIdentifier:
1230212233
AudioVolume: 1
12234+
MicVolumeScale: 1
1230312235
VideoType: 0
1230412236
VideoResolution: 1
1230512237
VideoQuality: 2
1230612238
Framerate: 15
1230712239
EchoCancellation: 0
1230812240
EnableDetection: 0
1230912241
EnableSync: 0
12310-
CaptureCamera: {fileID: 535887094}
12242+
CaptureCamera: {fileID: 26561707}
1231112243
ChatPeerRawImage:
1231212244
- {fileID: 1690060813}
1231312245
SelfRawImage: {fileID: 1043811784}
@@ -13961,13 +13893,13 @@ Transform:
1396113893
m_PrefabInternal: {fileID: 0}
1396213894
m_GameObject: {fileID: 2102343038}
1396313895
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
13964-
m_LocalPosition: {x: 0, y: 0, z: 0}
13896+
m_LocalPosition: {x: 0, y: 0, z: 6}
1396513897
m_LocalScale: {x: 1, y: 1, z: 1}
1396613898
m_Children:
1396713899
- {fileID: 1307157295}
1396813900
- {fileID: 957956923}
1396913901
m_Father: {fileID: 1468329509}
13970-
m_RootOrder: 2
13902+
m_RootOrder: 1
1397113903
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
1397213904
--- !u!95 &2102343040
1397313905
Animator:
@@ -14172,9 +14104,9 @@ MonoBehaviour:
1417214104
m_Script: {fileID: 11500000, guid: 181ad11e12e9de04f94b05a39e6aa4fb, type: 3}
1417314105
m_Name:
1417414106
m_EditorClassIdentifier:
14175-
SipServerIP: 192.168.2.100
14107+
SipServerIP: 192.168.8.102
1417614108
SipServerPort: 6650
14177-
ChatStreamServerIP: 192.168.2.100
14109+
ChatStreamServerIP: 192.168.8.102
1417814110
ChatStreamServerPort: 6680
1417914111
NetPanl: {fileID: 47060843}
1418014112
SipServerIPInputField: {fileID: 819478864}

Assets/UnityChatDemo(Can be deleted)/Scenes/UnityChatSDK_Live Broadcast.unity

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ Canvas:
669669
m_GameObject: {fileID: 116622477}
670670
m_Enabled: 1
671671
serializedVersion: 3
672-
m_RenderMode: 1
672+
m_RenderMode: 0
673673
m_Camera: {fileID: 26561707}
674674
m_PlaneDistance: 100
675675
m_PixelPerfect: 0
@@ -3970,14 +3970,15 @@ MonoBehaviour:
39703970
m_Name:
39713971
m_EditorClassIdentifier:
39723972
AudioVolume: 1
3973-
VideoType: 3
3973+
MicVolumeScale: 1
3974+
VideoType: 2
39743975
VideoResolution: 2
3975-
VideoQuality: 2
3976+
VideoQuality: 3
39763977
Framerate: 20
39773978
EchoCancellation: 0
39783979
EnableDetection: 0
39793980
EnableSync: 0
3980-
CaptureCamera: {fileID: 26561707}
3981+
CaptureCamera: {fileID: 0}
39813982
ChatPeerRawImage: []
39823983
SelfRawImage: {fileID: 0}
39833984
--- !u!114 &1869994741

Assets/UnityChatDemo(Can be deleted)/Scripts/Chat/ChatUIManager.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@ public class ChatUIManager : MonoBehaviour {
1919
public Text SelectFriendTetx;
2020
public Text CallFriendTetx;
2121
public Text InviteFriendTetx;
22-
public string SelectFriendName { get; set; }
23-
public int SelectFriendID{ get; set; }
2422

2523
public Texture2D DefultBlack;
2624
public RawImage StreamDisplay;
2725

2826
public void ShowSelectFriend(string username,int userID)
2927
{
30-
SelectFriendName = username;
31-
SelectFriendID = userID;
28+
ChatManager.Instance.ChatPeerName = username;
29+
ChatManager.Instance.ChatPeerID= userID;
3230
SelectFriendTetx.text = username;
3331
SelectFrendPanl.SetActive(true);
3432
}
@@ -74,13 +72,13 @@ void peerInvite()
7472
}
7573
public void VoiceCall()
7674
{
77-
Call(ChatType.Audio, SelectFriendID);
75+
Call(ChatType.Audio, ChatManager.Instance.ChatPeerID);
7876
print("VoiceCall");
7977
}
8078
public void VideoCall()
8179
{
8280
print("VideoCall");
83-
Call(ChatType.AV, SelectFriendID);
81+
Call(ChatType.AV, ChatManager.Instance.ChatPeerID);
8482
}
8583

8684
void Call(ChatType type, int peer)
@@ -97,7 +95,7 @@ public void CallResult(bool online)
9795
if (online)
9896
{
9997
SoundManager._instance.PlayEffect("Call");
100-
CallFriendTetx.text = SelectFriendName;
98+
CallFriendTetx.text = ChatManager.Instance.ChatPeerName;
10199
CallPanl.SetActive(true);
102100
}
103101
else

Assets/UnityChatDemo(Can be deleted)/Scripts/Live/LiveManager.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ public class LiveManager : MonoBehaviour {
1313

1414
public RawImage LiveImage;
1515

16+
Texture2D TextureLocal;
17+
1618
public bool Living;
19+
20+
1721
private void Awake()
1822
{
1923
Instance = this;
@@ -24,12 +28,26 @@ public void StartLive()
2428
UnityChatSDK.Instance.StartCapture();
2529

2630
Living = true;
31+
32+
TextureLocal = new Texture2D(Screen.width, Screen.height, TextureFormat.ARGB32, false);
33+
StartCoroutine(RecordScreen());
2734
}
2835
public void StopLive()
2936
{
3037
UnityChatSDK.Instance.StopCpture();
3138
Living = false;
3239
}
40+
IEnumerator RecordScreen()
41+
{
42+
while (Living)
43+
{
44+
yield return new WaitForEndOfFrame();
45+
TextureLocal.ReadPixels(new Rect(0.0f, 0.0f, Screen.width, Screen.height), 0, 0, false);
46+
TextureLocal.Apply();
47+
UnityChatSDK.Instance.UpdateCustomTexture(TextureLocal);
48+
yield return new WaitForSeconds(1f / UnityChatSDK.Instance.Framerate);
49+
}
50+
}
3351
public void OpenCam()
3452
{
3553
CamRawImage.transform.gameObject.SetActive(true);
@@ -54,7 +72,7 @@ public void CloseCam()
5472
public void DecodeVideoData(VideoPacket videoPacket)
5573
{
5674
if (LiveImage != null)
57-
LiveImage.texture= UnityChatSDK.Instance.DecodeVideoData(videoPacket);
75+
LiveImage.texture = UnityChatSDK.Instance.DecodeVideoData(videoPacket);
5876
}
5977
public void DecodeAudiooData(AudioPacket audioPacket)
6078
{
@@ -76,7 +94,7 @@ private void Update()
7694
if (Living)
7795
{
7896
VideoPacket packet = UnityChatSDK.Instance.GetVideo();
79-
if (packet != null)
97+
if (packet!= null && packet.Data != null)
8098
{
8199
DecodeVideoData(packet);
82100
}

Assets/UnityChatDemo(Can be deleted)/Scripts/Message/ChatSendMessageManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public void SendPeerMessage(byte[] message, MessageType t)
6161

6262
IMInfo info = new IMInfo();
6363
info.UserID = ChatManager.Instance.UserID;
64-
info.PeerID = ChatUIManager.Instance.SelectFriendID;
65-
info.UserName=ChatManager.Instance.UserName;
64+
info.UserName = ChatManager.Instance.UserName;
65+
info.PeerID = ChatManager.Instance.ChatPeerID;
6666

6767
info.MessageData = ByteString.CopyFrom(data);
6868

-2 KB
Binary file not shown.

Assets/UnityChatSDK/Scripts/UnityChatSet.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ void InitVideo()
8484
case VideoType.UnityCamera:
8585
SetVideoCaptureType(VideoType.UnityCamera, CaptureCamera);
8686
break;
87-
case VideoType.Screen:
88-
SetVideoCaptureType(VideoType.Screen, CaptureCamera);
89-
break;
9087
case VideoType.CustomTexture:
9188
SetVideoCaptureType(VideoType.CustomTexture, null);
9289
break;
@@ -166,8 +163,4 @@ public void SetUnityCam()
166163
{
167164
SetVideoCaptureType(VideoType.UnityCamera, CaptureCamera);
168165
}
169-
public void SetScreen()
170-
{
171-
SetVideoCaptureType(VideoType.Screen, CaptureCamera);
172-
}
173166
}

0 commit comments

Comments
 (0)