Ejemplo n.º 1
0
        /// <summary>
        /// Process the MMI and do callbacks.
        /// </summary>
        /// <param name="CiMenu"></param>
        /// <returns></returns>
        private bool ProcessCamMenu(DD_CAM_MENU_DATA CiMenu)
        {
            Log.Log.Debug("Menu received (ID {0} Type {1} Choices {2})", CiMenu.Id, CiMenu.Type, CiMenu.NumChoices);
            //Log.Log.Debug(" Menu Id      = {0}", CiMenu.Id);
            //Log.Log.Debug(" Menu Type    = {0}", CiMenu.Type);
            //Log.Log.Debug(" Menu Choices = {0}", CiMenu.NumChoices);
            //Log.Log.Debug(" Menu Length  = {0}", CiMenu.Length);

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

            switch (CiMenu.Type)
            {
            case 1:
            case 2:
                ciMenuCallbacks.OnCiMenu(CiMenu.Title, CiMenu.SubTitle, CiMenu.BottomText, CiMenu.NumChoices);
                int n = 0;
                foreach (String choice in CiMenu.Choices)
                {
                    ciMenuCallbacks.OnCiMenuChoice(n++, choice);
                }
                break;

            case 3:
            case 4:
                ciMenuCallbacks.OnCiRequest(false, (uint)CiMenu.NumChoices, CiMenu.Title);
                break;

            default:
                Log.Log.Debug("Unknown MMI Type {0}", CiMenu.Type);
                break;
            }
            return(true);
        }
Ejemplo n.º 2
0
    /// <summary>
    /// Process the MMI and do callbacks.
    /// </summary>
    /// <param name="CiMenu"></param>
    /// <returns></returns>
    private bool ProcessCamMenu(DD_CAM_MENU_DATA CiMenu)
    {
      Log.Log.Debug("Menu received (ID {0} Type {1} Choices {2})", CiMenu.Id, CiMenu.Type, CiMenu.NumChoices);
      //Log.Log.Debug(" Menu Id      = {0}", CiMenu.Id);
      //Log.Log.Debug(" Menu Type    = {0}", CiMenu.Type);
      //Log.Log.Debug(" Menu Choices = {0}", CiMenu.NumChoices);
      //Log.Log.Debug(" Menu Length  = {0}", CiMenu.Length);

      if (ciMenuCallbacks == null)
        return false;

      switch (CiMenu.Type)
      {
        case 1:
        case 2:
          ciMenuCallbacks.OnCiMenu(CiMenu.Title, CiMenu.SubTitle, CiMenu.BottomText, CiMenu.NumChoices);
          int n = 0;
          foreach (String choice in CiMenu.Choices)
          {
            ciMenuCallbacks.OnCiMenuChoice(n++, choice);
          }
          break;
        case 3:
        case 4:
          ciMenuCallbacks.OnCiRequest(false, (uint)CiMenu.NumChoices, CiMenu.Title);
          break;
        default:
          Log.Log.Debug("Unknown MMI Type {0}", CiMenu.Type);
          break;
      }
      return true;
    }
Ejemplo n.º 3
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);
      }
    }
Ejemplo n.º 4
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);
            }
        }