예제 #1
0
    // Use this for initialization
    IEnumerator Start()
    {
        if (Application.isWebPlayer)
        {
            yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone));
        }

        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        VideoChat.SetVideoQuality(videoQuality);
        VideoChat.SetAudioQuality(audioQuality);
        VideoChat.SetCompression(compression);
        VideoChat.SetEchoCancellation(echoCancellation);

        //Initialize to set base parameters such as the actual WebCamTexture height and width
        VideoChat.Init(0, framerate);

        //Add was created in case we need to defer the assignment of a remoteView until after it has been Network instantiated
        //In this example we are not doing network instantiation but if we were, this would come in handy
        VideoChat.Add(remoteView, null, null);

        //Make some adjustments to the default video chat quad object for this demo, this assumes a Main Camera at the origin
        if (!remoteView)
        {
            VideoChat.vcObject.transform.localScale *= 1.5f;
            VideoChat.vcObject.transform.position    = new Vector3(0, -1.4f, 5);
        }
    }
예제 #2
0
    private static void MantenerVChat(UdpClient cliente, VideoChat chat)
    {
        while (chat.isChatting())
        {
            try
            {
                IPEndPoint ip          = new IPEndPoint(IPAddress.Any, 0);
                Byte[]     comoquieras = cliente.Receive(ref ip);
                // ip Address Cliente , Puerto Clientom

                Comunicacion comA = listcom.Find(x => x.getUsuario() == chat.comunicacions[0]);
                Comunicacion comB = listcom.Find(x => x.getUsuario() == chat.comunicacions[1]);

                if (ip.Address.Equals(comA.getIpEndPoint().Address))
                {
                    IPEndPoint ips = new IPEndPoint(comB.getIpEndPoint().Address, 11000);
                    Console.Write(comA.getUsuario().username);
                    cliente.Send(comoquieras, comoquieras.Length, ips);
                }
                else
                {
                    IPEndPoint ips = new IPEndPoint(comA.getIpEndPoint().Address, 11000);
                    Console.Write(comB.getUsuario().username);
                    cliente.Send(comoquieras, comoquieras.Length, ips);
                }
            }
            catch (Exception x)
            {
                int a = 0;
            }
        }
        cliente.Close();
    }
예제 #3
0
    void Restart()
    {
        VideoChat.ClearAudioOut();

        Resources.UnloadUnusedAssets();
        SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    }
예제 #4
0
        private void videoChat_Click(object sender, EventArgs e)
        {
            VideoChat f = new VideoChat(MainForm._localIP, MainForm._localPort.ToString(), ipRecv, portRecv.ToString());

            f.Show();
            MainForm.vcForm = f;
        }
예제 #5
0
 void OnPlayerDisconnected(NetworkPlayer player)
 {
     Network.RemoveRPCsInGroup(VideoChat.videoGroup);
     Network.RemoveRPCsInGroup(VideoChat.audioGroup);
     Network.RemoveRPCs(player);
     VideoChat.deviceIndex = VideoChat.deviceIndex;         //This resets the camera to prepare for a new connection
     VideoChat.ClearAudioOut();
 }
예제 #6
0
 void ReceiveVideo(int x, int y, byte[] videoData, double timestamp)
 {
     VideoChat.ToVideo(x, y, videoData, timestamp);
     if (oneToManyBroadcast && !PhotonNetwork.isMasterClient)
     {
         videoView.RPC("ReceiveVideo", PhotonTargets.MasterClient, VideoChat.requestedWidth, VideoChat.requestedHeight, new byte[3], VideoChat.CurrentTimestamp());
     }
 }
예제 #7
0
 void ReceiveAudio(int micPosition, int length, byte[] audioData, string timestamp)
 {
     if (micPosition == 0 && Network.connections.Length > 0)
     {
         for (int i = 0; i < Network.connections.Length; i++)
         {
             Network.RemoveRPCs(Network.connections[i], VideoChat.audioGroup);
         }
     }
     VideoChat.ToAudio(micPosition, length, audioData, System.Convert.ToDouble(timestamp));
 }
예제 #8
0
    void Restart()
    {
        VideoChat.ClearAudioOut();

        if (PhotonNetwork.room != null)
        {
            PhotonNetwork.Disconnect();
        }

        Resources.UnloadUnusedAssets();
        SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    }
