• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2009-2010 Ole André Vadla Ravnås <oleavr@soundrop.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifdef HAVE_CONFIG_H
21# include <config.h>
22#endif
23
24#include <Foundation/Foundation.h>
25#include "corevideomemory.h"
26#ifdef HAVE_IOS
27#include "iosassetsrc.h"
28#include "iosglmemory.h"
29#endif
30#ifdef HAVE_AVFOUNDATION
31#include "avfvideosrc.h"
32#include "avfassetsrc.h"
33#include "avfdeviceprovider.h"
34#include "avsamplevideosink.h"
35#endif
36#ifdef HAVE_VIDEOTOOLBOX
37#include "vtdec.h"
38#endif
39#ifndef HAVE_IOS
40#define AV_RANK GST_RANK_SECONDARY
41#else
42#define AV_RANK GST_RANK_PRIMARY
43#endif
44#include "atdec.h"
45
46#ifdef HAVE_VIDEOTOOLBOX
47void gst_vtenc_register_elements (GstPlugin * plugin);
48#endif
49
50#ifndef HAVE_IOS
51
52static void
53enable_mt_mode (void)
54{
55  NSThread * th = [[NSThread alloc] init];
56  [th start];
57  g_assert ([NSThread isMultiThreaded]);
58}
59#endif
60
61static gboolean
62plugin_init (GstPlugin * plugin)
63{
64  gboolean res = TRUE;
65
66  gst_apple_core_video_memory_init ();
67
68#ifdef HAVE_IOS
69  gst_ios_gl_memory_init ();
70
71  res &= gst_element_register (plugin, "iosassetsrc", GST_RANK_SECONDARY,
72      GST_TYPE_IOS_ASSET_SRC);
73#else
74  enable_mt_mode ();
75#endif
76
77#ifdef HAVE_AVFOUNDATION
78  res &= gst_element_register (plugin, "avfvideosrc", AV_RANK,
79      GST_TYPE_AVF_VIDEO_SRC);
80  res &= gst_element_register (plugin, "avfassetsrc", AV_RANK,
81      GST_TYPE_AVF_ASSET_SRC);
82  res &= gst_element_register (plugin, "avsamplebufferlayersink",
83      GST_RANK_NONE, GST_TYPE_AV_SAMPLE_VIDEO_SINK);
84  res &= gst_device_provider_register (plugin, "avfdeviceprovider",
85    GST_RANK_PRIMARY, GST_TYPE_AVF_DEVICE_PROVIDER);
86#endif
87
88  res &= gst_element_register (plugin, "atdec", GST_RANK_MARGINAL, GST_TYPE_ATDEC);
89
90#ifdef HAVE_VIDEOTOOLBOX
91  /* Check if the framework actually exists at runtime */
92  if (&VTCompressionSessionCreate != NULL) {
93    gst_vtdec_register_elements (plugin);
94    gst_vtenc_register_elements (plugin);
95  }
96#endif
97
98
99  return res;
100}
101
102GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
103    GST_VERSION_MINOR,
104    applemedia,
105    "Elements for capture and codec access on Apple macOS and iOS",
106    plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
107