]> git.sesse.net Git - vlc/commitdiff
* vout.m : comment the NSLog call in windowContainsEmbedded: this method is called...
authorBenjamin Pracht <bigben@videolan.org>
Wed, 29 Mar 2006 20:03:48 +0000 (20:03 +0000)
committerBenjamin Pracht <bigben@videolan.org>
Wed, 29 Mar 2006 20:03:48 +0000 (20:03 +0000)
* other: implement on the fly aspect ratio change. Only works in the ogl output at the moment

extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib
extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib
extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib
modules/gui/macosx/intf.h
modules/gui/macosx/intf.m
modules/gui/macosx/vout.m
modules/gui/macosx/voutgl.m

index bfb3aa61fe5ce373e47893cd7851a3c013d327eb..a6a7ff3fda68c9ec66311320eca8ade78dd33677 100644 (file)
                 "o_messages" = id; 
                 "o_mi_about" = id; 
                 "o_mi_add_intf" = id; 
+                "o_mi_aspect_ratio" = id; 
                 "o_mi_audiotrack" = id; 
                 "o_mi_bookmarks" = id; 
                 "o_mi_bring_atf" = id; 
                 "o_msgs_btn_crashlog" = id; 
                 "o_msgs_panel" = id; 
                 "o_mu_add_intf" = id; 
+                "o_mu_aspect_ratio" = id; 
                 "o_mu_audio" = id; 
                 "o_mu_audiotrack" = id; 
                 "o_mu_channels" = id; 
index 48f1feb9255b0d6e0272d185622fc7b37604beff..4bdffa955df58abab7ec8b320f1255a27aab2433 100644 (file)
@@ -3,7 +3,7 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>35 101 478 430 0 0 1440 878 </string>
+       <string>43 22 478 430 0 0 1024 746 </string>
        <key>IBEditorPositions</key>
        <dict>
                <key>1617</key>
@@ -11,7 +11,7 @@
                <key>2197</key>
                <string>422 532 596 143 0 0 1440 878 </string>
                <key>29</key>
-               <string>71 662 438 44 0 0 1024 746 </string>
+               <string>76 675 438 44 0 0 1024 746 </string>
                <key>915</key>
                <string>777 479 187 249 0 0 1440 878 </string>
        </dict>
@@ -21,8 +21,8 @@
        <array/>
        <key>IBOpenObjects</key>
        <array>
+               <integer>21</integer>
                <integer>1789</integer>
-               <integer>29</integer>
        </array>
        <key>IBSystem Version</key>
        <string>8H14</string>
index 2cfbd665c3b033ff5edc32936d48d345a454ddb3..c13179d06f80c0b0f5a08fa257fd841e38f4f6a6 100644 (file)
Binary files a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib and b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/keyedobjects.nib differ
index 39a8a787e93d443f0039f5e0a388ae058413a180..797f02b37bdbdf2c3cd08ff49854b1efe68433e0 100644 (file)
@@ -228,6 +228,8 @@ struct intf_sys_t
     IBOutlet id o_mu_videotrack;
     IBOutlet id o_mi_screen;
     IBOutlet id o_mu_screen;
+    IBOutlet id o_mi_aspect_ratio;
+    IBOutlet id o_mu_aspect_ratio;
     IBOutlet id o_mi_subtitle;
     IBOutlet id o_mu_subtitle;
     IBOutlet id o_mi_deinterlace;
index 4e06828a999a051978e5e53b286cc51089b6c882..89ea595b4ba30bb7098f6a8829728a5f05ea44f1 100644 (file)
@@ -555,6 +555,8 @@ static VLCMain *_o_sharedMainInstance = nil;
     [o_mi_snapshot setTitle: _NS("Snapshot")];
     [o_mi_videotrack setTitle: _NS("Video Track")];
     [o_mu_videotrack setTitle: _NS("Video Track")];
+    [o_mi_aspect_ratio setTitle: _NS("Aspect-ratio")];
+    [o_mu_aspect_ratio setTitle: _NS("Aspect-ratio")];
     [o_mi_screen setTitle: _NS("Video Device")];
     [o_mu_screen setTitle: _NS("Video Device")];
     [o_mi_subtitle setTitle: _NS("Subtitles Track")];
@@ -1150,6 +1152,9 @@ static VLCMain *_o_sharedMainInstance = nil;
         {
             vlc_object_t * p_dec_obj;
 
+            [o_controls setupVarMenuItem: o_mi_aspect_ratio target: (vlc_object_t *)[VLCVoutView getRealVout: p_vout]
+                var: "aspect-ratio" selector: @selector(toggleVar:)];
+
             [o_controls setupVarMenuItem: o_mi_screen target: (vlc_object_t *)p_vout
                 var: "video-device" selector: @selector(toggleVar:)];
 
@@ -1325,6 +1330,7 @@ static VLCMain *_o_sharedMainInstance = nil;
     [o_mi_ffmpeg_pp setEnabled: b_enabled];
     [o_mi_device setEnabled: b_enabled];
     [o_mi_screen setEnabled: b_enabled];
+    [o_mi_aspect_ratio setEnabled: b_enabled];
 }
 
 - (void)manageVolumeSlider
