From: Ziqing Hui zhui@codeweavers.com
--- dlls/winegstreamer/mfplat.c | 17 ++++++++++++++++- dlls/winegstreamer/unixlib.h | 2 ++ dlls/winegstreamer/wg_format.c | 14 ++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c index 7a37f25fcb2..c7906a8bc1f 100644 --- a/dlls/winegstreamer/mfplat.c +++ b/dlls/winegstreamer/mfplat.c @@ -804,8 +804,9 @@ static void mf_media_type_to_wg_format_audio_wma(IMFMediaType *type, const GUID
static void mf_media_type_to_wg_format_video_h264(IMFMediaType *type, struct wg_format *format) { + UINT32 profile, level, codec_data_len; UINT64 frame_rate, frame_size; - UINT32 profile, level; + BYTE *codec_data;
memset(format, 0, sizeof(*format)); format->major_type = WG_MAJOR_TYPE_VIDEO_H264; @@ -832,6 +833,20 @@ static void mf_media_type_to_wg_format_video_h264(IMFMediaType *type, struct wg_
if (SUCCEEDED(IMFMediaType_GetUINT32(type, &MF_MT_MPEG2_LEVEL, &level))) format->u.video_h264.level = level; + + if (SUCCEEDED(IMFMediaType_GetAllocatedBlob(type, &MF_MT_MPEG_SEQUENCE_HEADER, &codec_data, &codec_data_len))) + { + if (codec_data_len <= sizeof(format->u.video_h264.codec_data)) + { + format->u.video_h264.codec_data_len = codec_data_len; + memcpy(format->u.video_h264.codec_data, codec_data, codec_data_len); + } + else + { + WARN("Codec data buffer too small, codec data size %u.\n", codec_data_len); + } + CoTaskMemFree(codec_data); + } }
static void mf_media_type_to_wg_format_video_indeo(IMFMediaType *type, uint32_t version, struct wg_format *format) diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h index 702bd7aa69b..15e0605fdde 100644 --- a/dlls/winegstreamer/unixlib.h +++ b/dlls/winegstreamer/unixlib.h @@ -148,6 +148,8 @@ struct wg_format uint32_t fps_n, fps_d; uint32_t profile; uint32_t level; + uint32_t codec_data_len; + unsigned char codec_data[64]; } video_h264; struct { diff --git a/dlls/winegstreamer/wg_format.c b/dlls/winegstreamer/wg_format.c index bd0ebf892c1..2353839bbc4 100644 --- a/dlls/winegstreamer/wg_format.c +++ b/dlls/winegstreamer/wg_format.c @@ -553,6 +553,7 @@ static GstCaps *wg_format_to_caps_audio_wma(const struct wg_format *format) static GstCaps *wg_format_to_caps_video_h264(const struct wg_format *format) { const char *profile, *level; + GstBuffer *buffer; GstCaps *caps;
if (!(caps = gst_caps_new_empty_simple("video/x-h264"))) @@ -609,6 +610,19 @@ static GstCaps *wg_format_to_caps_video_h264(const struct wg_format *format) if (level) gst_caps_set_simple(caps, "level", G_TYPE_STRING, level, NULL);
+ if (format->u.video_h264.codec_data_len) + { + if (!(buffer = gst_buffer_new_and_alloc(format->u.video_h264.codec_data_len))) + { + gst_caps_unref(caps); + return NULL; + } + + gst_buffer_fill(buffer, 0, format->u.video_h264.codec_data, format->u.video_h264.codec_data_len); + gst_caps_set_simple(caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL); + gst_buffer_unref(buffer); + } + return caps; }