Commit 98310d21 authored by Ziqing Hui's avatar Ziqing Hui Committed by Alexandre Julliard

winestreamer: Introduce media_sink_write_stream.

parent 96da5a8a
......@@ -115,6 +115,7 @@ void wg_muxer_destroy(wg_muxer_t muxer);
HRESULT wg_muxer_add_stream(wg_muxer_t muxer, UINT32 stream_id, const struct wg_format *format);
HRESULT wg_muxer_start(wg_muxer_t muxer);
HRESULT wg_muxer_push_sample(wg_muxer_t muxer, struct wg_sample *sample, UINT32 stream_id);
HRESULT wg_muxer_read_data(wg_muxer_t muxer, void *buffer, UINT32 *size, UINT64 *offset);
unsigned int wg_format_get_bytes_for_uncompressed(wg_video_format format, unsigned int width, unsigned int height);
unsigned int wg_format_get_max_size(const struct wg_format *format);
......
......@@ -544,6 +544,29 @@ HRESULT wg_muxer_push_sample(wg_muxer_t muxer, struct wg_sample *sample, UINT32
return S_OK;
}
HRESULT wg_muxer_read_data(wg_muxer_t muxer, void *buffer, UINT32 *size, UINT64 *offset)
{
struct wg_muxer_read_data_params params =
{
.muxer = muxer,
.buffer = buffer,
.size = *size,
.offset = UINT64_MAX,
};
NTSTATUS status;
TRACE("muxer %#I64x, buffer %p, size %u.\n", muxer, buffer, *size);
if (SUCCEEDED(status = WINE_UNIX_CALL(unix_wg_muxer_read_data, &params)))
{
*size = params.size;
*offset = params.offset;
TRACE("Read %u bytes, offset %#I64x.\n", *size, *offset);
}
return HRESULT_FROM_NT(status);
}
#define ALIGN(n, alignment) (((n) + (alignment) - 1) & ~((alignment) - 1))
unsigned int wg_format_get_stride(const struct wg_format *format)
......
......@@ -542,6 +542,28 @@ static HRESULT media_sink_queue_stream_event(struct media_sink *media_sink, Medi
return S_OK;
}
static HRESULT media_sink_write_stream(struct media_sink *media_sink)
{
BYTE buffer[1024];
UINT32 size = sizeof(buffer);
ULONG written;
QWORD offset;
HRESULT hr;
while (SUCCEEDED(hr = wg_muxer_read_data(media_sink->muxer, buffer, &size, &offset)))
{
if (offset != UINT64_MAX && FAILED(hr = IMFByteStream_SetCurrentPosition(media_sink->bytestream, offset)))
return hr;
if (FAILED(hr = IMFByteStream_Write(media_sink->bytestream, buffer, size, &written)))
return hr;
size = sizeof(buffer);
}
return S_OK;
}
static HRESULT media_sink_start(struct media_sink *media_sink)
{
HRESULT hr;
......@@ -577,6 +599,9 @@ static HRESULT media_sink_process(struct media_sink *media_sink, IMFSample *samp
TRACE("media_sink %p, sample %p, stream_id %u.\n", media_sink, sample, stream_id);
if (FAILED(hr = media_sink_write_stream(media_sink)))
WARN("Failed to write output samples to stream, hr %#lx.\n", hr);
if (FAILED(hr = wg_sample_create_mf(sample, &wg_sample)))
return hr;
......
......@@ -70,6 +70,7 @@ extern NTSTATUS wg_muxer_destroy(void *args) DECLSPEC_HIDDEN;
extern NTSTATUS wg_muxer_add_stream(void *args) DECLSPEC_HIDDEN;
extern NTSTATUS wg_muxer_start(void *args) DECLSPEC_HIDDEN;
extern NTSTATUS wg_muxer_push_sample(void *args) DECLSPEC_HIDDEN;
extern NTSTATUS wg_muxer_read_data(void *args) DECLSPEC_HIDDEN;
/* wg_allocator.c */
......
......@@ -392,6 +392,14 @@ struct wg_muxer_push_sample_params
UINT32 stream_id;
};
struct wg_muxer_read_data_params
{
wg_muxer_t muxer;
void *buffer;
UINT32 size;
UINT64 offset;
};
enum unix_funcs
{
unix_wg_init_gstreamer,
......@@ -437,6 +445,7 @@ enum unix_funcs
unix_wg_muxer_add_stream,
unix_wg_muxer_start,
unix_wg_muxer_push_sample,
unix_wg_muxer_read_data,
unix_wg_funcs_count,
};
......
......@@ -451,3 +451,9 @@ NTSTATUS wg_muxer_push_sample(void *args)
return STATUS_SUCCESS;
}
NTSTATUS wg_muxer_read_data(void *args)
{
GST_FIXME("Not implemented.");
return STATUS_NOT_IMPLEMENTED;
}
......@@ -1921,6 +1921,7 @@ const unixlib_entry_t __wine_unix_call_funcs[] =
X(wg_muxer_add_stream),
X(wg_muxer_start),
X(wg_muxer_push_sample),
X(wg_muxer_read_data),
};
C_ASSERT(ARRAYSIZE(__wine_unix_call_funcs) == unix_wg_funcs_count);
......@@ -2181,6 +2182,30 @@ NTSTATUS wow64_wg_muxer_push_sample(void *args)
return wg_muxer_push_sample(&params);
}
NTSTATUS wow64_wg_muxer_read_data(void *args)
{
struct
{
wg_muxer_t muxer;
PTR32 buffer;
UINT32 size;
UINT64 offset;
} *params32 = args;
struct wg_muxer_read_data_params params =
{
.muxer = params32->muxer,
.buffer = ULongToPtr(params32->buffer),
.size = params32->size,
.offset = params32->offset,
};
NTSTATUS ret;
ret = wg_muxer_read_data(&params);
params32->size = params.size;
params32->offset = params.offset;
return ret;
}
const unixlib_entry_t __wine_unix_call_wow64_funcs[] =
{
#define X64(name) [unix_ ## name] = wow64_ ## name
......@@ -2227,6 +2252,7 @@ const unixlib_entry_t __wine_unix_call_wow64_funcs[] =
X64(wg_muxer_add_stream),
X(wg_muxer_start),
X64(wg_muxer_push_sample),
X64(wg_muxer_read_data),
};
C_ASSERT(ARRAYSIZE(__wine_unix_call_wow64_funcs) == unix_wg_funcs_count);
......
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