예제 #1
0
        /// <summary>
        /// Enters the CI menu
        /// </summary>
        /// <returns></returns>
        public bool EnterCIMenu()
        {
            IKsControl pControl = CiFilter as IKsControl;

            if (pControl == null)
            {
                return(false);
            }

            KSMETHOD KsMethod = new KSMETHOD(KSMETHODSET_DD_CAM_CONTROL,
                                             (Int32)KSMETHOD_DD_CAM_CONTROL.KSMETHOD_DD_CAM_ENTER_MENU,
                                             KSMETHOD_TYPE_SEND);

            Int32 dwReturned = 0;
            Int32 hr         = pControl.KsMethod(ref KsMethod, Marshal.SizeOf(KsMethod),
                                                 IntPtr.Zero, 0,
                                                 ref dwReturned
                                                 );

            if (hr == 0)
            {
                _MenuId = 0; // reset
            }
            return(hr == 0);
        }
예제 #2
0
        /// <summary>
        /// Sends an answer after CI request
        /// </summary>
        /// <param name="Cancel">true to cancel</param>
        /// <param name="Answer">Answer string</param>
        /// <returns></returns>
        public bool SendMenuAnswer(bool Cancel, string Answer)
        {
            IKsControl pControl = CiFilter as IKsControl;

            if (pControl == null)
            {
                return(false);
            }

            // Initialize unmanged memory to hold the struct.
            Int32 answerLength = (String.IsNullOrEmpty(Answer) ? 0 : Answer.Length);
            Int32 bufferSize   = 8 + answerLength + 1;

            if (bufferSize < 12)
            {
                bufferSize = 12;
            }

            IntPtr pReply = Marshal.AllocHGlobal(bufferSize);

            try
            {
                // Copy the struct to unmanaged memory.
                Marshal.WriteInt32(pReply, 0, _MenuId);
                if (answerLength > 0)
                {
                    Marshal.WriteInt32(pReply, 4, (int)Answer.Length);
                    for (int i = 0; i < Answer.Length; i += 1)
                    {
                        Marshal.WriteByte(pReply, 8 + i, (byte)Answer[i]);
                    }
                    Marshal.WriteByte(pReply, 8 + Answer.Length, 0);
                }
                else
                {
                    Marshal.WriteInt32(pReply, 4, 0);
                }

                //DVB_MMI.DumpBinary(pReply, 0, bufferSize);

                KSMETHOD KsMethod = new KSMETHOD(KSMETHODSET_DD_CAM_CONTROL,
                                                 (Int32)KSMETHOD_DD_CAM_CONTROL.KSMETHOD_DD_CAM_ANSWER,
                                                 KSMETHOD_TYPE_SEND);
                Int32 dwReturned = 0;
                Int32 hr         = pControl.KsMethod(ref KsMethod, Marshal.SizeOf(KsMethod),
                                                     pReply, bufferSize,
                                                     ref dwReturned
                                                     );
                return(hr == 0);
            }
            finally
            {
                // Free the unmanaged memory.
                Marshal.FreeHGlobal(pReply);
            }
        }
예제 #3
0
        /// <summary>
        /// Resets the CAM.
        /// </summary>
        /// <returns></returns>
        public bool ResetCAM()
        {
            IKsControl pControl = CiFilter as IKsControl;

            if (pControl == null)
            {
                return(false);
            }

            KSMETHOD KsMethod = new KSMETHOD(KSMETHODSET_DD_CAM_CONTROL,
                                             (Int32)KSMETHOD_DD_CAM_CONTROL.KSMETHOD_DD_CAM_RESET,
                                             KSMETHOD_TYPE_SEND);

            Int32 dwReturned = 0;
            Int32 hr         = pControl.KsMethod(ref KsMethod, Marshal.SizeOf(KsMethod),
                                                 IntPtr.Zero, 0,
                                                 ref dwReturned
                                                 );

            return(hr == 0);
        }
