zoukankan      html  css  js  c++  java
  • C# 视频流操作

    发送视频流

     1   void SendVideoBuffer(object bufferIn)
     2         {
     3             try
     4             {
     5                TcpClient tcp = new TcpClient(PeerIP_TXT.Text, 6000);
     6                NetworkStream ns = tcp.GetStream();
     7                 Image buffer = (Image)bufferIn;
     8                 buffer.Save(ns, System.Drawing.Imaging.ImageFormat.Jpeg);
     9                 ns.Close();
    10                 tcp.Close();
    11             }
    12             catch (Exception) { }
    13         }


    接收视频流

     1    Socket server_sock;
     2         void server()
     3         {
     4             try
     5             {
     6                 server_sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     7                 server_sock.Bind(new IPEndPoint(IPAddress.Any, 6000));
     8                 server_sock.Listen(-1);
     9 
    10                 while (true)
    11                 {
    12                     try
    13                     {
    14                         Socket new_socket = server_sock.Accept();
    15                         NetworkStream ns = new NetworkStream(new_socket);
    16                         pictureBox_Remote.Image = Image.FromStream(ns);
    17                         ns.Close();
    18                         new_socket.Close();
    19                     }
    20                     catch (Exception)
    21                     {
    22                     }
    23                 }
    24             }
    25             catch(Exception){}
    26 
    27         }
  • 相关阅读:
    数据库连接池
    数据库操作
    cookie/session
    楼梯问题
    Response/Request
    Web
    Exception
    jQuery效果与事件方法
    jQuery基础知识点
    布局的几种形式
  • 原文地址:https://www.cnblogs.com/endv/p/6102872.html
Copyright © 2011-2022 走看看