예제 #9
0
 void ReceiveVideo(int x, int y, byte[] videoData, string timestamp)
 {
     if (videoData.Length == 1 && Network.connections.Length > 0)
     {
         for (int i = 0; i < Network.connections.Length; i++)
         {
             Network.RemoveRPCs(Network.connections[0], VideoChat.videoGroup);
         }
     }
     VideoChat.ToVideo(x, y, videoData, System.Convert.ToDouble(timestamp));
     if (!testMode && oneToManyBroadcast && Network.peerType != NetworkPeerType.Server)
     {
         videoView.RPC("ReceiveVideo", RPCMode.Server, VideoChat.requestedWidth, VideoChat.requestedHeight, new byte[3], System.Convert.ToString(VideoChat.CurrentTimestamp()));
     }
 }
예제 #10
0
    // Use this for initialization
    IEnumerator Start()
    {
        if (Application.isWebPlayer)
        {
            yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone));
        }

        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        VideoChat.SetVideoQuality(videoQuality);
        VideoChat.SetAudioQuality(audioQuality);
        VideoChat.SetCompression(compression);
        VideoChat.SetEchoCancellation(echoCancellation);

        //Initialize to set base parameters such as the actual WebCamTexture height and width
        VideoChat.Init(0, framerate);

        //Add was created in case we need to defer the assignment of a remoteView until after it has been Network instantiated
        //In this example we are not doing network instantiation but if we were, this would come in handy
        VideoChat.cameraView = cameraMaterial;
        VideoChat.Add(remoteView, null, null);

        if (LAN)
        {
            LANParty.Init("MidnightVideoChat", 1);
        }
        else
        {
            MasterServer.ClearHostList();
            MasterServer.RequestHostList("MidnightVideoChat");
            hostData = MasterServer.PollHostList();
        }

        //Make some adjustments to the default video chat quad object for this demo, this assumes a Main Camera at the origin
        if (!remoteView)
        {
            VideoChat.vcObject.transform.localScale *= 1.5f;
            VideoChat.vcObject.transform.position    = new Vector3(0, -1.4f, 5);
        }

        audioView = gameObject.AddComponent <NetworkView>();
        audioView.stateSynchronization = NetworkStateSynchronization.Off;
        audioView.group = VideoChat.audioGroup;

        videoView = gameObject.AddComponent <NetworkView>();
        videoView.stateSynchronization = NetworkStateSynchronization.Off;
        videoView.group = VideoChat.videoGroup;
    }
예제 #11
0
    // Use this for initialization
    IEnumerator Start()
    {
        audioView = gameObject.AddComponent <PhotonView>();
        audioView.synchronization = ViewSynchronization.Off;
        //audioView.observed = this;
        //audioView.ObservedComponents.Add(this);
        audioView.viewID = 1;

        videoView = gameObject.AddComponent <PhotonView>();
        videoView.synchronization = ViewSynchronization.Off;
        //videoView.observed = this;
        //videoView.ObservedComponents.Add(this);
        videoView.viewID = 2;

        if (Application.internetReachability != NetworkReachability.NotReachable)
        {
            PhotonNetwork.ConnectUsingSettings("1.0");
        }

        if (Application.isWebPlayer)
        {
            yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone));
        }

        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        VideoChat.SetVideoQuality(videoQuality);
        VideoChat.SetAudioQuality(audioQuality);
        VideoChat.SetCompression(compression);
        VideoChat.SetEchoCancellation(echoCancellation);

        //Initialize to set base parameters such as the actual WebCamTexture height and width
        VideoChat.Init(0, framerate);

        //Add was created in case we need to defer the assignment of a remoteView until after it has been Network instantiated
        //In this example we are not doing network instantiation but if we were, this would come in handy
        VideoChat.Add(remoteView, null, null);

        //Make some adjustments to the default video chat quad object for this demo, this assumes a Main Camera at the origin
        if (!remoteView)
        {
            VideoChat.vcObject.transform.localScale *= 1.5f;
            VideoChat.vcObject.transform.position    = new Vector3(0, -1.4f, 5);
        }
    }
예제 #12
0
        //lnkDisconnect1 LinkButton Click Event - To Disconnect The Video Chat Temprarly Means Doctor Disconnect Chat and
        protected void lnkDisconnect1_ServerClick(object sender, EventArgs e)
        {
            string    ReturnStatusMsg = "";
            Hashtable htSearch        = new Hashtable();
            DataSet   dataSet         = new DataSet();

            VideoChat objchat = new VideoChat();

            htSearch.Clear();
            htSearch.Add("flag", 10);
            htSearch.Add("AppointMentIds", Convert.ToInt32(AppontMentId.Value));

            dataSet = objchat.UpdateAppointmentStatus(htSearch, ref ReturnStatusMsg);

            if (dataSet.Tables[0].Rows.Count > 0)
            {
                Response.Redirect("doctorfutureconsults.aspx");
            }
        }
