Example #1
0
        } // ParseDidlContainerMetaData

        /// <summary>
        /// Parses DIDL item meta data.
        /// </summary>
        /// <param name="xitem">The parent.</param>
        /// <returns>A <see cref="BrowseMetaDataResult"/> object.</returns>
        private static BrowseMetaDataResult ParseDidlItemMetaData(XElement xitem)
        {
            var result = new BrowseMetaDataResult();

            result.Id       = XmlSupport.GetAttributeValue(xitem, "id");
            result.ParentId = XmlSupport.GetAttributeValue(xitem, "parentID");
            var help = XmlSupport.GetAttributeValue(xitem, "restricted");

            if (!string.IsNullOrEmpty(help))
            {
                result.Restricted = UPNP.ParseUpnpBoolean(help);
            } // if

            result.Title = XmlSupport.GetFirstSubNodeValue(xitem, "title");
            result.Class = XmlSupport.GetFirstSubNodeValue(xitem, "class");
            result.Date  = XmlSupport.GetFirstSubNodeValue(xitem, "date", false);

#if false
            result.Title = XmlSupport.XmlSupport.GetFirstSubNodeValue(xitem, "channelName", false);
            result.Title = XmlSupport.XmlSupport.GetFirstSubNodeValue(xitem, "date", false); // iso8601
            result.Title = XmlSupport.XmlSupport.GetFirstSubNodeValue(xitem, "objectType", false);
            result.Title = XmlSupport.XmlSupport.GetFirstSubNodeValue(xitem, "groupID", false);
            result.Title = XmlSupport.XmlSupport.GetFirstSubNodeValue(xitem, "storageMedium", false);
#endif

            var res = XmlSupport.GetFirstSubNode(xitem, "res", false);
            if (res != null)
            {
                result.ProtocolInfo = XmlSupport.GetAttributeValue(res, "protocolInfo", false);
                result.Resolution   = XmlSupport.GetAttributeValue(res, "resolution", false);
                help = XmlSupport.GetAttributeValue(res, "size", false);
                if (!string.IsNullOrEmpty(help))
                {
                    result.Size = long.Parse(help);
                } // if

                help = XmlSupport.GetAttributeValue(res, "bitrate", false);
                if (!string.IsNullOrEmpty(help))
                {
                    result.Bitrate = int.Parse(help);
                } // if

                result.Duration = XmlSupport.GetAttributeValue(xitem, "duration", false);
                help            = XmlSupport.GetAttributeValue(res, "nrAudioChannels", false);
                if (!string.IsNullOrEmpty(help))
                {
                    result.NumAudioChannels = int.Parse(help);
                } // if

                help = XmlSupport.GetAttributeValue(res, "sampleFrequency", false);
                if (!string.IsNullOrEmpty(help))
                {
                    result.SampleFrequency = int.Parse(help);
                } // if

                result.Resource = res.Value;
            } // if

            return(result);
        } // ParseDidlItemMetaData()
Example #2
0
        } // FindTreeNode()

        /// <summary>
        /// Called when a service has been found.
        /// </summary>
        /// <param name="nodeDevice">The node device.</param>
        /// <param name="upnpDevice">The <c>UPnP</c> device.</param>
        /// <param name="service">The service.</param>
        private async void OnServiceFound(TreeNode nodeDevice, UpnpDevice upnpDevice, UpnpService service)
        {
            try
            {
                var url  = UPNP.BuildUrl(upnpDevice, service.ScpdUrl);
                var text = await UPNP.GetRemoteTextFile(url);

                var serviceDescription = UPNP.ParseServiceSchema(text);
                service.UpdateServiceInfo(serviceDescription);
                service.ScpdUrl     = url;
                service.ControlUrl  = UPNP.BuildUrl(upnpDevice, service.ControlUrl);
                service.EventSubURL = UPNP.BuildUrl(upnpDevice, service.EventSubURL);

#if SHOW_SEARCH_RESULTS
                log.Info($"        {service.Type}");
#endif

                if ((service.Actions.Count == 0) && (service.StateVariables.Count == 0))
                {
                    // seems to be a dummy service
                    return;
                } // if

                var tn = AddServiceNode(nodeDevice, service);
                foreach (var action in service.Actions)
                {
                    action.Service = service;
                    this.OnActionFound(tn, action);
                } // foreach
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
            } // catch
        }     // OnServiceFound()
Example #3
0
 /// <summary>
 /// Stops UPNP if it is active
 /// </summary>
 protected void StopUPNP()
 {
     ExternalAddress = "";
     if (ServerUPNP != null)
     {
         ServerUPNP.DeletePortMapping(UPNPPort);
         ServerUPNP.Free();
         ServerUPNP = null;
     }
 }
Example #4
0
        /// <summary>
        /// Initialize UPNP
        /// </summary>
        /// <param name="Port">The port</param>
        /// <returns>The UPNP object</returns>
        protected UPNP InitUPNP(int Port)
        {
            UPNP NewUPNP = new UPNP();

            UPNP.UPNPResult DiscoverResult = (UPNP.UPNPResult)NewUPNP.Discover();
            MDLog.Info(LOG_CAT, $"UPNP Result for Discover is {DiscoverResult}");
            UPNP.UPNPResult MappingResult = (UPNP.UPNPResult)NewUPNP.AddPortMapping(Port);
            MDLog.Info(LOG_CAT, $"UPNP Result for Mapping Port {Port} is {MappingResult}");
            ExternalAddress = NewUPNP.QueryExternalAddress();
            MDLog.Info(LOG_CAT, $"UPNP External address found [{ExternalAddress}]");
            return(NewUPNP);
        }
