Esempio n. 1
0
        /// <summary>
        /// Called to handle DVD event window messages.
        /// </summary>
        private void OnDvdEvent()
        {
            if (_mediaEvt == null || _dvdCtrl == null)
            {
                return;
            }

            IntPtr p1, p2;

            try
            {
                int hr;
                do
                {
                    IMediaEventEx eventEx = (IMediaEventEx)_graphBuilder;
                    EventCode     code;
                    hr = eventEx.GetEvent(out code, out p1, out p2, 0);
                    if (hr < 0)
                    {
                        break;
                    }

                    switch (code)
                    {
                    case EventCode.DvdPlaybackStopped:
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer DvdPlaybackStopped event: {0:X} {1:X}", p1.ToInt32(), p2.ToInt32());
                        break;

                    case EventCode.DvdError:
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer DvdError event: {0:X} {1:X}", p1.ToInt32(), p2.ToInt32());
                        break;

                    case EventCode.VMRReconnectionFailed:
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer VMRReconnectionFailed event: {0:X} {1:X}", p1.ToInt32(), p2.ToInt32());
                        break;

                    case EventCode.DvdWarning:
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer DVD warning: {0} {1}", p1.ToInt32(), p2.ToInt32());
                        break;

                    case EventCode.DvdSubPicictureStreamChange:
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdSubPicture Changed to: {0} Enabled: {1}", p1.ToInt32(), p2.ToInt32());
                        break;

                    case EventCode.DvdCurrentHmsfTime:
                        SetCurrentTime(p1);
                        break;

                    case EventCode.DvdChapterStart:
                    {
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdChaptStart: {0}", p1.ToInt32());
                        lock (SyncObj)
                        {
                            _currChapter = p1.ToInt32();
                            CalculateDuration();
                        }
                        ServiceRegistration.Get <ILogger>().Debug("  _duration: {0}", _currentTime);
                        break;
                    }

                    case EventCode.DvdTitleChange:
                    {
                        OnTitleSelect(p1.ToInt32());
                        break;
                    }

                    case EventCode.DvdCmdStart:
                        ServiceRegistration.Get <ILogger>().Debug("  DvdCmdStart with pending");
                        break;

                    case EventCode.DvdCmdEnd:
                    {
                        OnCmdComplete(p1);
                        break;
                    }

                    case EventCode.DvdStillOn:
                    {
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdStillOn: {0}", p1.ToInt32());
                        break;
                    }

                    case EventCode.DvdStillOff:
                    {
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdStillOff: {0}", p1.ToInt32());
                        break;
                    }

                    case EventCode.DvdButtonChange:
                    {
                        _buttonCount   = p1.ToInt32();
                        _focusedButton = p2.ToInt32();
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdButtonChange: buttons: {0}, focused: {1}", _buttonCount, _focusedButton);
                        break;
                    }

                    case EventCode.DvdNoFpPgc:
                    {
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdNoFpPgc: {0}", p1.ToInt32());
                        hr = _dvdCtrl.PlayTitle(1, DvdCmdFlags.None, out _cmdOption);
                        break;
                    }

                    case EventCode.DvdAudioStreamChange:
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdAudioStreamChange: {0}", p1.ToInt32());
                        break;

                    case EventCode.DvdValidUopsChange:
                        _UOPs = (ValidUOPFlag)p1.ToInt32();
                        ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: DvdValidUopsChange: {0}", _UOPs);
                        break;

                    case EventCode.DvdDomainChange:
                    {
                        _currDomain = (DvdDomain)p1;
                        switch (_currDomain)
                        {
                        case DvdDomain.FirstPlay:
                            ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: Domain=FirstPlay");
                            _handlesInput = false;
                            break;

                        case DvdDomain.Stop:
                            ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: Domain=Stop");
                            Stop();
                            break;

                        case DvdDomain.VideoManagerMenu:
                            ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: Domain=VideoManagerMenu (menu)");
                            _handlesInput = true;
                            break;

                        case DvdDomain.VideoTitleSetMenu:
                            ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: Domain=VideoTitleSetMenu (menu)");
                            _handlesInput = true;
                            break;

                        case DvdDomain.Title:
                            _handlesInput = false;
                            break;

                        default:
                            ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: Unhandled event DvdDomainChange: {0}", p1.ToInt32());
                            break;
                        }
                        break;
                    }
                    }

                    eventEx.FreeEventParams(code, p1, p2);
                } while (hr == 0);
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: Exception in OnDvdEvent()", ex);
            }
        }
