Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi
İ want to send webcam video from server to client in c# windons application .In server , ı take video from webcam and then i send to client. so i can watch server's webcam . How can do that ? Please help me.
Posted
Comments
Sergey Alexandrovich Kryukov 25-Mar-15 15:44pm    
It depends on your application type and UI library you are using. CodeProject is one of the good source on the problem.
—SA

Please see my comment to the question. Please do the search, for example, http://www.codeproject.com/search.aspx?q=Webcam+video+capture+%28%22.NET%22+OR+%22C%23%22%29&doctypeid=1.

—SA
 
Share this answer
 
This source code can be used to send the image of your webcam to remote locations. I can help if you look for a solution like this: the server will be the PC that the webcam is connected to, and the remote computers will be the clients.

C#
namespace Onvif_IP_Camera_Server_04
{
    public class MyServer : IPCameraServer
    {
        private MediaConnector _connector;
        private IIPCamera _camera;
        private IIPCameraClient _client;
 
        public string IpAddress { get; set; }
        public int Port { get; set; }
 
        public event EventHandler<eventargs> ClientCountChange;
 
        public MyServer()
        {
            _connector = new MediaConnector();
            _camera = IPCameraFactory.GetCamera("192.168.115.175:8080", "admin", "admin");
 
            if (_camera != null)
                _camera.Start();
        }
 
        protected override void OnClientConnected(IIPCameraClient client)
        {
            _client = client;
            _connector.Connect(_camera.AudioChannel, _client.AudioChannel);
            _connector.Connect(_camera.VideoChannel, _client.VideoChannel);
 
            var handler = ClientCountChange;
            if (handler != null)
                handler(null, new EventArgs());
 
            base.OnClientConnected(_client);
        }
 
        protected override void OnClientDisconnected(IIPCameraClient client)
        {
            _connector.Disconnect(_camera.AudioChannel, _client.AudioChannel);
            _connector.Disconnect(_camera.VideoChannel, _client.VideoChannel);
            _connector.Dispose();
 
            var handler = ClientCountChange;
            if (handler != null)
                handler(null, new EventArgs());
 
            base.OnClientDisconnected(client);
        }
    }
 
    class Program
    {
        static MyServer _server = new MyServer();
 
        static void Main(string[] args)
        {
            _server.Start();
            _server.SetListenAddress("192.168.115.172", 554);
            _server.ClientCountChange += new EventHandler<eventargs>(server_ClientCountChange);
            Console.WriteLine("Started");
            Console.Read();
        }
 
        static void server_ClientCountChange(object sender, EventArgs e)
        {
            _server.ConnectedClients.ForEach(x => Console.WriteLine(x.TransportInfo.RemoteEndPoint.ToString()));
        }
    }
}


Reference:
How to stream video to multiple locations simultaneously (video stream duplication) in C#[^]
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900