[vlc-commits] [Git][videolan/vlc][master] 7 commits: macosx: Add a method to enable video filters in VLCPlayerController

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Apr 15 06:59:40 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
7f1872a8 by Claudio Cambra at 2026-04-15T06:40:41+00:00
macosx: Add a method to enable video filters in VLCPlayerController

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
fa4fa301 by Claudio Cambra at 2026-04-15T06:40:41+00:00
macosx: Add a method to apply properties on video filters in VLCPlayerController

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
49514432 by Claudio Cambra at 2026-04-15T06:40:41+00:00
macosx: Remove use of VLCVideoFilterHelper in VLCMainMenu

Addresses FIXMEs

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
4a08ca2c by Claudio Cambra at 2026-04-15T06:40:41+00:00
macosx: Add explanations for operations performed in VLCPlayerController enableVideoFilterWithName:state:

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
03bc0529 by Claudio Cambra at 2026-04-15T06:40:41+00:00
macosx: Remove unnecessary void casting

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
a72105cd by Claudio Cambra at 2026-04-15T06:40:41+00:00
macosx: Replace lengthOfBytesUsingEncoding with strlen

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
0355a3bd by Claudio Cambra at 2026-04-15T06:40:41+00:00
macosx: Improve clarity of variable naming, indexing in new player controller methods

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


3 changed files:

- modules/gui/macosx/menus/VLCMainMenu.m
- modules/gui/macosx/playqueue/VLCPlayerController.h
- modules/gui/macosx/playqueue/VLCPlayerController.m


Changes:

=====================================
modules/gui/macosx/menus/VLCMainMenu.m
=====================================
@@ -22,8 +22,6 @@
 
 #import "VLCMainMenu.h"
 
-#import "coreinteraction/VLCVideoFilterHelper.h"
-
 #import "extensions/NSScreen+VLCAdditions.h"
 #import "extensions/NSString+Helpers.h"
 
@@ -1191,19 +1189,16 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
 
 - (void)_disablePostProcessing
 {
-    // FIXME re-write using VLCPlayerController
-    [VLCVideoFilterHelper setVideoFilter:"postproc" on:false];
+    [_playerController enableVideoFilterWithName:@"postproc" state:NO];
 }
 
 - (void)_enablePostProcessing
 {
-    // FIXME re-write using VLCPlayerController
-    [VLCVideoFilterHelper setVideoFilter:"postproc" on:true];
+    [_playerController enableVideoFilterWithName:@"postproc" state:YES];
 }
 
 - (void)togglePostProcessing:(id)sender
 {
-    // FIXME re-write using VLCPlayerController
     NSInteger count = [_postprocessingMenu numberOfItems];
     for (NSUInteger x = 0; x < (NSUInteger)count; x++)
         [[_postprocessingMenu itemAtIndex:x] setState:NSOffState];
@@ -1215,7 +1210,7 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
         [self _enablePostProcessing];
         [sender setState:NSOnState];
 
-        [VLCVideoFilterHelper setVideoFilterProperty:"postproc-q" forFilter:"postproc" withValue:(vlc_value_t){ .i_int = [sender tag] }];
+        [_playerController setVideoFilterProperty:@"postproc-q" forFilter:@"postproc" withValue:(vlc_value_t){ .i_int = [sender tag] }];
     }
 }
 


=====================================
modules/gui/macosx/playqueue/VLCPlayerController.h
=====================================
@@ -889,6 +889,23 @@ extern const CGFloat VLCVolumeDefault;
 
 - (int)enableAudioFilterWithName:(NSString *)name state:(BOOL)state;
 
+/**
+ * Enable or disable a video filter by name
+ * @param name the name of the video filter module
+ * @param state YES to enable, NO to disable
+ * @return VLC_SUCCESS on success, error code otherwise
+ */
+- (int)enableVideoFilterWithName:(NSString *)name state:(BOOL)state;
+
+/**
+ * Set a property value for a video filter
+ * @param property the property name to set
+ * @param filterName the name of the video filter
+ * @param value the value to set
+ * @return VLC_SUCCESS on success, error code otherwise
+ */
+- (int)setVideoFilterProperty:(NSString *)property forFilter:(NSString *)filterName withValue:(vlc_value_t)value;
+
 @end
 
 @interface VLCInputStats : NSObject


=====================================
modules/gui/macosx/playqueue/VLCPlayerController.m
=====================================
@@ -24,6 +24,7 @@
 #include "vlc_player.h"
 
 #import <vlc_configuration.h>
