Commit 71bf5b24 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winegstreamer: Create static pads on wg_transform struct.

parent 51a262d3
......@@ -96,7 +96,8 @@ uint64_t wg_parser_stream_get_duration(struct wg_parser_stream *stream);
void wg_parser_stream_seek(struct wg_parser_stream *stream, double rate,
uint64_t start_pos, uint64_t stop_pos, DWORD start_flags, DWORD stop_flags);
struct wg_transform *wg_transform_create(void);
struct wg_transform *wg_transform_create(const struct wg_format *input_format,
const struct wg_format *output_format);
void wg_transform_destroy(struct wg_transform *transform);
unsigned int wg_format_get_max_size(const struct wg_format *format);
......
......@@ -254,9 +254,14 @@ void wg_parser_stream_seek(struct wg_parser_stream *stream, double rate,
__wine_unix_call(unix_handle, unix_wg_parser_stream_seek, &params);
}
struct wg_transform *wg_transform_create(void)
struct wg_transform *wg_transform_create(const struct wg_format *input_format,
const struct wg_format *output_format)
{
struct wg_transform_create_params params = {0};
struct wg_transform_create_params params =
{
.input_format = input_format,
.output_format = output_format,
};
if (__wine_unix_call(unix_handle, unix_wg_transform_create, &params))
return NULL;
......
......@@ -232,6 +232,8 @@ struct wg_parser_stream_seek_params
struct wg_transform_create_params
{
struct wg_transform *transform;
const struct wg_format *input_format;
const struct wg_format *output_format;
};
enum unix_funcs
......
......@@ -394,6 +394,43 @@ static GstCaps *wg_format_to_caps_video(const struct wg_format *format)
return caps;
}
static GstCaps *wg_format_to_caps_wma(const struct wg_format *format)
{
GstBuffer *buffer;
GstCaps *caps;
if (!(caps = gst_caps_new_empty_simple("audio/x-wma")))
return NULL;
if (format->u.wma.version)
gst_caps_set_simple(caps, "wmaversion", G_TYPE_INT, format->u.wma.version, NULL);
if (format->u.wma.bitrate)
gst_caps_set_simple(caps, "bitrate", G_TYPE_INT, format->u.wma.bitrate, NULL);
if (format->u.wma.rate)
gst_caps_set_simple(caps, "rate", G_TYPE_INT, format->u.wma.rate, NULL);
if (format->u.wma.depth)
gst_caps_set_simple(caps, "depth", G_TYPE_INT, format->u.wma.depth, NULL);
if (format->u.wma.channels)
gst_caps_set_simple(caps, "channels", G_TYPE_INT, format->u.wma.channels, NULL);
if (format->u.wma.block_align)
gst_caps_set_simple(caps, "block_align", G_TYPE_INT, format->u.wma.block_align, NULL);
if (format->u.wma.codec_data_len)
{
if (!(buffer = gst_buffer_new_and_alloc(format->u.wma.codec_data_len)))
{
gst_caps_unref(caps);
return NULL;
}
gst_buffer_fill(buffer, 0, format->u.wma.codec_data, format->u.wma.codec_data_len);
gst_caps_set_simple(caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL);
gst_buffer_unref(buffer);
}
return caps;
}
GstCaps *wg_format_to_caps(const struct wg_format *format)
{
switch (format->major_type)
......@@ -401,8 +438,7 @@ GstCaps *wg_format_to_caps(const struct wg_format *format)
case WG_MAJOR_TYPE_UNKNOWN:
return NULL;
case WG_MAJOR_TYPE_WMA:
GST_FIXME("WMA format not implemented!\n");
return NULL;
return wg_format_to_caps_wma(format);
case WG_MAJOR_TYPE_AUDIO:
return wg_format_to_caps_audio(format);
case WG_MAJOR_TYPE_VIDEO:
......
......@@ -44,13 +44,29 @@ GST_DEBUG_CATEGORY_EXTERN(wine);
struct wg_transform
{
int dummy;
GstPad *my_src, *my_sink;
};
static GstFlowReturn transform_sink_chain_cb(GstPad *pad, GstObject *parent, GstBuffer *buffer)
{
struct wg_transform *transform = gst_pad_get_element_private(pad);
GST_INFO("transform %p, buffer %p.", transform, buffer);
gst_buffer_unref(buffer);
return GST_FLOW_OK;
}
NTSTATUS wg_transform_destroy(void *args)
{
struct wg_transform *transform = args;
if (transform->my_sink)
g_object_unref(transform->my_sink);
if (transform->my_src)
g_object_unref(transform->my_src);
free(transform);
return STATUS_SUCCESS;
}
......@@ -58,6 +74,10 @@ NTSTATUS wg_transform_destroy(void *args)
NTSTATUS wg_transform_create(void *args)
{
struct wg_transform_create_params *params = args;
struct wg_format output_format = *params->output_format;
struct wg_format input_format = *params->input_format;
GstCaps *src_caps = NULL, *sink_caps = NULL;
GstPadTemplate *template = NULL;
struct wg_transform *transform;
NTSTATUS status;
......@@ -69,9 +89,38 @@ NTSTATUS wg_transform_create(void *args)
if (!(transform = calloc(1, sizeof(*transform))))
goto done;
if (!(src_caps = wg_format_to_caps(&input_format)))
goto done;
if (!(sink_caps = wg_format_to_caps(&output_format)))
goto done;
if (!(template = gst_pad_template_new("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps)))
goto done;
if (!(transform->my_src = gst_pad_new_from_template(template, "src")))
goto done;
g_object_unref(template);
template = NULL;
if (!(template = gst_pad_template_new("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps)))
goto done;
if (!(transform->my_sink = gst_pad_new_from_template(template, "sink")))
goto done;
g_object_unref(template);
template = NULL;
gst_pad_set_element_private(transform->my_sink, transform);
gst_pad_set_chain_function(transform->my_sink, transform_sink_chain_cb);
status = STATUS_SUCCESS;
done:
if (template)
g_object_unref(template);
if (sink_caps)
gst_caps_unref(sink_caps);
if (src_caps)
gst_caps_unref(src_caps);
if (status)
{
GST_ERROR("Failed to create winegstreamer transform.");
......
......@@ -78,7 +78,7 @@ static HRESULT try_create_wg_transform(struct wma_decoder *decoder)
if (output_format.major_type == WG_MAJOR_TYPE_UNKNOWN)
return MF_E_INVALIDMEDIATYPE;
if (!(decoder->wg_transform = wg_transform_create()))
if (!(decoder->wg_transform = wg_transform_create(&input_format, &output_format)))
return E_FAIL;
return S_OK;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment