Exemplo n.º 1
0
 public void Set(BluRayAPI.BluRayEvent data)
 {
   _buffer[_writePos] = data;
   _writePos = (_writePos + 1) % SIZE;
   if (_readPos == _writePos)
   {
     ServiceRegistration.Get<ILogger>().Warn("BluRayPlayer: Event buffer full");
   }
 }
Exemplo n.º 2
0
    private void InitTexture(BluRayAPI.OSDTexture item)
    {
      if (item.Width == 0 || item.Height == 0 || item.Texture == IntPtr.Zero)
      {
        FreeResources();
        return;
      }

      if (_combinedOsdTexture == null || _combinedOsdTexture.IsDisposed)
      {
        _combinedOsdTexture = new Texture(_device, _fullOsdSize.Width, _fullOsdSize.Height, 1, Usage.RenderTarget, FORMAT, Pool.Default);
        _combinedOsdSurface = _combinedOsdTexture.GetSurfaceLevel(0);

        _sprite = new Sprite(_device);

        Rectangle dstRect = new Rectangle(0, 0, _fullOsdSize.Width, _fullOsdSize.Height);
        _device.ColorFill(_combinedOsdSurface, dstRect, _transparentColor);
      }
    }
Exemplo n.º 3
0
    private static void GetStreamInfo(BluRayAPI.BDStreamInfo[] streamInfos, IntPtr ptrStreamInfo)
    {
      for (int i = 0; i < streamInfos.Length; i++)
      {
        BluRayAPI.BDStreamInfo streamInfo = (BluRayAPI.BDStreamInfo)
          Marshal.PtrToStructure(new IntPtr((int)ptrStreamInfo + i * Marshal.SizeOf(typeof(BluRayAPI.BDStreamInfo))),
            typeof(BluRayAPI.BDStreamInfo));

        streamInfos[i] = streamInfo;
      }
    }
Exemplo n.º 4
0
    protected void HandleBDEvent(BluRayAPI.BluRayEvent bdevent)
    {
      switch ((BluRayAPI.BDEvents)bdevent.Event)
      {
        case BluRayAPI.BDEvents.AudioStream:
          BluRayPlayerBuilder.LogDebug("Audio changed to {0}", bdevent.Param);
          //if (bdevent.Param != 0xff)
          //  CurrentAudioStream = bdevent.Param - 1;
          break;

        case BluRayAPI.BDEvents.PgText:
          BluRayPlayerBuilder.LogDebug("Subtitles available {0}", bdevent.Param);
          break;

        case BluRayAPI.BDEvents.PgTextStream:
          BluRayPlayerBuilder.LogDebug("Subtitle changed to {0}", bdevent.Param);
          //if (bdevent.Param != 0xfff)
          //  CurrentSubtitleStream = bdevent.Param;
          break;

        case BluRayAPI.BDEvents.IgStream:
          BluRayPlayerBuilder.LogDebug("Interactive graphics available {0}", bdevent.Param);
          break;

        case BluRayAPI.BDEvents.Playlist:
          BluRayPlayerBuilder.LogDebug("Playlist changed to {0}", bdevent.Param);
          if (_forceTitle || (_currentTitle != (int)BluRayAPI.BluRayTitle.FirstPlay && _currentTitle != (int)BluRayAPI.BluRayTitle.TopMenu))
            EnumerateChapters();
          break;

        case BluRayAPI.BDEvents.Playitem:
          BluRayPlayerBuilder.LogDebug("Playitem changed to {0}", bdevent.Param);
          //if (menuState == BluRayAPI.MenuState.Root && chapters != null && _currentTitle != BLURAY_TITLE_FIRST_PLAY && _currentTitle != BLURAY_TITLE_TOP_MENU)
          //  menuItems = MenuItems.All;
          break;

        case BluRayAPI.BDEvents.Title:
          BluRayPlayerBuilder.LogDebug("Title changed to {0}", bdevent.Param);
          _currentTitle = bdevent.Param;
          _currentChapter = 0xffff;
          switch ((BluRayAPI.BluRayTitle)bdevent.Param)
          {
            case BluRayAPI.BluRayTitle.TopMenu:
            case BluRayAPI.BluRayTitle.FirstPlay:
              if (!_forceTitle)
              {
                //menuItems = MenuItems.None;
                _menuState = BluRayAPI.MenuState.Root;
              }
              break;
            default:
              _menuState = BluRayAPI.MenuState.None;
              break;
          }
          break;

        case BluRayAPI.BDEvents.Chapter:
          BluRayPlayerBuilder.LogDebug("Chapter changed to {0}", bdevent.Param);
          if (bdevent.Param != 0xffff)
            _currentChapter = (uint)bdevent.Param - 1;
          break;

        case BluRayAPI.BDEvents.CustomEventMenuVisibility:
          //if (bdevent.Param == 1)
          //{
          //  BluRayPlayerBuilder.LogDebug("Toggle menu on");
          //if (menuState == BluRayAPI.MenuState.PopUp)
          //  menuItems = MenuItems.All;
          //else
          //  menuItems = MenuItems.None;

          //_iMenuOffPendingCount = 0;
          //_bMenuOn = true;
          //}
          //else if (_iMenuOffPendingCount == 0)
          //{
          //  _iMenuOffPendingCount++;
          //}
          break;
      }
    }
