[MPlayer-dev-eng] Compile mplayer as a dll under MinGW+MSYS environment and use it in VC++
李鑫
jackyxinli at gmail.com
Wed Aug 18 03:10:32 CEST 2010
Hi, all,
I try many times to compile mplayer as a single DLL file under MinGW+MSYS
environment. This step I get a single DLL file. And I write test code in
VC++, test code listed below:
================================================================================================
typedef void (*exp_print_version)(const char* name);
typedef int (*exp_parse_codec_cfg)(char* cfgfile);
typedef void (*export_mp_msg_init)();
typedef stream_t* (*export_open_stream)(const char* filename,char**
options,int* file_format);
typedef demuxer_t* (*export_demux_open)(stream_t *stream,int file_format,int
aid,int vid,int sid,char* filename);
typedef void (*export_demux_info_print)(demuxer_t* demuxer);
typedef int (*exp_select_audio)(demuxer_t* demuxer, int audio_id, char*
audio_lang);
typedef double (*exp_demuxer_get_time_length)(demuxer_t* demuxer);
int main(int argc, char* argv[])
{
// load library
HMODULE hModule = LoadLibrary(_T("mplayer.dll"));
if(!hModule)
return 0;
exp_print_version _print_version =
(exp_print_version)GetProcAddress(hModule, "print_version");
exp_parse_codec_cfg _parse_codec_cfg =
(exp_parse_codec_cfg)GetProcAddress(hModule, "parse_codec_cfg");
export_mp_msg_init _mp_msg_int =
(export_mp_msg_init)GetProcAddress(hModule, "mp_msg_init");
export_open_stream _open_stream =
(export_open_stream)GetProcAddress(hModule, "open_stream");
export_demux_open _demux_open =
(export_demux_open)GetProcAddress(hModule, "demux_open");
export_demux_info_print _demux_info_print =
(export_demux_info_print)GetProcAddress(hModule, "demux_info_print");
exp_select_audio _select_audio =
(exp_select_audio)GetProcAddress(hModule, "select_audio");
exp_demuxer_get_time_length _demuxer_get_time_length =
(exp_demuxer_get_time_length)GetProcAddress(hModule,
"demuxer_get_time_length");
stream_t* stream = NULL;
demuxer_t* demuxer = NULL;
char* filename = "D:\\Music\\01.mp3";
int file_format = 0;
demux_stream_t *d_audio = NULL;
demux_stream_t *d_video = NULL;
sh_audio_t *sh_audio = NULL;
sh_video_t *sh_video = NULL;
_mp_msg_int();
_print_version("mplayer");
_parse_codec_cfg(NULL);
stream = _open_stream(filename, 0, &file_format);
demuxer = _demux_open(stream, file_format, -1, -1, -1, filename);
d_audio = demuxer->audio;
d_video = demuxer->video;
_select_audio(demuxer, -1, NULL);
if(d_audio)
{
printf("%p\n", d_audio->sh);
sh_audio = (sh_audio_t *)d_audio->sh;
}
if(d_video)
{
printf("%p\n", d_video->sh);
sh_video = (sh_video_t *)d_video->sh;
}
_demux_info_print(demuxer);
double time = _demuxer_get_time_length(demuxer);
printf("%8.2f\n", time);
FreeLibrary(hModule);
system("pause");
return 0;
}
================================================================================================
when I run test code, it's failed. and I set compiler option
"StructMemberAlignment" as 1, the result "seem" right. when I run in debug
modal, the struct stream and demuxer's content is not right. but it is right
in gcc. Is someone can help me to resolve this problem?
the attachment is a Makefile make mplayer as single dll.
best regards,
jacky_zz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile_dll
Type: application/octet-stream
Size: 849 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20100818/12abe33c/attachment.obj>
More information about the MPlayer-dev-eng
mailing list