Exemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();

            wpfPublisherHost.Child  = new OpenTok.VideoRenderer();
            wpfSubscriberHost.Child = new OpenTok.VideoRenderer();


            var cams        = VideoCapturer.EnumerateDevices();
            var selectedcam = cams[0];

            capturer  = selectedcam.CreateVideoCapturer(VideoCapturer.Resolution.High);
            publisher = new Publisher.Builder(Context.Instance)
            {
                Renderer = (IVideoRenderer)wpfPublisherHost.Child,
                Capturer = capturer
            }.Build();

            var mics = AudioDevice.EnumerateInputAudioDevices();

            AudioDevice.SetInputAudioDevice(mics[0]); // Go with first microphone in the list

            session = new Session.Builder(Context.Instance, API_KEY, SESSION_ID).Build();

            session.Connected         += Session_Connected;
            session.Disconnected      += Session_Disconnected;
            session.Error             += Session_Error;
            session.ConnectionCreated += Session_ConnectionCreated;
            session.StreamReceived    += Session_StreamReceived;
            session.StreamDropped     += Session_StreamDropped;

            Closing += MainWindow_Closing;
        }
Exemplo n.º 2
0
        public override bool Connect()
        {
            IList <VideoCapturer.VideoDevice> devices = VideoCapturer.EnumerateDevices();

            if (devices.Count > 2)
            {
                _capturer = devices[2].CreateVideoCapturer();
                Status    = ConnectionStatus.Ready;
                return(true);
            }
            Status = ConnectionStatus.Disconnected;
            return(false);
        }
        public MainWindow()
        {
            InitializeComponent();

            // This shows how to enumarate the available capturer devices on the system to allow the user of the app
            // to select the desired camera. If a capturer is not provided in the publisher constructor the first available
            // camera will be used.
            var devices = VideoCapturer.EnumerateDevices();

            if (devices.Count > 0)
            {
                var selectedDevice = devices[0];
                Trace.WriteLine("Using camera: " + devices[0].Name);
                Capturer = selectedDevice.CreateVideoCapturer(VideoCapturer.Resolution.High);
            }
            else
            {
                Trace.WriteLine("Warning: no cameras available, the publisher will be audio only.");
            }

            // We create the publisher here to show the preview when application starts
            // Please note that the PublisherVideo component is added in the xaml file
            Publisher = new Publisher.Builder(Context.Instance)
            {
                Renderer = PublisherVideo,
                Capturer = Capturer
            }.Build();

            if (API_KEY == "" || SESSION_ID == "" || TOKEN == "")
            {
                MessageBox.Show("Please fill out the API_KEY, SESSION_ID and TOKEN variables in the source code " +
                                "in order to connect to the session", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                ConnectDisconnectButton.IsEnabled = false;
            }
            else
            {
                Session = new Session.Builder(Context.Instance, API_KEY, SESSION_ID).Build();

                Session.Connected      += Session_Connected;
                Session.Disconnected   += Session_Disconnected;
                Session.Error          += Session_Error;
                Session.StreamReceived += Session_StreamReceived;
                Session.StreamDropped  += Session_StreamDropped;
            }

            Closing += MainWindow_Closing;
        }
Exemplo n.º 4
0
        public MainWindow()
        {
            InitializeComponent();

            var devices        = VideoCapturer.EnumerateDevices();
            var selectedDevice = devices[0];

            capturer  = selectedDevice.CreateVideoCapturer(VideoCapturer.Resolution.High);
            publisher = new Publisher(Context.Instance, renderer: publisherVideo, capturer: capturer);

            //var screenSharing = new ScreenSharingCapturer();
            //publisher = new Publisher(Context.Instance, renderer: publisherVideo, capturer: screenSharing);

            session = new Session(Context.Instance, API_KEY, SESSION_ID);

            session.Connected         += Session_Connected;
            session.Disconnected      += Session_Disconnected;
            session.Error             += Session_Error;
            session.ConnectionCreated += Session_ConnectionCreated;
            session.StreamReceived    += Session_StreamReceived;
            session.StreamDropped     += Session_StreamDropped;

            Closing += MainWindow_Closing;
        }