예제 #4
0
        /// <summary>
        /// Selects a CI menu entry
        /// </summary>
        /// <param name="choice">choice</param>
        /// <returns></returns>
        public bool SelectMenu(byte choice)
        {
            IKsControl pControl = CiFilter as IKsControl;

            if (pControl == null)
            {
                return(false);
            }

            DD_CAM_MENU_REPLY Reply;

            Reply.Id     = _MenuId;
            Reply.Choice = choice;

            // Initialize unmanged memory to hold the struct.
            IntPtr pReply = Marshal.AllocHGlobal(Marshal.SizeOf(Reply));

            try
            {
                // Copy the struct to unmanaged memory.
                Marshal.StructureToPtr(Reply, pReply, false);

                KSMETHOD KsMethod = new KSMETHOD(KSMETHODSET_DD_CAM_CONTROL,
                                                 (Int32)KSMETHOD_DD_CAM_CONTROL.KSMETHOD_DD_CAM_MENU_REPLY,
                                                 KSMETHOD_TYPE_SEND);
                Int32 dwReturned = 0;
                Int32 hr         = pControl.KsMethod(ref KsMethod, Marshal.SizeOf(KsMethod),
                                                     pReply, Marshal.SizeOf(Reply),
                                                     ref dwReturned
                                                     );
                return(hr == 0);
            }
            finally
            {
                // Free the unmanaged memory.
                Marshal.FreeHGlobal(pReply);
            }
        }
예제 #5
0
        private bool GetCamMenuText(out DD_CAM_MENU_DATA CiMenu)
        {
            CiMenu = new DD_CAM_MENU_DATA();
            IKsControl pControl = CiFilter as IKsControl;

            if (pControl == null)
            {
                return(false);
            }

            // Initialize unmanged memory to hold the struct.
            Int32  ulMenuSize = 2048;
            IntPtr pCiMenu    = Marshal.AllocHGlobal(ulMenuSize);

            try
            {
                KSMETHOD KsMethod = new KSMETHOD(KSMETHODSET_DD_CAM_CONTROL,
                                                 (Int32)KSMETHOD_DD_CAM_CONTROL.KSMETHOD_DD_CAM_GET_MENU,
                                                 KSMETHOD_TYPE_SEND);
                Int32 dwReturned = 0;
                Int32 hr         = pControl.KsMethod(ref KsMethod, Marshal.SizeOf(KsMethod),
                                                     pCiMenu, ulMenuSize,
                                                     ref dwReturned
                                                     );
                if (hr == 0)
                {
                    Int32 offs = 0;
                    CiMenu.Id         = Marshal.ReadInt32(pCiMenu, offs);
                    offs             += 4;
                    CiMenu.Type       = Marshal.ReadInt32(pCiMenu, offs);
                    offs             += 4;
                    CiMenu.NumChoices = Marshal.ReadInt32(pCiMenu, offs);
                    offs             += 4;
                    CiMenu.Length     = Marshal.ReadInt32(pCiMenu, offs);
                    offs             += 4;

                    // check if we already received this menu, then ignore it.
                    // otherwise we would do an endless processing.
                    if (CiMenu.Id == _MenuId)
                    {
                        return(false);
                    }

                    //DVB_MMI.DumpBinary(pCiMenu, 0, dwReturned);

                    CiMenu.Choices = new List <String>();
                    for (int i = 0; i < CiMenu.NumChoices + 3; i++)
                    {
                        IntPtr newPtr = new IntPtr(pCiMenu.ToInt32() + offs);
                        String choice = Marshal.PtrToStringAnsi(newPtr);
                        switch (i)
                        {
                        case 0:
                            CiMenu.Title = choice;
                            break;

                        case 1:
                            CiMenu.SubTitle = choice;
                            break;

                        case 2:
                            CiMenu.BottomText = choice;
                            break;

                        default:
                            CiMenu.Choices.Add(choice);
                            break;
                        }
                        offs += choice.Length + 1;
                    }
                    // remember current received menu id
                    _MenuId = CiMenu.Id;
                }
                //else
                //  Marshal.ThrowExceptionForHR(hr);

                return(hr == 0);
            }
            finally
            {
                // Free the unmanaged memory.
                Marshal.FreeHGlobal(pCiMenu);
            }
        }