[PATCH 14/16] winegstreamer: Translate AAC attributes to caps.

Derek Lesho dlesho at codeweavers.com
Wed Mar 25 19:12:39 CDT 2020


Signed-off-by: Derek Lesho <dlesho at codeweavers.com>
---
 dlls/winegstreamer/mfplat.c | 68 +++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c
index 62f10a13b9..aa042a59d3 100644
--- a/dlls/winegstreamer/mfplat.c
+++ b/dlls/winegstreamer/mfplat.c
@@ -878,6 +878,74 @@ GstCaps *caps_from_media_type(IMFMediaType *type)
 
             gst_caps_set_simple(output, "format", G_TYPE_STRING, "F32LE", NULL);
         }
+        else if (IsEqualGUID(&subtype, &MFAudioFormat_AAC))
+        {
+            DWORD payload_type, indication;
+            struct aac_user_data *user_data;
+            UINT32 user_data_size;
+            output = gst_caps_new_empty_simple("audio/mpeg");
+
+            /* TODO */
+            gst_caps_set_simple(output, "framed", G_TYPE_BOOLEAN, TRUE, NULL);
+            gst_caps_set_simple(output, "mpegversion", G_TYPE_INT, 4, NULL);
+
+            if (SUCCEEDED(IMFMediaType_GetUINT32(type, &MF_MT_AAC_PAYLOAD_TYPE, &payload_type)))
+            {
+                switch (payload_type)
+                {
+                    case 0:
+                        gst_caps_set_simple(output, "stream-format", G_TYPE_STRING, "raw", NULL);
+                        break;
+                    case 1:
+                        gst_caps_set_simple(output, "stream-format", G_TYPE_STRING, "adts", NULL);
+                        break;
+                    default:
+                        gst_caps_set_simple(output, "stream-format", G_TYPE_STRING, "raw", NULL);
+                }
+            }
+            else
+                gst_caps_set_simple(output, "stream-format", G_TYPE_STRING, "raw", NULL);
+
+            if (SUCCEEDED(IMFMediaType_GetUINT32(type, &MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION, &indication)))
+            {
+                switch (indication)
+                {
+                    case 0x29:
+                    {
+                        gst_caps_set_simple(output, "profile", G_TYPE_STRING, "lc", NULL);
+                        gst_caps_set_simple(output, "level", G_TYPE_STRING, "2", NULL);
+                        break;
+                    }
+                    case 0x2A:
+                    {
+                        gst_caps_set_simple(output, "profile", G_TYPE_STRING, "lc", NULL);
+                        gst_caps_set_simple(output, "level", G_TYPE_STRING, "4", NULL);
+                        break;
+                    }
+                    case 0x2B:
+                    {
+                        gst_caps_set_simple(output, "profile", G_TYPE_STRING, "lc", NULL);
+                        gst_caps_set_simple(output, "level", G_TYPE_STRING, "5", NULL);
+                        break;
+                    }
+                    default:
+                        ERR("Unrecognized profile-level-indication %u\n", indication);
+                }
+            }
+
+            if (SUCCEEDED(IMFMediaType_GetAllocatedBlob(type, &MF_MT_USER_DATA, (BYTE **) &user_data, &user_data_size)))
+            {
+                if (user_data_size > sizeof(sizeof(*user_data)))
+                {
+                    GstBuffer *audio_specific_config = gst_buffer_new_allocate(NULL, user_data_size - sizeof(*user_data), NULL);
+                    gst_buffer_fill(audio_specific_config, 0, user_data + 1, user_data_size - sizeof(*user_data));
+
+                    gst_caps_set_simple(output, "codec_data", GST_TYPE_BUFFER, audio_specific_config, NULL);
+                    gst_buffer_unref(audio_specific_config);
+                }
+                CoTaskMemFree(user_data);
+            }
+        }
         else
         {
             ERR("Unrecognized subtype %s\n", debugstr_guid(&subtype));
-- 
2.25.1




More information about the wine-devel mailing list