Esempio n. 1
0
 private void Sink_OnServerRemoved(MediaServerDiscovery sender, CpMediaServer server)
 {
     if (this.OnMediaServersChanged != null)
     {
         this.OnMediaServersChanged(this);
     }
 }
Esempio n. 2
0
        protected String getMediaServerIP(CpMediaServer _mediaServer)
        {
            if (_mediaServer == null)
            {
                return(String.Empty);
            }

            this.writeLog(LogType.Info, "Auflösen der Raumfeld-MedienServer IP");

            Uri url = new Uri(mediaServer.Location);

            try
            {
                IPAddress address = IPAddress.Parse(url.Host);
                return(address.ToString());
            }
            catch (Exception e)
            {
                this.writeLog(LogType.Warning, String.Format("IP-Adresse konnte nicht aufgelöst werden. Host: {0} Suche über DNS", url.Host), e);
            }

            try
            {
                IPHostEntry hostEntry = Dns.GetHostEntry(url.Host);
                return(hostEntry.AddressList[0].ToString());
            }
            catch (Exception e)
            {
                this.writeLog(LogType.Error, String.Format("IP-Adresse konnte nicht per DNS aufgelöst werden. Host: {0}", url.Host), e);
                // this is a fatal error! App hast to crash!
                throw new Exception(Global.getCrashInfo());
            }
        }
 private void Sink_OnServerAdded(MediaServerDiscovery sender, CpMediaServer server)
 {
     if (this.OnMediaServersChanged != null)
     {
         this.OnMediaServersChanged(this);
     }
 }
 public void Browse(CpMediaServer server, System.String ObjectID, Intel.UPNP.AV.CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag BrowseFlag, System.String Filter, System.UInt32 StartingIndex, System.UInt32 RequestedCount, System.String SortCriteria, object _Tag, Delegate_OnBrowseDone _Callback)
 {
     _RequestState state = new _RequestState();
     state.Callback = _Callback;
     state.Tag = _Tag;
     state.Server = server;
     server.ContentDirectory.Browse(ObjectID, BrowseFlag, Filter, StartingIndex, RequestedCount, SortCriteria, state, new Intel.UPNP.AV.CpContentDirectory.Delegate_OnResult_Browse(_OnBrowseDone));
 }
Esempio n. 5
0
        public void Browse(CpMediaServer server, System.String ObjectID, Intel.UPNP.AV.CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag BrowseFlag, System.String Filter, System.UInt32 StartingIndex, System.UInt32 RequestedCount, System.String SortCriteria, object _Tag, Delegate_OnBrowseDone _Callback)
        {
            _RequestState state = new _RequestState();

            state.Callback = _Callback;
            state.Tag      = _Tag;
            state.Server   = server;
            server.ContentDirectory.Browse(ObjectID, BrowseFlag, Filter, StartingIndex, RequestedCount, SortCriteria, state, new Intel.UPNP.AV.CpContentDirectory.Delegate_OnResult_Browse(_OnBrowseDone));
        }
Esempio n. 6
0
        protected void mediaServerRemovedSink(CpMediaServer _mediaServer)
        {
            this.writeLog(LogType.Info, String.Format("MediaServer '{0}' verloren", _mediaServer.ServerFriendlyName));

            if (_mediaServer.ServerFriendlyName != raumfeldMediaServerDeviceName)
            {
                return;
            }

            mediaServer      = null;
            contentDirectory = null;
            if (mediaServerRemoved != null)
            {
                mediaServerRemoved();
            }
        }