예제 #13
0
    // Use this for initialization
    IEnumerator Start()
    {
        audioView = gameObject.AddComponent <PhotonView>();
        audioView.synchronization = ViewSynchronization.Off;
        //audioView.observed = this;
        //audioView.ObservedComponents.Add(this);
        audioView.viewID = 1;
        VideoChat.AddAudio(this.transform.Find("AudioIn").GetComponent <AudioSource>(), this.transform.Find("AudioOut").GetComponent <AudioSource>());

        videoView = gameObject.AddComponent <PhotonView>();
        videoView.synchronization = ViewSynchronization.Off;
        //videoView.observed = this;
        //videoView.ObservedComponents.Add(this);
        videoView.viewID = 2;

        yield return(null);

        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        VideoChat.SetVideoQuality(videoQuality);
        VideoChat.SetAudioQuality(audioQuality);
        VideoChat.SetCompression(compression);
        VideoChat.SetEchoCancellation(echoCancellation);

        //Initialize to set base parameters such as the actual WebCamTexture height and width
        VideoChat.Init(0, framerate);

        //Add was created in case we need to defer the assignment of a remoteView until after it has been Network instantiated
        //In this example we are not doing network instantiation but if we were, this would come in handy
        //VideoChat.Add(remoteView, null, null);

        //Make some adjustments to the default video chat quad object for this demo, this assumes a Main Camera at the origin

        /*if (!remoteView)
         * {
         *  VideoChat.vcObject.transform.localScale *= 1.5f;
         *  VideoChat.vcObject.transform.position = new Vector3(0, -1.4f, 5);
         * }*/

        //StartCoroutine(SetupVideo());
    }
예제 #14
0
    void OnGUI()
    {
        if (!VideoChat.tempImage && !VideoChat.videoPrimed || !UI)
        {
            return;
        }

        VideoChat.framerate = framerate;

        bool oldTestMode = testMode;

        testMode = GUI.Toggle(new Rect(0, 20, Screen.width / 3, 40), testMode, "Test Mode");
        if (testMode == false && oldTestMode == true)
        {
            VideoChat.ClearAudioOut();
        }
        if (testMode)
        {
            GUI.Label(new Rect(0, 40, Screen.width, 20), "Mic sensitivity " + audioThreshold);
            audioThreshold             = GUI.HorizontalSlider(new Rect(0, 60, Screen.width, 20), audioThreshold, 0.0f, 1.0f);
            echoCancel                 = GUI.Toggle(new Rect(0, 80, Screen.width / 3, 40), echoCancel, "Echo Cancellation");
            echoCancellation           = (echoCancel == true) ? EchoCancellation.on : EchoCancellation.off;
            VideoChat.echoCancellation = echoCancellation;
        }

        if (GUI.Button(new Rect(0, 100, Screen.width, 40), "Change Camera " + VideoChat.deviceIndex))
        {
            VideoChat.deviceIndex++;
        }

        GUI.color = Color.black;
        GUI.Label(new Rect(0, 120, Screen.width, Screen.height - 120), VideoChat.log);
        GUI.color = Color.white;

        VideoChat.testMode = testMode;

        return;
    }
예제 #15
0
 void ReceiveAudio(int micPosition, int length, byte[] audioData, double timestamp)
 {
     UnityEngine.Debug.LogWarning("AUDIO: " + micPosition + " , " + length + " , " + timestamp);
     VideoChat.ToAudio(micPosition, length, audioData, timestamp);
 }
