Exemplo n.º 1
0
        //Initializes the Hauppauge interfaces

        /// <summary>
        /// Constructor: Require the Hauppauge capture filter, and the deviceid for the card to be passed in
        /// </summary>
        public Hauppauge(IBaseFilter filter, string tuner)
        {
            try
            {
                //Don't create the class if we don't have any filter;

                if (filter == null)
                {
                    return;
                }

                //Load Library
                hauppaugelib = LoadLibrary("hauppauge.dll");

                //Get Proc addresses, and set the delegates for each function
                IntPtr procaddr = GetProcAddress(hauppaugelib, "Init");
                _Init = (Init)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(Init));

                procaddr = GetProcAddress(hauppaugelib, "DeInit");
                _DeInit  = (DeInit)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(DeInit));

                procaddr     = GetProcAddress(hauppaugelib, "IsHauppauge");
                _IsHauppauge = (IsHauppauge)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(IsHauppauge));

                procaddr       = GetProcAddress(hauppaugelib, "SetVidBitRate");
                _SetVidBitRate = (SetVidBitRate)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(SetVidBitRate));

                procaddr       = GetProcAddress(hauppaugelib, "GetVidBitRate");
                _GetVidBitRate = (GetVidBitRate)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(GetVidBitRate));

                procaddr       = GetProcAddress(hauppaugelib, "SetAudBitRate");
                _SetAudBitRate = (SetAudBitRate)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(SetAudBitRate));

                procaddr       = GetProcAddress(hauppaugelib, "GetAudBitRate");
                _GetAudBitRate = (GetAudBitRate)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(GetAudBitRate));

                procaddr       = GetProcAddress(hauppaugelib, "SetStreamType");
                _SetStreamType = (SetStreamType)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(SetStreamType));

                procaddr       = GetProcAddress(hauppaugelib, "GetStreamType");
                _GetStreamType = (GetStreamType)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(GetStreamType));

                procaddr      = GetProcAddress(hauppaugelib, "SetDNRFilter");
                _SetDNRFilter = (SetDNRFilter)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(SetDNRFilter));

                //Hack
                //The following is strangely necessary when using delegates instead of P/Invoke - linked to MP using utf-8
                //Hack

                byte[] encodedstring = Encoding.UTF32.GetBytes(tuner);
                string card          = Encoding.Unicode.GetString(encodedstring);

                hr = new HResult(_Init(filter, card));
                Log.Log.WriteFile("Hauppauge Quality Control Initializing " + hr.ToDXString());
            }
            catch (Exception ex)
            {
                Log.Log.WriteFile("Hauppauge Init failed " + ex.Message);
            }
        }
Exemplo n.º 2
0
    //Initializes the Hauppauge interfaces

    /// <summary>
    /// Constructor: Require the Hauppauge capture filter, and the deviceid for the card to be passed in
    /// </summary>
    public Hauppauge(IBaseFilter filter, string tuner)
    {
      try
      {
        //Don't create the class if we don't have any filter;

        if (filter == null)
        {
          return;
        }

        //Load Library
        hauppaugelib = LoadLibrary("hauppauge.dll");

        //Get Proc addresses, and set the delegates for each function
        IntPtr procaddr = GetProcAddress(hauppaugelib, "Init");
        _Init = (Init)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (Init));

        procaddr = GetProcAddress(hauppaugelib, "DeInit");
        _DeInit = (DeInit)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (DeInit));

        procaddr = GetProcAddress(hauppaugelib, "IsHauppauge");
        _IsHauppauge = (IsHauppauge)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (IsHauppauge));

        procaddr = GetProcAddress(hauppaugelib, "SetVidBitRate");
        _SetVidBitRate = (SetVidBitRate)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (SetVidBitRate));

        procaddr = GetProcAddress(hauppaugelib, "GetVidBitRate");
        _GetVidBitRate = (GetVidBitRate)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (GetVidBitRate));

        procaddr = GetProcAddress(hauppaugelib, "SetAudBitRate");
        _SetAudBitRate = (SetAudBitRate)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (SetAudBitRate));

        procaddr = GetProcAddress(hauppaugelib, "GetAudBitRate");
        _GetAudBitRate = (GetAudBitRate)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (GetAudBitRate));

        procaddr = GetProcAddress(hauppaugelib, "SetStreamType");
        _SetStreamType = (SetStreamType)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (SetStreamType));

        procaddr = GetProcAddress(hauppaugelib, "GetStreamType");
        _GetStreamType = (GetStreamType)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (GetStreamType));

        procaddr = GetProcAddress(hauppaugelib, "SetDNRFilter");
        _SetDNRFilter = (SetDNRFilter)Marshal.GetDelegateForFunctionPointer(procaddr, typeof (SetDNRFilter));

        //Hack
        //The following is strangely necessary when using delegates instead of P/Invoke - linked to MP using utf-8
        //Hack

        byte[] encodedstring = Encoding.UTF32.GetBytes(tuner);
        string card = Encoding.Unicode.GetString(encodedstring);

        hr = new HResult(_Init(filter, card));
        Log.Log.WriteFile("Hauppauge Quality Control Initializing " + hr.ToDXString());
      }
      catch (Exception ex)
      {
        Log.Log.WriteFile("Hauppauge Init failed " + ex.Message);
      }
    }