Felix Paul Kühne pushed to branch 3.0.x at VideoLAN / VLC


Commits:
3e6cf18f by Steve Lhomme at 2022-06-28T19:16:44+00:00
doc: libvlc: add a simple win32 app using set_hwnd()

(cherry picked from commit 4a91e760ae232de0eb58cf4fe1c380bf61aa981a) (edited)
edited:
- in 3.0 libvlc_media_player_stop_async() doesn't exist

Signed-off-by: Steve Lhomme <rob...@ycbcr.xyz>

- - - - -
2f111e02 by Steve Lhomme at 2022-06-28T19:16:44+00:00
doc: libvlc: add drag and drop support to the basic set_hwnd sample app

(cherry picked from commit e44940dd92337df4c8a33b91b97a7e54121347f3) (edited)
edited:
- in 3.0 libvlc_media_player_stop_async() doesn't exist

Signed-off-by: Steve Lhomme <rob...@ycbcr.xyz>

- - - - -
be49e664 by Steve Lhomme at 2022-06-28T19:16:44+00:00
doc: win32: handle 'a' keyboard key to change the aspect ratio in 
sample apps

Use the same shortcuts and values as in VLC.

(cherry picked from commit 7d00336823c380b89bd8a95e7c953a3b7526d2ed) (edited)
edited:
- 3.0 doesn't d3d callback examples

Signed-off-by: Steve Lhomme <rob...@ycbcr.xyz>

- - - - -
da51e70e by Steve Lhomme at 2022-06-28T19:16:44+00:00
doc: libvlc: use _strdup() on Windows samples

strdup() is issuing a deprecated warning with the MS SDK.

(cherry picked from commit 4bad605e3b98ea48a91d422775ee2bb3500593cc) (edited)
edited:
- 3.0 doesn't d3d callback examples

Signed-off-by: Steve Lhomme <rob...@ycbcr.xyz>

- - - - -
58a4b93a by Steve Lhomme at 2022-06-28T19:16:44+00:00
doc: libvlc: fix type casting

(cherry picked from commit db6ad1bc86580290eb27013e126b3e031d3aa5df) (edited)
edited:
- 3.0 doesn't d3d callback examples

Signed-off-by: Steve Lhomme <rob...@ycbcr.xyz>

- - - - -
214a24cc by Steve Lhomme at 2022-06-28T19:16:44+00:00
doc: libvlc: add a CMake makefile to build the win32 samples

CMake has good integration with VSCode which makes it as easy as just loading
the folder in VSCode, set the SDK folder and build.

(cherry picked from commit e70bb0163093c2f7d846de902f0dad8591c40823) (edited)
edited:
- 3.0 doesn't d3d callback examples

Signed-off-by: Steve Lhomme <rob...@ycbcr.xyz>

- - - - -
797db11c by Steve Lhomme at 2022-06-28T19:16:44+00:00
doc: libvlc: fix MSVC build

`ssize_t` doesn't exist in MSVC and is not used in included headers on 4.0.

- - - - -
9deff7e0 by Steve Lhomme at 2022-06-28T19:16:44+00:00
doc: add the libvlc set_hwnd sample code

(cherry picked from commit 1c4ec06836a7002ac9378a1d45fefc48711c0572) (rebased)
rebased:
- 3.0 doesn't d3d callback examples

Signed-off-by: Steve Lhomme <rob...@ycbcr.xyz>

- - - - -
bdeae9ac by Steve Lhomme at 2022-06-28T19:16:44+00:00
doc: libvlc: add the CMakeLists.txt to the tarball

(cherry picked from commit 090b5ee9d29cbb55fd9d4d4e34c8bc33b1513d7c)

Signed-off-by: Steve Lhomme <rob...@ycbcr.xyz>

- - - - -


3 changed files:

- doc/Makefile.am
- + doc/libvlc/CMakeLists.txt
- + doc/libvlc/win_player.c


Changes:

=====================================
doc/Makefile.am
=====================================
@@ -10,6 +10,8 @@ LIBVLC_SAMPLES = \
        libvlc/QtPlayer/QtVLC.pro \
        libvlc/vlc-thumb.c \
        libvlc/wx_player.cpp \
+       libvlc/win_player.c \
+       libvlc/CMakeLists.txt \
        $(NULL)
 
 nobase_doc_DATA = $(LIBVLC_SAMPLES)


