Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorerikb <erikb@574bc980-5f2d-0410-acbc-c8f9f0eb14e0>2007-10-19 01:40:26 (GMT)
committer erikb <erikb@574bc980-5f2d-0410-acbc-c8f9f0eb14e0>2007-10-19 01:40:26 (GMT)
commit7da326971358297236699864379e86d5c72f7ebc (patch)
treeee48af1f8c743d0b48ee68fd8babcf73f7c84105
parent14e010ad53a9112e7125e62a8576cd57c1f14214 (diff)
buttons scale correctly throughout
git-svn-id: http://mediamods.com/public-svn/camera-activity/Record.activity@648 574bc980-5f2d-0410-acbc-c8f9f0eb14e0
-rw-r--r--button.py37
-rw-r--r--glive.py13
-rw-r--r--model.py22
3 files changed, 36 insertions, 36 deletions
diff --git a/button.py b/button.py
index 8fef0c4..84f110c 100644
--- a/button.py
+++ b/button.py
@@ -23,50 +23,43 @@ class RecdButton(TrayButton, gobject.GObject):
def getImg( self ):
- #todo: remove mem refs
-
img = gtk.Image()
ipb = self.recd.getThumbPixbuf()
+ xoff = 0
+ yoff = 0
+ pb = None
if (self.recd.type == self.ui.ca.m.TYPE_PHOTO):
+ xoff = 8
+ yoff = 8
if (self.recd.buddy):
thumbPhotoSvg = self.ui.loadSvg(self.ui.thumbPhotoSvgData, self.recd.colorStroke.hex, self.recd.colorFill.hex)
pb = thumbPhotoSvg.get_pixbuf()
- img.set_from_pixbuf( pb )
- img.show()
- ipb.composite(pb, 8, 8, ipb.get_width(), ipb.get_height(), 0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, 255 )
else:
pb = self.ui.thumbPhotoSvg.get_pixbuf()
- img.set_from_pixbuf( pb )
- img.show()
- ipb.composite(pb, 8, 8, ipb.get_width(), ipb.get_height(), 0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, 255 )
- if (self.recd.type == self.ui.ca.m.TYPE_VIDEO):
+ elif (self.recd.type == self.ui.ca.m.TYPE_VIDEO):
+ xoff = 8
+ yoff = 22
if (self.recd.buddy):
thumbVideoSvg = self.ui.loadSvg(self.ui.thumbVideoSvgData, self.recd.colorStroke.hex, self.recd.colorFill.hex)
pb = thumbVideoSvg.get_pixbuf()
- img.set_from_pixbuf( pb )
- img.show()
- ipb.composite(pb, 8, 8, ipb.get_width(), ipb.get_height(), 0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, 255 )
else:
pb = self.ui.thumbVideoSvg.get_pixbuf()
- img.set_from_pixbuf( pb )
- img.show()
- ipb.composite(pb, 8, 22, ipb.get_width(), ipb.get_height(), 0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, 255 )
- if (self.recd.type == self.ui.ca.m.TYPE_AUDIO):
+ elif (self.recd.type == self.ui.ca.m.TYPE_AUDIO):
if (self.recd.buddy):
thumbAudioSvg = self.ui.loadSvg(self.ui.thumbAudioSvgData, self.recd.colorStroke.hex, self.recd.colorFill.hex)
pb = thumbAudioSvg.get_pixbuf()
- img.set_from_pixbuf( pb )
- img.show()
- ipb.composite(pb, 8, 8, ipb.get_width(), ipb.get_height(), 0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, 255 )
else:
pb = self.ui.thumbVideoSvg.get_pixbuf()
- img.set_from_pixbuf( pb )
- img.show()
- ipb.composite(pb, 8, 22, ipb.get_width(), ipb.get_height(), 0, 0, 1, 1, gtk.gdk.INTERP_BILINEAR, 255 )
+ img.set_from_pixbuf( pb )
+ img.show()
+ ipb.composite(pb, xoff, yoff, ipb.get_width(), ipb.get_height(), xoff, yoff, 1, 1, gtk.gdk.INTERP_BILINEAR, 255 )
img.set_from_pixbuf(pb)
+
+ gc.collect()
+
return img
diff --git a/glive.py b/glive.py
index 2f0e367..78081be 100644
--- a/glive.py
+++ b/glive.py
@@ -52,6 +52,9 @@ class Glive:
self.TRANSCODE_UPDATE_INTERVAL = 200
+ self.VIDEO_WIDTH_SMALL = 160
+ self.VIDEO_HEIGHT_SMALL = 120
+
self.thumbPipes = []
self.muxPipes = []
self._nextPipe()
@@ -141,7 +144,7 @@ class Glive:
n = str(len(self.pipes))
v4l2 = False
if (self._PIPETYPE == self.PIPETYPE_XV_VIDEO_DISPLAY_RECORD):
- pipeline = gst.parse_launch("v4l2src name=v4l2src_"+n+" ! tee name=videoTee_"+n+" ! queue name=movieQueue_"+n+" ! videorate name=movieVideorate_"+n+" ! video/x-raw-yuv,framerate=15/1 ! videoscale name=movieVideoscale_"+n+" ! video/x-raw-yuv,width=160,height=120 ! ffmpegcolorspace name=movieFfmpegcolorspace_"+n+" ! theoraenc quality=16 name=movieTheoraenc_"+n+" ! oggmux name=movieOggmux_"+n+" ! filesink name=movieFilesink_"+n+" videoTee_"+n+". ! xvimagesink name=xvimagesink_"+n+" videoTee_"+n+". ! queue name=picQueue_"+n+" ! ffmpegcolorspace name=picFfmpegcolorspace_"+n+" ! jpegenc name=picJPegenc_"+n+" ! fakesink name=picFakesink_"+n+" alsasrc name=audioAlsasrc_"+n+" ! audio/x-raw-int,rate=16000,channels=1,depth=16 ! tee name=audioTee_"+n +" ! wavenc name=audioWavenc_"+n+" ! filesink name=audioFilesink_"+n + " audioTee_"+n+". ! fakesink name=audioFakesink_"+n )
+ pipeline = gst.parse_launch("v4l2src name=v4l2src_"+n+" ! tee name=videoTee_"+n+" ! queue name=movieQueue_"+n+" ! videorate name=movieVideorate_"+n+" ! video/x-raw-yuv,framerate=15/1 ! videoscale name=movieVideoscale_"+n+" ! video/x-raw-yuv,width="+str(self.VIDEO_WIDTH_SMALL)+",height="+str(self.VIDEO_HEIGHT_SMALL)+" ! ffmpegcolorspace name=movieFfmpegcolorspace_"+n+" ! theoraenc quality=16 name=movieTheoraenc_"+n+" ! oggmux name=movieOggmux_"+n+" ! filesink name=movieFilesink_"+n+" videoTee_"+n+". ! xvimagesink name=xvimagesink_"+n+" videoTee_"+n+". ! queue name=picQueue_"+n+" ! ffmpegcolorspace name=picFfmpegcolorspace_"+n+" ! jpegenc name=picJPegenc_"+n+" ! fakesink name=picFakesink_"+n+" alsasrc name=audioAlsasrc_"+n+" ! audio/x-raw-int,rate=16000,channels=1,depth=16 ! tee name=audioTee_"+n +" ! wavenc name=audioWavenc_"+n+" ! filesink name=audioFilesink_"+n + " audioTee_"+n+". ! fakesink name=audioFakesink_"+n )
v4l2 = True
videoTee = pipeline.get_by_name('videoTee_'+n)
@@ -170,7 +173,7 @@ class Glive:
videoTee.unlink(picQueue)
elif (self._PIPETYPE == self.PIPETYPE_X_VIDEO_DISPLAY ):
- pipeline = gst.parse_launch("v4l2src name=v4l2src_"+n+" ! queue name=xQueue_"+n+" ! videorate ! video/x-raw-yuv,framerate=2/1 ! videoscale ! video/x-raw-yuv,width=160,height=120 ! ffmpegcolorspace ! ximagesink name=ximagesink_"+n)
+ pipeline = gst.parse_launch("v4l2src name=v4l2src_"+n+" ! queue name=xQueue_"+n+" ! videorate ! video/x-raw-yuv,framerate=2/1 ! videoscale ! video/x-raw-yuv,width="+str(self.ca.ui.pipw)+",height="+str(self.ca.ui.piph)+" ! ffmpegcolorspace ! ximagesink name=ximagesink_"+n)
v4l2 = True
elif (self._PIPETYPE == self.PIPETYPE_AUDIO_RECORD):
@@ -370,7 +373,7 @@ class Glive:
else:
self.record = False
self.audio = False
- self.ca.m.saveVideo(self.thumbBuf, str(oggFilepath))
+ self.ca.m.saveVideo(self.thumbBuf, str(oggFilepath), self.VIDEO_WIDTH_SMALL, self.VIDEO_HEIGHT_SMALL)
self.ca.m.stoppedRecordingVideo()
@@ -378,7 +381,7 @@ class Glive:
position, duration = self.queryPosition( self.muxPipe() )
if position != gst.CLOCK_TIME_NONE:
value = position * 100.0 / duration
- value = value/100
+ value = value/100.0
self.ca.ui.progressWindow.updateProgress( value, self.ca.istrSaving )
return True
@@ -415,7 +418,7 @@ class Glive:
muxFilepath = os.path.join(self.ca.tempPath, "mux.ogg") #ogv
os.remove( wavFilepath )
os.remove( oggFilepath )
- self.ca.m.saveVideo(self.thumbBuf, str(muxFilepath))
+ self.ca.m.saveVideo(self.thumbBuf, str(muxFilepath), self.VIDEO_WIDTH_SMALL, self.VIDEO_HEIGHT_SMALL)
self.ca.m.stoppedRecordingVideo()
diff --git a/model.py b/model.py
index 7e907f2..ff30531 100644
--- a/model.py
+++ b/model.py
@@ -279,14 +279,14 @@ class Model:
def saveAudio( self, tempPath, pixbuf ):
- print("save audio")
self.setUpdating( True )
recd = self.createNewRecorded( self.TYPE_AUDIO )
os.rename( tempPath, os.path.join(self.ca.tempPath,recd.mediaFilename))
thumbPath = os.path.join(self.ca.tempPath, recd.thumbFilename)
- thumbImg = self.generateThumbnail(pixbuf, float(0.1671875))
+ scale = float((self.ca.ui.tw+0.0)/(pixbuf.get_width()+0.0))
+ thumbImg = self.generateThumbnail(pixbuf, scale)
thumbImg.write_to_png(thumbPath)
imagePath = os.path.join(self.ca.tempPath, "audioPicture.png")
@@ -341,12 +341,13 @@ class Model:
self.ca.glive.stopRecordingVideo()
- def saveVideo( self, pixbuf, tempPath ):
+ def saveVideo( self, pixbuf, tempPath, wid, hit ):
recd = self.createNewRecorded( self.TYPE_VIDEO )
os.rename( tempPath, os.path.join(self.ca.tempPath,recd.mediaFilename))
thumbPath = os.path.join(self.ca.tempPath, recd.thumbFilename)
- thumbImg = self.generateThumbnail(pixbuf, float(.66875) ) #todo: dynamic creation of this ratio
+ scale = float((self.ca.ui.tw+0.0)/(wid+0.0))
+ thumbImg = self.generateThumbnail(pixbuf, scale )
thumbImg.write_to_png(thumbPath)
self.createNewRecordedMd5Sums( recd )
@@ -403,10 +404,12 @@ class Model:
pixbuf.save( imgpath, "jpeg" )
thumbpath = os.path.join(self.ca.tempPath, recd.thumbFilename)
- #todo: generate this dynamically
- thumbImg = self.generateThumbnail(pixbuf, float(0.1671875))
+ scale = float((self.ca.ui.tw+0.0)/(pixbuf.get_width()+0.0))
+ thumbImg = self.generateThumbnail(pixbuf, scale)
thumbImg.write_to_png(thumbpath)
+ gc.collect()
+
#now that we've saved both the image and its pixbuf, we get their md5s
self.createNewRecordedMd5Sums( recd )
self.addRecd( recd )
@@ -458,8 +461,7 @@ class Model:
self.mediaHashs[recd.type].append( recd )
#updateUi
- #todo: gobject idle?
- self.thumbAdded( recd.type )
+ gobject.idle_add( self.thumbAdded, recd.type )
def createNewRecorded( self, type ):
@@ -533,10 +535,12 @@ class Model:
thumbImg = cairo.ImageSurface(cairo.FORMAT_ARGB32, self.ca.ui.tw, self.ca.ui.th)
tctx = cairo.Context(thumbImg)
img = _camera.cairo_surface_from_gdk_pixbuf(pixbuf)
-
tctx.scale(scale, scale)
tctx.set_source_surface(img, 0, 0)
tctx.paint()
+
+ gc.collect()
+
return thumbImg