예제 #16
0
    void Update()
    {
        if (VideoChat.renderTextureCamera != renderTextureCamera)
        {
            VideoChat.renderTextureCamera = renderTextureCamera;
        }

        // You can utilize VideoChat.receivedAudioPackets and VideoChat.receivedVideoPackets to save/record AV data coming over the network
        // Otherwise, this clears those packets (not recording)
        // Comment this out or add conditional logic to control the recording process and then do something interesting with those lists of packets
        VideoChat.ClearReceivedPackets();

        if (Input.mousePosition.x == lastMousePosition.x && Input.mousePosition.y == lastMousePosition.y)
        {
            mouseStillCount++;
            if (mouseStillCount > mouseStillThreshold)
            {
                UI = false;
            }
        }
        else
        {
            mouseStillCount = 0;
            UI = true;
        }
        lastMousePosition = Input.mousePosition;

        if (Input.GetKey(KeyCode.Escape))
        {
            Application.Quit();
        }

        VideoChat.PreVideo();

        if ((!testMode && PhotonNetwork.room == null) || (PhotonNetwork.room != null && PhotonNetwork.otherPlayers.Length < 1))
        {
            VideoChat.PostVideo();
            return;
        }

        if (oneToManyBroadcast)
        {
            if ((!testMode && !PhotonNetwork.isMasterClient) || (PhotonNetwork.isMasterClient && PhotonNetwork.otherPlayers.Length < 1))
            {
                VideoChat.PostVideo();
                return;
            }
        }

        #region AUDIO
        if (testMode)
        {
            VideoChat.audioThreshold = audioThreshold;
        }

        VideoChat.SetEchoCancellation(echoCancellation);

        //Collect source audio, this will create a new AudioPacket and add it to the audioPackets list in the VideoChat static class
        VideoChat.FromAudio();

        //Send the latest VideoChat audio packet for a local test or your networking library of choice, in this case Unity Networking
        int           numPackets       = VideoChat.audioPackets.Count;
        AudioPacket[] tempAudioPackets = new AudioPacket[numPackets];
        VideoChat.audioPackets.CopyTo(tempAudioPackets);

        for (int i = 0; i < numPackets; i++)
        {
            AudioPacket currentPacket = tempAudioPackets[i];

            if (testMode)
            {
                ReceiveAudio(currentPacket.position, currentPacket.length, currentPacket.data, currentPacket.timestamp);                   //Test mode just plays back on one machine
            }
            else
            {
                audioView.RPC("ReceiveAudio", PhotonTargets.Others, currentPacket.position, currentPacket.length, currentPacket.data, currentPacket.timestamp);                   //Photon Networking
            }
            VideoChat.audioPackets.Remove(tempAudioPackets[i]);
        }
        #endregion


        #region VIDEO
        PhotonNetwork.sendRate = (int)(VideoChat.packetsPerFrame + ((1 / Time.fixedDeltaTime) / 10));

        //Collect source video, this will create a new VideoPacket(s) and add it(them) to the videoPackets list in the VideoChat static class
        if (doRenderTexture)
        {
            StartCoroutine(VideoChat.FromVideoRenderTexture());
        }
        else
        {
            if (doTexture2D)
            {
                VideoChat.FromVideoTexture2D(texture2D);
            }
            else
            {
                VideoChat.FromVideo();
            }
        }

        numPackets = VideoChat.videoPackets.Count > VideoChat.packetsPerFrame ? VideoChat.packetsPerFrame : VideoChat.videoPackets.Count;
        VideoPacket[] tempVideoPackets = new VideoPacket[VideoChat.videoPackets.Count];
        VideoChat.videoPackets.CopyTo(tempVideoPackets);

        //Send the latest VideoChat video packets for a local test or your networking library of choice, in this case Unity Networking
        for (int i = 0; i < numPackets; i++)
        {
            VideoPacket currentPacket = tempVideoPackets[i];

            if (testMode)
            {
                ReceiveVideo(currentPacket.x, currentPacket.y, currentPacket.data, currentPacket.timestamp);                   //Test mode just displays on one machine
            }
            else
            {
                videoView.RPC("ReceiveVideo", PhotonTargets.Others, currentPacket.x, currentPacket.y, currentPacket.data, currentPacket.timestamp);                   //Photon Networking
            }
            VideoChat.videoPackets.Remove(tempVideoPackets[i]);
        }

        VideoChat.PostVideo();
        #endregion
    }
예제 #17
0
 void ReceiveAudio(int micPosition, int length, byte[] audioData, double timestamp)
 {
     VideoChat.ToAudio(micPosition, length, audioData, timestamp);
 }
