Commit 053b55d2 authored by Anton Baskanov's avatar Anton Baskanov Committed by Alexandre Julliard

amstream/tests: Add a test AVI file.

parent 7490b857
......@@ -3,3 +3,6 @@ IMPORTS = strmbase strmiids uuid ddraw ole32 user32
C_SRCS = \
amstream.c
RC_SRCS = \
rsrc.rc
......@@ -53,6 +53,45 @@ static const AM_MEDIA_TYPE audio_mt =
static const WCHAR primary_video_sink_id[] = L"I{A35FF56A-9FDA-11D0-8FDF-00C04FD9189D}";
static const WCHAR primary_audio_sink_id[] = L"I{A35FF56B-9FDA-11D0-8FDF-00C04FD9189D}";
static const WCHAR *load_resource(const WCHAR *name)
{
HMODULE module = GetModuleHandleA(NULL);
HRSRC resource;
DWORD written;
HANDLE file;
WCHAR *path;
DWORD size;
void *ptr;
path = calloc(MAX_PATH + 1, sizeof(WCHAR));
ok(!!path, "Failed to allocate temp path string.\n");
GetTempPathW(MAX_PATH + 1, path);
wcscat(path, name);
file = CreateFileW(path, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
ok(file != INVALID_HANDLE_VALUE, "Failed to create file %s, error %u.\n", wine_dbgstr_w(path), GetLastError());
resource = FindResourceW(module, name, (const WCHAR *)RT_RCDATA);
ok(!!resource, "Failed to find resource %s, error %u.\n", wine_dbgstr_w(name), GetLastError());
size = SizeofResource(module, resource);
ptr = LockResource(LoadResource(module, resource));
WriteFile(file, ptr, size, &written, NULL);
ok(written == size, "Failed to write file %s.\n", wine_dbgstr_w(path));
CloseHandle(file);
return path;
}
static void unload_resource(const WCHAR *path)
{
BOOL ret = DeleteFileW(path);
ok(ret, "Failed to delete file %s.\n", wine_dbgstr_w(path));
free((void *)path);
}
#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
static void _expect_ref(IUnknown* obj, ULONG ref, int line)
{
......@@ -229,7 +268,7 @@ static void test_interfaces(void)
ok(!ref, "Got outstanding refcount %u.\n", ref);
}
static void test_openfile(void)
static void test_openfile(const WCHAR *test_avi_path)
{
IAMMultiMediaStream *mmstream = create_ammultimediastream();
IMediaStreamFilter *filter;
......@@ -241,7 +280,7 @@ static void test_openfile(void)
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!graph, "Expected NULL graph.\n");
hr = IAMMultiMediaStream_OpenFile(mmstream, L"test.avi", AMMSF_NORENDER);
hr = IAMMultiMediaStream_OpenFile(mmstream, test_avi_path, AMMSF_NORENDER);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph);
......@@ -260,7 +299,7 @@ static void test_openfile(void)
check_interface(filter, &IID_IMediaSeeking, FALSE);
hr = IAMMultiMediaStream_OpenFile(mmstream, L"test.avi", 0);
hr = IAMMultiMediaStream_OpenFile(mmstream, test_avi_path, 0);
ok(hr == S_OK, "Got hr %#x.\n", hr);
check_interface(filter, &IID_IMediaSeeking, TRUE);
......@@ -271,7 +310,7 @@ static void test_openfile(void)
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
static void test_renderfile(void)
static void test_renderfile(const WCHAR *test_avi_path)
{
IAMMultiMediaStream *pams;
HRESULT hr;
......@@ -298,7 +337,7 @@ static void test_renderfile(void)
hr = IAMMultiMediaStream_AddMediaStream(pams, NULL, &MSPID_PrimaryAudio, AMMSF_ADDDEFAULTRENDERER, NULL);
ok(hr == S_OK || hr == VFW_E_NO_AUDIO_HARDWARE, "Got hr %#x.\n", hr);
hr = IAMMultiMediaStream_OpenFile(pams, L"test.avi", 0);
hr = IAMMultiMediaStream_OpenFile(pams, test_avi_path, 0);
ok(hr==S_OK, "IAMMultiMediaStream_OpenFile returned: %x\n", hr);
hr = IAMMultiMediaStream_GetMediaStream(pams, &MSPID_PrimaryVideo, &pvidstream);
......@@ -5066,7 +5105,7 @@ static void test_ddrawstream_getsetdirectdraw(void)
START_TEST(amstream)
{
HANDLE file;
const WCHAR *test_avi_path;
CoInitializeEx(NULL, COINIT_MULTITHREADED);
......@@ -5081,14 +5120,12 @@ START_TEST(amstream)
test_media_types();
test_IDirectDrawStreamSample();
file = CreateFileW(L"test.avi", 0, 0, NULL, OPEN_EXISTING, 0, NULL);
if (file != INVALID_HANDLE_VALUE)
{
CloseHandle(file);
test_avi_path = load_resource(L"test.avi");
test_openfile();
test_renderfile();
}
test_openfile(test_avi_path);
test_renderfile(test_avi_path);
unload_resource(test_avi_path);
test_audiodata_query_interface();
test_audiodata_get_info();
......
/*
* Resource file for amstream tests.
*
* Copyright 2020 Anton Baskanov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "windef.h"
/* ffmpeg -f lavfi -i smptebars -f lavfi -i "sine=frequency=1000" -t 0.1 -r 10 -ar 8000 -f avi -vcodec rawvideo -vf scale=32x24 -acodec pcm_u8 test.avi */
/* @makedep: test.avi */
test.avi RCDATA "test.avi"
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