Пример #1
0
 public int GetCurrentConnectionInfo(System.Int32 ConnectionID)
 {
     UPnPArgument[] args = new UPnPArgument[8];
     args[0] = new UPnPArgument("ConnectionID", ConnectionID);
     args[1] = new UPnPArgument("RcsID", "");
     args[2] = new UPnPArgument("AVTransportID", "");
     args[3] = new UPnPArgument("ProtocolInfo", "");
     args[4] = new UPnPArgument("PeerConnectionManager", "");
     args[5] = new UPnPArgument("PeerConnectionID", "");
     args[6] = new UPnPArgument("Direction", "");
     args[7] = new UPnPArgument("Status", "");
     return(_S.InvokeAsync("GetCurrentConnectionInfo", args, new UPnPService.UPnPServiceInvokeHandler(Sink_GetCurrentConnectionInfo), new UPnPService.UPnPServiceInvokeErrorHandler(Error_Sink_GetCurrentConnectionInfo)));
 }
 public void GetCurrentConnectionInfo(System.Int32 ConnectionID, object _Tag, Delegate_OnResult_GetCurrentConnectionInfo _Callback)
 {
     UPnPArgument[] args = new UPnPArgument[8];
     args[0] = new UPnPArgument("ConnectionID", ConnectionID);
     args[1] = new UPnPArgument("RcsID", "");
     args[2] = new UPnPArgument("AVTransportID", "");
     args[3] = new UPnPArgument("ProtocolInfo", "");
     args[4] = new UPnPArgument("PeerConnectionManager", "");
     args[5] = new UPnPArgument("PeerConnectionID", "");
     args[6] = new UPnPArgument("Direction", "");
     args[7] = new UPnPArgument("Status", "");
     _S.InvokeAsync("GetCurrentConnectionInfo", args, new object[2] {
         _Tag, _Callback
     }, new UPnPService.UPnPServiceInvokeHandler(Sink_GetCurrentConnectionInfo), new UPnPService.UPnPServiceInvokeErrorHandler(Error_Sink_GetCurrentConnectionInfo));
 }
Пример #3
0
        /// <summary>
        /// 投屏
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void proj_Click(object sender, RoutedEventArgs e)
        {
            string uri = this.resourceUri.Text;

            if (string.IsNullOrEmpty(uri) || ResourceIsDefault())
            {
                MessageBox.Show("请填入正确的资源URI");
                return;
            }

            var device = this.deviceList.SelectedItem as UPnPDevice;

            if (device == null)
            {
                MessageBox.Show("请选择要投的设备");
                return;
            }

            try
            {
                UPnPService service = device.GetService("AVTransport");
                if (service == null)
                {
                    MessageBox.Show("设备无投屏功能");
                    return;
                }

                this.instanceID++;
                UPnPAction   transportAction = service.GetAction("SetAVTransportURI");
                UPnPArgument instanceID      = transportAction.GetArg("InstanceID");
                instanceID.DataValue = this.instanceID;
                UPnPArgument currentURI = transportAction.GetArg("CurrentURI");
                currentURI.DataValue = uri;

                UPnPArgument current = transportAction.GetArg("CurrentURIMetaData");
                current.DataValue = string.Empty;
                service.InvokeAsync(transportAction.Name, new[] { instanceID, currentURI, current });


                UPnPAction   playAction = service.GetAction("Play");
                UPnPArgument speed      = playAction.GetArg("Speed");
                service.InvokeAsync(playAction.Name, new[] { instanceID, speed });
            }
            catch (Exception ex)
            {
                MessageBox.Show("投屏失败," + ex.Message);
            }
        }
        public void InvokeAsync(UPnPService S, string Action, byte[] InArgs, string Caller, int Handle)
        {
            UPnPAction A     = S.GetAction(Action);
            ArrayList  AList = new ArrayList();

            foreach (UPnPArgument arg in A.ArgumentList)
            {
                if (arg.IsReturnValue == false && arg.Direction == "out")
                {
                    UPnPArgument _arg = (UPnPArgument)arg.Clone();
                    _arg.DataValue = UPnPService.CreateObjectInstance(arg.RelatedStateVar.GetNetType(), null);
                    AList.Add(_arg);
                }
            }

            UPnPArgument[] Temp = ParseArguments(InArgs);
            foreach (UPnPArgument _arg in Temp)
            {
                _arg.DataType  = A.GetArg(_arg.Name).RelatedStateVar.ValueType;
                _arg.Direction = "in";
                AList.Add(_arg);
            }

            UPnPArgument[] Arguments = (UPnPArgument[])AList.ToArray(typeof(UPnPArgument));

            (new UPnPDebugObject(S)).SetProperty("ValidationMode", false);
            S.InvokeAsync(Action, Arguments, new Object[2] {
                Caller, Handle
            }, A_ICB, A_IECB);
        }
        protected void InvokeSink(UPnPAction sender, UPnPArgument[] InArgs, out object RetVal, out UPnPArgument[] OutArgs)
        {
            UPnPService S = (UPnPService)ServiceTable[sender.ParentService];
            UPnPAction  A = S.GetAction(sender.Name);

            ArrayList TempList = new ArrayList();

            foreach (UPnPArgument arg in A.Arguments)
            {
                if ((arg.IsReturnValue == false) && (arg.Direction == "out"))
                {
                    TempList.Add(arg.Clone());
                }
            }

            foreach (UPnPArgument arg in InArgs)
            {
                TempList.Add(arg);
            }

            lock (CallQueue)
            {
                ++InvokeID;
                CallQueue.Enqueue(InvokeID);
                S.InvokeAsync(sender.Name, (UPnPArgument[])TempList.ToArray(typeof(UPnPArgument)),
                              InvokeID,
                              new UPnPService.UPnPServiceInvokeHandler(RealInvokeSink),
                              null);
                InvokeTable[InvokeID] = sender.ParentService;
            }

            UPnPArgument[] OtherArgs;
            sender.ParentService.DelayInvokeRespose(InvokeID, out OtherArgs);
            throw(new DelayedResponseException());
        }
        private void invokeButton_Click(object sender, System.EventArgs e)
        {
            DebugTextBox.Clear();
            UPnPArgs = null;
            ArrayList args = new ArrayList();

            if (argControlList != null)
            {
                for (int i = 0; i < argControlList.Length; ++i)
                {
                    if (argControlList[i].UPnPArgument.IsReturnValue == false)
                    {
                        if (argControlList[i].UPnPArgument.Direction == "in")
                        {
                            args.Add(new UPnPArgument(argControlList[i].UPnPArgument.Name, argControlList[i].ArgumentValue));
                        }
                        else
                        {
                            args.Add(new UPnPArgument(argControlList[i].UPnPArgument.Name, ""));
                        }
                    }
                }
            }

            UPnPArgs = (UPnPArgument[])args.ToArray(typeof(UPnPArgument));
            (new UPnPDebugObject(service)).SetProperty("ValidationMode", PreValidateMenuItem.Checked);


            invokeTime = DateTime.Now;
            try
            {
                service.InvokeAsync(action.Name, UPnPArgs,
                                    null,
                                    new UPnPService.UPnPServiceInvokeHandler(HandleInvoke),
                                    new UPnPService.UPnPServiceInvokeErrorHandler(HandleInvokeError));
                statusBar.Text = "Connecting and processing invocation...";
            }
            catch (UPnPInvokeException ie)
            {
                statusBar.Text = "UPnPInvokeException: " + ie.Message;
            }
        }