예제 #18
0
    void OnGUI()
    {
        if (!VideoChat.tempImage && !VideoChat.setup || !UI)
        {
            return;
        }

        VideoChat.framerate = framerate;

        if (PhotonNetwork.room == null)
        {
            bool oldTestMode = testMode;
            testMode = GUI.Toggle(new Rect(0, 20, Screen.width / 3, 40), testMode, "Test Mode");
            if (testMode == false && oldTestMode == true)
            {
                VideoChat.ClearAudioOut();
            }
            if (testMode)
            {
                GUI.Label(new Rect(0, 40, Screen.width, 20), "Mic sensitivity " + audioThreshold);
                audioThreshold             = GUI.HorizontalSlider(new Rect(0, 60, Screen.width, 20), audioThreshold, 0.0f, 1.0f);
                echoCancel                 = GUI.Toggle(new Rect(0, 80, Screen.width / 3, 40), echoCancel, "Echo Cancellation");
                echoCancellation           = (echoCancel == true) ? EchoCancellation.on : EchoCancellation.off;
                VideoChat.echoCancellation = echoCancellation;
            }

            VideoChat.testMode = testMode;

            if (!testMode)
            {
                if (GUI.Button(new Rect(0, 140, Screen.width, 40), "Start"))
                {
                    RoomOptions roomOptions = new RoomOptions();
                    if (oneToManyBroadcast)
                    {
                        roomOptions.maxPlayers = (byte)(numberReceivers + 1);
                    }
                    else
                    {
                        roomOptions.maxPlayers = 2;
                    }
                    roomOptions.cleanupCacheOnLeave = true;
                    roomOptions.isVisible           = true;
                    roomOptions.isOpen = true;
                    TypedLobby typedLobby = new TypedLobby();
                    typedLobby.Name = "chat";
                    typedLobby.Type = LobbyType.Default;
                    PhotonNetwork.CreateRoom("MidnightVideoChat", roomOptions, typedLobby);
                    PhotonNetwork.NetworkStatisticsEnabled = true;
                }

                if (GUI.Button(new Rect(0, 180, Screen.width, 40), "Join"))
                {
                    PhotonNetwork.JoinRoom("MidnightVideoChat");
                }
            }
        }
        else
        {
            if (GUI.Button(new Rect(0, 20, Screen.width, 40), "Disconnect"))
            {
                Restart();
            }

            GUI.Label(new Rect(0, 40, Screen.width, 20), "Friend's mic sensitivity " + audioThreshold);

            currentAudioThreshold = GUI.HorizontalSlider(new Rect(0, 60, Screen.width, 20), currentAudioThreshold, 0.0f, 1.0f);
            if (!testMode)
            {
                if (currentAudioThreshold != audioThreshold && setAudioThresholdTimer + 0.1f < Time.time)
                {
                    audioView.RPC("SetAudioThreshold", PhotonTargets.Others, currentAudioThreshold);
                    audioThreshold         = currentAudioThreshold;
                    setAudioThresholdTimer = Time.time;
                }
            }

            echoCancel                 = GUI.Toggle(new Rect(0, 80, Screen.width / 3, 20), echoCancel, "Echo Cancellation");
            echoCancellation           = (echoCancel == true) ? EchoCancellation.on : EchoCancellation.off;
            VideoChat.echoCancellation = echoCancellation;
        }

        return;
    }
예제 #19
0
    void Update()
    {
        // You can utilize VideoChat.receivedAudioPackets and VideoChat.receivedVideoPackets to save/record AV data coming over the network
        // Otherwise, this clears those packets (not recording)
        // Comment this out or add conditional logic to control the recording process and then do something interesting with those lists of packets
        VideoChat.ClearReceivedPackets();

        if (Input.mousePosition.x == lastMousePosition.x && Input.mousePosition.y == lastMousePosition.y)
        {
            mouseStillCount++;
            if (mouseStillCount > mouseStillThreshold)
            {
                UI = false;
            }
        }
        else
        {
            mouseStillCount = 0;
            UI = true;
        }
        lastMousePosition = Input.mousePosition;

        if (Input.GetKey(KeyCode.Escape))
        {
            Application.Quit();
        }

        VideoChat.PreVideo();

        if (!testMode)
        {
            VideoChat.ClearAudioOut();
            VideoChat.PostVideo();
            return;
        }

        #region AUDIO
        if (testMode)
        {
            VideoChat.audioThreshold = audioThreshold;
        }

        VideoChat.SetEchoCancellation(echoCancellation);

        //Collect source audio, this will create a new AudioPacket and add it to the audioPackets list in the VideoChat static class
        VideoChat.FromAudio();

        //Send the latest VideoChat audio packet for a local test or your networking library of choice, in this case Unity Networking
        int           numPackets       = VideoChat.audioPackets.Count;
        AudioPacket[] tempAudioPackets = new AudioPacket[numPackets];
        VideoChat.audioPackets.CopyTo(tempAudioPackets);

        for (int i = 0; i < numPackets; i++)
        {
            AudioPacket currentPacket = tempAudioPackets[i];

            if (testMode)
            {
                ReceiveAudio(currentPacket.position, currentPacket.length, currentPacket.data, currentPacket.timestamp);                   //Test mode just plays back on one machine
            }
            VideoChat.audioPackets.Remove(tempAudioPackets[i]);
        }
        #endregion


        #region VIDEO
        //Collect source video, this will create a new VideoPacket(s) and add it(them) to the videoPackets list in the VideoChat static class
        VideoChat.FromVideo();

        numPackets = VideoChat.videoPackets.Count > VideoChat.packetsPerFrame ? VideoChat.packetsPerFrame : VideoChat.videoPackets.Count;
        VideoPacket[] tempVideoPackets = new VideoPacket[VideoChat.videoPackets.Count];
        VideoChat.videoPackets.CopyTo(tempVideoPackets);

        //Send the latest VideoChat video packets for a local test or your networking library of choice, in this case Unity Networking
        for (int i = 0; i < numPackets; i++)
        {
            VideoPacket currentPacket = tempVideoPackets[i];

            if (testMode)
            {
                ReceiveVideo(currentPacket.x, currentPacket.y, currentPacket.data, currentPacket.timestamp);                   //Test mode just displays on one machine
            }
            VideoChat.videoPackets.Remove(tempVideoPackets[i]);
        }

        VideoChat.PostVideo();
        #endregion
    }
