public WebRtcCoreWindows()
    {
//        text = GameObject.Find("TestText").GetComponent<UnityEngine.UI.Text>();

        Close();
        List <string> servers = new List <string>();

        servers.Add("stun: stun.l.google.com:19302");
        peer         = new PeerConnectionM(servers, "", "");
        UniquePeerId = peer.GetUniqueId();


        peer.OnLocalSdpReadytoSend    += OnLocalSdpReadytoSend;
        peer.OnIceCandiateReadytoSend += OnIceCandiateReadytoSend;
        peer.FramgeGate_onReceived    += ReceivedRGBFrame;
        peer.OnFailureMessage         += OnFailureMessage;

        peer.OnDataFromDataChannelReady += DataFromDataChannelReady;
        peer.OnLocalDataChannelReady    += DataFromDataChannelReady2;

        peer.AddStream(false);
        bool rst = peer.AddDataChannel();

        Debug.Log("add data channel rst : " + rst);

        Texture2D tex = new Texture2D((int)1920, (int)1080, TextureFormat.ARGB32, false);

        ReceivedVideoFrame = new RTCVideoFrame(tex, 0);



        receivedTextureBuffer = new byte[4 * ReceivedVideoFrame.texture2D.height * ReceivedVideoFrame.texture2D.width];

        Debug.Log("Created WebRTC Core for Windows x64");
    }
Exemple #2
0
    public void InitWebRTC()
    {
#if UNITY_ANDROID
        AndroidJavaClass systemClass = new AndroidJavaClass("java.lang.System");
        string           libname     = "jingle_peerconnection_so";
        systemClass.CallStatic("loadLibrary", new object[1] {
            libname
        });
        Debug.Log("loadLibrary loaded : " + libname);

        /*
         * Below is equivalent of this java code:
         * PeerConnectionFactory.InitializationOptions.Builder builder =
         *   PeerConnectionFactory.InitializationOptions.builder(UnityPlayer.currentActivity);
         * PeerConnectionFactory.InitializationOptions options =
         *   builder.createInitializationOptions();
         * PeerConnectionFactory.initialize(options);
         */

        AndroidJavaClass  playerClass      = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject activity         = playerClass.GetStatic <AndroidJavaObject>("currentActivity");
        AndroidJavaClass  webrtcClass      = new AndroidJavaClass("org.webrtc.PeerConnectionFactory");
        AndroidJavaClass  initOptionsClass = new AndroidJavaClass("org.webrtc.PeerConnectionFactory$InitializationOptions");
        AndroidJavaObject builder          = initOptionsClass.CallStatic <AndroidJavaObject>("builder", new object[1] {
            activity
        });
        AndroidJavaObject options = builder.Call <AndroidJavaObject>("createInitializationOptions");
        if (webrtcClass != null)

        {
            Debug.Log("PeerConnectionFactory.initialize calling");
            webrtcClass.CallStatic("initialize", new object[1] {
                options
            });
            Debug.Log("PeerConnectionFactory.initialize called.");
        }
#endif
        List <string> servers = new List <string>();
        servers.Add("stun: stun.skyway.io:3478");
        servers.Add("stun: stun.l.google.com:19302");
        peer = new PeerConnectionM("44.226.10.202", 8080, roomID, servers, "", "");

        int id = peer.GetUniqueId();
        Debug.Log("PeerConnectionM.GetUniqueId() : " + id);


        peer.OnLocalVideoFrameReady  += OnI420LocalFrameReady;
        peer.OnRemoteVideoFrameReady += OnI420RemoteFrameReady;
        // peer.OnFailureMessage += OnFailureMessage;

        peer.AddStream(false);

        cameraPlayer.peer = peer;
    }
 public void OfferWithCamera()
 {
     Close();
     InitWebRTC();
     if (peer != null)
     {
         peer.AddStream(false);
         Debug.Log("calling peer.CreateOffer()");
         peer.CreateOffer();
         Debug.Log("called peer.CreateOffer()");
     }
 }
Exemple #4
0
    public void InitWebRTC()
    {
        List <string> servers = new List <string>();

        servers.Add("stun: stun.l.google.com:19302");
        peer = new PeerConnectionM(servers, "", "");
        int id = peer.GetUniqueId();

        Debug.Log("WebRTC PeerConnectionM.GetUniqueId() : " + id);

        peer.OnLocalSdpReadytoSend    += OnLocalSdpReadytoSend;
        peer.OnIceCandiateReadytoSend += OnIceCandiateReadytoSend;
        peer.FramgeGate_onRecieved    += RecievedRGBFrame;
        peer.OnFailureMessage         += OnFailureMessage;



        MsgExchanger           = webRtcMsgExchanger.GetComponent <WebRtcMsgExchanger>();
        MsgExchanger.WebRtcCtr = this;
        peer.AddStream(false);
    }
Exemple #5
0
    public WebRtcCoreWindows(int width, int height) : base(width, height)
    {
        Close();
        var servers = new string[] {
            "stun: stun.l.google.com:19302"
        };

        peer         = new PeerConnectionM(servers, "", "");
        UniquePeerId = peer.GetUniqueId();

        peer.OnLocalSdpReadytoSend    += OnLocalSdpReadytoSend;
        peer.OnIceCandiateReadytoSend += OnIceCandiateReadytoSend;
        peer.FramgeGate_onReceived    += ReceivedRGBFrame;
        peer.OnFailureMessage         += OnFailureMessage;
        peer.AddStream(false);

        ReceivedTexture2D = new Texture2D(width, height, TextureFormat.ARGB32, false);

        receivedTextureBuffer = new byte[4 * ReceivedTexture2D.height * ReceivedTexture2D.width];

        Debug.Log("Created WebRTC Core for Windows x64");
    }