gst_ios_init.m 2.24 KB
Newer Older
1 2 3
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

4
#include "gst_ios_init.h"
5 6 7 8 9 10

#if defined(GST_IOS_GIO_MODULE_GNUTLS)
  #include <gio/gio.h>
  GST_G_IO_MODULE_DECLARE(gnutls);
#endif

11
void gst_ios_pre_init(void)
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
{
  NSString *resources = [[NSBundle mainBundle] resourcePath];
  NSString *tmp = NSTemporaryDirectory();
  NSString *cache = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];
  NSString *docs = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    
  const gchar *resources_dir = [resources UTF8String];
  const gchar *tmp_dir = [tmp UTF8String];
  const gchar *cache_dir = [cache UTF8String];
  const gchar *docs_dir = [docs UTF8String];
  gchar *ca_certificates;
    
  g_setenv ("TMP", tmp_dir, TRUE);
  g_setenv ("TEMP", tmp_dir, TRUE);
  g_setenv ("TMPDIR", tmp_dir, TRUE);
  g_setenv ("XDG_RUNTIME_DIR", resources_dir, TRUE);
  g_setenv ("XDG_CACHE_HOME", cache_dir, TRUE);
    
  g_setenv ("HOME", docs_dir, TRUE);
  g_setenv ("XDG_DATA_DIRS", resources_dir, TRUE);
  g_setenv ("XDG_CONFIG_DIRS", resources_dir, TRUE);
  g_setenv ("XDG_CONFIG_HOME", cache_dir, TRUE);
  g_setenv ("XDG_DATA_HOME", resources_dir, TRUE);
  g_setenv ("FONTCONFIG_PATH", resources_dir, TRUE);

  ca_certificates = g_build_filename (resources_dir, "ssl", "certs", "ca-certificates.crt", NULL);
  g_setenv ("CA_CERTIFICATES", ca_certificates, TRUE);
  g_free (ca_certificates);
40
}
41

42 43 44 45
void gst_ios_post_init(void)
{
  GstPluginFeature *plugin;
  GstRegistry *reg;
46 47 48 49 50 51 52 53 54
  /* Lower the ranks of filesrc and giosrc so iosavassetsrc is
   * tried first in gst_element_make_from_uri() for file:// */
  reg = gst_registry_get();
  plugin = gst_registry_lookup_feature(reg, "filesrc");
  if (plugin)
    gst_plugin_feature_set_rank(plugin, GST_RANK_SECONDARY);
  plugin = gst_registry_lookup_feature(reg, "giosrc");
  if (plugin)
    gst_plugin_feature_set_rank(plugin, GST_RANK_SECONDARY-1);
55 56 57 58 59 60 61 62
  if (!gst_registry_lookup_feature(reg, "vtdec_hw")) {
    /* Usually there is no vtdec_hw plugin on iOS - in that case
     * we are increasing vtdec rank since VideoToolbox on iOS
     * tries to use hardware implementation first */
    plugin = gst_registry_lookup_feature(reg, "vtdec");
    if (plugin)
      gst_plugin_feature_set_rank(plugin, GST_RANK_PRIMARY + 1);
    }
63
}