Esempio n. 2
0
        /// <summary> DVD event message handler</summary>
        void OnDvdEvent()
        {
            IntPtr p1, p2;
            int hr = 0;
            EventCode code;
            do
            {
                hr = mediaEvt.GetEvent( out code, out p1, out p2, 0 );
                if( hr < 0 )
                {
                    break;
                }

                switch( code )
                {
                    case EventCode.DvdCurrentHmsfTime:
                    {
                        byte[] ati = BitConverter.GetBytes( p1.ToInt32() );
                        currnTime.bHours	= ati[0];
                        currnTime.bMinutes	= ati[1];
                        currnTime.bSeconds	= ati[2];
                        currnTime.bFrames	= ati[3];
                        UpdateFrameCaption();
                        break;
                    }
                    case EventCode.DvdChapterStart:
                    {
                        currnChapter = p1.ToInt32();
                        UpdateFrameCaption();
                        break;
                    }
                    case EventCode.DvdTitleChange:
                    {
                        currnTitle = p1.ToInt32();
                        UpdateFrameCaption();
                        break;
                    }
                    case EventCode.DvdDomainChange:
                    {
                        currnDomain = (DvdDomain) p1;
                        UpdateFrameCaption();
                        break;
                    }

                    case EventCode.DvdCmdStart:
                    {
                        break;
                    }
                    case EventCode.DvdCmdEnd:
                    {
                        OnCmdComplete( p1, p2 );
                        break;
                    }

                    case EventCode.DvdStillOn:
                    {
                        if( p1 == IntPtr.Zero )
                        {
                            menuMode = MenuMode.Buttons;
                        }
                        else
                        {
                            menuMode = MenuMode.Still;
                        }
                        break;
                    }
                    case EventCode.DvdStillOff:
                    {
                        if( menuMode == MenuMode.Still )
                        {
                            menuMode = MenuMode.No;
                        }
                        break;
                    }
                    case EventCode.DvdButtonChange:
                    {
                        if( p1.ToInt32() <= 0 )
                        {
                            menuMode = MenuMode.No;
                        }
                        else
                        {
                            menuMode = MenuMode.Buttons;
                        }
                        break;
                    }

                    case EventCode.DvdNoFpPgc:
                    {
                        IDvdCmd icmd;

                        if( dvdCtrl != null )
                        {
                            hr = dvdCtrl.PlayTitle( 1, DvdCmdFlags.None, out icmd );
                        }
                        break;
                    }
                }

                hr = mediaEvt.FreeEventParams( code, p1, p2 );
            }
            while( hr == 0 );
        }
Esempio n. 3
0
    /// <summary>
    /// Called to handle DVD event window messages.
    /// </summary>
    private void OnDvdEvent()
    {
      if (_mediaEvt == null || _dvdCtrl == null)
        return;

      IntPtr p1, p2;
      try
      {
        int hr;
        do
        {
          IMediaEventEx eventEx = (IMediaEventEx) _graphBuilder;
          EventCode code;
          hr = eventEx.GetEvent(out code, out p1, out p2, 0);
          if (hr < 0)
            break;

          switch (code)
          {
            case EventCode.DvdPlaybackStopped:
              ServiceRegistration.Get<ILogger>().Debug("DVDPlayer DvdPlaybackStopped event: {0:X} {1:X}", p1.ToInt32(), p2.ToInt32());
              break;
            case EventCode.DvdError:
              ServiceRegistration.Get<ILogger>().Debug("DVDPlayer DvdError event: {0:X} {1:X}", p1.ToInt32(), p2.ToInt32());
              break;
            case EventCode.VMRReconnectionFailed:
              ServiceRegistration.Get<ILogger>().Debug("DVDPlayer VMRReconnectionFailed event: {0:X} {1:X}", p1.ToInt32(), p2.ToInt32());
              break;
            case EventCode.DvdWarning:
              ServiceRegistration.Get<ILogger>().Debug("DVDPlayer DVD warning: {0} {1}", p1.ToInt32(), p2.ToInt32());
              break;
            case EventCode.DvdSubPicictureStreamChange:
              ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: DvdSubPicture Changed to: {0} Enabled: {1}", p1.ToInt32(), p2.ToInt32());
              break;
            case EventCode.DvdCurrentHmsfTime:
              SetCurrentTime(p1);
              break;

            case EventCode.DvdChapterStart:
              {
                ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: DvdChaptStart: {0}", p1.ToInt32());
                lock (SyncObj)
                {
                  _currChapter = p1.ToInt32();
                  CalculateDuration();
                }
                ServiceRegistration.Get<ILogger>().Debug("  _duration: {0}", _currentTime);
                break;
              }

            case EventCode.DvdTitleChange:
              {
                OnTitleSelect(p1.ToInt32());
                break;
              }

            case EventCode.DvdCmdStart:
              ServiceRegistration.Get<ILogger>().Debug("  DvdCmdStart with pending");
              break;

            case EventCode.DvdCmdEnd:
              {
                OnCmdComplete(p1);
                break;
              }

            case EventCode.DvdStillOn:
              {
                ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: DvdStillOn: {0}", p1.ToInt32());
                break;
              }

            case EventCode.DvdStillOff:
              {
                ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: DvdStillOff: {0}", p1.ToInt32());
                break;
              }

            case EventCode.DvdButtonChange:
              {
                _buttonCount = p1.ToInt32();
                _focusedButton = p2.ToInt32();
                ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: DvdButtonChange: buttons: {0}, focused: {1}", _buttonCount, _focusedButton);
                break;
              }

            case EventCode.DvdNoFpPgc:
              {
                ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: DvdNoFpPgc: {0}", p1.ToInt32());
                hr = _dvdCtrl.PlayTitle(1, DvdCmdFlags.None, out _cmdOption);
                break;
              }

            case EventCode.DvdAudioStreamChange:
              ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: DvdAudioStreamChange: {0}", p1.ToInt32());
              break;

            case EventCode.DvdValidUopsChange:
              _UOPs = (ValidUOPFlag) p1.ToInt32();
              ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: DvdValidUopsChange: {0}", _UOPs);
              break;

            case EventCode.DvdDomainChange:
              {
                _currDomain = (DvdDomain) p1;
                switch (_currDomain)
                {
                  case DvdDomain.FirstPlay:
                    ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: Domain=FirstPlay");
                    _handlesInput = false;
                    break;
                  case DvdDomain.Stop:
                    ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: Domain=Stop");
                    Stop();
                    break;
                  case DvdDomain.VideoManagerMenu:
                    ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: Domain=VideoManagerMenu (menu)");
                    _handlesInput = true;
                    break;
                  case DvdDomain.VideoTitleSetMenu:
                    ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: Domain=VideoTitleSetMenu (menu)");
                    _handlesInput = true;
                    break;
                  case DvdDomain.Title:
                    _handlesInput = false;
                    break;
                  default:
                    ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: Unhandled event DvdDomainChange: {0}", p1.ToInt32());
                    break;
                }
                break;
              }
          }

          eventEx.FreeEventParams(code, p1, p2);
        } while (hr == 0);
      }
      catch (Exception ex)
      {
        ServiceRegistration.Get<ILogger>().Debug("DVDPlayer: Exception in OnDvdEvent()", ex);
      }
    }
