[vlc-commits] macosx: setup filter variables on the main vout
Thomas Guillem
git at videolan.org
Fri May 10 09:51:43 CEST 2019
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Apr 16 13:36:22 2019 +0200| [520d8560e4ce6e9dd2498ba0f85fbd56f3c9c2b0] | committer: Thomas Guillem
macosx: setup filter variables on the main vout
The vout is now always present, there is no need to use the old playlist as a
proxy.
IMPORTANT: the video filter settings will now only change for the main vout. We
need to define a way to change vout settings for other windows.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=520d8560e4ce6e9dd2498ba0f85fbd56f3c9c2b0
---
.../macosx/coreinteraction/VLCVideoFilterHelper.m | 76 +++--------
.../panels/VLCVideoEffectsWindowController.m | 151 +++++++++++----------
2 files changed, 97 insertions(+), 130 deletions(-)
diff --git a/modules/gui/macosx/coreinteraction/VLCVideoFilterHelper.m b/modules/gui/macosx/coreinteraction/VLCVideoFilterHelper.m
index b3dd9b801b..fb6627fb9f 100644
--- a/modules/gui/macosx/coreinteraction/VLCVideoFilterHelper.m
+++ b/modules/gui/macosx/coreinteraction/VLCVideoFilterHelper.m
@@ -24,7 +24,6 @@
#import <vlc_modules.h>
#import <vlc_charset.h>
-#import <vlc_playlist_legacy.h>
#import "main/VLCMain.h"
#import "playlist/VLCPlaylistController.h"
@@ -58,7 +57,6 @@
intf_thread_t *p_intf = getIntf();
if (!p_intf)
return;
- playlist_t *p_playlist = pl_Get(p_intf);
char *psz_string, *psz_parser;
const char *psz_filter_type = [self getFilterType:psz_name];
@@ -67,9 +65,14 @@
return;
}
+ VLCPlayerController *playerController = [[[VLCMain sharedInstance] playlistController] playerController];
+ vout_thread_t *vout = [playerController mainVideoOutputThread];
+ if (!vout)
+ return;
+
msg_Dbg(p_intf, "will turn filter '%s' %s", psz_name, b_on ? "on" : "off");
- psz_string = var_InheritString(p_playlist, psz_filter_type);
+ psz_string = var_InheritString(vout, psz_filter_type);
if (b_on) {
if (psz_string == NULL) {
@@ -81,7 +84,10 @@
}
} else {
if (!psz_string)
+ {
+ vout_Release(vout);
return;
+ }
psz_parser = strstr(psz_string, psz_name);
if (psz_parser) {
@@ -97,22 +103,12 @@
*(psz_string + strlen(psz_string) -1) = '\0';
} else {
free(psz_string);
+ vout_Release(vout);
return;
}
}
- var_SetString(p_playlist, psz_filter_type, psz_string);
-
- /* Try to set non splitter filters on the fly */
- if (strcmp(psz_filter_type, "video-splitter")) {
- NSArray<NSValue *> *vouts = [[[[VLCMain sharedInstance] playlistController] playerController] allVideoOutputThreads];
- if (vouts)
- for (NSValue * val in vouts) {
- vout_thread_t *p_vout = [val pointerValue];
- var_SetString(p_vout, psz_filter_type, psz_string);
- vout_Release(p_vout);
- }
- }
-
+ var_SetString(vout, psz_filter_type, psz_string);
+ vout_Release(vout);
free(psz_string);
}
@@ -120,13 +116,10 @@
forFilter: (char const *)psz_filter
withValue: (vlc_value_t)value
{
- NSArray<NSValue *> *vouts = [[[[VLCMain sharedInstance] playlistController] playerController] allVideoOutputThreads];
intf_thread_t *p_intf = getIntf();
if (!p_intf)
return;
- playlist_t *p_playlist = pl_Get(p_intf);
-
int i_type = 0;
bool b_is_command = false;
char const *psz_filter_type = [self getFilterType: psz_filter];
@@ -135,47 +128,18 @@
return;
}
- if (vouts && [vouts count])
- {
- i_type = var_Type((vout_thread_t *)[[vouts firstObject] pointerValue], psz_property);
- b_is_command = i_type & VLC_VAR_ISCOMMAND;
- }
+ VLCPlayerController *playerController = [[[VLCMain sharedInstance] playlistController] playerController];
+ vout_thread_t *vout = [playerController mainVideoOutputThread];
+ if (!vout)
+ return;
+
+ i_type = var_Type(vout, psz_property);
if (!i_type)
i_type = config_GetType(psz_property);
i_type &= VLC_VAR_CLASS;
- if (i_type == VLC_VAR_BOOL)
- var_SetBool(p_playlist, psz_property, value.b_bool);
- else if (i_type == VLC_VAR_INTEGER)
- var_SetInteger(p_playlist, psz_property, value.i_int);
- else if (i_type == VLC_VAR_FLOAT)
- var_SetFloat(p_playlist, psz_property, value.f_float);
- else if (i_type == VLC_VAR_STRING)
- var_SetString(p_playlist, psz_property, EnsureUTF8(value.psz_string));
- else
- {
- msg_Err(p_intf,
- "Module %s's %s variable is of an unsupported type ( %d )",
- psz_filter, psz_property, i_type);
- b_is_command = false;
- }
-
- if (b_is_command)
- if (vouts)
- for (NSValue *ptr in vouts)
- {
- vout_thread_t *p_vout = [ptr pointerValue];
- var_SetChecked(p_vout, psz_property, i_type, value);
-#ifndef NDEBUG
- int i_cur_type = var_Type(p_vout, psz_property);
- assert((i_cur_type & VLC_VAR_CLASS) == i_type);
- assert(i_cur_type & VLC_VAR_ISCOMMAND);
-#endif
- }
-
- if (vouts)
- for (NSValue *ptr in vouts)
- vout_Release((vout_thread_t *)[ptr pointerValue]);
+ var_SetChecked(vout, psz_property, i_type, value);
+ vout_Release(vout);
}
diff --git a/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m b/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
index fe92d65a84..254b04f6cc 100644
--- a/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
+++ b/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
@@ -33,8 +33,6 @@
#import "playlist/VLCPlayerController.h"
#import "windows/video/VLCVideoOutputProvider.h"
-#import <vlc_playlist_legacy.h>
-
#define getWidgetBoolValue(w) ((vlc_value_t){ .b_bool = [w state] })
#define getWidgetIntValue(w) ((vlc_value_t){ .i_int = [w intValue] })
#define getWidgetFloatValue(w) ((vlc_value_t){ .f_float = [w floatValue] })
@@ -92,7 +90,6 @@
- (void)loadProfile
{
intf_thread_t *p_intf = getIntf();
- playlist_t *p_playlist = pl_Get(p_intf);
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSInteger profileIndex = [self currentProfileIndex];
@@ -112,36 +109,27 @@
/* filter handling */
NSString *tempString = B64DecNSStr([items firstObject]);
- NSArray<NSValue *> *vouts = [[[[VLCMain sharedInstance] playlistController] playerController] allVideoOutputThreads];
+ VLCPlayerController *playerController = [[[VLCMain sharedInstance] playlistController] playerController];
+ vout_thread_t *vout = [playerController mainVideoOutputThread];
/* enable the new filters */
- var_SetString(p_playlist, "video-filter", [tempString UTF8String]);
- if (vouts) {
- for (NSValue *ptr in vouts) {
- vout_thread_t *p_vout = [ptr pointerValue];
- var_SetString(p_vout, "video-filter", [tempString UTF8String]);
- }
- }
+ if (vout)
+ var_SetString(vout, "video-filter", [tempString UTF8String]);
tempString = B64DecNSStr([items objectAtIndex:1]);
/* enable another round of new filters */
- var_SetString(p_playlist, "sub-source", [tempString UTF8String]);
- if (vouts) {
- for (NSValue *ptr in vouts) {
- vout_thread_t *p_vout = [ptr pointerValue];
- var_SetString(p_vout, "sub-source", [tempString UTF8String]);
- vout_Release(p_vout);
- }
- }
+ if (vout)
+ var_SetString(vout, "sub-source", [tempString UTF8String]);
tempString = B64DecNSStr([items objectAtIndex:2]);
/* enable another round of new filters */
- char *psz_current_splitter = var_GetString(p_playlist, "video-splitter");
- bool b_filter_changed = ![tempString isEqualToString:toNSStr(psz_current_splitter)];
+ char *psz_current_splitter = vout ? var_GetString(vout, "video-splitter") : NULL;
+ bool b_filter_changed = psz_current_splitter && ![tempString isEqualToString:toNSStr(psz_current_splitter)];
free(psz_current_splitter);
if (b_filter_changed)
- var_SetString(p_playlist, "video-splitter", [tempString UTF8String]);
+ var_SetString(vout, "video-splitter", [tempString UTF8String]);
+ vout_Release(vout);
/* try to set filter values on-the-fly and store them appropriately */
// index 3 is deprecated
@@ -409,7 +397,6 @@
- (void)setWidgetValue: (id)widget forOption: (char *)psz_option enabled: (bool)b_state
{
intf_thread_t *p_intf = getIntf();
- playlist_t *p_playlist = pl_Get(p_intf);
vlc_value_t val;
int i_type = config_GetType(psz_option) & VLC_VAR_CLASS;
@@ -425,10 +412,17 @@
return;
}
- if (var_Create(p_playlist, psz_option, i_type | VLC_VAR_DOINHERIT) ||
- var_GetChecked(p_playlist, psz_option, i_type, &val)) {
+ VLCPlayerController *playerController = [[[VLCMain sharedInstance] playlistController] playerController];
+ vout_thread_t *vout = [playerController mainVideoOutputThread];
+ if (!vout)
+ return;
+
+ if (var_Create(vout, psz_option, i_type | VLC_VAR_DOINHERIT) ||
+ var_GetChecked(vout, psz_option, i_type, &val)) {
+ vout_Release(vout);
return;
}
+ vout_Release(vout);
if (i_type == VLC_VAR_BOOL || i_type == VLC_VAR_INTEGER)
{
@@ -478,12 +472,15 @@
- (void)resetValues
{
intf_thread_t *p_intf = getIntf();
- playlist_t *p_playlist = pl_Get(p_intf);
+ VLCPlayerController *playerController = [[[VLCMain sharedInstance] playlistController] playerController];
+ vout_thread_t *vout = [playerController mainVideoOutputThread];
+ if (!vout)
+ return;
BOOL b_state;
/* do we have any filter enabled? if yes, show it. */
char * psz_vfilters;
- psz_vfilters = var_InheritString(p_playlist, "video-filter");
+ psz_vfilters = var_InheritString(vout, "video-filter");
if (psz_vfilters) {
[_adjustCheckbox setState: (NSInteger)strstr(psz_vfilters, "adjust")];
[_sharpenCheckbox setState: (NSInteger)strstr(psz_vfilters, "sharpen")];
@@ -527,7 +524,7 @@
[_anaglyphCheckbox setState: NSOffState];
}
- psz_vfilters = var_InheritString(p_playlist, "sub-source");
+ psz_vfilters = var_InheritString(vout, "sub-source");
if (psz_vfilters) {
[_addTextCheckbox setState: (NSInteger)strstr(psz_vfilters, "marq")];
[_addLogoCheckbox setState: (NSInteger)strstr(psz_vfilters, "logo")];
@@ -537,7 +534,7 @@
[_addLogoCheckbox setState: NSOffState];
}
- psz_vfilters = var_InheritString(p_playlist, "video-splitter");
+ psz_vfilters = var_InheritString(vout, "video-splitter");
if (psz_vfilters) {
[_cloneCheckbox setState: (NSInteger)strstr(psz_vfilters, "clone")];
[_wallCheckbox setState: (NSInteger)strstr(psz_vfilters, "wall")];
@@ -547,6 +544,8 @@
[_wallCheckbox setState: NSOffState];
}
+ vout_Release(vout);
+
/* fetch and show the various values */
b_state = [_adjustCheckbox state];
[self setWidgetValue: _adjustHueSlider forOption: "hue" enabled: b_state];
@@ -649,45 +648,50 @@
- (NSString *)generateProfileString
{
intf_thread_t *p_intf = getIntf();
- playlist_t *p_playlist = pl_Get(p_intf);
- return [NSString stringWithFormat:@"%@;%@;%@;%lli;%f;%f;%f;%f;%f;%lli;%f;%@;%lli;%lli;%lli;%lli;%lli;%lli;%@;%lli;%lli;%lli;%lli;%lli;%@;%lli;%@;%lli;%lli;%lli;%lli;%lli;%lli;%f",
- B64EncAndFree(var_InheritString(p_playlist, "video-filter")),
- B64EncAndFree(var_InheritString(p_playlist, "sub-source")),
- B64EncAndFree(var_InheritString(p_playlist, "video-splitter")),
+ VLCPlayerController *playerController = [[[VLCMain sharedInstance] playlistController] playerController];
+ vout_thread_t *vout = [playerController mainVideoOutputThread];
+ if (!vout)
+ return nil;
+ NSString *string = [NSString stringWithFormat:@"%@;%@;%@;%lli;%f;%f;%f;%f;%f;%lli;%f;%@;%lli;%lli;%lli;%lli;%lli;%lli;%@;%lli;%lli;%lli;%lli;%lli;%@;%lli;%@;%lli;%lli;%lli;%lli;%lli;%lli;%f",
+ B64EncAndFree(var_InheritString(vout, "video-filter")),
+ B64EncAndFree(var_InheritString(vout, "sub-source")),
+ B64EncAndFree(var_InheritString(vout, "video-splitter")),
0LL, // former "hue" value, deprecated since 3.0.0
- var_InheritFloat(p_playlist, "contrast"),
- var_InheritFloat(p_playlist, "brightness"),
- var_InheritFloat(p_playlist, "saturation"),
- var_InheritFloat(p_playlist, "gamma"),
- var_InheritFloat(p_playlist, "sharpen-sigma"),
- var_InheritInteger(p_playlist, "gradfun-radius"),
- var_InheritFloat(p_playlist, "grain-variance"),
- B64EncAndFree(var_InheritString(p_playlist, "transform-type")),
- var_InheritInteger(p_playlist, "puzzle-rows"),
- var_InheritInteger(p_playlist, "puzzle-cols"),
- var_InheritInteger(p_playlist, "colorthres-color"),
- var_InheritInteger(p_playlist, "colorthres-saturationthres"),
- var_InheritInteger(p_playlist, "colorthres-similaritythres"),
- var_InheritInteger(p_playlist, "sepia-intensity"),
- B64EncAndFree(var_InheritString(p_playlist, "gradient-mode")),
- (int64_t)var_InheritBool(p_playlist, "gradient-cartoon"),
- var_InheritInteger(p_playlist, "gradient-type"),
- var_InheritInteger(p_playlist, "extract-component"),
- var_InheritInteger(p_playlist, "posterize-level"),
- var_InheritInteger(p_playlist, "blur-factor"),
- B64EncAndFree(var_InheritString(p_playlist, "marq-marquee")),
- var_InheritInteger(p_playlist, "marq-position"),
- B64EncAndFree(var_InheritString(p_playlist, "logo-file")),
- var_InheritInteger(p_playlist, "logo-position"),
- var_InheritInteger(p_playlist, "logo-opacity"),
- var_InheritInteger(p_playlist, "clone-count"),
- var_InheritInteger(p_playlist, "wall-rows"),
- var_InheritInteger(p_playlist, "wall-cols"),
+ var_InheritFloat(vout, "contrast"),
+ var_InheritFloat(vout, "brightness"),
+ var_InheritFloat(vout, "saturation"),
+ var_InheritFloat(vout, "gamma"),
+ var_InheritFloat(vout, "sharpen-sigma"),
+ var_InheritInteger(vout, "gradfun-radius"),
+ var_InheritFloat(vout, "grain-variance"),
+ B64EncAndFree(var_InheritString(vout, "transform-type")),
+ var_InheritInteger(vout, "puzzle-rows"),
+ var_InheritInteger(vout, "puzzle-cols"),
+ var_InheritInteger(vout, "colorthres-color"),
+ var_InheritInteger(vout, "colorthres-saturationthres"),
+ var_InheritInteger(vout, "colorthres-similaritythres"),
+ var_InheritInteger(vout, "sepia-intensity"),
+ B64EncAndFree(var_InheritString(vout, "gradient-mode")),
+ (int64_t)var_InheritBool(vout, "gradient-cartoon"),
+ var_InheritInteger(vout, "gradient-type"),
+ var_InheritInteger(vout, "extract-component"),
+ var_InheritInteger(vout, "posterize-level"),
+ var_InheritInteger(vout, "blur-factor"),
+ B64EncAndFree(var_InheritString(vout, "marq-marquee")),
+ var_InheritInteger(vout, "marq-position"),
+ B64EncAndFree(var_InheritString(vout, "logo-file")),
+ var_InheritInteger(vout, "logo-position"),
+ var_InheritInteger(vout, "logo-opacity"),
+ var_InheritInteger(vout, "clone-count"),
+ var_InheritInteger(vout, "wall-rows"),
+ var_InheritInteger(vout, "wall-cols"),
// version 2 of profile string:
- (int64_t)var_InheritBool(p_playlist, "brightness-threshold"), // index: 32
+ (int64_t)var_InheritBool(vout, "brightness-threshold"), // index: 32
// version 3 of profile string: (vlc-3.0.0)
- var_InheritFloat(p_playlist, "hue") // index: 33
+ var_InheritFloat(vout, "hue") // index: 33
];
+ vout_Release(vout);
+ return string;
}
#pragma mark -
@@ -1016,16 +1020,15 @@
[self setCropRightValue: [self cropLeftValue]];
}
- NSArray<NSValue *> *vouts = [[[[VLCMain sharedInstance] playlistController] playerController] allVideoOutputThreads];
- if (vouts)
- for (NSValue *ptr in vouts) {
- vout_thread_t *p_vout = [ptr pointerValue];
- var_SetInteger(p_vout, "crop-top", [_cropTopTextField intValue]);
- var_SetInteger(p_vout, "crop-bottom", [_cropBottomTextField intValue]);
- var_SetInteger(p_vout, "crop-left", [_cropLeftTextField intValue]);
- var_SetInteger(p_vout, "crop-right", [_cropRightTextField intValue]);
- vout_Release(p_vout);
- }
+ VLCPlayerController *playerController = [[[VLCMain sharedInstance] playlistController] playerController];
+ vout_thread_t *p_vout = [playerController mainVideoOutputThread];
+ if (p_vout) {
+ var_SetInteger(p_vout, "crop-top", [_cropTopTextField intValue]);
+ var_SetInteger(p_vout, "crop-bottom", [_cropBottomTextField intValue]);
+ var_SetInteger(p_vout, "crop-left", [_cropLeftTextField intValue]);
+ var_SetInteger(p_vout, "crop-right", [_cropRightTextField intValue]);
+ vout_Release(p_vout);
+ }
}
#pragma mark -
More information about the vlc-commits
mailing list