Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2013-03-20 12:57:20 (GMT)
committer Daniel Drake <dsd@laptop.org>2013-03-25 20:57:37 (GMT)
commit9bceeec1a24bb3b7c579e432f1a0f1d4d9caf721 (patch)
treef65bb1839b40118680f7145fc46756f4d7c3c27f
parent07f557ded08cc24dafd15bd596355308206a2680 (diff)
Don't save preview encoded - SL #4470
We don't need save the preview in the metadata encoded, doing it makes more difficult the interoperability with other activities using it, and takes more space in the disk. Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--glive.py2
-rw-r--r--serialize.py9
-rw-r--r--utils.py9
3 files changed, 14 insertions, 6 deletions
diff --git a/glive.py b/glive.py
index 8618284..8fd11e7 100644
--- a/glive.py
+++ b/glive.py
@@ -366,7 +366,7 @@ class Glive:
taglist = self._get_tags(constants.TYPE_AUDIO)
if self._audio_pixbuf:
- pixbuf_b64 = utils.getStringFromPixbuf(self._audio_pixbuf)
+ pixbuf_b64 = utils.getStringEncodedFromPixbuf(self._audio_pixbuf)
taglist[gst.TAG_EXTENDED_COMMENT] = "coverart=" + pixbuf_b64
vorbis_enc = audioline.get_by_name('audioVorbisenc')
diff --git a/serialize.py b/serialize.py
index 687bbaa..74e3a3c 100644
--- a/serialize.py
+++ b/serialize.py
@@ -3,6 +3,7 @@ import cStringIO
import os
import gtk
import logging
+import dbus
from sugar.datastore import datastore
@@ -163,7 +164,7 @@ def _addRecdXmlAttrs(el, recd, forMeshTransmit):
if (recd.type == constants.TYPE_AUDIO) and (not forMeshTransmit):
aiPixbuf = recd.getAudioImagePixbuf()
if aiPixbuf:
- aiPixbufString = str(utils.getStringFromPixbuf(aiPixbuf))
+ aiPixbufString = str(utils.getStringEncodedFromPixbuf(aiPixbuf))
el.setAttribute('audioImage', aiPixbufString)
if (recd.datastoreId != None) and (not forMeshTransmit):
@@ -189,7 +190,7 @@ def _addRecdXmlAttrs(el, recd, forMeshTransmit):
pixbuf = recd.getThumbPixbuf()
if pixbuf:
- thumb64 = str(utils.getStringFromPixbuf(pixbuf))
+ thumb64 = str(utils.getStringEncodedFromPixbuf(pixbuf))
el.setAttribute('base64Thumb', thumb64)
def saveMediaHash(mediaHashs, activity):
@@ -272,8 +273,8 @@ def _saveMediaToDatastore(el, recd, activity):
if datastorePreviewPixbuf.get_width() != datastorePreviewWidth:
datastorePreviewPixbuf = datastorePreviewPixbuf.scale_simple(datastorePreviewWidth, datastorePreviewHeight, gtk.gdk.INTERP_NEAREST)
- datastorePreviewBase64 = utils.getStringFromPixbuf(datastorePreviewPixbuf)
- mediaObject.metadata['preview'] = datastorePreviewBase64
+ datastorePreview = utils.getStringFromPixbuf(datastorePreviewPixbuf)
+ mediaObject.metadata['preview'] = dbus.ByteArray(datastorePreview)
colors = str(recd.colorStroke) + "," + str(recd.colorFill)
mediaObject.metadata['icon-color'] = colors
diff --git a/utils.py b/utils.py
index 28adc9c..701e45f 100644
--- a/utils.py
+++ b/utils.py
@@ -8,12 +8,19 @@ from time import strftime
import constants
-def getStringFromPixbuf(pixbuf):
+
+def getStringEncodedFromPixbuf(pixbuf):
data = [""]
pixbuf.save_to_callback(_saveDataToBufferCb, "png", {}, data)
return base64.b64encode(str(data[0]))
+def getStringFromPixbuf(pixbuf):
+ data = [""]
+ pixbuf.save_to_callback(_saveDataToBufferCb, "png", {}, data)
+ return str(data[0])
+
+
def _saveDataToBufferCb(buf, data):
data[0] += buf
return True