<html><head></head><body>Hi,<br><br>It looks like the render context does nothing here? To the extent possible, it's preferable that the embedded window provider plugin detects size changes without help of the app (as is done for X11). Otherwise devs will get it wrong, especially in the case of portable frameworks around LibVLC.<br><br><div class="gmail_quote">Le 6 mai 2020 11:28:28 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail"><hr> doc/libvlc/win_player.c | 148 ++++++++++++++++++++++++++++++++++++++++<br> 1 file changed, 148 insertions(+)<br> create mode 100644 doc/libvlc/win_player.c<br><br>diff --git a/doc/libvlc/win_player.c b/doc/libvlc/win_player.c<br>new file mode 100644<br>index 000000000000..41061d936c4e<br>--- /dev/null<br>+++ b/doc/libvlc/win_player.c<br>@@ -0,0 +1,148 @@<br>+/* compile: cc win_player.c -o win_player.exe -L<path/libvlc> -lvlc */<br>+<br>+#include <windows.h><br>+#include <assert.h><br>+<br>+#include <vlc/vlc.h><br>+<br>+#define SCREEN_WIDTH 1500<br>+#define SCREEN_HEIGHT 900<br>+#define BORDER_LEFT (-0.95f)<br>+#define BORDER_RIGHT ( 0.85f)<br>+#define BORDER_TOP ( 0.95f)<br>+#define BORDER_BOTTOM (-0.90f)<br>+<br>+#define check_leak(x) assert(x)<br>+<br>+struct render_context<br>+{<br>+ HWND hWnd;<br>+ CRITICAL_SECTION sizeLock; // the ReportSize callback cannot be called during/after the Cleanup_cb is called<br>+ unsigned width, height;<br>+ void (*ReportSize)(void *ReportOpaque, unsigned width, unsigned height);<br>+ void *ReportOpaque;<br>+};<br>+<br>+static LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)<br>+{<br>+ if( message == WM_CREATE )<br>+ {<br>+ /* Store p_mp for future use */<br>+ CREATESTRUCT *c = (CREATESTRUCT *)lParam;<br>+ SetWindowLongPtr( hWnd, GWLP_USERDATA, (LONG_PTR)c->lpCreateParams );<br>+ return 0;<br>+ }<br>+<br>+ LONG_PTR p_user_data = GetWindowLongPtr( hWnd, GWLP_USERDATA );<br>+ if( p_user_data == 0 )<br>+ return DefWindowProc(hWnd, message, wParam, lParam);<br>+ struct render_context *ctx = (struct render_context *)p_user_data;<br>+<br>+ switch(message)<br>+ {<br>+ case WM_SIZE:<br>+ {<br>+ /* tell libvlc that our size has changed */<br>+ ctx->width = LOWORD(lParam) * (BORDER_RIGHT - BORDER_LEFT) / 2.0f; /* remove the orange part ! */<br>+ ctx->height = HIWORD(lParam) * (BORDER_TOP - BORDER_BOTTOM) / 2.0f;<br>+ EnterCriticalSection(&ctx->sizeLock);<br>+ if (ctx->ReportSize != NULL)<br>+ ctx->ReportSize(ctx->ReportOpaque, ctx->width, ctx->height);<br>+ LeaveCriticalSection(&ctx->sizeLock);<br>+ }<br>+ break;<br>+<br>+ case WM_DESTROY:<br>+ PostQuitMessage(0);<br>+ return 0;<br>+ }<br>+<br>+ return DefWindowProc (hWnd, message, wParam, lParam);<br>+}<br>+<br>+int WINAPI WinMain(HINSTANCE hInstance,<br>+ HINSTANCE hPrevInstance,<br>+ LPSTR lpCmdLine,<br>+ int nCmdShow)<br>+{<br>+ WNDCLASSEX wc;<br>+ struct render_context Context = { };<br>+ char *file_path;<br>+ libvlc_instance_t *p_libvlc;<br>+ libvlc_media_t *p_media;<br>+ libvlc_media_player_t *p_mp;<br>+ (void)hPrevInstance;<br>+<br>+ /* remove "" around the given path */<br>+ if (lpCmdLine[0] == '"')<br>+ {<br>+ file_path = strdup( lpCmdLine+1 );<br>+ if (file_path[strlen(file_path)-1] == '"')<br>+ file_path[strlen(file_path)-1] = '\0';<br>+ }<br>+ else<br>+ file_path = strdup( lpCmdLine );<br>+<br>+ p_libvlc = libvlc_new( 0, NULL );<br>+ p_media = libvlc_media_new_path( p_libvlc, file_path );<br>+ free( file_path );<br>+ p_mp = libvlc_media_player_new_from_media( p_media );<br>+<br>+ InitializeCriticalSection(&Context.sizeLock);<br>+<br>+ ZeroMemory(&wc, sizeof(WNDCLASSEX));<br>+<br>+ wc.cbSize = sizeof(WNDCLASSEX);<br>+ wc.style = CS_HREDRAW | CS_VREDRAW;<br>+ wc.lpfnWndProc = WindowProc;<br>+ wc.hInstance = hInstance;<br>+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);<br>+ wc.lpszClassName = "WindowClass";<br>+<br>+ RegisterClassEx(&wc);<br>+<br>+ RECT wr = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};<br>+ AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);<br>+<br>+ Context.hWnd = CreateWindowEx(0,<br>+ "WindowClass",<br>+ "libvlc Demo app",<br>+ WS_OVERLAPPEDWINDOW,<br>+ CW_USEDEFAULT, CW_USEDEFAULT,<br>+ wr.right - wr.left,<br>+ wr.bottom - wr.top,<br>+ NULL,<br>+ NULL,<br>+ hInstance,<br>+ &Context);<br>+<br>+ ShowWindow(Context.hWnd, nCmdShow);<br>+<br>+ libvlc_media_player_set_hwnd(p_mp, Context.hWnd);<br>+<br>+ libvlc_media_player_play( p_mp );<br>+<br>+ MSG msg;<br>+<br>+ while(TRUE)<br>+ {<br>+ if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))<br>+ {<br>+ TranslateMessage(&msg);<br>+ DispatchMessage(&msg);<br>+<br>+ if(msg.message == WM_QUIT)<br>+ break;<br>+ }<br>+ }<br>+<br>+ libvlc_media_player_stop_async( p_mp );<br>+<br>+ libvlc_media_player_release( p_mp );<br>+ libvlc_media_release( p_media );<br>+ libvlc_release( p_libvlc );<br>+<br>+ DeleteCriticalSection(&Context.sizeLock);<br>+<br>+ return msg.wParam;<br>+}</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>