summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2020-08-28 12:56:38 +0300
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-08-30 22:12:22 +0000
commit391d09dc245a72391ef5a72bb6e3053573f1614c (patch)
tree151b5a6014b24fcdba7f45f53891942922603c4c
parent4f12ce62139586e68bc6e41922fc68396c89ff62 (diff)
downloadgstreamer-plugins-base-391d09dc245a72391ef5a72bb6e3053573f1614c.tar.gz
audio/video: Copy more metas by default in the codec base classes
For audio we copy metas that have no tags at all, or that only have the "audio" and/or "audio-channels" tag. Audio codecs don't change the audio aspect of the stream and in almost all cases don't change the number of channels. They might however change the sample rate (e.g. Opus). Subclasses that change the number of channels will have to override ::transform_meta() accordingly. For video we copy metas that have no tags at all, or that only have the "video" and/or "video-size" and/or "video-orientation" tag. Video codecs don't change the "video" aspect of the stream and in almost all cases don't change the resolution or orientation. Subclasses that rescale or change the orientation will have to override ::transform_meta() accordingly. See https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/576#note_610581 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/801>
-rw-r--r--gst-libs/gst/audio/gstaudiodecoder.c16
-rw-r--r--gst-libs/gst/audio/gstaudioencoder.c16
-rw-r--r--gst-libs/gst/video/gstvideodecoder.c17
-rw-r--r--gst-libs/gst/video/gstvideoencoder.c17
4 files changed, 54 insertions, 12 deletions
diff --git a/gst-libs/gst/audio/gstaudiodecoder.c b/gst-libs/gst/audio/gstaudiodecoder.c
index 8f6e5ab04..b9ecc8d36 100644
--- a/gst-libs/gst/audio/gstaudiodecoder.c
+++ b/gst-libs/gst/audio/gstaudiodecoder.c
@@ -1208,14 +1208,24 @@ gst_audio_decoder_transform_meta_default (GstAudioDecoder *
{
const GstMetaInfo *info = meta->info;
const gchar *const *tags;
+ const gchar *const supported_tags[] = {
+ GST_META_TAG_AUDIO_STR,
+ GST_META_TAG_AUDIO_CHANNELS_STR,
+ NULL,
+ };
tags = gst_meta_api_type_get_tags (info->api);
- if (!tags || (g_strv_length ((gchar **) tags) == 1
- && gst_meta_api_type_has_tag (info->api, META_TAG_AUDIO)))
+ if (!tags)
return TRUE;
- return FALSE;
+ while (*tags) {
+ if (!g_strv_contains (supported_tags, *tags))
+ return FALSE;
+ tags++;
+ }
+
+ return TRUE;
}
typedef struct
diff --git a/gst-libs/gst/audio/gstaudioencoder.c b/gst-libs/gst/audio/gstaudioencoder.c
index 10c1b67e4..68cb069b2 100644
--- a/gst-libs/gst/audio/gstaudioencoder.c
+++ b/gst-libs/gst/audio/gstaudioencoder.c
@@ -670,14 +670,24 @@ gst_audio_encoder_transform_meta_default (GstAudioEncoder *
{
const GstMetaInfo *info = meta->info;
const gchar *const *tags;
+ const gchar *const supported_tags[] = {
+ GST_META_TAG_AUDIO_STR,
+ GST_META_TAG_AUDIO_CHANNELS_STR,
+ NULL,
+ };
tags = gst_meta_api_type_get_tags (info->api);
- if (!tags || (g_strv_length ((gchar **) tags) == 1
- && gst_meta_api_type_has_tag (info->api, META_TAG_AUDIO)))
+ if (!tags)
return TRUE;
- return FALSE;
+ while (*tags) {
+ if (!g_strv_contains (supported_tags, *tags))
+ return FALSE;
+ tags++;
+ }
+
+ return TRUE;
}
typedef struct
diff --git a/gst-libs/gst/video/gstvideodecoder.c b/gst-libs/gst/video/gstvideodecoder.c
index 300d18183..e69074a8d 100644
--- a/gst-libs/gst/video/gstvideodecoder.c
+++ b/gst-libs/gst/video/gstvideodecoder.c
@@ -3032,14 +3032,25 @@ gst_video_decoder_transform_meta_default (GstVideoDecoder *
{
const GstMetaInfo *info = meta->info;
const gchar *const *tags;
+ const gchar *const supported_tags[] = {
+ GST_META_TAG_VIDEO_STR,
+ GST_META_TAG_VIDEO_ORIENTATION_STR,
+ GST_META_TAG_VIDEO_SIZE_STR,
+ NULL,
+ };
tags = gst_meta_api_type_get_tags (info->api);
- if (!tags || (g_strv_length ((gchar **) tags) == 1
- && gst_meta_api_type_has_tag (info->api, META_TAG_VIDEO)))
+ if (!tags)
return TRUE;
- return FALSE;
+ while (*tags) {
+ if (!g_strv_contains (supported_tags, *tags))
+ return FALSE;
+ tags++;
+ }
+
+ return TRUE;
}
typedef struct
diff --git a/gst-libs/gst/video/gstvideoencoder.c b/gst-libs/gst/video/gstvideoencoder.c
index a3b55495d..d45a4f6e7 100644
--- a/gst-libs/gst/video/gstvideoencoder.c
+++ b/gst-libs/gst/video/gstvideoencoder.c
@@ -2139,14 +2139,25 @@ gst_video_encoder_transform_meta_default (GstVideoEncoder *
{
const GstMetaInfo *info = meta->info;
const gchar *const *tags;
+ const gchar *const supported_tags[] = {
+ GST_META_TAG_VIDEO_STR,
+ GST_META_TAG_VIDEO_ORIENTATION_STR,
+ GST_META_TAG_VIDEO_SIZE_STR,
+ NULL,
+ };
tags = gst_meta_api_type_get_tags (info->api);
- if (!tags || (g_strv_length ((gchar **) tags) == 1
- && gst_meta_api_type_has_tag (info->api, META_TAG_VIDEO)))
+ if (!tags)
return TRUE;
- return FALSE;
+ while (*tags) {
+ if (!g_strv_contains (supported_tags, *tags))
+ return FALSE;
+ tags++;
+ }
+
+ return TRUE;
}
typedef struct