Commit 33f270af authored by Dan Hipschman's avatar Dan Hipschman Committed by Alexandre Julliard

qedit: Implement IMediaDet_(put|get)_CurrentStream.

parent d3061d48
......@@ -37,6 +37,8 @@ typedef struct MediaDetImpl {
IGraphBuilder *graph;
IBaseFilter *source;
IBaseFilter *splitter;
long num_streams;
long cur_stream;
} MediaDetImpl;
static void MD_cleanup(MediaDetImpl *This)
......@@ -47,6 +49,8 @@ static void MD_cleanup(MediaDetImpl *This)
This->splitter = NULL;
if (This->graph) IGraphBuilder_Release(This->graph);
This->graph = NULL;
This->num_streams = -1;
This->cur_stream = 0;
}
static ULONG WINAPI MediaDet_AddRef(IMediaDet* iface)
......@@ -116,6 +120,12 @@ static HRESULT WINAPI MediaDet_get_OutputStreams(IMediaDet* iface, long *pVal)
if (!This->splitter)
return E_INVALIDARG;
if (This->num_streams != -1)
{
*pVal = This->num_streams;
return S_OK;
}
*pVal = 0;
hr = IBaseFilter_EnumPins(This->splitter, &pins);
......@@ -138,21 +148,42 @@ static HRESULT WINAPI MediaDet_get_OutputStreams(IMediaDet* iface, long *pVal)
}
IEnumPins_Release(pins);
This->num_streams = *pVal;
return S_OK;
}
static HRESULT WINAPI MediaDet_get_CurrentStream(IMediaDet* iface, long *pVal)
{
MediaDetImpl *This = (MediaDetImpl *)iface;
FIXME("(%p)->(%p): not implemented!\n", This, pVal);
return E_NOTIMPL;
TRACE("(%p)\n", This);
if (!pVal)
return E_POINTER;
*pVal = This->cur_stream;
return S_OK;
}
static HRESULT WINAPI MediaDet_put_CurrentStream(IMediaDet* iface, long newVal)
{
MediaDetImpl *This = (MediaDetImpl *)iface;
FIXME("(%p)->(%ld): not implemented!\n", This, newVal);
return E_NOTIMPL;
HRESULT hr;
TRACE("(%p)->(%ld)\n", This, newVal);
if (This->num_streams == -1)
{
long n;
hr = MediaDet_get_OutputStreams(iface, &n);
if (FAILED(hr))
return hr;
}
if (newVal < 0 || This->num_streams <= newVal)
return E_INVALIDARG;
This->cur_stream = newVal;
return S_OK;
}
static HRESULT WINAPI MediaDet_get_StreamType(IMediaDet* iface, GUID *pVal)
......@@ -469,6 +500,8 @@ HRESULT MediaDet_create(IUnknown * pUnkOuter, LPVOID * ppv) {
obj->graph = NULL;
obj->source = NULL;
obj->splitter = NULL;
obj->num_streams = -1;
obj->cur_stream = 0;
*ppv = obj;
return S_OK;
......
......@@ -120,11 +120,37 @@ static void test_mediadet(void)
ok(hr == E_INVALIDARG, "IMediaDet_get_OutputStreams\n");
ok(nstrms == -1, "IMediaDet_get_OutputStreams\n");
strm = -1;
/* The stream defaults to 0, even without a file! */
hr = IMediaDet_get_CurrentStream(pM, &strm);
ok(hr == S_OK, "IMediaDet_get_CurrentStream\n");
ok(strm == 0, "IMediaDet_get_CurrentStream\n");
hr = IMediaDet_get_CurrentStream(pM, NULL);
ok(hr == E_POINTER, "IMediaDet_get_CurrentStream\n");
/* But put_CurrentStream doesn't. */
hr = IMediaDet_put_CurrentStream(pM, 0);
ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream\n");
hr = IMediaDet_put_CurrentStream(pM, -1);
ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream\n");
filename = SysAllocString(test_avi_filename);
hr = IMediaDet_put_Filename(pM, filename);
ok(hr == S_OK, "IMediaDet_put_Filename -> %x\n", hr);
SysFreeString(filename);
strm = -1;
/* The stream defaults to 0. */
hr = IMediaDet_get_CurrentStream(pM, &strm);
ok(hr == S_OK, "IMediaDet_get_CurrentStream\n");
ok(strm == 0, "IMediaDet_get_CurrentStream\n");
/* Even before get_OutputStreams. */
hr = IMediaDet_put_CurrentStream(pM, 1);
ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream\n");
hr = IMediaDet_get_OutputStreams(pM, &nstrms);
ok(hr == S_OK, "IMediaDet_get_OutputStreams\n");
ok(nstrms == 1, "IMediaDet_get_OutputStreams\n");
......@@ -139,13 +165,33 @@ static void test_mediadet(void)
hr = IMediaDet_get_Filename(pM, NULL);
ok(hr == E_POINTER, "IMediaDet_get_Filename\n");
strm = -1;
hr = IMediaDet_get_CurrentStream(pM, &strm);
ok(hr == S_OK, "IMediaDet_get_CurrentStream\n");
ok(strm == 0, "IMediaDet_get_CurrentStream\n");
hr = IMediaDet_get_CurrentStream(pM, NULL);
ok(hr == E_POINTER, "IMediaDet_get_CurrentStream\n");
hr = IMediaDet_put_CurrentStream(pM, -1);
ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream\n");
hr = IMediaDet_put_CurrentStream(pM, 1);
ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream\n");
/* Try again. */
strm = -1;
hr = IMediaDet_get_CurrentStream(pM, &strm);
ok(hr == S_OK, "IMediaDet_get_CurrentStream\n");
ok(strm == 0, "IMediaDet_get_CurrentStream\n");
hr = IMediaDet_put_CurrentStream(pM, 0);
todo_wine ok(hr == S_OK, "IMediaDet_put_CurrentStream\n");
ok(hr == S_OK, "IMediaDet_put_CurrentStream\n");
strm = -1;
hr = IMediaDet_get_CurrentStream(pM, &strm);
todo_wine ok(hr == S_OK, "IMediaDet_get_CurrentStream\n");
todo_wine ok(strm == 0, "IMediaDet_get_CurrentStream\n");
ok(hr == S_OK, "IMediaDet_get_CurrentStream\n");
ok(strm == 0, "IMediaDet_get_CurrentStream\n");
ZeroMemory(&mt, sizeof mt);
hr = IMediaDet_get_StreamMediaType(pM, &mt);
......@@ -185,7 +231,7 @@ static void test_mediadet(void)
flags = 0;
hr = IMediaDet_put_CurrentStream(pM, 0);
todo_wine ok(hr == S_OK, "IMediaDet_put_CurrentStream\n");
ok(hr == S_OK, "IMediaDet_put_CurrentStream\n");
ZeroMemory(&mt, sizeof mt);
hr = IMediaDet_get_StreamMediaType(pM, &mt);
......@@ -197,7 +243,12 @@ static void test_mediadet(void)
: 0));
hr = IMediaDet_put_CurrentStream(pM, 1);
todo_wine ok(hr == S_OK, "IMediaDet_put_CurrentStream\n");
ok(hr == S_OK, "IMediaDet_put_CurrentStream\n");
strm = -1;
hr = IMediaDet_get_CurrentStream(pM, &strm);
ok(hr == S_OK, "IMediaDet_get_CurrentStream\n");
ok(strm == 1, "IMediaDet_get_CurrentStream\n");
ZeroMemory(&mt, sizeof mt);
hr = IMediaDet_get_StreamMediaType(pM, &mt);
......@@ -210,6 +261,14 @@ static void test_mediadet(void)
todo_wine ok(flags == 3, "IMediaDet_get_StreamMediaType\n");
hr = IMediaDet_put_CurrentStream(pM, 2);
ok(hr == E_INVALIDARG, "IMediaDet_put_CurrentStream\n");
strm = -1;
hr = IMediaDet_get_CurrentStream(pM, &strm);
ok(hr == S_OK, "IMediaDet_get_CurrentStream\n");
ok(strm == 1, "IMediaDet_get_CurrentStream\n");
hr = IMediaDet_Release(pM);
ok(hr == 0, "IMediaDet_Release returned: %x\n", hr);
......
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