1

所以 1.0+ 的 GStreamer 文档似乎......至少可以说是缺乏。GStreamer SDK 有一些有用的提示,但不幸的是它们不够用。

所以,这就是我所做的。我在/Library/GStreamer.Framework/中构建了一个调用 GStreamer 的应用程序

我使用命令行工具构建。这是我可以构建此应用程序的唯一方法。我不能使用 XCode GUI。

我想将此应用程序提交到商店,但这样做我不能将它作为一个包提交(因此我可以捆绑 GStreamer 包安装程序),这意味着我必须将 GStreamer.framework 与我的应用程序捆绑在一起。

在上面的 GStreamer SDK 文档中,您会注意到一个名为 osxrelocator.py 的工具。这很棒,因为它将/Library/GStreamer.Framework的所有引用更改为@executable_path/../Frameworks/GStreamer.framework/

不幸的是,所有 GStreamer .dylibs 都有一个问题......您需要使用 install_name_tool -id 来更改他们的路径,因为 install_name_tool -change 不会改变他们自己的路径!

因此,例如使用 otool:

$ otool -L Application.app/Contents/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstreamer-1.0.0.dylib
Application.app/Contents/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstreamer-1.0.0.dylib:
    Library/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstreamer-1.0.0.dylib (compatibility version 402.0.0, current version 402.0.0)
    Library/Frameworks/Frameworks/GStreamer.framework/Versions/1.0/lib/libgobject-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
    Library/Frameworks/GStreamer.framework/Versions/1.0/lib/libffi.6.dylib (compatibility version 7.0.0, current version 7.1.0)
    Library/Frameworks/GStreamer.framework/Versions/1.0/lib/libgmodule-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
    Library/Frameworks/Frameworks/GStreamer.framework/Versions/1.0/lib/libglib-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
    Library/Frameworks/Frameworks/GStreamer.framework/Versions/1.0/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.2.0)
    Library/Frameworks/Frameworks/GStreamer.framework/Versions/1.0/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 855.14.0)

然后使用 osxrelocator.py(调用 install_name_tool -change):

./osxrelocator.py Application.app/Contents/MacOS /Library/Frameworks/GStreamer.framework/Versions/Current/lib @executable_path/../Frameworks/GStreamer.framework/Versions/Current/lib -r

给出:

$ otool -L Application.app/Contents/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstreamer-1.0.0.dylib
Application.app/Contents/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstreamer-1.0.0.dylib:
    /Library/Frameworks/GStreamer.framework/Versions/1.0/lib/libgstreamer-1.0.0.dylib (compatibility version 402.0.0, current version 402.0.0)
    @executable_path/../Frameworks/GStreamer.framework/Versions/1.0/lib/libgobject-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
    @executable_path/../Frameworks/GStreamer.framework/Versions/1.0/lib/libffi.6.dylib (compatibility version 7.0.0, current version 7.1.0)
    @executable_path/../Frameworks/GStreamer.framework/Versions/1.0/lib/libgmodule-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
    @executable_path/../Frameworks/GStreamer.framework/Versions/1.0/lib/libglib-2.0.0.dylib (compatibility version 4001.0.0, current version 4001.0.0)
    @executable_path/../Frameworks/GStreamer.framework/Versions/1.0/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.2.0)
    @executable_path/../Frameworks/GStreamer.framework/Versions/1.0/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
    /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 855.14.0)

请注意 .dylib 引用自身的第一行?这不会更改为 @executable_path/../Frameworks/GStreamer.framework/ 除非您调用 install_name_tool -id。GStreamer 框架中的每个 .dylib 都会发生这种情况!有数百个,我敢肯定手动执行此操作肯定会导致错误。

希望我已经把我的问题说清楚了。有人对该怎么做有任何建议吗?

谢谢!

4

1 回答 1

1

我创建了一个简单的 Xcode 项目来向您展示如何捆绑框架: https ://github.com/corrosion/gstreamer-osx-bundle.git


对于图书馆搬迁使用: https ://github.com/tito/osxrelocator


使用 XCode 构建项目的设置:

  • 安装 gstreamer-1.0-1.5.2-x86_64.pkg
  • 安装 gstreamer-1.0-devel-1.5.2-x86_64.pkg
  • 移动 /Library/Frameworks/GStreamer.framework 到 $(PROJECT_DIR)/GStreamer-devel.framework
  • 转到 $(PROJECT_DIR) 并运行以下命令:
  • osxrelocator ./GStreamer-devel.framework/Versions/Current /Library/Frameworks/GStreamer.framework/密码/GStreamer-devel.framework/
  • install_name_tool -id @executable_path/../Frameworks/GStreamer.framework/GStreamer ./GStreamer-devel.framework/Versions/Current/GStreamer
  • 将“$(PROJECT_DIR)/GStreamer-devel.framework/Headers”添加到标题搜索路径
  • 将“GStreamer-devel.framework/GStreamer”文件添加到 Xcode 项目

准备运行时框架:

  • 安装 gstreamer-1.0-1.5.2-x86_64.pkg
  • 移动 /Library/Frameworks/GStreamer.framework 到 $(PROJECT_DIR)/GStreamer.framework
  • 对框架进行一些清理:
  • rm ./GStreamer.framework/Headers ./GStreamer.framework/Commands
  • rm ./GStreamer.framework/Versions/Current/Commands
  • rm -r ./GStreamer.framework/Versions/Current/bin/
  • rm -r ./GStreamer.framework/Versions/Current/etc/
  • rm -r ./GStreamer.framework/Versions/Current/share/
  • 重新定位框架的 .dylibs:
  • osxrelocator -r ./GStreamer.framework/Versions/Current /Library/Frameworks/GStreamer.framework/ @executable_path/../Frameworks/GStreamer.framework/
  • 由于 gst-plugin-scanner 在 gst_init 期间执行,它还必须能够找到所有库。因此,在 libexec 目录中创建指向“Frameworks”的链接以解析 @executable_path/../Frameworks/GStreamer.framework/
  • ln -sf ../../../../ GStreamer.framework/Versions/Current/libexec/Frameworks
  • 在项目的 Build Phases 设置中创建新的 Copy Files Phase 并将 GStreamer.framework 复制到 Fameworks

在调用 gst_init() 之前在代码中设置 GST_PLUGIN_SCANNER 和 GST_PLUGIN_SYSTEM_PATH 环境变量:

// Setup GSTreamer environment
NSString *frameworksPath = [[NSBundle mainBundle] privateFrameworksPath];
NSString *scannerPath = [NSString stringWithFormat:@"%@/%s", frameworksPath,
                         "GStreamer.framework/Versions/1.0/libexec/gstreamer-1.0/gst-plugin-scanner"];
NSString *pluginsPath = [NSString stringWithFormat:@"%@/%s", frameworksPath,
                         "GStreamer.framework/Versions/1.0/lib"];
setenv("GST_PLUGIN_SCANNER", [scannerPath UTF8String], 1);
setenv("GST_PLUGIN_SYSTEM_PATH", [pluginsPath UTF8String], 1);

// Initialize GStreamer
gst_init(&argc, (char ***) &argv);
于 2015-09-14T19:10:50.923 回答