public Gatekeeper(int PortNumber)
        {
            A_ICB = new UPnPService.UPnPServiceInvokeHandler(A_InvokeSink);
            A_IECB = new UPnPService.UPnPServiceInvokeErrorHandler(A_InvokeErrorSink);

            Port = PortNumber;
            Root = UPnPDevice.CreateRootDevice(1000,1,"");
            Root.FriendlyName = "UPnPShare";

            Root.StandardDeviceType = "UPnPGateKeeper";
            DV = new DvGateKeeper();
            Root.AddService(DV);

            DV.External_Register = new DvGateKeeper.Delegate_Register(RegisterSink);
            DV.External_UnRegister = new DvGateKeeper.Delegate_UnRegister(UnRegisterSink);
            DV.External_GetDocument = new DvGateKeeper.Delegate_GetDocument(GetDocumentSink);
            DV.External_AddDevice = new DvGateKeeper.Delegate_AddDevice(AddDeviceSink);
            DV.External_RemoveDevice = new DvGateKeeper.Delegate_RemoveDevice(RemovedDeviceSink);
            DV.External_FireEvent = new DvGateKeeper.Delegate_FireEvent(FireEventSink);
            DV.External_GetStateTable = new DvGateKeeper.Delegate_GetStateTable(GetStateTableSink);

            DV.External_Invoke = new DvGateKeeper.Delegate_Invoke(InvokeSink);
            DV.External_InvokeAsync = new DvGateKeeper.Delegate_InvokeAsync(InvokeAsyncSink);
            DV.External_InvokeAsyncResponse = new DvGateKeeper.Delegate_InvokeAsyncResponse(InvokeAsyncResponseSink);

            (new UPnPDebugObject(Root)).SetField("NoSSDP",true);

            Root.StartDevice(PortNumber);
        }
        private void startMenuItem_Click(object sender, System.EventArgs e)
        {
            startMenuItem.Enabled = false;
            foreach (MenuItem i in pfcMenuItem.MenuItems) {i.Enabled = false;}
            foreach (MenuItem i in menuItem3.MenuItems) {i.Enabled = false;}
            InfoStringBox.Enabled = false;

            device = UPnPDevice.CreateRootDevice(900,1,"");
            device.UniqueDeviceName = Guid.NewGuid().ToString();
            device.StandardDeviceType = "MediaRenderer";
            device.FriendlyName = "Media Renderer (" + System.Net.Dns.GetHostName() + ")";
            device.HasPresentation = false;

            device.Manufacturer = "OpenSource";
            device.ManufacturerURL = "http://opentools.homeip.net/";
            device.PresentationURL = "/";
            device.HasPresentation = true;
            device.ModelName = "AV Renderer";
            device.ModelDescription = "Media Renderer Device";
            device.ModelURL = new Uri("http://opentools.homeip.net/");

            UPnPService ts = new UPnPService(1, "EmptyService", "EmptyService", true, this);
            ts.AddMethod("NullMethod");
            //device.AddService(ts);

            DText p = new DText();
            p.ATTRMARK = "\r\n";
            p[0] = this.InfoStringBox.Text;
            int len = p.DCOUNT();
            ProtocolInfoString[] istring = new ProtocolInfoString[len];
            for(int i=1;i<=len;++i)
            {
                istring[i-1] = new ProtocolInfoString(p[i]);
            }
            r = new AVRenderer(MaxConnections, istring, new AVRenderer.ConnectionHandler(NewConnectionSink));

            r.OnClosedConnection += new AVRenderer.ConnectionHandler(ClosedConnectionSink);

            if (supportRecordMenuItem.Checked == false)
            {
                r.AVT.RemoveAction_Record();
            }

            if (supportRecordQualityMenuItem.Checked == false)
            {
                r.AVT.RemoveAction_SetRecordQualityMode();
            }

            if (supportNextContentUriMenuItem.Checked == false)
            {
                r.AVT.RemoveAction_SetNextAVTransportURI();
            }

            if (MaxConnections == 0)
            {
                r.Manager.RemoveAction_PrepareForConnection();
                r.Manager.RemoveAction_ConnectionComplete();
            }

            r.AVT.GetUPnPService().GetStateVariableObject("CurrentPlayMode").AllowedStringValues = new String[3]{"NORMAL","REPEAT_ALL","INTRO"};

            r.Control.GetUPnPService().GetStateVariableObject("A_ARG_TYPE_Channel").AllowedStringValues = new String[3]{"Master","LF","RF"};
            r.Control.GetUPnPService().GetStateVariableObject("RedVideoBlackLevel").SetRange((ushort)0,(ushort)100,(ushort)1);
            r.Control.GetUPnPService().GetStateVariableObject("GreenVideoBlackLevel").SetRange((ushort)0,(ushort)100,(ushort)1);
            r.Control.GetUPnPService().GetStateVariableObject("BlueVideoBlackLevel").SetRange((ushort)0,(ushort)100,(ushort)1);
            r.Control.GetUPnPService().GetStateVariableObject("RedVideoGain").SetRange((ushort)0,(ushort)100,(ushort)1);
            r.Control.GetUPnPService().GetStateVariableObject("GreenVideoGain").SetRange((ushort)0,(ushort)100,(ushort)1);
            r.Control.GetUPnPService().GetStateVariableObject("BlueVideoGain").SetRange((ushort)0,(ushort)100,(ushort)1);

            r.Control.GetUPnPService().GetStateVariableObject("Brightness").SetRange((ushort)0,(ushort)100,(ushort)1);
            r.Control.GetUPnPService().GetStateVariableObject("Contrast").SetRange((ushort)0,(ushort)100,(ushort)1);
            r.Control.GetUPnPService().GetStateVariableObject("Sharpness").SetRange((ushort)0,(ushort)100,(ushort)1);
            r.Control.GetUPnPService().GetStateVariableObject("Volume").SetRange((UInt16)0,(UInt16)100,(ushort)1);

            device.AddService(r.Control);
            device.AddService(r.AVT);
            device.AddService(r.Manager);

            //device.AddDevice(r);

            device.StartDevice();

            //r.Start();
        }