Exemplo n.º 5
0
 public int OnOSDUpdate(BluRayAPI.OSDTexture osdInfo)
 {
   _osdRenderer.DrawItem(osdInfo);
   return 0;
 }
Exemplo n.º 6
0
 public int OnBDevent(BluRayAPI.BluRayEvent bluRayEvent)
 {
   if (bluRayEvent.Event != 0 &&
     bluRayEvent.Event != (int)BluRayAPI.BDEvents.Still &&
     bluRayEvent.Event != (int)BluRayAPI.BDEvents.StillTime)
   {
     HandleBDEvent(bluRayEvent);
   }
   return 0;
 }
Exemplo n.º 7
0
    public int OnMediaTypeChanged(BluRayAPI.VideoRate videoRate, BluRayAPI.BluRayStreamFormats videoFormat, BluRayAPI.BluRayStreamFormats audioFormat)
    {
      BluRayPlayerBuilder.LogInfo("OnMediaTypeChanged() - {0} ({1} fps), {2}", videoFormat, videoRate, audioFormat);
      bool requireRebuild = false;

      _changedChangedMediaType = BluRayAPI.ChangedMediaType.None;

      if (videoFormat != _currentVideoFormat)
      {
        if (_currentVideoFormat != BluRayAPI.BluRayStreamFormats.Unknown)
          requireRebuild = true;

        _changedChangedMediaType |= BluRayAPI.ChangedMediaType.Video;
        _currentVideoFormat = videoFormat;
      }

      if (audioFormat != _currentAudioFormat)
      {
        if (_currentAudioFormat != BluRayAPI.BluRayStreamFormats.Unknown)
          requireRebuild = true;

        _changedChangedMediaType |= BluRayAPI.ChangedMediaType.Audio;
        _currentAudioFormat = audioFormat;
      }

      // Only rebuild the graph when we had a former media type (not on first run!)
      if (requireRebuild)
        _graphRebuilder.DoAsynchRebuild();

      return _changedChangedMediaType != BluRayAPI.ChangedMediaType.None && requireRebuild ? 0 : 1;
    }
Exemplo n.º 8
0
    public void DrawItem(BluRayAPI.OSDTexture item)
    {
      try
      {
        lock (_syncObj)
        {
          InitTexture(item);
          if (_combinedOsdSurface != null)
          {
            Rectangle sourceRect = new Rectangle(0, 0, item.Width, item.Height);
            Rectangle dstRect = new Rectangle(item.X, item.Y, item.Width, item.Height);

            using (Texture itemTexture = new Texture(item.Texture))
              _device.StretchRectangle(itemTexture.GetSurfaceLevel(0), sourceRect, _combinedOsdSurface, dstRect, TextureFilter.None);
          }
        }
      }
      catch (Exception ex)
      {
        BluRayPlayerBuilder.LogError(ex.ToString());
      }

      if (_onTextureInvalidated != null)
        _onTextureInvalidated();
    }