+#import <vlc_modules.h>
 #import <vlc_url.h>
 
 #import "extensions/NSString+Helpers.h"
@@ -1974,6 +1975,116 @@ static int BossCallback(vlc_object_t *p_this,
     return vlc_player_aout_EnableFilter(_p_player, [name UTF8String], state);
 }
 
+- (int)enableVideoFilterWithName:(NSString *)name state:(BOOL)state
+{
+    if (name == nil || name.length == 0) {
+        return VLC_EINVAL;
+    }
+
+    vout_thread_t * const vout = [self mainVideoOutputThread];
+    if (vout == NULL) {
+        return VLC_EGENERIC;
+    }
+
+    const char * const nameUTF8String = name.UTF8String;
+    module_t * const module_obj = module_find(nameUTF8String);
+    if (module_obj == NULL) {
+        vout_Release(vout);
+        return VLC_EGENERIC;
+    }
+
+    const char *filter_type = NULL;
+    if (module_provides(module_obj, "video splitter")) {
+        filter_type = "video-splitter";
+    } else if (module_provides(module_obj, "video filter")) {
+        filter_type = "video-filter";
+    } else if (module_provides(module_obj, "sub source")) {
+        filter_type = "sub-source";
+    } else if (module_provides(module_obj, "sub filter")) {
+        filter_type = "sub-filter";
+    }
+
+    if (filter_type == NULL) {
+        vout_Release(vout);
+        return VLC_EGENERIC;
+    }
+
+    // Get the current filter string
+    char *modules_string = var_InheritString(vout, filter_type);
+
+    if (state) { // Enable the filter
+        if (modules_string == NULL) { // No current filters
+            modules_string = strdup(nameUTF8String);
+        } else if (strstr(modules_string, nameUTF8String) == NULL) { // Filter not already enabled
+            char *psz_tmp = NULL;
+            // Append the filter to the current filter string
+            if (asprintf(&psz_tmp, "%s:%s", modules_string, nameUTF8String) == -1) {
+                free(modules_string);
+                vout_Release(vout);
+                return VLC_ENOMEM;
+            }
+            free(modules_string);
+            modules_string = psz_tmp;
+        }
+    } else { // Disable the filter
+        if (modules_string == NULL) { // No current filters
+            vout_Release(vout);
+            return VLC_SUCCESS;
+        }
+
+        char * const parser = strstr(modules_string, nameUTF8String);
+        if (parser != NULL) { // Enabled filter found
+            const size_t name_len = strlen(nameUTF8String);
+            // Check the next character to see if it is a colon, if it is...
+            if (parser[name_len] == ':') { // ...filter is not the last one in the list
+                // Remove the filter from the list by moving the rest of the string after the filter left
+                memmove(parser, parser + name_len + 1,
+                        strlen(parser + name_len + 1) + 1);
+            } else { // Filter is the last one in the list
+                // Remove the filter from the list by setting the null terminator to the end of the string
+                *parser = '\0';
+            }
+
+            if (modules_string[0] != '\0' && modules_string[strlen(modules_string) - 1] == ':') {
+                // Remove the trailing colon if it exists
+                modules_string[strlen(modules_string) - 1] = '\0';
+            }
+        } else { // Filter not enabled, nothing needs doing
+            free(modules_string);
+            vout_Release(vout);
+            return VLC_SUCCESS;
+        }
+    }
+
+    var_SetString(vout, filter_type, modules_string);
+    free(modules_string);
+    vout_Release(vout);
+    return VLC_SUCCESS;
+}
+
+- (int)setVideoFilterProperty:(NSString *)property forFilter:(NSString *)filterName withValue:(vlc_value_t)value
+{
+    if (property == nil || property.length == 0 || filterName == nil || filterName.length == 0) {
+        return VLC_EINVAL;
+    }
+
+    vout_thread_t * const vout = [self mainVideoOutputThread];
+    if (vout == NULL) {
+        return VLC_EGENERIC;
+    }
+
+    const char * const propertyUTF8String = property.UTF8String;
+    int i_type = var_Type(vout, propertyUTF8String);
+    if (i_type == 0) {
+        i_type = config_GetType(propertyUTF8String);
+    }
+
+    i_type &= VLC_VAR_CLASS;
+    var_SetChecked(vout, propertyUTF8String, i_type, value);
+    vout_Release(vout);
+    return VLC_SUCCESS;
+}
+
 @end
 
 @implementation VLCInputStats



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4034598d821ea86b4dc2ec9a2577e39a537ac55b...0355a3bd16e06641cfd6b689fa0c7a8ac96e3047

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




More information about the vlc-commits mailing list