コード例 #1
0
        public DebugForm(UPnPDeviceWatcher d)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            device = d;
            device.OnSniff += new UPnPDeviceWatcher.SniffHandler(SniffSink);

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }
コード例 #2
0
        /// <summary>
        /// Starts the UPnP server.
        /// </summary>
        public static void Start()
        {
            if (IsRunning)
            {
                Log.Info("An UPnP/DLNA server start was requested, but it is already running.");
                Stop();
            }

            if (!Signature.IsActivated)
            {
                Log.Error("An UPnP/DLNA server start was requested, but the software is not activated.");
                return;
            }

            Log.Info("Starting UPnP/DLNA server...");

            _ms = new MediaServerDevice(_di, null, true, "http-get:*:*:*", "");
            _dw = new UPnPDeviceWatcher(_ms._Device);

            var dv = _ms.GetUPnPDevice();

            if (_favicon == null)
            {
                _favicon = new Icon(Application.GetResourceStream(new Uri("pack://application:,,,/RSTVShowTracker;component/tv.ico")).Stream);
                _icon    = new Bitmap(Application.GetResourceStream(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/tv48.png")).Stream);
                _icon2   = new Bitmap(Application.GetResourceStream(new Uri("pack://application:,,,/RSTVShowTracker;component/Images/tv64.png")).Stream);
            }

            dv.favicon = _favicon;
            dv.Icon    = _icon;
            dv.Icon2   = _icon2;

            _ms.Start();

            IsRunning = true;

            _mimes = new HashSet<string>();

            RebuildList();
        }
コード例 #3
0
        public MediaServerCore(string friendlyName)
        {
            if (serverCore != null) throw new Exception("Only a single MediaServerCode instance is allowed");
            serverCore = this;

            OpenSource.Utilities.EventLogger.SetLog("Media Server", "MediaServerCode", System.Windows.Forms.Application.ProductVersion.ToString());

            DeviceInfo info = new DeviceInfo();
            info.AllowRemoteContentManagement = true;
            info.FriendlyName = friendlyName;
            info.Manufacturer = "OpenSource";
            info.ManufacturerURL = "";
            info.ModelName = "Media Server";
            info.ModelDescription = "Provides content through UPnP ContentDirectory service";
            info.ModelURL = "";
            info.ModelNumber = "0.765";
            info.LocalRootDirectory = "";
            Tags T = Tags.GetInstance();
            info.SearchCapabilities = "dc:title,dc:creator,upnp:class,upnp:album,res@protocolInfo,res@size,res@bitrate";
            info.SortCapabilities = "dc:title,dc:creator,upnp:class,upnp:album";
            info.EnableSearch = true;
            info.CacheTime = MediaServerCore.CacheTime;
            info.CustomUDN = MediaServerCore.CustomUDN;
            info.INMPR03 = MediaServerCore.INMPR;

            // encode in UTF16 instead of UTF8
            MediaObject.ENCODE_UTF8 = false;

            mediaServer = new MediaServerDevice(info, null, true, "http-get:*:*:*", "");
            mediaServer.OnStatsChanged += new MediaServerDevice.Delegate_MediaServerHandler(StatsChangedChangedSink);
            mediaServer.OnHttpTransfersChanged += new MediaServerDevice.Delegate_MediaServerHandler(HttpTransfersChangedSink);
            mediaServer.OnFileNotMapped = new MediaServerDevice.Delegate_FileNotMappedHandler(this.Handle_OnRequestUnmappedFile);
            mediaServer.OnRequestAddBranch = new MediaServerDevice.Delegate_AddBranch(this.Handle_OnRequestAddBranch);
            mediaServer.OnRequestRemoveBranch = new MediaServerDevice.Delegate_RemoveBranch(this.Handle_OnRequestRemoveBranch);
            mediaServer.OnRequestChangeMetadata = new MediaServerDevice.Delegate_ChangeMetadata(this.Handle_OnRequestChangeMetadata);
            mediaServer.OnRequestSaveBinary = new MediaServerDevice.Delegate_ModifyBinary (this.Handle_OnRequestSaveBinary);
            mediaServer.OnRequestDeleteBinary = new MediaServerDevice.Delegate_ModifyBinary(this.Handle_OnRequestDeleteBinary);

            this.ResetCoreRoot();

            this.m_DeviceWatcher = new UPnPDeviceWatcher(mediaServer._Device);
            this.m_DeviceWatcher.OnSniff += new OpenSource.UPnP.UPnPDeviceWatcher.SniffHandler(this.Sink_DeviceWatcherSniff);

            this.mediaServer.Start();
            m_Paused = false;
        }
コード例 #4
0
 public void Dispose()
 {
     rootContainer = null;
     mediaServer.Dispose();
     mediaServer = null;
     serverCore = null;
     this.m_DeviceWatcher = null;
     this.m_DeviceWatcher.OnSniff -= new OpenSource.UPnP.UPnPDeviceWatcher.SniffHandler(this.Sink_DeviceWatcherSniff);
 }
コード例 #5
0
        /// <summary>
        /// Stops the UPnP server.
        /// </summary>
        public static void Stop()
        {
            Log.Info("Stopping UPnP/DLNA server...");

            IsRunning = false;

            _ms.Stop();
            _ms.Dispose();
            _ms = null;
            _dw = null;
        }