2019-10-07 12:49:26 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
|
|
|
|
* Copyright (C) 2020 Seungha Yang <seungha@centricular.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2020-01-07 08:45:22 +00:00
|
|
|
#include <winapifamily.h>
|
|
|
|
|
2019-10-07 12:49:26 +00:00
|
|
|
#include <gst/gst.h>
|
2020-01-07 08:45:22 +00:00
|
|
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
2019-10-07 12:49:26 +00:00
|
|
|
#include "gstmfvideosrc.h"
|
2020-01-07 08:45:22 +00:00
|
|
|
#endif
|
2019-10-07 12:49:26 +00:00
|
|
|
#include "gstmfutils.h"
|
2020-01-07 08:45:22 +00:00
|
|
|
#include "gstmfh264enc.h"
|
2019-10-07 12:49:26 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY (gst_mf_debug);
|
|
|
|
GST_DEBUG_CATEGORY (gst_mf_utils_debug);
|
2020-01-07 08:45:22 +00:00
|
|
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
2019-10-07 12:49:26 +00:00
|
|
|
GST_DEBUG_CATEGORY (gst_mf_source_object_debug);
|
2020-01-07 08:45:22 +00:00
|
|
|
#endif
|
|
|
|
GST_DEBUG_CATEGORY (gst_mf_transform_debug);
|
2019-10-07 12:49:26 +00:00
|
|
|
|
|
|
|
#define GST_CAT_DEFAULT gst_mf_debug
|
|
|
|
|
2020-01-07 08:45:22 +00:00
|
|
|
/* NOTE: If you want to use this plugin in UWP app, don't try to load/initialize
|
|
|
|
* this plugin on UI thread, since the UI thread would be STA Thread
|
|
|
|
* but this plugin will be initialized with COINIT_MULTITHREADED parameter.
|
|
|
|
* This rule can be applied over all GStreamer plugins which are involved with
|
|
|
|
* COM libraries */
|
2019-10-07 12:49:26 +00:00
|
|
|
static gboolean
|
|
|
|
plugin_init (GstPlugin * plugin)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_mf_debug, "mf", 0, "media foundation");
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_mf_utils_debug,
|
|
|
|
"mfutils", 0, "media foundation utility functions");
|
2020-01-07 08:45:22 +00:00
|
|
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
2019-10-07 12:49:26 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_mf_source_object_debug,
|
|
|
|
"mfsourceobject", 0, "mfsourceobject");
|
2020-01-07 08:45:22 +00:00
|
|
|
#endif
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_mf_transform_debug,
|
|
|
|
"mftransform", 0, "mftransform");
|
2019-10-07 12:49:26 +00:00
|
|
|
|
|
|
|
hr = MFStartup (MF_VERSION, MFSTARTUP_NOSOCKET);
|
|
|
|
if (!gst_mf_result (hr)) {
|
|
|
|
GST_WARNING ("MFStartup failure, hr: 0x%x", hr);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2020-01-07 08:45:22 +00:00
|
|
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
2019-10-07 12:49:26 +00:00
|
|
|
gst_element_register (plugin,
|
|
|
|
"mfvideosrc", GST_RANK_SECONDARY, GST_TYPE_MF_VIDEO_SRC);
|
2020-01-07 08:45:22 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
gst_mf_h264_enc_plugin_init (plugin, GST_RANK_SECONDARY);
|
2019-10-07 12:49:26 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
mediafoundation,
|
|
|
|
"Microsoft Media Foundation plugin",
|
|
|
|
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|