예제 #20
0
 void ReceiveVideo(int x, int y, byte[] videoData, double timestamp)
 {
     VideoChat.ToVideo(x, y, videoData, timestamp);
 }
예제 #21
0
 void OnPlayerConnected(NetworkPlayer player)
 {
     Network.RemoveRPCsInGroup(VideoChat.videoGroup);
     Network.RemoveRPCsInGroup(VideoChat.audioGroup);
     VideoChat.deviceIndex = VideoChat.deviceIndex;         //This resets the camera to prepare for a new connection
     if (!testMode && oneToManyBroadcast && Network.peerType == NetworkPeerType.Server)
     {
         videoView.RPC("ReceiveVideo", player, VideoChat.requestedWidth, VideoChat.requestedHeight, new byte[2], System.Convert.ToString(VideoChat.CurrentTimestamp()));
     }
 }
예제 #22
0
 void OnPhotonPlayerDisconnected(PhotonPlayer player)
 {
     VideoChat.deviceIndex = VideoChat.deviceIndex;         //This resets the camera to prepare for a new connection
     VideoChat.ClearAudioOut();
 }
예제 #23
0
 void OnPhotonPlayerConnected(PhotonPlayer player)
 {
     VideoChat.deviceIndex = VideoChat.deviceIndex;         //This resets the camera to prepare for a new connection
     if (oneToManyBroadcast && PhotonNetwork.isMasterClient)
     {
         videoView.RPC("ReceiveVideo", player, VideoChat.requestedWidth, VideoChat.requestedHeight, new byte[2], VideoChat.CurrentTimestamp());
     }
 }
예제 #24
0
    void OnGUI()
    {
        if (!VideoChat.tempImage && !VideoChat.videoPrimed || !UI)
        {
            return;
        }

        VideoChat.framerate = framerate;

        if (!Network.isClient && !Network.isServer)
        {
            bool oldTestMode = testMode;
            testMode = GUI.Toggle(new Rect(0, 20, Screen.width / 3, 40), testMode, "Test Mode");
            if (testMode == false && oldTestMode == true)
            {
                VideoChat.ClearAudioOut();
            }
            if (testMode)
            {
                GUI.Label(new Rect(0, 40, Screen.width, 20), "Mic sensitivity " + audioThreshold);
                audioThreshold             = GUI.HorizontalSlider(new Rect(0, 60, Screen.width, 20), audioThreshold, 0.0f, 1.0f);
                echoCancel                 = GUI.Toggle(new Rect(0, 80, Screen.width / 3, 40), echoCancel, "Echo Cancellation");
                echoCancellation           = (echoCancel == true) ? EchoCancellation.on : EchoCancellation.off;
                VideoChat.echoCancellation = echoCancellation;
            }

            VideoChat.testMode = testMode;

            if (!testMode)
            {
                if (GUI.Button(new Rect(0, 140, Screen.width, 40), "Start"))
                {
                    if (LAN)
                    {
                        LANParty.peerType = "server";

                        if (oneToManyBroadcast)
                        {
                            LANParty.possibleConnections = numberReceivers;
                        }
                        else
                        {
                            LANParty.possibleConnections = 1;
                        }

                        LANParty.log += "\n" + Network.InitializeServer(LANParty.possibleConnections, 2301, false);
                    }
                    else
                    {
                        if (oneToManyBroadcast)
                        {
                            Network.InitializeServer(numberReceivers, 2301, true);
                        }
                        else
                        {
                            Network.InitializeServer(1, 2301, true);
                        }

                        MasterServer.RegisterHost("MidnightVideoChat", "Test");
                    }
                }

                if (GUI.Button(new Rect(0, 180, Screen.width, 40), "Join"))
                {
                    if (LAN)
                    {
                        LANParty.peerType = "client";
                        LANParty.Broadcast(LANParty.ipRequestString + LANParty.gameName);
                    }
                    else
                    {
                        if (hostData.Length == 0)
                        {
                            hostData = MasterServer.PollHostList();
                        }
                    }
                    StartCoroutine("DelayedConnection");
                }
            }
        }
        else
        {
            if (GUI.Button(new Rect(0, 20, Screen.width, 40), "Disconnect"))
            {
                StartCoroutine(Restart());
            }

            GUI.Label(new Rect(0, 40, Screen.width, 20), "Friend's mic sensitivity " + audioThreshold);

            currentAudioThreshold = GUI.HorizontalSlider(new Rect(0, 60, Screen.width, 20), currentAudioThreshold, 0.0f, 1.0f);
            if (!testMode)
            {
                if (currentAudioThreshold != audioThreshold && setAudioThresholdTimer + 0.1f < Time.time)
                {
                    audioView.RPC("SetAudioThreshold", RPCMode.Others, currentAudioThreshold);
                    audioThreshold         = currentAudioThreshold;
                    setAudioThresholdTimer = Time.time;
                }
            }

            if (GUI.Button(new Rect(0, 100, Screen.width, 40), "Change Camera " + VideoChat.deviceIndex))
            {
                VideoChat.deviceIndex++;
            }

            echoCancel                 = GUI.Toggle(new Rect(0, 80, Screen.width / 3, 20), echoCancel, "Echo Cancellation");
            echoCancellation           = (echoCancel == true) ? EchoCancellation.on : EchoCancellation.off;
            VideoChat.echoCancellation = echoCancellation;
        }

        return;
    }
