summaryrefslogtreecommitdiff
path: root/recipes/gst-ffmpeg-static.recipe
blob: 41906bd951999b7421fcfe02ea42a7638764c84d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
import shutil

from cerbero.utils import shell
from cerbero.tools.libtool import LibtoolLibrary


class Recipe(custom.GStreamerStatic):
    name = 'gst-ffmpeg-static'
    version = '0.10.13'
    # TODO - check license, plugin is certainly LGPLv2+, but need to check
    #        the linked libs
    licenses = [License.LGPLv2Plus]
    extra_configure_options = " --enable-lgpl --disable-examples "
    deps = ['gstreamer', 'gst-plugins-base', 'bzip2', 'zlib' ]

    files_plugins_codecs_restricted_devel = ['libgstffmpeg']

    def prepare(self):
        if self.config.target_platform == Platform.WINDOWS:
            self.configure_options += \
                    '--with-ffmpeg-extra-configure="--enable-w32threads"'

        if self.config.target_platform == Platform.DARWIN:
            if self.config.target_arch == Architecture.X86_64:
                asflags = ' -arch x86_64 -m64'
            elif self.config.target_arch == Architecture.X86:
                asflags = ' -arch i386 -m32'
            elif self.config.target_arch == Architecture.PPC:
                asflags = ' -arch ppc'
            self.configure_options += ' ASFLAGS="%s"' % asflags
        super(Recipe, self).prepare()
        for f in ['libavcodec', 'libavformat', 'libavutil']:
            for ext in ['.a', '.la']:
                path = os.path.join('lib', f + ext)
                self.files_plugins_codecs_restricted_devel.append(path)

    def configure(self):
        opts = None
        if self.config.target_platform == Platform.ANDROID:
            if self.config.target_arch == Architecture.X86:
                opts = '--extra-cflags=-mincoming-stack-boundary=4'
        if self.config.target_platform == Platform.WINDOWS:
            opts = '--cross-prefix=%s- --target-os=mingw32 --arch=%s' %\
                (self.config.host, self.config.target_arch)
        if self.config.target_platform == Platform.IOS:
            opts = "--enable-cross-compile --target-os=darwin --cross-prefix='' --arch=%s "\
                   "--cc='$CC' --ar='$AR' --nm='$NM' --extra-cflags='$CFLAGS'" % self.config.target_arch
            if self.config.target_arch == Architecture.X86:
                opts += ' --as=$AS'
            else:
                opts += " --as='$GAS'"
        if opts:
            opts_file = os.path.join(self.build_dir, 'ffmpeg_extra_configure_options')
            with open(opts_file, 'w+') as f:
                f.write(opts)
        super(Recipe, self).configure()
        if self.config.target_platform == Platform.DARWIN:
            if self.config.target_arch == Architecture.X86:
                libav_path = os.path.join(self.build_dir, 'gst-libs', 'ext', 'libav')
                replacements = {'HAVE_EBX_AVAILABLE=yes': 'HAVE_EBX_AVAILABLE=no',
                                'HAVE_EBX_AVAILABLE 1': 'HAVE_EBX_AVAILABLE 0',}
                shell.replace(os.path.join(libav_path, 'config.mak'), replacements)
                shell.replace(os.path.join(libav_path, 'config.h'), replacements)

        # log2 and log2f are not provided by bionic, but they are not checked
        # properly
        if self.config.target_platform == Platform.ANDROID:
                libav_path = os.path.join(self.build_dir, 'gst-libs', 'ext', 'libav')
                replacements = {'HAVE_LOG2 1': 'HAVE_LOG2 0',
                                'HAVE_LOG2F 1': 'HAVE_LOG2F 0',}
                shell.replace(os.path.join(libav_path, 'config.h'), replacements)

    def post_install(self):
        for n in ['avutil', 'avcodec', 'avformat']:
            name = 'lib%s' % n
            lib = '%s.a' % name
            path = os.path.join(self.build_dir, 'gst-libs', 'ext', 'libav',
                    name, lib)
            shutil.copy(path, self.config.libdir)
            deps = ['z', 'bz2']
            if n == 'avcodec':
                deps += ['avutil']
            if n == 'avformat':
                deps += ['avutil', 'avcodec']
            libtool_la = LibtoolLibrary(n, None, None, None, self.config.libdir,
                self.config.target_platform, deps)
            libtool_la.change_value ('dlname', '')
            libtool_la.change_value ('library_names', '')
            libtool_la.save()
        super(Recipe, self).post_install()
        gstffmpeglib = os.path.join(self.config.prefix, 'lib', 'gstreamer-0.10',
                'static', 'libgstffmpeg.la')
        shell.replace (gstffmpeglib,
                {'-lavformat': os.path.join(self.config.libdir, 'libavformat.la'),
                '-lavcodec': os.path.join(self.config.libdir, 'libavcodec.la'),
                '-lavutil': os.path.join(self.config.libdir, 'libavutil.la')})