Selaa lähdekoodia

VLCMediaPlayer: add API to work with the adjust video filter to manipulate contrast, brightness, hue, saturation and gamma on the fly

Felix Paul Kühne 12 vuotta sitten
vanhempi
commit
efb4a9bb71
2 muutettua tiedostoa jossa 91 lisäystä ja 0 poistoa
  1. 37 0
      Headers/Public/VLCMediaPlayer.h
  2. 54 0
      Sources/VLCMediaPlayer.m

+ 37 - 0
Headers/Public/VLCMediaPlayer.h

@@ -167,6 +167,43 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
  */
 - (void)setDeinterlaceFilter: (NSString *)name;
 
+/**
+ * Enable or disable adjust video filter (contrast, brightness, hue, saturation, gamma)
+ *
+ * \param bool value
+ */
+@property BOOL adjustFilterEnabled;
+/**
+ * Set/Get the adjust filter's contrast value
+ *
+ * \param float value (range: 0-2, default: 1.0)
+ */
+@property float contrast;
+/**
+ * Set/Get the adjust filter's brightness value
+ *
+ * \param float value (range: 0-2, default: 1.0)
+ */
+@property float brightness;
+/**
+ * Set/Get the adjust filter's hue value
+ *
+ * \param integer value (range: 0-360, default: 0)
+ */
+@property NSInteger hue;
+/**
+ * Set/Get the adjust filter's saturation value
+ *
+ * \param float value (range: 0-3, default: 1.0)
+ */
+@property float saturation;
+/**
+ * Set/Get the adjust filter's gamma value
+ *
+ * \param float value (range: 0-10, default: 1.0)
+ */
+@property float gamma;
+
 @property float rate;
 
 @property (readonly) VLCAudio * audio;

+ 54 - 0
Sources/VLCMediaPlayer.m

@@ -395,6 +395,60 @@ static void HandleMediaPlayerMediaChanged(const libvlc_event_t * event, void * s
     libvlc_video_set_deinterlace(instance, [name UTF8String]);
 }
 
+- (BOOL)adjustFilterEnabled
+{
+    return libvlc_video_get_adjust_int(instance, libvlc_adjust_Enable);
+}
+- (void)setAdjustFilterEnabled:(BOOL)b_value
+{
+    libvlc_video_set_adjust_int(instance, libvlc_adjust_Enable, b_value);
+}
+- (float)contrast
+{
+    return libvlc_video_get_adjust_float(instance, libvlc_adjust_Contrast);
+}
+- (void)setContrast:(float)f_value
+{
+    if (f_value <= 2. && f_value >= 0.)
+        libvlc_video_set_adjust_float(instance,libvlc_adjust_Contrast, f_value);
+}
+- (float)brightness
+{
+    return libvlc_video_get_adjust_float(instance, libvlc_adjust_Brightness);
+}
+- (void)setBrightness:(float)f_value
+{
+    if (f_value <= 2. && f_value >= 0.)
+        libvlc_video_set_adjust_float(instance, libvlc_adjust_Brightness, f_value);
+}
+- (NSInteger)hue
+{
+    return libvlc_video_get_adjust_int(instance, libvlc_adjust_Hue);
+}
+- (void)setHue:(NSInteger)i_value
+{
+    if (i_value <= 360 && i_value >= 0)
+        libvlc_video_set_adjust_int(instance, libvlc_adjust_Hue, i_value);
+}
+- (float)saturation
+{
+    return libvlc_video_get_adjust_float(instance, libvlc_adjust_Saturation);
+}
+- (void)setSaturation:(float)f_value
+{
+    if (f_value <= 3. && f_value >= 0.)
+        libvlc_video_set_adjust_float(instance, libvlc_adjust_Saturation, f_value);
+}
+- (float)gamma
+{
+    return libvlc_video_get_adjust_float(instance, libvlc_adjust_Gamma);
+}
+- (void)setGamma:(float)f_value
+{
+    if (f_value <= 10. && f_value >= 0.)
+        libvlc_video_set_adjust_float(instance, libvlc_adjust_Gamma, f_value);
+}
+
 - (void)setRate:(float)value
 {
     libvlc_media_player_set_rate(instance, value);