=====================================
doc/libvlc/CMakeLists.txt
=====================================
@@ -0,0 +1,34 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
+
+# configure with your own path
+#  
-DLIBVLC_SDK_INC:STRING=S:/sources/build/win64/win64/vlc-4.0.0-dev/sdk/include
+#  -DLIBVLC_SDK_LIB:STRING=S:/sources/build/win64/win64/vlc-4.0.0-dev/sdk/lib
+#
+# or set them in your VSCode settings
+# {
+#     "cmake.configureSettings": {
+#         "LIBVLC_SDK_INC": "S:/sources/vlc/include",
+#         "LIBVLC_SDK_LIB": "S:/sources/build/win64/win64/lib/.libs"
+#     }
+# }
+
+set("LIBVLC_SDK_INC" "" CACHE PATH "libvlc include folder, containing the vlc/ 
includes")
+set("LIBVLC_SDK_LIB" "" CACHE PATH "libvlc library folder, containing the 
libvlc libraries")
+
+project("libvlc samples")
+
+# define the libvlc external build
+add_library(libvlc SHARED IMPORTED GLOBAL)
+target_include_directories(libvlc INTERFACE "${LIBVLC_SDK_INC}")
+if (MSVC)
+    set_target_properties(libvlc PROPERTIES IMPORTED_IMPLIB 
"${LIBVLC_SDK_LIB}/libvlc.lib")
+else ()
+    set_target_properties(libvlc PROPERTIES IMPORTED_IMPLIB 
"${LIBVLC_SDK_LIB}/libvlc.dll.a")
+endif ()
+
+if(WIN32)
+
+    add_executable(win_player WIN32 win_player.c)
+    target_link_libraries(win_player libvlc)
+
+endif()


=====================================
doc/libvlc/win_player.c
=====================================
@@ -0,0 +1,177 @@
+/* compile: cc win_player.c -o win_player.exe -L<path/libvlc> -lvlc */
+
+#include <windows.h>
+#include <assert.h>
+
+#ifdef _MSC_VER
+typedef int ssize_t;
+#endif
+
+#include <vlc/vlc.h>
+
+#define SCREEN_WIDTH  1500
+#define SCREEN_HEIGHT  900
+
+struct vlc_context
+{
+    libvlc_instance_t     *p_libvlc;
+    libvlc_media_player_t *p_mediaplayer;
+};
+
+
+static const char *AspectRatio = NULL;
+
+static LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, 
LPARAM lParam)
+{
+    if( message == WM_CREATE )
+    {
+        /* Store p_mediaplayer for future use */
+        CREATESTRUCT *c = (CREATESTRUCT *)lParam;
+        SetWindowLongPtr( hWnd, GWLP_USERDATA, (LONG_PTR)c->lpCreateParams );
+        return 0;
+    }
+
+    LONG_PTR p_user_data = GetWindowLongPtr( hWnd, GWLP_USERDATA );
+    if( p_user_data == 0 )
+        return DefWindowProc(hWnd, message, wParam, lParam);
+    struct vlc_context *ctx = (struct vlc_context *)p_user_data;
+
+    switch(message)
+    {
+        case WM_DESTROY:
+            PostQuitMessage(0);
+            return 0;
+        case WM_DROPFILES:
+            {
+                HDROP hDrop = (HDROP)wParam;
+                char file_path[MAX_PATH];
+                libvlc_media_player_stop( ctx->p_mediaplayer );
+
+                if (DragQueryFile(hDrop, 0, file_path, sizeof(file_path)))
+                {
+                    libvlc_media_t *p_media = libvlc_media_new_path( 
ctx->p_libvlc, file_path );
+                    libvlc_media_t *p_old_media = 
libvlc_media_player_get_media( ctx->p_mediaplayer );
+                    libvlc_media_player_set_media( ctx->p_mediaplayer, p_media 
);
+                    libvlc_media_release( p_old_media );
+
+                    libvlc_media_player_play( ctx->p_mediaplayer );
+                }
+                DragFinish(hDrop);
+            }
+            return 0;
+        case WM_KEYDOWN:
+        case WM_SYSKEYDOWN:
+            {
+                int key = tolower( MapVirtualKey( (UINT)wParam, 2 ) );
+                if (key == 'a')
+                {
+                    if (AspectRatio == NULL)
+                        AspectRatio = "16:10";
+                    else if (strcmp(AspectRatio,"16:10")==0)
+                        AspectRatio = "16:9";
+                    else if (strcmp(AspectRatio,"16:9")==0)
+                        AspectRatio = "4:3";
+                    else if (strcmp(AspectRatio,"4:3")==0)
+                        AspectRatio = "185:100";
+                    else if (strcmp(AspectRatio,"185:100")==0)
+                        AspectRatio = "221:100";
+                    else if (strcmp(AspectRatio,"221:100")==0)
+                        AspectRatio = "235:100";
+                    else if (strcmp(AspectRatio,"235:100")==0)
+                        AspectRatio = "239:100";
+                    else if (strcmp(AspectRatio,"239:100")==0)
+                        AspectRatio = "5:3";
+                    else if (strcmp(AspectRatio,"5:3")==0)
+                        AspectRatio = "5:4";
+                    else if (strcmp(AspectRatio,"5:4")==0)
+                        AspectRatio = "1:1";
+                    else if (strcmp(AspectRatio,"1:1")==0)
+                        AspectRatio = NULL;
+                    libvlc_video_set_aspect_ratio( ctx->p_mediaplayer, 
AspectRatio );
+                }
+                break;
+            }
+        default: break;
+    }
+
+    return DefWindowProc (hWnd, message, wParam, lParam);
+}
+
+int WINAPI WinMain(HINSTANCE hInstance,
+                   HINSTANCE hPrevInstance,
+                   LPSTR lpCmdLine,
+                   int nCmdShow)
+{
+    WNDCLASSEX wc;
+    char *file_path;
+    struct vlc_context Context;
+    libvlc_media_t *p_media;
+    (void)hPrevInstance;
+    HWND hWnd;
+
+    /* remove "" around the given path */
+    if (lpCmdLine[0] == '"')
+    {
+        file_path = _strdup( lpCmdLine+1 );
+        if (file_path[strlen(file_path)-1] == '"')
+            file_path[strlen(file_path)-1] = '\0';
+    }
+    else
+        file_path = _strdup( lpCmdLine );
+
+    Context.p_libvlc = libvlc_new( 0, NULL );
+    p_media = libvlc_media_new_path( Context.p_libvlc, file_path );
+    free( file_path );
+    Context.p_mediaplayer = libvlc_media_player_new_from_media( p_media );
+
+    ZeroMemory(&wc, sizeof(WNDCLASSEX));
+
+    wc.cbSize = sizeof(WNDCLASSEX);
+    wc.style = CS_HREDRAW | CS_VREDRAW;
+    wc.lpfnWndProc = WindowProc;
+    wc.hInstance = hInstance;
+    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+    wc.lpszClassName = "WindowClass";
+
+    RegisterClassEx(&wc);
+
+    RECT wr = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
+    AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);
+
+    hWnd = CreateWindowEx(0,
+                          "WindowClass",
+                          "libvlc Demo app",
+                          WS_OVERLAPPEDWINDOW,
+                          CW_USEDEFAULT, CW_USEDEFAULT,
+                          wr.right - wr.left,
+                          wr.bottom - wr.top,
+                          NULL,
+                          NULL,
+                          hInstance,
+                          &Context);
+    DragAcceptFiles(hWnd, TRUE);
+
+    libvlc_media_player_set_hwnd(Context.p_mediaplayer, hWnd);
+
+    ShowWindow(hWnd, nCmdShow);
+
+    libvlc_media_player_play( Context.p_mediaplayer );
+
+    MSG msg;
+    while (GetMessage(&msg, NULL, 0, 0))
+    {
+        TranslateMessage(&msg);
+        DispatchMessage(&msg);
+
+        if(msg.message == WM_QUIT)
+            break;
+    }
+
+    libvlc_media_player_stop( Context.p_mediaplayer );
+
+    libvlc_media_release( libvlc_media_player_get_media( Context.p_mediaplayer 
) );
+    libvlc_media_player_release( Context.p_mediaplayer );
+    libvlc_release( Context.p_libvlc );
+
+    return (int)msg.wParam;
+}



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/c4150b4d03467d336aa7590efd501bee51d7042e...bdeae9ac5eb9b1fb6ab6703b35c16870886cc0e1

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/c4150b4d03467d336aa7590efd501bee51d7042e...bdeae9ac5eb9b1fb6ab6703b35c16870886cc0e1
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to