msmith gst-plugins-good: gst-plugins-good/ gst-plugins-good/sys/osxvideo/

[email protected]
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
CVS Root:       /cvs/gstreamer
Module:         gst-plugins-good
Changes by:     msmith
Date:           Thu Nov 20 2008  23:59:21 UTC

Log message:
    * sys/osxvideo/osxvideosink.h:
    * sys/osxvideo/osxvideosink.m:
      Handle video window resizing more correctly, avoiding crashes when
      embedding the window and resizing it.

Modified files:
    .               : ChangeLog
    sys/osxvideo    : osxvideosink.h osxvideosink.m

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3825&r2=1.3826
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/sys/osxvideo/osxvideosink.h.diff?r1=1.10&r2=1.11
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/sys/osxvideo/osxvideosink.m.diff?r1=1.13&r2=1.14

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v
retrieving revision 1.3825
retrieving revision 1.3826
diff -u -d -r1.3825 -r1.3826
--- ChangeLog	20 Nov 2008 22:56:55 -0000	1.3825
+++ ChangeLog	20 Nov 2008 23:59:05 -0000	1.3826
@@ -1,5 +1,12 @@
 2008-11-20  Michael Smith <[email protected]>
 
+	* sys/osxvideo/osxvideosink.h:
+	* sys/osxvideo/osxvideosink.m:
+	  Handle video window resizing more correctly, avoiding crashes when
+	  embedding the window and resizing it.
+
+2008-11-20  Michael Smith <[email protected]>
 	* gst/udp/gstmultiudpsink.c:
 	* gst/udp/gstudpnetutils.c:
 	* gst/udp/gstudpnetutils.h:
Index: osxvideosink.h
RCS file: /cvs/gstreamer/gst-plugins-good/sys/osxvideo/osxvideosink.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- osxvideosink.h	18 Mar 2008 15:03:06 -0000	1.10
+++ osxvideosink.h	20 Nov 2008 23:59:07 -0000	1.11
@@ -73,9 +73,6 @@
   GstVideoSink videosink;
   GstOSXWindow *osxwindow;
   
-  gint fps_n;
-  gint fps_d;
-  
   GstTask *event_task;
   GStaticRecMutex event_task_lock;
Index: osxvideosink.m
RCS file: /cvs/gstreamer/gst-plugins-good/sys/osxvideo/osxvideosink.m,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- osxvideosink.m	17 Jul 2008 16:42:53 -0000	1.13
+++ osxvideosink.m	20 Nov 2008 23:59:07 -0000	1.14
@@ -228,11 +228,12 @@
     gint height)
 {
   NSRect rect;
-
   GstOSXWindow *osxwindow = NULL;
   g_return_val_if_fail (GST_IS_OSX_VIDEO_SINK (osxvideosink), NULL);
+  GST_DEBUG_OBJECT (osxvideosink, "Creating new OSX window");
   osxwindow = g_new0 (GstOSXWindow, 1);
   osxwindow->width = width;
@@ -266,6 +267,7 @@
                          backing: NSBackingStoreBuffered
                          defer: NO
                          screen: nil];
+    GST_DEBUG("VideoSinkWindow created, %p", osxwindow->win);
     [osxwindow->win autorelease];
     [NSApplication sharedApplication];
     [osxwindow->win makeKeyAndOrderFront:NSApp];
@@ -303,8 +305,8 @@
 			   nil);
     tmp = gst_structure_to_string (s);
-    GST_DEBUG_OBJECT (osxvideosink, "Sending message %s",
-		      tmp);
+    GST_DEBUG_OBJECT (osxvideosink, "Sending message %s (with view %p)",
+		      tmp, osxwindow->gstview);
     g_free (tmp);
     msg = gst_message_new_element (GST_OBJECT (osxvideosink), s);
@@ -340,7 +342,6 @@
 gst_osx_video_sink_osxwindow_resize (GstOSXVideoSink * osxvideosink,
     GstOSXWindow * osxwindow, guint width, guint height)
-  NSSize size;
   NSAutoreleasePool *subPool = [[NSAutoreleasePool alloc] init];
   g_return_if_fail (osxwindow != NULL);
   g_return_if_fail (GST_IS_OSX_VIDEO_SINK (osxvideosink));
@@ -348,11 +349,23 @@
   osxwindow->height = height;
-  size.width = width;
-  size.height = height;
-  /* Call relevant cocoa function to resize window */
- [osxwindow->win setContentSize:size];
- [subPool release];
+  GST_DEBUG_OBJECT (osxvideosink, "Resizing window to (%d,%d)", width, height);
+  if (osxwindow->win) {
+    /* Call relevant cocoa function to resize window */
+    NSSize size;
+    size.width = width;
+    size.height = height;
+    NSLog(@"osxwindow->win = %@", osxwindow->win);
+    GST_DEBUG_OBJECT (osxvideosink, "Calling setContentSize on %p", osxwindow->win); 
+    [osxwindow->win setContentSize:size];
+  }
+  else {
+    /* Directly resize the underlying view */
+    GST_DEBUG_OBJECT (osxvideosink, "Calling setVideoSize on %p", osxwindow->gstview); 
+    [osxwindow->gstview setVideoSize:width :height];
+  [subPool release];
 }
 static void
@@ -374,7 +387,6 @@
   GstStructure *structure;
   gboolean res, result = FALSE;
   gint video_width, video_height;
-  const GValue *framerate;
   osxvideosink = GST_OSX_VIDEO_SINK (bsink);
@@ -383,18 +395,13 @@
   structure = gst_caps_get_structure (caps, 0);
   res = gst_structure_get_int (structure, "width", &video_width);
   res &= gst_structure_get_int (structure, "height", &video_height);
-  framerate = gst_structure_get_value (structure, "framerate");
-  res &= (framerate != NULL);
   if (!res) {
     goto beach;
   }
-  osxvideosink->fps_n = gst_value_get_fraction_numerator (framerate);
-  osxvideosink->fps_d = gst_value_get_fraction_denominator (framerate);
-  GST_DEBUG_OBJECT (osxvideosink, "our format is: %dx%d video at %d/%d fps",
-      video_width, video_height, osxvideosink->fps_n, osxvideosink->fps_d);
+  GST_DEBUG_OBJECT (osxvideosink, "our format is: %dx%d video",
+      video_width, video_height);
   GST_VIDEO_SINK_WIDTH (osxvideosink) = video_width;
   GST_VIDEO_SINK_HEIGHT (osxvideosink) = video_height;
@@ -451,8 +458,6 @@
     case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
       break;
     case GST_STATE_CHANGE_PAUSED_TO_READY:
-      osxvideosink->fps_n = 0;
-      osxvideosink->fps_d = 0;
       osxvideosink->sw_scaling_failed = FALSE;
       GST_VIDEO_SINK_WIDTH (osxvideosink) = 0;
       GST_VIDEO_SINK_HEIGHT (osxvideosink) = 0;
@@ -549,9 +554,6 @@
   osxvideosink->osxwindow = NULL;
-  osxvideosink->fps_n = 0;
-  osxvideosink->fps_d = 0;
   osxvideosink->pixel_width = osxvideosink->pixel_height = 1;
   osxvideosink->sw_scaling_failed = FALSE;
   osxvideosink->embed = FALSE;

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.