1 /*****************************************************************************
2 * extended.m: MacOS X Extended interface panel
3 *****************************************************************************
4 * Copyright (C) 2005-2006 the VideoLAN team
7 * Authors: Felix Kühne <fkuehne@users.sf.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
25 /*****************************************************************************
27 * the code used to bind with VLC's modules is heavily based upon
28 * ../wxwidgets/extrapanel.cpp, written by Clément Stenac.
29 * the code used to insert/remove the views was inspired by intf.m,
30 * written by Derk-Jan Hartman and Benjamin Pracht.
31 * (all 3 are members of the VideoLAN team)
32 *****************************************************************************/
35 /*****************************************************************************
37 *****************************************************************************/
44 #import <vlc_interface.h>
46 /*****************************************************************************
47 * VLCExtended implementation
48 *****************************************************************************/
50 @implementation VLCExtended
52 static VLCExtended *_o_sharedInstance = nil;
54 + (VLCExtended *)sharedInstance
56 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
61 if (_o_sharedInstance) {
64 _o_sharedInstance = [super init];
67 return _o_sharedInstance;
70 /*****************************************************************************
72 *****************************************************************************/
76 /* localise GUI-strings */
77 /* method is called from intf.m (in method showExtended) */
78 [o_extended_window setTitle: _NS("Extended controls")];
79 [o_lbl_video setStringValue: _NS("Video")];
80 [o_lbl_audio setStringValue: _NS("Audio")];
81 [o_lbl_audioFlts setStringValue: _NS("Audio filters")];
82 [o_lbl_videoFlts setStringValue: _NS("Video filters")];
83 [o_lbl_adjustImage setStringValue: _NS("Image adjustment")];
84 [o_btn_vidFlts_mrInfo setToolTip: _NS("Shows more information about the available video filters.")];
85 [o_ckb_wave setTitle: _NS("Wave")];
86 [o_ckb_ripple setTitle: _NS("Ripple")];
87 [o_ckb_psycho setTitle: _NS("Psychedelic")];
88 [o_ckb_gradient setTitle: _NS("Gradient")];
89 [o_lbl_general setStringValue: _NS("General editing filters")];
90 [o_lbl_distort setStringValue: _NS("Distortion filters")];
91 [o_ckb_blur setTitle: _NS("Blur")];
92 [o_ckb_blur setToolTip: _NS("Adds motion blurring to the image")];
93 [o_ckb_imgClone setTitle: _NS("Image clone")];
94 [o_ckb_imgClone setToolTip: _NS("Creates several copies of the Video "
96 [o_ckb_imgCrop setTitle: _NS("Image cropping")];
97 [o_ckb_imgCrop setToolTip: _NS("Crops a defined part of the image")];
98 [o_ckb_imgInvers setTitle: _NS("Invert colors")];
99 [o_ckb_imgInvers setToolTip: _NS("Inverts the colors of the image")];
100 [o_ckb_trnsform setTitle: _NS("Transformation")];
101 [o_ckb_trnsform setToolTip: _NS("Rotates or flips the image")];
102 [o_ckb_intZoom setTitle: _NS("Interactive Zoom")];
103 [o_ckb_intZoom setToolTip: _NS("Enables an interactive Zoom feature")];
104 [o_ckb_vlme_norm setTitle: _NS("Volume normalization")];
105 [o_ckb_vlme_norm setToolTip: _NS("Prevents the audio output from going "
106 "over a predefined value.")];
107 [o_ckb_hdphnVirt setTitle: _NS("Headphone virtualization")];
108 [o_ckb_hdphnVirt setToolTip: _NS("Imitates the effect of surround sound "
109 "when using headphones.")];
110 [o_lbl_maxLevel setStringValue: _NS("Maximum level")];
111 [o_btn_rstrDefaults setTitle: _NS("Restore Defaults")];
112 [o_ckb_enblAdjustImg setTitle: _NS("Enable")];
113 [o_lbl_brightness setStringValue: _NS("Brightness")];
114 [o_lbl_contrast setStringValue: _NS("Contrast")];
115 [o_lbl_gamma setStringValue: _NS("Gamma")];
116 [o_lbl_hue setStringValue: _NS("Hue")];
117 [o_lbl_saturation setStringValue: _NS("Saturation")];
118 [o_lbl_opaque setStringValue: _NS("Opaqueness")];
124 /* set the adjust-filter-sliders to the values from the prefs and enable
127 intf_thread_t * p_intf = VLCIntf;
128 psz_vfilters = config_GetPsz( p_intf, "vout-filter" );
129 /* set the video-filter-checkboxes to the correct values */
132 [o_ckb_blur setState: (int)strstr( psz_vfilters, "motionblur")];
133 [o_ckb_imgClone setState: (int)strstr( psz_vfilters, "clone")];
134 [o_ckb_imgCrop setState: (int)strstr( psz_vfilters, "crop")];
135 [o_ckb_trnsform setState: (int)strstr( psz_vfilters, "transform")];
137 free( psz_vfilters );
140 /* set the video-filter checkboxes to the correct values */
141 char * psz_vifilters;
142 psz_vifilters = config_GetPsz( p_intf, "video-filter" );
143 if( psz_vifilters && strstr( psz_vifilters, "adjust" ) )
145 [o_ckb_enblAdjustImg setState: NSOnState];
146 [o_btn_rstrDefaults setEnabled: YES];
147 [o_sld_brightness setEnabled: YES];
148 [o_sld_contrast setEnabled: YES];
149 [o_sld_gamma setEnabled: YES];
150 [o_sld_hue setEnabled: YES];
151 [o_sld_saturation setEnabled: YES];
155 [o_ckb_enblAdjustImg setState: NSOffState];
156 [o_btn_rstrDefaults setEnabled: NO];
157 [o_sld_brightness setEnabled: NO];
158 [o_sld_contrast setEnabled: NO];
159 [o_sld_gamma setEnabled: NO];
160 [o_sld_hue setEnabled: NO];
161 [o_sld_saturation setEnabled: NO];
165 [o_ckb_wave setState: (int)strstr( psz_vifilters, "wave")];
166 [o_ckb_psycho setState: (int)strstr( psz_vifilters, "psychedelic")];
167 [o_ckb_ripple setState: (int)strstr( psz_vifilters, "ripple")];
168 [o_ckb_gradient setState: (int)strstr( psz_vifilters, "gradient")];
169 [o_ckb_imgInvers setState: (int)strstr( psz_vifilters, "invert")];
171 free( psz_vifilters );
174 /* set the audio-filter-checkboxes to the values taken from the prefs */
176 psz_afilters = config_GetPsz( p_intf, "audio-filter" );
179 [o_ckb_hdphnVirt setState: (int)strstr( psz_afilters, "headphone" ) ];
180 [o_ckb_vlme_norm setState: (int)strstr( psz_afilters, "normvol" ) ];
182 free( psz_afilters );
188 /* collaps all views so Cocoa saves the window position correctly */
189 if( o_adjImg_expanded )
191 [self extWin_exp_adjImg: nil];
193 if( o_audFlts_expanded )
195 [self extWin_exp_audFlts: nil];
197 if( o_vidFlts_expanded )
199 [self extWin_exp_vidFlts: nil];
203 - (BOOL)getConfigChanged
205 return o_config_changed;
210 /* get the correct slider values from the prefs, in case they were changed
212 intf_thread_t * p_intf = VLCIntf;
214 int i_value = config_GetInt( p_intf, "hue" );
215 if( i_value > 0 && i_value < 360 )
217 [o_sld_hue setIntValue: i_value];
222 f_value = config_GetFloat( p_intf, "saturation" );
223 if( f_value > 0 && f_value < 5 )
225 [o_sld_saturation setIntValue: (int)(100 * f_value) ];
228 f_value = config_GetFloat( p_intf, "contrast" );
229 if( f_value > 0 && f_value < 4 )
231 [o_sld_contrast setIntValue: (int)(100 * f_value) ];
234 f_value = config_GetFloat( p_intf, "brightness" );
235 if( f_value > 0 && f_value < 2 )
237 [o_sld_brightness setIntValue: (int)(100 * f_value) ];
240 f_value = config_GetFloat( p_intf, "gamma" );
241 if( f_value > 0 && f_value < 10 )
243 [o_sld_gamma setIntValue: (int)(10 * f_value) ];
246 f_value = config_GetFloat( p_intf, "norm-max-level" );
247 if( f_value > 0 && f_value < 10 )
249 [o_sld_maxLevel setFloatValue: f_value ];
252 [o_sld_opaque setFloatValue: (config_GetFloat( p_intf,
253 "macosx-opaqueness") * 100)];
256 /* show the window */
257 [o_extended_window displayIfNeeded];
258 [o_extended_window makeKeyAndOrderFront:nil];
261 - (IBAction)adjImg_Enbl:(id)sender
263 /* en-/disable the sliders */
264 if ([o_ckb_enblAdjustImg state] == NSOnState)
266 [o_btn_rstrDefaults setEnabled: YES];
267 [o_sld_brightness setEnabled: YES];
268 [o_sld_contrast setEnabled: YES];
269 [o_sld_gamma setEnabled: YES];
270 [o_sld_hue setEnabled: YES];
271 [o_sld_saturation setEnabled: YES];
272 [self changeVideoFiltersString: "adjust" onOrOff: VLC_TRUE];
274 [o_btn_rstrDefaults setEnabled: NO];
275 [o_sld_brightness setEnabled: NO];
276 [o_sld_contrast setEnabled: NO];
277 [o_sld_gamma setEnabled: NO];
278 [o_sld_hue setEnabled: NO];
279 [o_sld_saturation setEnabled: NO];
280 [self changeVideoFiltersString: "adjust" onOrOff: VLC_FALSE];
284 - (IBAction)adjImg_rstrDefaults:(id)sender
286 /* reset the sliders */
287 [o_sld_brightness setIntValue: 100];
288 [o_sld_contrast setIntValue: 100];
289 [o_sld_gamma setIntValue: 10];
290 [o_sld_hue setIntValue: 0];
291 [o_sld_saturation setIntValue: 100];
293 /* transmit the values */
294 [self adjImg_sliders: o_sld_brightness];
295 [self adjImg_sliders: o_sld_contrast];
296 [self adjImg_sliders: o_sld_gamma];
297 [self adjImg_sliders: o_sld_hue];
298 [self adjImg_sliders: o_sld_saturation];
301 - (IBAction)adjImg_sliders:(id)sender
303 /* read-out the sliders' values and apply them */
304 intf_thread_t * p_intf = VLCIntf;
305 vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find(p_intf,
306 VLC_OBJECT_VOUT, FIND_ANYWHERE);
309 if (sender == o_sld_brightness)
311 config_PutFloat( p_intf , "brightness" , [o_sld_brightness floatValue] / 100);
312 } else if (sender == o_sld_contrast)
314 config_PutFloat( p_intf , "contrast" , [o_sld_contrast floatValue] / 100);
315 } else if (sender == o_sld_gamma)
317 config_PutFloat( p_intf , "gamma" , [o_sld_gamma floatValue] / 10);
318 } else if (sender == o_sld_hue)
320 config_PutInt( p_intf , "hue" , [o_sld_hue intValue]);
321 } else if (sender == o_sld_saturation)
323 config_PutFloat( p_intf , "saturation" , [o_sld_saturation floatValue] / 100);
325 msg_Warn( p_intf, "the corresponding subfilter coundn't be found" );
329 if (sender == o_sld_brightness)
331 val.f_float = [o_sld_brightness floatValue] / 100;
332 var_Set( p_vout, "brightness", val );
333 config_PutFloat( p_intf , "brightness" , [o_sld_brightness floatValue] / 100);
334 } else if (sender == o_sld_contrast)
336 val.f_float = [o_sld_contrast floatValue] / 100;
337 var_Set( p_vout, "contrast", val );
338 config_PutFloat( p_intf , "contrast" , [o_sld_contrast floatValue] / 100);
339 } else if (sender == o_sld_gamma)
341 val.f_float = [o_sld_gamma floatValue] / 10;
342 var_Set( p_vout, "gamma", val );
343 config_PutFloat( p_intf , "gamma" , [o_sld_gamma floatValue] / 10);
344 } else if (sender == o_sld_hue)
346 val.i_int = [o_sld_hue intValue];
347 var_Set( p_vout, "hue", val );
348 config_PutInt( p_intf , "hue" , [o_sld_hue intValue]);
349 } else if (sender == o_sld_saturation)
351 val.f_float = [o_sld_saturation floatValue] / 100;
352 var_Set( p_vout, "saturation", val );
353 config_PutFloat( p_intf , "saturation" , [o_sld_saturation floatValue] / 100);
355 msg_Warn( p_intf, "the corresponding subfilter coundn't be found" );
357 vlc_object_release( p_vout );
360 o_config_changed = YES;
363 /* change the opaqueness of the vouts */
364 - (IBAction)adjImg_opaque:(id)sender
367 id o_window = [NSApp keyWindow];
368 NSArray *o_windows = [NSApp orderedWindows];
369 NSEnumerator *o_enumerator = [o_windows objectEnumerator];
370 playlist_t * p_playlist = pl_Yield( VLCIntf );
371 vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
372 vout_thread_t *p_real_vout;
374 val.f_float = [o_sld_opaque floatValue] / 100;
379 p_real_vout = [VLCVoutView getRealVout: p_vout];
380 var_Set( p_real_vout, "macosx-opaqueness", val );
382 while ((o_window = [o_enumerator nextObject]))
384 if( [[o_window className] isEqualToString: @"VLCVoutWindow"] ||
385 [[[VLCMain sharedInstance] getEmbeddedList]
386 windowContainsEmbedded: o_window])
388 [o_window setAlphaValue: val.f_float];
392 vlc_object_release( p_vout );
396 config_PutFloat( p_playlist , "macosx-opaqueness" , val.f_float );
398 vlc_object_release( p_playlist );
400 o_config_changed = YES;
403 - (IBAction)audFtls_hdphnVirt:(id)sender
405 /* en-/disable headphone virtualisation */
406 if ([o_ckb_hdphnVirt state] == NSOnState)
408 [self changeAFiltersString: "headphone_channel_mixer" onOrOff: VLC_TRUE ];
410 [self changeAFiltersString: "headphone_channel_mixer" onOrOff: VLC_FALSE ];
414 - (IBAction)audFtls_maxLevelSld:(id)sender
416 /* read-out the slider's value and apply it */
417 intf_thread_t * p_intf = VLCIntf;
418 aout_instance_t * p_aout= (aout_instance_t *)vlc_object_find(p_intf,
419 VLC_OBJECT_AOUT, FIND_ANYWHERE);
422 var_SetFloat( p_aout, "norm-max-level", [o_sld_maxLevel floatValue] );
423 vlc_object_release( p_aout );
425 config_PutFloat( p_intf, "norm-max-level", [o_sld_maxLevel floatValue] );
427 o_config_changed = YES;
430 - (IBAction)audFtls_vlmeNorm:(id)sender
432 /* en-/disable volume normalisation */
433 if ([o_ckb_vlme_norm state] == NSOnState)
435 [self changeAFiltersString: "normvol" onOrOff: YES ];
437 [self changeAFiltersString: "normvol" onOrOff: NO ];
441 - (IBAction)extWin_exp_adjImg:(id)sender
443 /* expand or collapse adjImg */
444 NSRect o_win_rect = [o_extended_window frame];
445 NSRect o_box_audFlts_rect = [o_box_audFlts frame];
446 NSRect o_box_vidFlts_rect = [o_box_vidFlts frame];
447 NSRect o_box_adjImg_rect = [o_box_adjImg frame];
449 if (o_adjImg_expanded)
451 /* move the window contents upwards (partially done through settings
452 * inside the nib) and resize the window */
453 o_win_rect.size.height = o_win_rect.size.height - 193;
454 o_win_rect.origin.y = [o_extended_window frame].origin.y + 193;
455 o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y + 193;
456 o_box_vidFlts_rect.origin.y = o_box_vidFlts_rect.origin.y + 193;
458 /* remove the inserted view */
459 [o_adjustImg_view removeFromSuperviewWithoutNeedingDisplay];
462 /* move the window contents downwards and resize the window */
463 o_win_rect.size.height = o_win_rect.size.height + 193;
464 o_win_rect.origin.y = [o_extended_window frame].origin.y - 193;
465 o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y - 193;
466 o_box_vidFlts_rect.origin.y = o_box_vidFlts_rect.origin.y - 193;
469 [o_box_audFlts setFrameFromContentFrame: o_box_audFlts_rect];
470 [o_box_vidFlts setFrameFromContentFrame: o_box_vidFlts_rect];
471 [o_extended_window displayIfNeeded];
472 [o_extended_window setFrame: o_win_rect display:YES animate: YES];
474 if (o_adjImg_expanded)
476 o_box_adjImg_rect.size.height = [o_box_adjImg frame].size.height - 193;
477 o_adjImg_expanded = NO;
480 o_box_adjImg_rect.size.height = [o_box_adjImg frame].size.height + 193;
481 [o_adjustImg_view setFrame: NSMakeRect( 20, -10, 370, 203)];
482 [o_adjustImg_view setNeedsDisplay:YES];
483 [o_adjustImg_view setAutoresizesSubviews: YES];
484 [[o_box_adjImg contentView] addSubview: o_adjustImg_view];
485 o_adjImg_expanded = YES;
487 [o_box_adjImg setFrameFromContentFrame: o_box_adjImg_rect];
490 - (IBAction)extWin_exp_audFlts:(id)sender
492 /* expand or collapse audFlts */
493 NSRect o_win_rect = [o_extended_window frame];
494 NSRect o_box_audFlts_rect = [o_box_audFlts frame];
496 if (o_audFlts_expanded)
498 /* move the window contents upwards (partially done through settings
499 * inside the nib) and resize the window */
500 o_win_rect.size.height = o_win_rect.size.height - 66;
501 o_win_rect.origin.y = [o_extended_window frame].origin.y + 66;
503 /* remove the inserted view */
504 [o_audioFlts_view removeFromSuperviewWithoutNeedingDisplay];
506 /* move the window contents downwards and resize the window */
507 o_win_rect.size.height = o_win_rect.size.height + 66;
508 o_win_rect.origin.y = [o_extended_window frame].origin.y - 66;
510 [o_extended_window displayIfNeeded];
511 [o_extended_window setFrame: o_win_rect display:YES animate: YES];
514 if (o_audFlts_expanded)
516 o_box_audFlts_rect.size.height = [o_box_audFlts frame].size.height - 66;
517 o_audFlts_expanded = NO;
520 o_box_audFlts_rect.size.height = [o_box_audFlts frame].size.height + 66;
521 [o_audioFlts_view setFrame: NSMakeRect( 20, -20, 370, 76)];
522 [o_audioFlts_view setNeedsDisplay:YES];
523 [o_audioFlts_view setAutoresizesSubviews: YES];
524 [[o_box_audFlts contentView] addSubview: o_audioFlts_view];
525 o_audFlts_expanded = YES;
527 [o_box_audFlts setFrameFromContentFrame: o_box_audFlts_rect];
530 - (IBAction)extWin_exp_vidFlts:(id)sender
532 /* expand or collapse vidFlts */
533 NSRect o_win_rect = [o_extended_window frame];
534 NSRect o_box_audFlts_rect = [o_box_audFlts frame];
535 NSRect o_box_vidFlts_rect = [o_box_vidFlts frame];
537 if (o_vidFlts_expanded)
539 /* move the window contents upwards (partially done through settings
540 * inside the nib) and resize the window */
541 o_win_rect.size.height = o_win_rect.size.height - 188;
542 o_win_rect.origin.y = [o_extended_window frame].origin.y + 188;
543 o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y + 188;
545 /* remove the inserted view */
546 [o_videoFilters_view removeFromSuperviewWithoutNeedingDisplay];
549 /* move the window contents downwards and resize the window */
550 o_win_rect.size.height = o_win_rect.size.height + 188;
551 o_win_rect.origin.y = [o_extended_window frame].origin.y - 188;
552 o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y - 188;
555 [o_box_audFlts setFrameFromContentFrame: o_box_audFlts_rect];
556 [o_extended_window displayIfNeeded];
557 [o_extended_window setFrame: o_win_rect display:YES animate: YES];
559 if (o_vidFlts_expanded)
561 o_box_vidFlts_rect.size.height = [o_box_vidFlts frame].size.height - 188;
562 o_vidFlts_expanded = NO;
565 o_box_vidFlts_rect.size.height = [o_box_vidFlts frame].size.height + 188;
566 [o_videoFilters_view setFrame: NSMakeRect( 20, -10, 370, 188)];
567 [o_videoFilters_view setNeedsDisplay:YES];
568 [o_videoFilters_view setAutoresizesSubviews: YES];
569 [[o_box_vidFlts contentView] addSubview: o_videoFilters_view];
570 o_vidFlts_expanded = YES;
572 [o_box_vidFlts setFrameFromContentFrame: o_box_vidFlts_rect];
575 - (IBAction)vidFlts:(id)sender
577 /* en-/disable video filters */
578 if (sender == o_ckb_blur)
579 [self changeVoutFiltersString: "motionblur" onOrOff: [o_ckb_blur state]];
581 else if (sender == o_ckb_imgClone)
582 [self changeVoutFiltersString: "clone" onOrOff: [o_ckb_imgClone state]];
584 else if (sender == o_ckb_imgCrop)
585 [self changeVoutFiltersString: "crop" onOrOff: [o_ckb_imgCrop state]];
587 else if (sender == o_ckb_imgInvers)
588 [self changeVideoFiltersString: "invert" onOrOff: [o_ckb_imgInvers state]];
590 else if (sender == o_ckb_trnsform)
591 [self changeVoutFiltersString: "transform" onOrOff: [o_ckb_trnsform state]];
593 else if (sender == o_ckb_intZoom )
594 [self changeVoutFiltersString: "magnify" onOrOff: [o_ckb_intZoom state]];
596 else if (sender == o_ckb_wave )
597 [self changeVideoFiltersString: "wave" onOrOff: [o_ckb_wave state]];
599 else if (sender == o_ckb_gradient )
600 [self changeVideoFiltersString: "gradient" onOrOff: [o_ckb_gradient state]];
602 else if (sender == o_ckb_psycho )
603 [self changeVideoFiltersString: "psychedelic" onOrOff: [o_ckb_psycho state]];
605 else if (sender == o_ckb_ripple )
606 [self changeVideoFiltersString: "ripple" onOrOff: [o_ckb_ripple state]];
609 /* this shouldn't happen */
610 msg_Warn (VLCIntf, "cannot find switched video-filter");
614 - (IBAction)vidFlts_mrInfo:(id)sender
616 /* show info sheet */
617 NSBeginInformationalAlertSheet(_NS("About the video filters"), _NS("OK"), @"", @"",
618 o_extended_window, nil, nil, nil, nil, _NS("This panel allows "
619 "on-the-fly selection of various video effects.\n"
620 "These filters can be configured individually in the Preferences, in "
621 "the subsections of Video/Filters.\n"
622 "To choose the order in which the filter are applied, a filter "
623 "option string can be set in the Preferences, Video / Filters section."));
627 /*****************************************************************************
628 * methods to communicate changes to VLC's core
629 *****************************************************************************/
631 - (void)changeVoutFiltersString:(char *)psz_name onOrOff:(vlc_bool_t )b_add
633 /* copied from ../wxwidgets/extrapanel.cpp
634 * renamed to conform with Cocoa's rules */
635 /* this method only changes 1st generation video filters (the ones which
636 * can't be used for transcoding). Have a look at changeVideoFiltersString
637 * for the 2nd generation filters. */
639 vout_thread_t *p_vout;
640 intf_thread_t * p_intf = VLCIntf;
642 char *psz_parser, *psz_string;
643 psz_string = config_GetPsz( p_intf, "vout-filter" );
645 if( !psz_string ) psz_string = strdup("");
647 psz_parser = strstr( psz_string, psz_name );
653 psz_parser = psz_string;
654 asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
655 psz_string, psz_name );
667 memmove( psz_parser, psz_parser + strlen(psz_name) +
668 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
669 strlen(psz_parser + strlen(psz_name)) + 1 );
671 /* Remove trailing : : */
672 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
674 *(psz_string+strlen(psz_string ) -1 ) = '\0';
683 /* Vout is not kept, so put that in the config */
684 config_PutPsz( p_intf, "vout-filter", psz_string );
686 /* Try to set on the fly */
687 p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
691 var_SetString( p_vout, "vout-filter", psz_string );
692 vlc_object_release( p_vout );
697 o_config_changed = YES;
701 - (void)changeVideoFiltersString:(char *)psz_name onOrOff:(vlc_bool_t )b_add
703 /* same as changeVoutFiltersString but addressing the "video-filter"
704 * variable which represents the video filter 2 modules */
706 vout_thread_t *p_vout;
707 intf_thread_t * p_intf = VLCIntf;
709 char *psz_parser, *psz_string;
710 psz_string = config_GetPsz( p_intf, "video-filter" );
712 if( !psz_string ) psz_string = strdup("");
714 psz_parser = strstr( psz_string, psz_name );
720 psz_parser = psz_string;
721 asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
722 psz_string, psz_name );
734 memmove( psz_parser, psz_parser + strlen(psz_name) +
735 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
736 strlen(psz_parser + strlen(psz_name)) + 1 );
738 /* Remove trailing : : */
739 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
741 *(psz_string+strlen(psz_string ) -1 ) = '\0';
750 /* Vout is not kept, so put that in the config */
751 config_PutPsz( p_intf, "video-filter", psz_string );
753 /* Try to set on the fly */
754 p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
758 var_SetString( p_vout, "video-filter", psz_string );
759 vlc_object_release( p_vout );
764 o_config_changed = YES;
767 - (void)changeAFiltersString: (char *)psz_name onOrOff: (vlc_bool_t )b_add;
769 /* copied from ../wxwidgets/extrapanel.cpp
770 * renamed to conform with Cocoa's rules */
772 char *psz_parser, *psz_string;
773 intf_thread_t * p_intf = VLCIntf;
774 aout_instance_t * p_aout= (aout_instance_t *)vlc_object_find(p_intf,
775 VLC_OBJECT_AOUT, FIND_ANYWHERE);
779 psz_string = var_GetString( p_aout, "audio-filter" );
783 psz_string = config_GetPsz( p_intf, "audio-filter" );
786 if( !psz_string ) psz_string = strdup("");
788 psz_parser = strstr( psz_string, psz_name );
794 psz_parser = psz_string;
795 asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
796 psz_string, psz_name );
808 memmove( psz_parser, psz_parser + strlen(psz_name) +
809 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
810 strlen(psz_parser + strlen(psz_name)) + 1 );
812 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
814 *(psz_string+strlen(psz_string ) -1 ) = '\0';
826 config_PutPsz( p_intf, "audio-filter", psz_string );
830 var_SetString( p_aout, "audio-filter", psz_string );
832 while( i < p_aout->i_nb_inputs )
834 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
837 vlc_object_release( p_aout );
841 o_config_changed = YES;
846 /* save the preferences to make sure that our module-changes will up on
847 * next launch again */
848 playlist_t * p_playlist = pl_Yield( VLCIntf );
850 NSArray * theModules;
851 theModules = [[NSArray alloc] initWithObjects: @"main", @"headphone",
852 @"transform", @"adjust", @"invert", @"motionblur", @"distort",
853 @"clone", @"crop", @"normvol", @"headphone_channel_mixer", @"macosx",
857 while ( x != [theModules count] )
859 returnedValue = config_SaveConfigFile( p_playlist, [[theModules
860 objectAtIndex: x] UTF8String] );
862 if (returnedValue != 0)
864 msg_Err(p_playlist, "unable to save the preferences of the "
865 "extended control attribute '%s' (%i)",
866 [[theModules objectAtIndex: x] UTF8String] , returnedValue);
867 [theModules release];
868 vlc_object_release( p_playlist );
876 msg_Dbg( p_playlist, "VLCExtended: saved certain preferences successfully" );
878 [theModules release];
879 vlc_object_release( p_playlist );