Esempio n. 4
0
    /// <summary> DVD event message handler</summary>
    private void OnDvdEvent()
    {
      //Log.Info("OnDvdEvent()");
      if (_mediaEvt == null)
        return;

      int p1, p2, hr = 0;
      EventCode code;
      try
      {
        do
        {
          hr = _mediaEvt.GetEvent(out code, out p1, out p2, 0);
          if (hr < 0)
          {
            break;
          }

          //Log.Info( "DVDPlayer DVD EVT :" + code.ToString() );

          switch (code)
          {
            case EventCode.DvdPlaybackRateChange:
              if (_speed != p1 / 10000)
              {
                _speed = p1 / 10000; // if RWD reaches start then PlaybackRate is changing automaticly 
              }
              break;

            case EventCode.DvdWarning:
              Log.Debug("DVDPlayer DVD warning :{0}", p1, p2);
              break;

            case EventCode.DvdCurrentHmsfTime:
              byte[] ati = BitConverter.GetBytes(p1);
              if (ati != null)
              {
                _currTime.bHours = ati[0];
                _currTime.bMinutes = ati[1];
                _currTime.bSeconds = ati[2];
                _currTime.bFrames = ati[3];
                _currentTime = new TimeSpan(_currTime.bHours, _currTime.bMinutes, _currTime.bSeconds).TotalSeconds;
              }
              break;

            case EventCode.DvdSubPicictureStreamChange:
              Log.Debug("EVT:DvdSubPicture Changed to:{0} Enabled:{1}", p1, p2);
              break;

            case EventCode.DvdChapterStart:
              Log.Debug("EVT:DvdChaptStart:{0}", p1);
              _currChapter = p1;
              UpdateDuration();
              break;

            case EventCode.DvdTitleChange:
              Log.Debug("EVT:DvdTitleChange:{0}", p1);
              _currTitle = p1;
              UpdateTitle(_currTitle);
              break;

            case EventCode.DvdCmdStart:
              if (_pendingCmd)
              {
                Log.Debug("EVT:DvdCmdStart with pending");
              }
              break;

            case EventCode.DvdCmdEnd:
              OnCmdComplete(p1, p2);
              break;

            case EventCode.DvdStillOn:
              Log.Debug("EVT:DvdStillOn:{0}", p1);
              break;

            case EventCode.DvdStillOff:
              Log.Debug("EVT:DvdStillOff:{0}", p1);
              break;

            case EventCode.DvdButtonChange:
              Log.Debug("EVT:DvdButtonChange: buttons:#{0}, focused button: {1}", p1, p2);
              buttonCount = p1;
              focusedButton = p2;
              break;

            case EventCode.DvdNoFpPgc:
              Log.Debug("EVT:DvdNoFpPgc:{0}", p1);
              if (_dvdCtrl != null)
              {
                hr = _dvdCtrl.PlayTitle(1, DvdCmdFlags.None, out _cmdOption);
              }
              break;

            case EventCode.DvdAudioStreamChange:
              Log.Debug("EVT:DvdAudioStreamChange:{0}", p1);
              break;

            case EventCode.DvdValidUopsChange:
              Log.Debug("EVT:DvdValidUopsChange:0x{0:X}", p1);
              _UOPs = p1;
              break;

            case EventCode.DvdDomainChange:
              _currDomain = (DvdDomain)p1;
              switch ((DvdDomain)p1)
              {
                case DvdDomain.FirstPlay:
                  Log.Debug("EVT:DVDPlayer:domain=firstplay");
                  _state = PlayState.Playing;
                  VMR9Util.g_vmr9.EVRSetDVDMenuState(false);
                  break;
                  // The DVD Navigator has completed playback of the title or 
                  // chapter and did not find any other branching instruction for 
                  // subsequent playback.
                case DvdDomain.Stop:
                  Log.Debug("EVT:DVDPlayer:domain=stop");
                  Stop();
                  break;
                case DvdDomain.VideoManagerMenu:
                  Log.Debug("EVT:DVDPlayer:domain=videomanagermenu (menu)");
                  _state = PlayState.Menu;
                  VMR9Util.g_vmr9.EVRSetDVDMenuState(true);
                  break;
                case DvdDomain.VideoTitleSetMenu:
                  Log.Debug("EVT:DVDPlayer:domain=videotitlesetmenu (menu)");
                  _state = PlayState.Menu;
                  VMR9Util.g_vmr9.EVRSetDVDMenuState(true);
                  break;
                case DvdDomain.Title:
                  _state = PlayState.Playing;
                  VMR9Util.g_vmr9.EVRSetDVDMenuState(false);
                  break;
                default:
                  Log.Debug("EVT:DvdDomChange:{0}", p1);
                  break;
              }
              break;
          }

          hr = _mediaEvt.FreeEventParams(code, p1, p2);
        } while (hr == 0);
      }
      catch (Exception ex)
      {
        Log.Error("DVDPlayer:OnDvdEvent() {0} {1} {2}", ex.Message, ex.Source, ex.StackTrace);
      }
      //      Log.Info("DVDEvent done");
    }
