Skip to content

Commit

Permalink
fix aduio play and record error
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanguUncle committed Sep 21, 2020
1 parent e994b25 commit 10094fb
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ Camera:
m_Depth: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294966271
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
Expand Down Expand Up @@ -3808,74 +3808,6 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 523341788}
--- !u!1 &535887093
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 1565746348981914, guid: 48d512021e38e2245856d414c70e274e,
type: 2}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 535887095}
- component: {fileID: 535887094}
m_Layer: 10
m_Name: CaptureCamera
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!20 &535887094
Camera:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 20761546725244870, guid: 48d512021e38e2245856d414c70e274e,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 535887093}
m_Enabled: 0
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.01
far clip plane: 100
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 1280
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 0
m_AllowMSAA: 0
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 0
m_StereoSeparation: 0
--- !u!4 &535887095
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 4148342547608750, guid: 48d512021e38e2245856d414c70e274e,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 535887093}
m_LocalRotation: {x: 0.10342088, y: -0, z: -0, w: 0.9946377}
m_LocalPosition: {x: -0.409, y: 1.01, z: -2.94}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1468329509}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 11.872001, y: 0, z: 0}
--- !u!1 &579700496
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -7091,7 +7023,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0.000057185243}
m_AnchoredPosition: {x: 0, y: 0.00006645337}
m_SizeDelta: {x: 0, y: 439.7}
m_Pivot: {x: 0, y: 1}
--- !u!114 &1080824776
Expand Down Expand Up @@ -9738,7 +9670,6 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1869994738}
- {fileID: 535887095}
- {fileID: 2102343039}
m_Father: {fileID: 0}
m_RootOrder: 8
Expand Down Expand Up @@ -12300,14 +12231,15 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
AudioVolume: 1
MicVolumeScale: 1
VideoType: 0
VideoResolution: 1
VideoQuality: 2
Framerate: 15
EchoCancellation: 0
EnableDetection: 0
EnableSync: 0
CaptureCamera: {fileID: 535887094}
CaptureCamera: {fileID: 26561707}
ChatPeerRawImage:
- {fileID: 1690060813}
SelfRawImage: {fileID: 1043811784}
Expand Down Expand Up @@ -13961,13 +13893,13 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2102343038}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 6}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1307157295}
- {fileID: 957956923}
m_Father: {fileID: 1468329509}
m_RootOrder: 2
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!95 &2102343040
Animator:
Expand Down Expand Up @@ -14172,9 +14104,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 181ad11e12e9de04f94b05a39e6aa4fb, type: 3}
m_Name:
m_EditorClassIdentifier:
SipServerIP: 192.168.2.100
SipServerIP: 192.168.8.102
SipServerPort: 6650
ChatStreamServerIP: 192.168.2.100
ChatStreamServerIP: 192.168.8.102
ChatStreamServerPort: 6680
NetPanl: {fileID: 47060843}
SipServerIPInputField: {fileID: 819478864}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ Canvas:
m_GameObject: {fileID: 116622477}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 1
m_RenderMode: 0
m_Camera: {fileID: 26561707}
m_PlaneDistance: 100
m_PixelPerfect: 0
Expand Down Expand Up @@ -3970,14 +3970,15 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
AudioVolume: 1
VideoType: 3
MicVolumeScale: 1
VideoType: 2
VideoResolution: 2
VideoQuality: 2
VideoQuality: 3
Framerate: 20
EchoCancellation: 0
EnableDetection: 0
EnableSync: 0
CaptureCamera: {fileID: 26561707}
CaptureCamera: {fileID: 0}
ChatPeerRawImage: []
SelfRawImage: {fileID: 0}
--- !u!114 &1869994741
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ public class ChatUIManager : MonoBehaviour {
public Text SelectFriendTetx;
public Text CallFriendTetx;
public Text InviteFriendTetx;
public string SelectFriendName { get; set; }
public int SelectFriendID{ get; set; }

public Texture2D DefultBlack;
public RawImage StreamDisplay;

public void ShowSelectFriend(string username,int userID)
{
SelectFriendName = username;
SelectFriendID = userID;
ChatManager.Instance.ChatPeerName = username;
ChatManager.Instance.ChatPeerID= userID;
SelectFriendTetx.text = username;
SelectFrendPanl.SetActive(true);
}
Expand Down Expand Up @@ -74,13 +72,13 @@ void peerInvite()
}
public void VoiceCall()
{
Call(ChatType.Audio, SelectFriendID);
Call(ChatType.Audio, ChatManager.Instance.ChatPeerID);
print("VoiceCall");
}
public void VideoCall()
{
print("VideoCall");
Call(ChatType.AV, SelectFriendID);
Call(ChatType.AV, ChatManager.Instance.ChatPeerID);
}