Exemple #3
0
 public void CreateLocalDevice(string deviceGuid, string deviceType, string presentationUrl, string rootDirectory, string modelName, string modelDescription, string modelUrl, string modelNumber, string manufacturer, string manufacturerUrl)
 {
     if (localDevice != null)
     {
         localDevice.StopDevice();
         localDevice = null;
     }
     //
     IPHostEntry host;
     string localIP = "";
     host = Dns.GetHostEntry(Dns.GetHostName());
     foreach (var ip in host.AddressList)
     {
         if (ip.AddressFamily == AddressFamily.InterNetwork)
         {
             localIP = ip.ToString();
             break;
         }
     }
     localDevice = UPnPDevice.CreateRootDevice(900, 1, rootDirectory);
     //hgdevice.Icon = null;
     if (presentationUrl != "")
     {
         localDevice.HasPresentation = true;
         localDevice.PresentationURL = presentationUrl;
     }
     localDevice.FriendlyName = modelName + ": " + Environment.MachineName;
     localDevice.Manufacturer = manufacturer;
     localDevice.ManufacturerURL = manufacturerUrl;
     localDevice.ModelName = modelName;
     localDevice.ModelDescription = modelDescription;
     if (Uri.IsWellFormedUriString(manufacturerUrl, UriKind.Absolute))
     {
         localDevice.ModelURL = new Uri(manufacturerUrl);
     }
     localDevice.ModelNumber = modelNumber;
     localDevice.StandardDeviceType = deviceType;
     localDevice.UniqueDeviceName = deviceGuid;
     localDevice.StartDevice();
 }