aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Video/DefaultVideoCaptureProvider.cs
blob: 3aa9d4c88d864bbcdd9ece3b6ae6af6a26c1b660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Video.DirectCapture;

namespace Tango.MachineStudio.Common.Video
{
    /// <summary>
    /// Represents the default implementation of <see cref="IVideoCaptureProvider"/>.
    /// </summary>
    /// <seealso cref="Tango.MachineStudio.Common.Video.IVideoCaptureProvider" />
    public class DefaultVideoCaptureProvider : IVideoCaptureProvider
    {
        /// <summary>
        /// Gets the available capture devices.
        /// </summary>
        public ObservableCollection<CaptureDevice> AvailableCaptureDevices { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultVideoCaptureProvider"/> class.
        /// </summary>
        public DefaultVideoCaptureProvider()
        {
            AvailableCaptureDevices = new ObservableCollection<CaptureDevice>();

            var availableDevices = CaptureDevice.GetAvailableCaptureDevices();

            for (int i = 0; i < 3; i++)
            {
                if (i > availableDevices.Count - 1)
                {
                    AvailableCaptureDevices.Add(new CaptureDevice() { Device = null });
                }
                else
                {
                    AvailableCaptureDevices.Add(new CaptureDevice() { Device = availableDevices[i] });
                }
            }
        }
    }
}