Github messages for voidlinux
 help / color / mirror / Atom feed
From: zdykstra <zdykstra@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] plex-media-player: remove deprecated opengl-cb API, use libmpv Render API
Date: Mon, 14 Dec 2020 17:40:42 +0100	[thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-27152@inbox.vuxu.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 366 bytes --]

There is a new pull request by zdykstra against master on the void-packages repository

https://github.com/zdykstra/void-packages pmp-fix-build
https://github.com/void-linux/void-packages/pull/27152

plex-media-player: remove deprecated opengl-cb API, use libmpv Render API


A patch file from https://github.com/void-linux/void-packages/pull/27152.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pmp-fix-build-27152.patch --]
[-- Type: text/x-diff, Size: 6706 bytes --]

From 85215e0fd6b4a8b9c5596f06aea3b295d206e524 Mon Sep 17 00:00:00 2001
From: Zach Dykstra <dykstra.zachary@gmail.com>
Date: Mon, 14 Dec 2020 10:39:45 -0600
Subject: [PATCH] plex-media-player: remove deprecated opengl-cb API, use
 libmpv Render API

---
 .../patches/fix-opengl-cb-api-usage.patch     | 164 ++++++++++++++++++
 srcpkgs/plex-media-player/template            |   2 +-
 2 files changed, 165 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/plex-media-player/patches/fix-opengl-cb-api-usage.patch

