diff --git a/subprojects/gst-plugins-bad/gst/mxf/gstmxfelement.c b/subprojects/gst-plugins-bad/gst/mxf/gstmxfelement.c index f2c11663c3..c9ca201be5 100644 --- a/subprojects/gst-plugins-bad/gst/mxf/gstmxfelement.c +++ b/subprojects/gst-plugins-bad/gst/mxf/gstmxfelement.c @@ -38,6 +38,7 @@ #include "mxfvc3.h" #include "mxfprores.h" #include "mxfvanc.h" +#include "mxfcustom.h" GST_DEBUG_CATEGORY (mxf_debug); #define GST_CAT_DEFAULT mxf_debug @@ -77,6 +78,7 @@ mxf_element_init (GstPlugin * plugin) mxf_vc3_init (); mxf_prores_init (); mxf_vanc_init (); + mxf_custom_init (); g_once_init_leave (&res, TRUE); } } diff --git a/subprojects/gst-plugins-bad/gst/mxf/meson.build b/subprojects/gst-plugins-bad/gst/mxf/meson.build index 73d08b3496..24ec93a49a 100644 --- a/subprojects/gst-plugins-bad/gst/mxf/meson.build +++ b/subprojects/gst-plugins-bad/gst/mxf/meson.build @@ -18,6 +18,7 @@ mxf_sources = [ 'mxfvc3.c', 'mxfprores.c', 'mxfvanc.c', + 'mxfcustom.c', # 'mxfdms1.c', ] diff --git a/subprojects/gst-plugins-bad/gst/mxf/mxfcustom.c b/subprojects/gst-plugins-bad/gst/mxf/mxfcustom.c new file mode 100644 index 0000000000..d266045785 --- /dev/null +++ b/subprojects/gst-plugins-bad/gst/mxf/mxfcustom.c @@ -0,0 +1,115 @@ +/* GStreamer + * Copyright (C) 2022 Edward Hervey + * + * 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. + */ + +/* Custom mappings + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include "mxfcustom.h" +#include "mxfessence.h" + +GST_DEBUG_CATEGORY_EXTERN (mxf_debug); +#define GST_CAT_DEFAULT mxf_debug + +/* Custom Canon XF-HEVC essence */ +static const MXFUL mxf_canon_xf_hevc = { {0x06, 0x0E, 0x2B, 0x34, + 0x04, 0x01, 0x01, 0x0c, + 0x0e, 0x15, 0x00, 0x04, + 0x02, 0x10, 0x00, 0x01} +}; + +static gboolean +mxf_is_canon_xfhevc_essence_track (const MXFMetadataTimelineTrack * track) +{ + guint i; + + g_return_val_if_fail (track != NULL, FALSE); + + if (track->parent.descriptor == NULL) + return FALSE; + + for (i = 0; i < track->parent.n_descriptor; i++) { + MXFMetadataFileDescriptor *d = track->parent.descriptor[i]; + MXFUL *key; + + if (!d) + continue; + + key = &d->essence_container; + if (mxf_ul_is_equal (key, &mxf_canon_xf_hevc)) + return TRUE; + } + + return FALSE; +} + +static GstFlowReturn +mxf_canon_xfhevc_handle_essence_element (const MXFUL * key, GstBuffer * buffer, + GstCaps * caps, + MXFMetadataTimelineTrack * track, + gpointer mapping_data, GstBuffer ** outbuf) +{ + *outbuf = buffer; + /* Blindly accept it */ + return GST_FLOW_OK; +} + +static MXFEssenceWrapping +mxf_canon_xfhevc_get_track_wrapping (const MXFMetadataTimelineTrack * track) +{ + /* Assume it's always frame wrapping */ + return MXF_ESSENCE_WRAPPING_FRAME_WRAPPING; +} + +static GstCaps * +mxf_canon_xfhevc_create_caps (MXFMetadataTimelineTrack * track, + GstTagList ** tags, gboolean * intra_only, + MXFEssenceElementHandleFunc * handler, gpointer * mapping_data) +{ + GstCaps *caps = NULL; + + g_return_val_if_fail (track != NULL, NULL); + + *handler = mxf_canon_xfhevc_handle_essence_element; + *intra_only = TRUE; + caps = gst_caps_from_string ("video/x-h265"); + + return caps; +} + +static const MXFEssenceElementHandler mxf_canon_xfhevc_essence_element_handler = { + mxf_is_canon_xfhevc_essence_track, + mxf_canon_xfhevc_get_track_wrapping, + mxf_canon_xfhevc_create_caps +}; + +void +mxf_custom_init (void) +{ + mxf_essence_element_handler_register + (&mxf_canon_xfhevc_essence_element_handler); +} diff --git a/subprojects/gst-plugins-bad/gst/mxf/mxfcustom.h b/subprojects/gst-plugins-bad/gst/mxf/mxfcustom.h new file mode 100644 index 0000000000..cd085a6f84 --- /dev/null +++ b/subprojects/gst-plugins-bad/gst/mxf/mxfcustom.h @@ -0,0 +1,30 @@ +/* GStreamer + * Copyright (C) 2022 Edward Hervey + * + * 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. + */ + +/* Custom mappings + */ + +#ifndef __MXF_CUSTOM_H__ +#define __MXF_CUSTOM_H__ + +#include + +void mxf_custom_init (void); + +#endif /* __MXF_CUSTOM_H__ */