public PlaybackControl(IUPnP sink) { UPnPSink = sink; Player = new MPlayerWrapper(); PlayQueueHandler = new PlayqueueHandler(); XMLconverter = new XMLReader1(); SubscribeToWrapper(); SubscribeToSink(); }
public Detect() { ProgressChanged = new ProgressChange(OnProgressChanged); SuccessChanged = new ProgressChange(OnSuccessChanged); UpdateBase = new FmdcEventHandler(OnUpdateBase); upnp = new UPnP(this); upnp.ProtocolUPnP.Update += new FmdcEventHandler(OnUPnPUpdate); Port = 31173; }
public Detect() { ProgressChanged = new ProgressChange(OnProgressChanged); SuccessChanged = new ProgressChange(OnSuccessChanged); UpdateBase = new FmdcEventHandler(OnUpdateBase); // We are only interested to find the IGD device. upnp = new UPnP(this, "urn:schemas-upnp-org:service:WANIPConnection:1"); upnp.ProtocolUPnP.Update += new FmdcEventHandler(OnUPnPUpdate); Port = 31173; }
/// <summary> /// Constructor. Creates Audio Player Wrapper, XMLreader and XMLwriter and subscribes to wrapper and UPnP Sink /// </summary> /// <param name="sink">UPnP Sink</param> /// <param name="pqhandl">Playqueue Handler</param> public PlaybackControl(IUPnP sink, IPlayqueueHandler pqhandl) { UPnPSink = sink; Player = new MPlayerWrapper(); PlayQueueHandler = pqhandl; XMLconverter = new XMLReader.XMLReader(); wr = new XMLWriter(); SubscribeToWrapper(); SubscribeToSink(); _TransportState = "STOPPED"; }
public DBHandle(IUPnP sourceDevice) { _sourceDevice = sourceDevice; _sourceDevice.ActionEvent += _sourceDevice_ActionEvent; _dbXmlWriter = new XMLWriterPi(); _dbLookup = new DBLookup(); CreateDictionary(); }
protected virtual void OnUPnPUpdate(object sender, FmdcEventArgs e) { IUPnP upnp = sender as IUPnP; FlowLib.Containers.UPnP.UPnPDevice device = e.Data as FlowLib.Containers.UPnP.UPnPDevice; if (upnp != null && device != null) { switch (e.Action) { case Actions.UPnPRootDeviceFound: //FlowLib.Events.FmdcEventArgs e3 = new FlowLib.Events.FmdcEventArgs(Actions.UPnPDeviceDescription, device.Information.Sender.ToString()); //UpdateBase(this, e3); Success |= Functions.UPnPDevices; break; case Actions.UPnPDeviceUpdated: foreach (ServiceBase service in device.Services) { if (WANIPConnectionService.IsMatching(service)) { #region Retreive internal ip if (this.InternalIP == null) { string routerIP = ((IPEndPoint)device.Information.Sender).Address.ToString(); string[] secRouter = routerIP.Split('.', ':'); System.Net.IPHostEntry hostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()); if (hostEntry != null) { System.Net.IPAddress[] collectionOfIPs = hostEntry.AddressList; for (int i = 0; i < collectionOfIPs.Length; i++) { System.Net.IPAddress ip = collectionOfIPs[i]; string[] secIP = ip.ToString().Split('.', ':'); bool found = true; for (int y = 0; y < secRouter.Length - 1; y++) { if (secIP.Length > y) { if (!secRouter[y].Equals(secIP[y])) { found = false; break; } } } if (found) { InternalIP = ip; } } } } #endregion if (InternalIP != null) { wanipService = new WANIPConnectionService(service); #region GetExternalIPAddress try { Progress = Functions.UPnPExternalIp; IPAddress tmpAddress = wanipService.GetExternalIPAddress(this); if (tmpAddress != null) { // Is ExternalIP different then the one we got from router? ExternalIPUPnP = tmpAddress; if (ExternalIP == null) { ExternalIP = ExternalIPUPnP; } Success |= Functions.UPnPExternalIp; } } catch { } #endregion #region AddPortMapping Progress = Functions.UPnPAddMapping; mapping = new WANIPConnectionService.PortMapping( string.Empty, Port, "TCP", Port, InternalIP.ToString(), true, "FlowLibPowered - Connection Detection", /*"FlowLibPowered",*/ 0 ); bool hasAddPortMapping = false; if (hasAddPortMapping = wanipService.AddPortMapping(this, mapping)) { Success |= Functions.UPnPAddMapping; } #endregion #region GetSpecificPortMappingEntry Progress = Functions.UPnPGetMapping; if (hasAddPortMapping) { if (wanipService.GetSpecificPortMappingEntry(this, ref mapping)) { Success |= Functions.UPnPGetMapping; } } #endregion #region DeletePortMapping Progress = Functions.UPnPDeleteMapping; if (hasAddPortMapping) { if (wanipService.DeletePortMapping(this, mapping)) { Success |= Functions.UPnPDeleteMapping; } } #endregion } } Success |= Functions.UPnPIGD; //Progress = Functions.End; } break; } } }
//public event PropertyChangedDel propEvent; /// <summary> /// Constructor /// Creates associations between the class, The UPnP device and the playqueue handler. /// </summary> /// <param name="sourceDevice">UPnP Source device communicating with control points</param> /// <param name="pqhandl">Handler containing and managing the playqueue</param> public DBHandle(IUPnP sourceDevice, IPlayqueueHandler pqhandl) { _sourceDevice = sourceDevice; _sourceDevice.ActionEvent += _sourceDevice_ActionEvent; _dbXmlWriter = new XMLWriter(); _dbLookup = new DBLookup(); _PQHandler = pqhandl; CreateDictionary(); }