diff --git a/srcpkgs/plex-media-player/patches/fix-opengl-cb-api-usage.patch b/srcpkgs/plex-media-player/patches/fix-opengl-cb-api-usage.patch
new file mode 100644
index 00000000000..53010d9fc32
--- /dev/null
+++ b/srcpkgs/plex-media-player/patches/fix-opengl-cb-api-usage.patch
@@ -0,0 +1,164 @@
+The opengl-cb interface has been retired; patch in libmpv usage. 
+https://github.com/plexinc/plex-media-player/issues/997
+https://github.com/plexinc/plex-media-player/pull/999
+
+--- src/player/PlayerComponent.cpp
++++ src/player/PlayerComponent.cpp
+@@ -259,7 +259,7 @@ void PlayerComponent::setQtQuickWindow(QQuickWindow* window)
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+ void PlayerComponent::setWindow(QQuickWindow* window)
+ {
+-  QString vo = "opengl-cb";
++  QString vo = "libmpv";
+ 
+ #ifdef TARGET_RPI
+   window->setFlags(Qt::FramelessWindowHint);
+@@ -276,7 +276,7 @@ void PlayerComponent::setWindow(QQuickWindow* window)
+ 
+   mpv::qt::set_property(m_mpv, "vo", vo);
+ 
+-  if (vo == "opengl-cb")
++  if (vo == "libmpv")
+     setQtQuickWindow(window);
+ }
+ 
+--- src/player/PlayerQuickItem.cpp
++++ src/player/PlayerQuickItem.cpp
+@@ -11,6 +11,8 @@
+ #include <QtQuick/QQuickWindow>
+ #include <QOpenGLFunctions>
+ 
++#include <mpv/render_gl.h>
++
+ #include "QsLog.h"
+ #include "utils/Utils.h"
+ 
+@@ -93,7 +95,6 @@ class RequestRepaintJob : public QRunnable
+ PlayerRenderer::PlayerRenderer(mpv::qt::Handle mpv, QQuickWindow* window)
+ : m_mpv(mpv), m_mpvGL(nullptr), m_window(window), m_size(), m_hAvrtHandle(nullptr), m_videoRectangle(-1, -1, -1, -1), m_fbo(0)
+ {
+-  m_mpvGL = (mpv_opengl_cb_context *)mpv_get_sub_api(m_mpv, MPV_SUB_API_OPENGL_CB);
+ }
+ 
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+@@ -104,11 +105,27 @@ bool PlayerRenderer::init()
+   DwmEnableMMCSS(TRUE);
+ #endif
+ 
+-  mpv_opengl_cb_set_update_callback(m_mpvGL, on_update, (void *)this);
+ 
+   // Signals presence of MPGetNativeDisplay().
+   const char *extensions = "GL_MP_MPGetNativeDisplay";
+-  return mpv_opengl_cb_init_gl(m_mpvGL, extensions, get_proc_address, nullptr) >= 0;
++
++  mpv_opengl_init_params opengl_params = {
++      .get_proc_address = get_proc_address,
++      .get_proc_address_ctx = NULL,
++      .extra_exts = extensions,
++  }; 
++  mpv_render_param params[] = {
++    {MPV_RENDER_PARAM_API_TYPE, (void*)MPV_RENDER_API_TYPE_OPENGL},
++    {MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &opengl_params},
++    {MPV_RENDER_PARAM_INVALID},
++  };
++  int err = mpv_render_context_create(&m_mpvGL, m_mpv, params);
++
++  if (err >= 0) {
++    mpv_render_context_set_update_callback(m_mpvGL, on_update, (void *)this);
++    return true;
++  }
++  return false;
+ }
+ 
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+@@ -116,7 +133,8 @@ PlayerRenderer::~PlayerRenderer()
+ {
+   // Keep in mind that the m_mpv handle must be held until this is done.
+   if (m_mpvGL)
+-    mpv_opengl_cb_uninit_gl(m_mpvGL);
++    mpv_render_context_free(m_mpvGL);
++  m_mpvGL = nullptr;
+   delete m_fbo;
+ }
+ 
+@@ -158,9 +176,18 @@ void PlayerRenderer::render()
+     }
+   }
+ 
+-  // The negative height signals to mpv that the video should be flipped
+-  // (according to the flipped OpenGL coordinate system).
+-  mpv_opengl_cb_draw(m_mpvGL, fbo, fboSize.width(), (flip ? -1 : 1) * fboSize.height());
++  mpv_opengl_fbo mpv_fbo = {
++    .fbo = fbo,
++    .w = fboSize.width(),
++    .h = fboSize.height(),
++  };
++  int mpv_flip = flip ? -1 : 0;
++  mpv_render_param params[] = {
++    {MPV_RENDER_PARAM_OPENGL_FBO, &mpv_fbo},
++    {MPV_RENDER_PARAM_FLIP_Y, &mpv_flip},
++    {MPV_RENDER_PARAM_INVALID}
++  };
++  mpv_render_context_render(m_mpvGL, params);
+ 
+   m_window->resetOpenGLState();
+ 
+@@ -177,7 +204,8 @@ void PlayerRenderer::render()
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+ void PlayerRenderer::swap()
+ {
+-  mpv_opengl_cb_report_flip(m_mpvGL, 0);
++  if (m_mpvGL)
++    mpv_render_context_report_swap(m_mpvGL);
+ }
+ 
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+@@ -224,7 +252,7 @@ PlayerQuickItem::PlayerQuickItem(QQuickItem* parent)
+ PlayerQuickItem::~PlayerQuickItem()
+ {
+   if (m_mpvGL)
+-    mpv_opengl_cb_set_update_callback(m_mpvGL, nullptr, nullptr);
++    mpv_render_context_set_update_callback(m_mpvGL, nullptr, nullptr);
+ }
+ 
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+@@ -298,10 +326,6 @@ void PlayerQuickItem::initMpv(PlayerComponent* player)
+ {
+   m_mpv = player->getMpvHandle();
+ 
+-  m_mpvGL = (mpv_opengl_cb_context *)mpv_get_sub_api(m_mpv, MPV_SUB_API_OPENGL_CB);
+-  if (!m_mpvGL)
+-    throw FatalException(tr("OpenGL not enabled in libmpv."));
+-
+   connect(player, &PlayerComponent::windowVisible, this, &QQuickItem::setVisible);
+   window()->update();
+ }
+--- src/player/PlayerQuickItem.h
++++ src/player/PlayerQuickItem.h
+@@ -6,7 +6,7 @@
+ #include <QOpenGLFramebufferObject>
+ 
+ #include <mpv/client.h>
+-#include <mpv/opengl_cb.h>
++#include <mpv/render.h>
+ 
+ #ifdef Q_OS_WIN32
+ #include <windows.h>
+@@ -34,7 +34,7 @@ public slots:
+ private:
+   static void on_update(void *ctx);
+   mpv::qt::Handle m_mpv;
+-  mpv_opengl_cb_context* m_mpvGL;
++  mpv_render_context* m_mpvGL;
+   QQuickWindow* m_window;
+   QSize m_size;
+   HANDLE m_hAvrtHandle;
+@@ -64,7 +64,7 @@ private slots:
+ 
+ private:
+     mpv::qt::Handle m_mpv;
+-    mpv_opengl_cb_context* m_mpvGL;
++    mpv_render_context* m_mpvGL;
+     PlayerRenderer* m_renderer;
+     QString m_debugInfo;
+ };
diff --git a/srcpkgs/plex-media-player/template b/srcpkgs/plex-media-player/template
index 9704d150d25..323b6c4f766 100644
--- a/srcpkgs/plex-media-player/template
+++ b/srcpkgs/plex-media-player/template
@@ -1,7 +1,7 @@
 # Template file for 'plex-media-player'
 pkgname=plex-media-player
 version=2.58.0
-revision=2
+revision=3
 _verbuild=1076
 _commit_rev=38e019da
 # See CMakeModules/WebClient.cmake

             reply	other threads:[~2020-12-14 16:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14 16:40 zdykstra [this message]
2020-12-14 16:55 ` zdykstra
2020-12-14 17:26 ` ericonr
2020-12-14 17:27 ` ericonr
2020-12-14 17:38 ` [PR PATCH] [Updated] " zdykstra
2020-12-14 17:56 ` zdykstra
2020-12-14 17:56 ` zdykstra
2020-12-15 14:17 ` [PR PATCH] [Merged]: " ericonr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-27152@inbox.vuxu.org \
    --to=zdykstra@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).