Esempio n. 5
0
        protected override void HandleGraphEvent(EventCode code, int p1, int p2)
        {
            switch (code)
            {
            case EventCode.DvdCurrentHmsfTime:
                byte[] ati = BitConverter.GetBytes(p1);
                _currentPosition = new TimeSpan(ati[0], ati[1], ati[2]);
                break;

            case EventCode.DvdDomChange:
                DvdDomain dom = (DvdDomain)p1;
                Logger.LogTrace("Currently in domain: {0}", dom);

                if (dom == DvdDomain.Title)
                {
                    object comobj = null;
                    dvdGraphBuilder.GetDvdInterface(typeof(IDvdInfo2).GUID, out comobj);

                    dvdInfo = comobj as IDvdInfo2;

                    DvdHMSFTimeCode  timeCode;
                    DvdTimeCodeFlags flags;
                    dvdInfo.GetTotalTitleTime(out timeCode, out flags);
                    _totalTime = new TimeSpan(timeCode.bHours, timeCode.bMinutes, timeCode.bSeconds);
                }
                break;

            case EventCode.DvdChaptStart:
            case EventCode.DvdTitleChange:
            case EventCode.DvdCmdStart:
            case EventCode.DvdCmdEnd:
                break;

            case EventCode.DvdStillOn:
                if (p1 == 0)
                {
                    menuMode = MenuMode.Buttons;
                }
                else
                {
                    menuMode = MenuMode.Still;
                }
                break;

            case EventCode.DvdStillOff:
                if (menuMode == MenuMode.Still)
                {
                    menuMode = MenuMode.No;
                }
                break;

            case EventCode.DvdButtonChange:
                if (p1 <= 0)
                {
                    menuMode = MenuMode.No;
                }
                else
                {
                    menuMode = MenuMode.Buttons;
                }
                break;

            case EventCode.DvdNoFpPgc:
                if (dvdControl2 != null)
                {
                    int hr = dvdControl2.PlayTitle(1, DvdCmdFlags.None, _lastCmd);
                    DsError.ThrowExceptionForHR(hr);
                }
                break;
            }
        }