summaryrefslogtreecommitdiff
path: root/recipes/gst-ios.recipe
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/gst-ios.recipe')
-rw-r--r--recipes/gst-ios.recipe87
1 files changed, 87 insertions, 0 deletions
diff --git a/recipes/gst-ios.recipe b/recipes/gst-ios.recipe
new file mode 100644
index 0000000..4beee64
--- /dev/null
+++ b/recipes/gst-ios.recipe
@@ -0,0 +1,87 @@
+# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
+from collections import defaultdict
+from cerbero.build.cookbook import CookBook
+from cerbero.utils import shell
+
+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 = '''
+
+%s
+
+void
+gst_backend_register_plugins (void)
+{
+%s
+}
+'''
+
+
+class Recipe(recipe.Recipe):
+ name = 'gst-ios'
+ 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)
+
+ # Create a plugins.mk file with lists of plugins grouped by categories
+ cookbook = CookBook(self.config)
+ # For plugins named differently
+ replacements = {'decodebin2': 'uridecodebin', 'playbin': 'playback',
+ 'encodebin': 'encoding', 'souphttpsrc': 'soup',
+ 'siren': 'gstsiren', 'sdpelem': 'sdp',
+ 'rtpmanager': 'gstrtpmanager', 'scaletempoplugin' : 'scaletempo',
+ 'mpegdemux': 'mpegdemux2', 'rmdemux': 'realmedia'}
+ plugins = defaultdict(list)
+ for r in ['gstreamer', 'gst-plugins-base', 'gst-plugins-good',
+ 'gst-plugins-bad', 'gst-plugins-ugly', 'gst-ffmpeg']:
+ r = cookbook.get_recipe(r)
+ for attr_name in dir(r):
+ if attr_name.startswith('files_plugins_'):
+ cat_name = attr_name[len('files_plugins_'):]
+ plugins_list = getattr(r, attr_name)
+ elif attr_name.startswith('platform_files_plugins_'):
+ cat_name = attr_name[len('platform_files_plugins_'):]
+ plugins_dict = getattr(r, attr_name)
+ plugins_list = plugins_dict.get(self.config.target_platform, [])
+ else:
+ continue
+ for e in plugins_list:
+ if not e.startswith('lib/gstreamer-'):
+ continue
+ plugins[cat_name].append(e[25:-8])
+ 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]
+ p = p.upper()
+ decls.append(DEFINES_TPL % (p, c, DECLARE_PLUGIN_TPL % p))
+ regs.append(DEFINES_TPL % (p, c, REGISTER_PLUGIN_TPL % p))
+ 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()