예제 #25
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.J))
        {
            JoinVideoChat();
        }

        // You can utilize VideoChat.receivedAudioPackets and VideoChat.receivedVideoPackets to save/record AV data coming over the network
        // Otherwise, this clears those packets (not recording)
        // Comment this out or add conditional logic to control the recording process and then do something interesting with those lists of packets
        VideoChat.ClearReceivedPackets();

        if (Input.mousePosition.x == lastMousePosition.x && Input.mousePosition.y == lastMousePosition.y)
        {
            mouseStillCount++;
            if (mouseStillCount > mouseStillThreshold)
            {
                UI = false;
            }
        }
        else
        {
            mouseStillCount = 0;
            UI = true;
        }
        lastMousePosition = Input.mousePosition;

        if (Input.GetKey(KeyCode.Escape))
        {
            Application.Quit();
        }

        //This is new in version 1.004, initializes things early for thumbnail
        VideoChat.PreVideo();

        // TODO: Experiment with throttling rendering
        if ((!testMode && Network.peerType == NetworkPeerType.Disconnected) || (Network.peerType != NetworkPeerType.Disconnected && Network.connections.Length < 1))
        {
            VideoChat.PostVideo();
            return;
        }

        if (oneToManyBroadcast)
        {
            if ((!testMode && Network.peerType != NetworkPeerType.Server) || (Network.peerType == NetworkPeerType.Server && Network.connections.Length < 1))
            {
                VideoChat.PostVideo();
                return;
            }
        }
        int numPackets = 0;

        #region AUDIO

        /*
         *      VideoChat.audioThreshold = audioThreshold;
         *
         *      //Collect source audio, this will create a new AudioPacket and add it to the audioPackets list in the VideoChat static class
         *      VideoChat.FromAudio();
         *
         *      //Send the latest VideoChat audio packet for a local test or your networking library of choice, in this case Unity Networking
         *      numPackets = VideoChat.audioPackets.Count;
         *      AudioPacket[] tempAudioPackets = new AudioPacket[ numPackets ];
         *      VideoChat.audioPackets.CopyTo( tempAudioPackets );
         *
         *      for( int i = 0; i < numPackets; i++ ) {
         *              AudioPacket currentPacket = tempAudioPackets[ i ];
         *
         *              if( testMode )
         *                      ReceiveAudio( currentPacket.position, currentPacket.length, currentPacket.data, System.Convert.ToString( currentPacket.timestamp ) ); //Test mode just plays back on one machine
         *              else
         *                      audioView.RPC( "ReceiveAudio", RPCMode.Others, currentPacket.position, currentPacket.length, currentPacket.data, System.Convert.ToString( currentPacket.timestamp ) ); //Unity Networking
         *
         *              VideoChat.audioPackets.Remove( tempAudioPackets[ i ] );
         *      }
         */
        #endregion


        #region VIDEO
        Network.sendRate = (int)(VideoChat.packetsPerFrame + ((1 / Time.fixedDeltaTime) / 10));

        //Collect source video, this will create a new VideoPacket(s) and add it(them) to the videoPackets list in the VideoChat static class
        VideoChat.FromVideo();
        //return;
        numPackets = VideoChat.videoPackets.Count > VideoChat.packetsPerFrame ? VideoChat.packetsPerFrame : VideoChat.videoPackets.Count;
        VideoPacket[] tempVideoPackets = new VideoPacket[VideoChat.videoPackets.Count];
        VideoChat.videoPackets.CopyTo(tempVideoPackets);

        //Send the latest VideoChat video packets for a local test or your networking library of choice, in this case Unity Networking
        for (int i = 0; i < numPackets; i++)
        {
            VideoPacket currentPacket = tempVideoPackets[i];

            if (testMode)
            {
                ReceiveVideo(currentPacket.x, currentPacket.y, currentPacket.data, System.Convert.ToString(currentPacket.timestamp));                     //Test mode just displays on one machine
            }
            else
            {
                videoView.RPC("ReceiveVideo", RPCMode.Others, currentPacket.x, currentPacket.y, currentPacket.data, System.Convert.ToString(currentPacket.timestamp));                     //Unity Networking
            }
            VideoChat.videoPackets.Remove(tempVideoPackets[i]);
        }

        VideoChat.PostVideo();
        #endregion
    }
