Exemplo n.º 1
0
    async void Start()
    {
        deviceList = await DeviceVideoTrackSource.GetCaptureDevicesAsync();

        Debug.Log($"Found {deviceList.Count} devices.");
        foreach (var device in deviceList)
        {
            Debug.Log($"Found webcam {device.name} (id: {device.id}):");
            var profiles = await DeviceVideoTrackSource.GetCaptureProfilesAsync(device.id);

            if (profiles.Count > 0)
            {
                foreach (var profile in profiles)
                {
                    Debug.Log($"+ Profile '{profile.uniqueId}'");
                    var configs = await DeviceVideoTrackSource.GetCaptureFormatsAsync(device.id, profile.uniqueId);

                    foreach (var config in configs)
                    {
                        Debug.Log($"  - {config.width}x{config.height}@{config.framerate}");
                    }
                }
            }
            else
            {
                var configs = await DeviceVideoTrackSource.GetCaptureFormatsAsync(device.id);

                foreach (var config in configs)
                {
                    Debug.Log($"- {config.width}x{config.height}@{config.framerate}");
                }
            }
        }

        // Setup signaling
        Debug.Log("Starting signaling...");
        switch (ConnectionType)
        {
        case SignalerType.TCP:
            signaler = new TCPSignaler(Port);
            break;

        case SignalerType.WebSocket:
            signaler = new WebSocketSignaler(Port);
            break;

        default:
            throw new System.Exception($"Signaler connection type {ConnectionType} is not valid!");
        }
        signaler.ClientConnected    += OnClientConnected;
        signaler.ClientDisconnected += OnClientDisconnected;
        if (UseRemoteStun)
        {
            signaler.IceServers.Add(new IceServer {
                Urls = { "stun:stun.l.google.com:19302" }
            });
        }
        signaler.Start();
    }
Exemplo n.º 2
0
        public async void RefreshVideoProfiles(VideoCaptureDeviceInfo item, VideoProfileKind kind)
        {
            // Clear formats, which are profile-dependent. This ensures the former list doesn't
            // stay visible if the current profile kind is not supported (does not return any profile).
            VideoCaptureFormats.Clear();

            var videoProfiles = new CollectionViewModel <VideoProfile>();

            if (item != null)
            {
                IReadOnlyList <VideoProfile> profiles = await DeviceVideoTrackSource.GetCaptureProfilesAsync(item.Id, kind);

                foreach (var profile in profiles)
                {
                    videoProfiles.Add(profile);
                }
            }
            VideoProfiles = videoProfiles;

            // Select first item for convenience
            VideoProfiles.SelectFirstItemIfAny();
        }