index f6fa1136124c1a07ae48dda5954a699ac7ea8ed3..3bb355f64bb43dd8ff492540d0c51f596c2c4129 100644 (file)
@@ -111,10 +111,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 
 - (BOOL)windowContainsEmbedded: (id)o_window
 {
-    if( ![[o_window className] isEqualToString: @"VLCWindow"] )
+/*    if( ![[o_window className] isEqualToString: @"VLCWindow"] )
     {
         NSLog( @"We were not given a VLCWindow" );
-    }
+    }*/
     return ([self getViewForWindow: o_window] == nil ? NO : YES );
 }
 
index 8b3c89ed20b22b99928d293102a24a362aac2e9a..e628ff5bd944d9a70c19587858de9004ab226554 100644 (file)
@@ -61,6 +61,7 @@ struct vout_sys_t
     NSRect              s_frame;
     vlc_bool_t          b_got_frame;
     vlc_mutex_t         lock;
+    vlc_bool_t          b_vout_size_update;
 };
 
 /*****************************************************************************
@@ -75,6 +76,9 @@ static void Swap   ( vout_thread_t * p_vout );
 static int  Lock   ( vout_thread_t * p_vout );
 static void Unlock ( vout_thread_t * p_vout );
 
+static int AspectCallback( vlc_object_t *, char const *,
+                           vlc_value_t, vlc_value_t, void * );
+
 int E_(OpenVideoGL)  ( vlc_object_t * p_this )
 {
     vout_thread_t * p_vout = (vout_thread_t *) p_this;
@@ -140,12 +144,20 @@ void E_(CloseVideoGL) ( vlc_object_t * p_this )
 
 static int Init( vout_thread_t * p_vout )
 {
+    /* The variable is in fact changed on the parent vout */
+    if( !var_Type( p_vout->p_parent, "aspect-ratio" ) )
+    {
+        var_Create( p_vout->p_parent, "aspect-ratio",
+                                VLC_VAR_STRING | VLC_VAR_DOINHERIT );
+    }
+    var_AddCallback( p_vout->p_parent, "aspect-ratio", AspectCallback, p_vout );
     [[p_vout->p_sys->o_glview openGLContext] makeCurrentContext];
     return VLC_SUCCESS;
 }
 
 static void End( vout_thread_t * p_vout )
 {
+    var_DelCallback( p_vout->p_parent, "aspect-ratio", AspectCallback, p_vout );
     [[p_vout->p_sys->o_glview openGLContext] makeCurrentContext];
 }
 
@@ -192,6 +204,20 @@ static int Manage( vout_thread_t * p_vout )
 
         p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
     }
+
+    if( p_vout->p_sys->b_vout_size_update )
+    {
+        NSRect old_bounds = [p_vout->p_sys->o_glview bounds];
+        [p_vout->p_sys->o_glview reshape];
+        if( [p_vout->p_sys->o_glview bounds].size.height !=
+            old_bounds.size.height ||
+            [p_vout->p_sys->o_glview bounds].size.width !=
+            old_bounds.size.width);
+        {
+             p_vout->p_sys->b_vout_size_update = VLC_FALSE;
+        }
+    }
+
     [p_vout->p_sys->o_vout_view manage];
     return VLC_SUCCESS;
 }
@@ -235,6 +261,18 @@ static void Unlock( vout_thread_t * p_vout )
     vlc_mutex_unlock( &p_vout->p_sys->lock );
 }
 
+static int AspectCallback( vlc_object_t *p_this, char const *psz_cmd,
+                         vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+    /* Only update the vout size if the aspect ratio has actually been changed*/
+
+    if( strcmp( oldval.psz_string, newval.psz_string ) )
+    {
+        ((vout_thread_t *)p_data)->p_sys->b_vout_size_update = VLC_TRUE;
+    }
+    return VLC_SUCCESS;
+}
+
 /*****************************************************************************
  * VLCGLView implementation
  *****************************************************************************/
@@ -295,16 +333,21 @@ static void Unlock( vout_thread_t * p_vout )
         x = bounds.size.width;
         y = bounds.size.height;
     }
-    else if( bounds.size.height * p_vout->render.i_aspect <
-             bounds.size.width * VOUT_ASPECT_FACTOR )
+    else if( bounds.size.height * p_vout->render.i_aspect *
+             p_vout->fmt_in.i_sar_num <
+             bounds.size.width * VOUT_ASPECT_FACTOR * p_vout->fmt_in.i_sar_den )
     {
-        x = bounds.size.height * p_vout->render.i_aspect / VOUT_ASPECT_FACTOR;
+        x = bounds.size.height * p_vout->render.i_aspect *
+            p_vout->fmt_in.i_sar_num / ( VOUT_ASPECT_FACTOR *
+            p_vout->fmt_in.i_sar_den );
         y = bounds.size.height;
     }
     else
     {
         x = bounds.size.width;
-        y = bounds.size.width * VOUT_ASPECT_FACTOR / p_vout->render.i_aspect;
+        y = bounds.size.width * p_vout->fmt_in.i_sar_den *
+            VOUT_ASPECT_FACTOR / ( p_vout->fmt_in.i_sar_num *
+            p_vout->render.i_aspect );
     }
 
     glViewport( ( bounds.size.width - x ) / 2,