Example #5
0
        private void ServerOnStarted()
        {
            if (GameInstance.UseUPNP())
            {
                ServerUPNP = InitUPNP(UPNPPort);
            }

            MDLog.Info(LOG_CAT, "Server started");
#if !GODOT_SERVER
            OnPlayerJoined_Internal(SERVER_ID);
            MDPlayerInfo PlayerInfo = GetPlayerInfo(SERVER_ID);
            if (PlayerInfo != null)
            {
                PlayerInfo.BeginInitialization();
            }
#endif
            OnSessionStartedEvent();
            IsSessionStarted = true;
        }
Example #6
0
    // Main menu network controls:
    public void OnHostPressed()
    {
        ClientVariables.SaveMainMenu();
        if (ClientVariables.NetworkOptions.UseUPNP)
        {
            UPNP            upnp     = new UPNP();
            UPNP.UPNPResult resultV4 = (UPNP.UPNPResult)upnp.Discover(2000, 2, "InternetGatewayDevice");
            if (resultV4 == UPNP.UPNPResult.Success)
            {
                GD.Print("Will attempt to add port-forward with upnp ip v4");
                upnp.AddPortMapping(ClientVariables.NetworkOptions.Port);
            }
            else
            {
                upnp.DiscoverIpv6 = true;
                UPNP.UPNPResult resultV6 = (UPNP.UPNPResult)upnp.Discover(2000, 2, "InternetGatewayDevice");
                if (resultV6 == UPNP.UPNPResult.Success)
                {
                    GD.Print("Will attemt to add port-forward with upnp ip v6");
                    upnp.AddPortMapping(ClientVariables.NetworkOptions.Port);
                }
            }
        }
        var   peer   = new NetworkedMultiplayerENet();
        Error result = peer.CreateServer(ClientVariables.NetworkOptions.Port);

        if (result == Error.Ok)
        {
            GetTree().NetworkPeer = peer;
            Global.GotoScene("res://Session/Session.tscn");
        }
        else
        {
            GD.Print(result);
            GD.Print("On port:" + ClientVariables.NetworkOptions.Port);
        }
    }
Example #7
0
        } // TreeViewDevicesAfterSelect()

        #endregion // UI HANDLING
        //// ---------------------------------------------------------------------

        #region PRIVATE METHODS
        /// <summary>
        /// Called when a device has been found.
        /// </summary>
        /// <param name="upnpDevice">The <c>UPnP</c> device.</param>
        private async void OnDeviceFound(UpnpDevice upnpDevice)
        {
            try
            {
                var text = await UPNP.GetRemoteTextFile(upnpDevice.Location);

                upnpDevice.DeviceDescription = UPNP.ParseDeviceSchema(text);

                Image image = null;
                var   icon  = upnpDevice.DeviceDescription.Icons.FirstOrDefault(x => x.Height == 48);
                if (icon != null)
                {
                    var url = UPNP.BuildUrl(upnpDevice, icon.URL);
                    image = await UPNP.GetRemoteImageFile(url);
                } // if

                var node = this.AddDevice(upnpDevice, this.root, image);
                this.AddSubDevices(upnpDevice, node, image);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
            } // catch
        }     // OnDeviceFound()
 public PlaylistManagement(UPNP.UNPN _upnpStack = null)
     : base(_upnpStack)
 {
 }
 public PlaylistBrowser(UPNP.UNPN _upnpStack = null)
     : base(PlaylistRootContainerId, _upnpStack)
 {
 }
Example #10
0
 public ContentDirectoryBrowser(string _rootContainerId = "", UPNP.UNPN _upnpStack = null)
     : base(_upnpStack)
 {
     rootContainerId = _rootContainerId;
 }
Example #11
0
 public RendererManager(UPNP.UNPN _upnpStack)
     : base(_upnpStack)
 {
     renderers = new Dictionary<string, Renderer.Renderer>();
 }
Example #12
0
 public MediaServerManager(UPNP.UNPN _upnpStack)
     : base(_upnpStack)
 {
 }
Example #13
0
 public MediaListManager(UPNP.UNPN _upnpStack)
     : base(_upnpStack)
 {
     lists = new Dictionary<String, UPNPMediaList>();
 }
Example #14
0
 public ZoneTitleListManager(UPNP.UNPN _upnpStack)
     : base(_upnpStack)
 {
 }
Example #15
0
 public ContentDirectoryBrowserMulti(String _rootListId = "", UPNP.UNPN _upnpStack = null)
     : base(_rootListId, _upnpStack)
 {
     dictCurListIdContent = new Dictionary<ContentDirectoryMainContentType, String>();
     dictCurListIdSearchParent = new Dictionary<ContentDirectoryMainContentType, String>();
 }
Example #16
0
 public ZoneManager(UPNP.UNPN _upnpStack)
     : base(_upnpStack)
 {
     zones = new Dictionary<string, Zone>();
     rooms = new Dictionary<string, Room>();
 }
Example #17
-1
 public ConfigManager(UPNP.UNPN _upnpStack)
     : base(_upnpStack)
 {
 }