Esempio n. 7
0
        protected void mediaServerFoundSink(CpMediaServer _mediaServer)
        {
            this.writeLog(LogType.Info, String.Format("MediaServer '{0}' gefunden", _mediaServer.ServerFriendlyName));

            if (_mediaServer.ServerFriendlyName != raumfeldMediaServerDeviceName)
            {
                return;
            }

            mediaServer               = _mediaServer;
            mediaServerIpAddress      = this.getMediaServerIP(mediaServer);
            mediaServerRequestUriBase = this.getMediaServerRequestUri();

            contentDirectory = mediaServer.contentDirectory;
            contentDirectory.onStateVariableContainerUpdateIds += contentDirectory_onStateVariableContainerUpdateIds;

            this.writeLog(LogType.Info, String.Format("Medienserver IP: '{0}', RequestUrl: '{1}'", mediaServerIpAddress, mediaServerRequestUriBase));

            if (mediaServerFound != null)
            {
                mediaServerFound();
            }
        }
        private void Sink_OnBrowse(CpMediaServer server, System.String ObjectID, Intel.UPNP.AV.CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag BrowseFlag, System.String Filter, System.UInt32 StartingIndex, System.UInt32 RequestedCount, System.String SortCriteria, UPnPInvokeException e, Exception parseError, object _Tag, IUPnPMedia[] Result, System.UInt32 NumberReturned, System.UInt32 TotalMatches, System.UInt32 UpdateID)
        {
            if (server == this.m_Server)
            {
                if (ObjectID == this.m_Context)
                {
                    if (_Tag == this.m_Container)
                    {
                        if ((e != null) || (parseError != null))
                        {
                            //error encountered
                        }
                        else
                        {
                            // add children
                            this.m_Children.AddRange(Result);
                            this.m_Container.AddObjects(Result, true);

                            if (this.OnIncrementalUpdate != null)
                            {
                                this.OnIncrementalUpdate(this, Result);
                            }

                            if (
                                ((this.m_Children.Count == TotalMatches) && (NumberReturned > 0)) ||
                                ((TotalMatches == 0) && (NumberReturned > 0))
                                )
                            {
                                // more items to come
                                this.m_CurrentIndex = NumberReturned;
                                DoNextBrowse();
                            }
                            else
                            {
                                lock (this)
                                {
                                    // no more items, prune children from m_Container
                                    ArrayList remove = new ArrayList();
                                    foreach (IUPnPMedia m1 in this.m_Container.CompleteList)
                                    {
                                        bool found = false;
                                        foreach (IUPnPMedia m2 in this.m_Children)
                                        {
                                            if (m1 == m2)
                                            {
                                                found = true;
                                                break;
                                            }
                                        }
                                        if (found == false)
                                        {
                                            remove.Add(m1);
                                        }
                                    }
                                    this.m_Container.RemoveObjects(remove);
                                }

                                if (this.OnRefreshComplete != null)
                                {
                                    IUPnPMedia[] list = (IUPnPMedia[])this.m_Children.ToArray(typeof(IUPnPMedia));
                                    this.OnRefreshComplete(this, list);
                                }
                            }
                        }
                    }
                }
            }
        }
        private void Sink_OnBrowse(CpMediaServer server, System.String ObjectID, Intel.UPNP.AV.CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag BrowseFlag, System.String Filter, System.UInt32 StartingIndex, System.UInt32 RequestedCount, System.String SortCriteria, UPnPInvokeException e, Exception parseError, object _Tag, IUPnPMedia[] Result, System.UInt32 NumberReturned, System.UInt32 TotalMatches, System.UInt32 UpdateID)
        {
            if (server == this.m_Server)
            {
                if (ObjectID == this.m_Context)
                {
                    if (_Tag == this.m_Container)
                    {
                        if ((e != null) || (parseError != null))
                        {
                            //error encountered
                        }
                        else
                        {
                            // add children
                            this.m_Children.AddRange(Result);
                            this.m_Container.AddObjects(Result, true);

                            if (this.OnIncrementalUpdate != null)
                            {
                                this.OnIncrementalUpdate(this, Result);
                            }

                            if (
                                ((this.m_Children.Count == TotalMatches) && (NumberReturned > 0)) ||
                                ((TotalMatches == 0) && (NumberReturned > 0))
                                )
                            {
                                // more items to come
                                this.m_CurrentIndex = NumberReturned;
                                DoNextBrowse();
                            }
                            else
                            {
                                lock (this)
                                {
                                    // no more items, prune children from m_Container
                                    ArrayList remove = new ArrayList();
                                    foreach (IUPnPMedia m1 in this.m_Container.CompleteList)
                                    {
                                        bool found = false;
                                        foreach (IUPnPMedia m2 in this.m_Children)
                                        {
                                            if (m1 == m2)
                                            {
                                                found = true;
                                                break;
                                            }
                                        }
                                        if (found == false)
                                        {
                                            remove.Add(m1);
                                        }
                                    }
                                    this.m_Container.RemoveObjects(remove);
                                }

                                if (this.OnRefreshComplete != null)
                                {
                                    IUPnPMedia[] list = (IUPnPMedia[]) this.m_Children.ToArray(typeof(IUPnPMedia));
                                    this.OnRefreshComplete(this, list);
                                }
                            }
                        }
                    }
                }
            }
        }