• 大小: 276KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-24
  • 语言: C#
  • 标签: MJPEG  STREAM  SERVER  CLIENT  

资源简介

Implementing a MJPEG (or Motion JPEG) streaming server that can be used to steam screenshots or any other source of images over the HTTP protocol to any web browser client (MJPEG stream writer is included in the library).

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Windows.Forms;
using System.IO;

// -------------------------------------------------
// Developed By : Ragheed Al-Tayeb
// e-Mail       : ragheedemail@gmail.com
// Date         : April 2012
// -------------------------------------------------

namespace rtaNetworking.Streaming
{

    /// 
    /// Provides a streaming server that can be used to stream any images source
    /// to any client.
    /// 

    public class ImageStreamingServer:IDisposable
    {

        private List _Clients;
        private Thread _Thread;

        public ImageStreamingServer():this(Screen.Snapshots(600450true))
        {

        }

        public ImageStreamingServer(IEnumerable imagesSource)
        {

            _Clients = new List();
            _Thread = null;

            this.ImagesSource = imagesSource;
            this.Interval = 50;

        }


        /// 
        /// Gets or sets the source of images that will be streamed to the 
        /// any connected client.
        /// 

        public IEnumerable ImagesSource { get; set; }

        /// 
        /// Gets or sets the interval in milliseconds (or the delay time) between 
        /// the each image and the other of the stream (the default is . 
        /// 

        public int Interval { get; set; }

        /// 
        /// Gets a collection of client sockets.
        /// 

        public IEnumerable Clients { get { return _Clients; } }

        /// 
        /// Returns the status of the server. True means the server is currently 
        /// running and ready to serve any client requests.
        /// 

        public bool IsRunning { get { return (_Thread != null && _Thread.IsAlive); } }

        /// 
        /// Starts the server to accepts any new connections on the specified port.
        /// 

        /// 
        public void Start(int port)
        {

            lock (this)
            {
                _Thread = new Thread(new ParameterizedThreadStart(ServerThread));
                _Thread.IsBackground = true;
                _Thread.Start(port);
            }

        }

        /// 
        /// Starts the server to accepts any new connections on the default port (8080).
        /// 

        public void Start()
        {
            this.Start(8080);
        }

        public void Stop()
        {

            if (this.IsRunning)
            {
                try
                {
                    _Thread.Join();
                    _Thread.Abort();
                }
                finally
                

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-04-24 00:45  rtaVideoStreamer\rtaNetworking.Streaming\
     文件        8500  2012-04-23 00:17  rtaVideoStreamer\rtaNetworking.Streaming\ImageStreamingServer.cs
     文件        3445  2012-04-23 00:29  rtaVideoStreamer\rtaNetworking.Streaming\MjpegWriter.cs
     目录           0  2012-04-24 00:45  rtaVideoStreamer\rtaNetworking.Streaming\obj\
     目录           0  2012-04-24 00:45  rtaVideoStreamer\rtaNetworking.Streaming\obj\Debug\
     目录           0  2012-04-24 00:45  rtaVideoStreamer\rtaNetworking.Streaming\obj\Debug\Refactor\
     文件        5120  2012-04-23 01:07  rtaVideoStreamer\rtaNetworking.Streaming\obj\Debug\Refactor\rtaNetworking.Streaming.dll
     文件         608  2012-04-22 21:58  rtaVideoStreamer\rtaNetworking.Streaming\obj\Debug\rtaNetworking.Streaming.csproj.FileListAbsolute.txt
     文件       14848  2012-04-23 00:29  rtaVideoStreamer\rtaNetworking.Streaming\obj\Debug\rtaNetworking.Streaming.dll
     文件       30208  2012-04-23 00:29  rtaVideoStreamer\rtaNetworking.Streaming\obj\Debug\rtaNetworking.Streaming.pdb
     目录           0  2012-04-20 10:16  rtaVideoStreamer\rtaNetworking.Streaming\obj\Debug\TempPE\
     目录           0  2012-04-24 00:45  rtaVideoStreamer\rtaNetworking.Streaming\Properties\
     文件        1458  2012-04-20 10:16  rtaVideoStreamer\rtaNetworking.Streaming\Properties\AssemblyInfo.cs
     文件        2672  2012-04-21 20:29  rtaVideoStreamer\rtaNetworking.Streaming\rtaNetworking.Streaming.csproj
     文件        1461  2012-04-23 01:05  rtaVideoStreamer\rtaVideoStreamer.sln
     文件       32768  2012-04-24 00:44  rtaVideoStreamer\rtaVideoStreamer.suo
     目录           0  2012-04-24 00:47  rtaVideoStreamer\rtaVideoStreamer\
     文件        1223  2012-04-24 00:44  rtaVideoStreamer\rtaVideoStreamer\Form1.cs
     文件        4643  2012-04-23 01:25  rtaVideoStreamer\rtaVideoStreamer\Form1.Designer.cs
     文件        6209  2012-04-23 01:25  rtaVideoStreamer\rtaVideoStreamer\Form1.resx
     目录           0  2012-04-24 00:45  rtaVideoStreamer\rtaVideoStreamer\obj\
     目录           0  2012-04-24 00:45  rtaVideoStreamer\rtaVideoStreamer\obj\Debug\
     目录           0  2012-04-23 01:07  rtaVideoStreamer\rtaVideoStreamer\obj\Debug\Refactor\
     文件        8279  2012-04-23 00:29  rtaVideoStreamer\rtaVideoStreamer\obj\Debug\ResolveAssemblyReference.cache
     文件        1159  2012-04-24 00:44  rtaVideoStreamer\rtaVideoStreamer\obj\Debug\rtaVideoStreamer.csproj.FileListAbsolute.txt
     文件         847  2012-04-23 01:25  rtaVideoStreamer\rtaVideoStreamer\obj\Debug\rtaVideoStreamer.csproj.GenerateResource.Cache
     文件       10240  2012-04-24 00:44  rtaVideoStreamer\rtaVideoStreamer\obj\Debug\rtaVideoStreamer.exe
     文件         180  2012-04-24 00:44  rtaVideoStreamer\rtaVideoStreamer\obj\Debug\rtaVideoStreamer.Form1.resources
     文件       26112  2012-04-24 00:44  rtaVideoStreamer\rtaVideoStreamer\obj\Debug\rtaVideoStreamer.pdb
     文件         180  2012-04-24 00:44  rtaVideoStreamer\rtaVideoStreamer\obj\Debug\rtaVideoStreamer.Properties.Resources.resources
     目录           0  2012-04-20 10:14  rtaVideoStreamer\rtaVideoStreamer\obj\Debug\TempPE\
............此处省略9个文件信息

评论

共有 条评论