Ticket #4470: 0001-Don-t-save-preview-encoded-SL-4470.patch

File 0001-Don-t-save-preview-encoded-SL-4470.patch, 3.4 KB (added by godiard, 11 years ago)
  • glive.py

    From dd63d9edb7ee37d88fbde52f7dcd6029263a4dd9 Mon Sep 17 00:00:00 2001
    From: Gonzalo Odiard <godiard@gmail.com>
    Date: Wed, 20 Mar 2013 09:57:20 -0300
    Subject: [PATCH] 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>
    ---
     glive.py     | 2 +-
     serialize.py | 9 +++++----
     utils.py     | 9 ++++++++-
     3 files changed, 14 insertions(+), 6 deletions(-)
    
    diff --git a/glive.py b/glive.py
    index 8618284..8fd11e7 100644
    a b class Glive: 
    366366        taglist = self._get_tags(constants.TYPE_AUDIO)
    367367
    368368        if self._audio_pixbuf:
    369             pixbuf_b64 = utils.getStringFromPixbuf(self._audio_pixbuf)
     369            pixbuf_b64 = utils.getStringEncodedFromPixbuf(self._audio_pixbuf)
    370370            taglist[gst.TAG_EXTENDED_COMMENT] = "coverart=" + pixbuf_b64
    371371
    372372        vorbis_enc = audioline.get_by_name('audioVorbisenc')
  • serialize.py

    diff --git a/serialize.py b/serialize.py
    index 687bbaa..74e3a3c 100644
    a b import cStringIO 
    33import os
    44import gtk
    55import logging
     6import dbus
    67
    78from sugar.datastore import datastore
    89
    def _addRecdXmlAttrs(el, recd, forMeshTransmit): 
    163164    if (recd.type == constants.TYPE_AUDIO) and (not forMeshTransmit):
    164165        aiPixbuf = recd.getAudioImagePixbuf()
    165166        if aiPixbuf:
    166             aiPixbufString = str(utils.getStringFromPixbuf(aiPixbuf))
     167            aiPixbufString = str(utils.getStringEncodedFromPixbuf(aiPixbuf))
    167168            el.setAttribute('audioImage', aiPixbufString)
    168169
    169170    if (recd.datastoreId != None) and (not forMeshTransmit):
    def _addRecdXmlAttrs(el, recd, forMeshTransmit): 
    189190
    190191    pixbuf = recd.getThumbPixbuf()
    191192    if pixbuf:
    192         thumb64 = str(utils.getStringFromPixbuf(pixbuf))
     193        thumb64 = str(utils.getStringEncodedFromPixbuf(pixbuf))
    193194        el.setAttribute('base64Thumb', thumb64)
    194195
    195196def saveMediaHash(mediaHashs, activity):
    def _saveMediaToDatastore(el, recd, activity): 
    272273            if datastorePreviewPixbuf.get_width() != datastorePreviewWidth:
    273274                datastorePreviewPixbuf = datastorePreviewPixbuf.scale_simple(datastorePreviewWidth, datastorePreviewHeight, gtk.gdk.INTERP_NEAREST)
    274275
    275             datastorePreviewBase64 = utils.getStringFromPixbuf(datastorePreviewPixbuf)
    276             mediaObject.metadata['preview'] = datastorePreviewBase64
     276            datastorePreview = utils.getStringFromPixbuf(datastorePreviewPixbuf)
     277            mediaObject.metadata['preview'] = dbus.ByteArray(datastorePreview)
    277278
    278279        colors = str(recd.colorStroke) + "," + str(recd.colorFill)
    279280        mediaObject.metadata['icon-color'] = colors
  • utils.py

    diff --git a/utils.py b/utils.py
    index 28adc9c..701e45f 100644
    a b from time import strftime 
    88
    99import constants
    1010
    11 def getStringFromPixbuf(pixbuf):
     11
     12def getStringEncodedFromPixbuf(pixbuf):
    1213    data = [""]
    1314    pixbuf.save_to_callback(_saveDataToBufferCb, "png", {}, data)
    1415    return base64.b64encode(str(data[0]))
    1516
    1617
     18def getStringFromPixbuf(pixbuf):
     19    data = [""]
     20    pixbuf.save_to_callback(_saveDataToBufferCb, "png", {}, data)
     21    return str(data[0])
     22
     23
    1724def _saveDataToBufferCb(buf, data):
    1825    data[0] += buf
    1926    return True