gstreamer-ios-templates.recipe 2.11 KB
Newer Older
1
2
3
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
from collections import defaultdict
from cerbero.utils import shell
4
from custom import list_gstreamer_plugins_by_category
5
6
7
8
9
10
11
12
13
14
15

DECLARE_PLUGIN_TPL = 'GST_PLUGIN_STATIC_DECLARE(%s)'
REGISTER_PLUGIN_TPL = 'GST_PLUGIN_STATIC_REGISTER(%s)'
DEFINE_TPL = '/* #define GST_IOS_PLUGINS_%s */\n'
REGISTER_TPL = 'void gst_backend_register_plugins (void);'
DEFINES_TPL = '''\
#if defined(GST_IOS_PLUGIN_%s) || defined(GST_IOS_PLUGINS_%s)
%s
#endif'''
GST_IOS_PLUGINS_C_TPL = '''

16
17
18
#include <gst/gst.h>
#include "gst_ios_plugins.h"

19
20
21
22
23
24
25
26
27
28
29
%s

void
gst_backend_register_plugins (void)
{
%s
}
'''


class Recipe(recipe.Recipe):
30
    name = 'gstreamer-ios-templates'
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    version = '0.1'
    licenses = [License.LGPLv2_1]
    stype = SourceType.CUSTOM
    btype = BuildType.CUSTOM

    files_devel = [
            'share/xcode/templates/ios/',
            ]

    def install(self):
        share_dir = os.path.join(self.config.prefix, 'share', 'xcode',
                                 'templates', 'ios')
        shell.copy_dir(os.path.join(self.config.data_dir, 'xcode',
                                    'templates', 'ios'), share_dir)

46
        plugins, replacements = list_gstreamer_plugins_by_category(self.config)
47
48
49
50
51
52
53
54
55
56
        plugins_h = open(os.path.join(share_dir, 'GStreamer Base.xctemplate',
                                      'gst_ios_plugins.h'), 'w')
        decls = []
        regs = []
        for c, ps in plugins.iteritems():
            c = c.upper()
            plugins_h.write(DEFINE_TPL % c)
            for p in ps:
                if p in replacements:
                    p = replacements[p]
57
58
59
                p_up = p.upper()
                decls.append(DEFINES_TPL % (p_up, c, DECLARE_PLUGIN_TPL % p))
                regs.append(DEFINES_TPL % (p_up, c, REGISTER_PLUGIN_TPL % p))
60
61
62
63
64
65
        plugins_h.write(REGISTER_TPL)
        plugins_h.close()
        plugins_c = open(os.path.join(share_dir, 'GStreamer Base.xctemplate',
                                      'gst_ios_plugins.c'), 'w')
        plugins_c.write(GST_IOS_PLUGINS_C_TPL % ('\n'.join(decls), '\n'.join(regs)))
        plugins_c.close()