38 lines
824 B
C#
38 lines
824 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Net.WebSockets;
|
|
using Unity.WebRTC;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class WEBRTCSender : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private string serverIp;
|
|
[SerializeField]
|
|
private int port;
|
|
[SerializeField]
|
|
private RawImage image;
|
|
[SerializeField]
|
|
private bool isServer = true;
|
|
|
|
private Camera camera;
|
|
|
|
private RTCPeerConnection peer;
|
|
private VideoStreamTrack track;
|
|
private WebSocket socket;
|
|
|
|
private void Start()
|
|
{
|
|
StartCoroutine(WebRTC.Update());
|
|
|
|
peer = new RTCPeerConnection();
|
|
if (isServer)
|
|
{
|
|
camera = GetComponent<Camera>();
|
|
track = camera.CaptureStreamTrack(1280, 720);
|
|
peer.AddTrack(track);
|
|
}
|
|
}
|
|
}
|