void Call(ChatType type, int peer)
Expand All @@ -97,7 +95,7 @@ public void CallResult(bool online)
if (online)
{
SoundManager._instance.PlayEffect("Call");
CallFriendTetx.text = SelectFriendName;
CallFriendTetx.text = ChatManager.Instance.ChatPeerName;
CallPanl.SetActive(true);
}
else
Expand Down
22 changes: 20 additions & 2 deletions Assets/UnityChatDemo(Can be deleted)/Scripts/Live/LiveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ public class LiveManager : MonoBehaviour {

public RawImage LiveImage;

Texture2D TextureLocal;

public bool Living;


private void Awake()
{
Instance = this;
Expand All @@ -24,12 +28,26 @@ public void StartLive()
UnityChatSDK.Instance.StartCapture();

Living = true;

TextureLocal = new Texture2D(Screen.width, Screen.height, TextureFormat.ARGB32, false);
StartCoroutine(RecordScreen());
}
public void StopLive()
{
UnityChatSDK.Instance.StopCpture();
Living = false;
}
IEnumerator RecordScreen()
{
while (Living)
{
yield return new WaitForEndOfFrame();
TextureLocal.ReadPixels(new Rect(0.0f, 0.0f, Screen.width, Screen.height), 0, 0, false);
TextureLocal.Apply();
UnityChatSDK.Instance.UpdateCustomTexture(TextureLocal);
yield return new WaitForSeconds(1f / UnityChatSDK.Instance.Framerate);
}
}
public void OpenCam()
{
CamRawImage.transform.gameObject.SetActive(true);
Expand All @@ -54,7 +72,7 @@ public void CloseCam()
public void DecodeVideoData(VideoPacket videoPacket)
{
if (LiveImage != null)
LiveImage.texture= UnityChatSDK.Instance.DecodeVideoData(videoPacket);
LiveImage.texture = UnityChatSDK.Instance.DecodeVideoData(videoPacket);
}
public void DecodeAudiooData(AudioPacket audioPacket)
{
Expand All @@ -76,7 +94,7 @@ private void Update()
if (Living)
{
VideoPacket packet = UnityChatSDK.Instance.GetVideo();
if (packet != null)
if (packet!= null && packet.Data != null)
{
DecodeVideoData(packet);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public void SendPeerMessage(byte[] message, MessageType t)

IMInfo info = new IMInfo();
info.UserID = ChatManager.Instance.UserID;
info.PeerID = ChatUIManager.Instance.SelectFriendID;
info.UserName=ChatManager.Instance.UserName;
info.UserName = ChatManager.Instance.UserName;
info.PeerID = ChatManager.Instance.ChatPeerID;

info.MessageData = ByteString.CopyFrom(data);

Expand Down
Binary file modified Assets/UnityChatSDK/Plugins/UnityChatSDK.dll
Binary file not shown.
7 changes: 0 additions & 7 deletions Assets/UnityChatSDK/Scripts/UnityChatSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ void InitVideo()
case VideoType.UnityCamera:
SetVideoCaptureType(VideoType.UnityCamera, CaptureCamera);
break;
case VideoType.Screen:
SetVideoCaptureType(VideoType.Screen, CaptureCamera);
break;
case VideoType.CustomTexture:
SetVideoCaptureType(VideoType.CustomTexture, null);
break;
Expand Down Expand Up @@ -166,8 +163,4 @@ public void SetUnityCam()
{
SetVideoCaptureType(VideoType.UnityCamera, CaptureCamera);
}
public void SetScreen()
{
SetVideoCaptureType(VideoType.Screen, CaptureCamera);
}
}

0 comments on commit 10094fb

Please sign in to comment.