예제 #26
0
    void OnGUI()
    {
        return; // moved to Unity GUI, press buttons to call these methods. The actions are attached to the buttons on the scene, referencing the gameobject with this script.

        if (!VideoChat.tempImage && !VideoChat.videoPrimed || !UI)
        {
            return;
        }

        VideoChat.framerate = framerate;

        if (!Network.isClient && !Network.isServer)
        {
            bool oldTestMode = testMode;
            testMode = GUI.Toggle(new Rect(0, 20, Screen.width / 3, 40), testMode, "Test Mode");
            if (testMode == false && oldTestMode == true)
            {
                VideoChat.ClearAudioOut();
            }
            if (testMode)
            {
                GUI.Label(new Rect(0, 40, Screen.width, 20), "Mic sensitivity " + audioThreshold);
                audioThreshold             = GUI.HorizontalSlider(new Rect(0, 60, Screen.width, 20), audioThreshold, 0.0f, 1.0f);
                echoCancel                 = GUI.Toggle(new Rect(0, 80, Screen.width / 3, 40), echoCancel, "Echo Cancellation");
                echoCancellation           = (echoCancel == true) ? EchoCancellation.on : EchoCancellation.off;
                VideoChat.echoCancellation = echoCancellation;
            }

            VideoChat.testMode = testMode;

            if (!testMode)
            {
                if (GUI.Button(new Rect(0, 140, Screen.width, 40), "Start"))
                {
                    StartVideoChat();
                }

                if (GUI.Button(new Rect(0, 180, Screen.width, 40), "Join"))
                {
                    JoinVideoChat();
                }
            }
        }
        else
        {
            if (GUI.Button(new Rect(0, 20, Screen.width, 40), "Disconnect"))
            {
                StartCoroutine(Restart());
            }

            GUI.Label(new Rect(0, 40, Screen.width, 20), "Friend's mic sensitivity " + audioThreshold);

            currentAudioThreshold = GUI.HorizontalSlider(new Rect(0, 60, Screen.width, 20), currentAudioThreshold, 0.0f, 1.0f);
            if (!testMode)
            {
                if (currentAudioThreshold != audioThreshold && setAudioThresholdTimer + 0.1f < Time.time)
                {
                    audioView.RPC("SetAudioThreshold", RPCMode.Others, currentAudioThreshold);
                    audioThreshold         = currentAudioThreshold;
                    setAudioThresholdTimer = Time.time;
                }
            }

            if (GUI.Button(new Rect(0, 100, Screen.width, 40), "Change Camera " + VideoChat.deviceIndex))
            {
                VideoChat.deviceIndex++;
            }

            echoCancel                 = GUI.Toggle(new Rect(0, 80, Screen.width / 3, 20), echoCancel, "Echo Cancellation");
            echoCancellation           = (echoCancel == true) ? EchoCancellation.on : EchoCancellation.off;
            VideoChat.echoCancellation = echoCancellation;
        }

        return;
    }
예제 #27
0
 void ReceiveVideo(int x, int y, byte[] videoData, double timestamp)
 {
     VideoChat.ToVideo(x, y, videoData, timestamp);
     //UnityEngine.Debug.Log("x: " + x + " , y: " + y);
 }