# Include ".../../include/Mita. H"/** <@ brief Mita SDK header */
# Ifdef _ debug
# Pragma comment (Lib, ".../../library/mitad. lib ")
# Else
# Pragma comment (Lib, ".../../library/Mita. lib ")
# Endif
# Include <windows. h>
# Include <stdio. h>
# Include <conio. h>
# Include <math. h>
# DEFINE _ iid_examplemita_uuid_make (aaaabbbb, 5059, 11e0, 8000, 0b15, 00000a15)
Typedef struct mita_tag_moduleheader
{
Mita_idecoderbase;
//////////////////////////////////////// //////////////////////////////////
// Todo: add additional module data
} Mita_moduleheader;
# Pragma warning (push)
# Pragma warning (Disable: 4996)
Mita_static
Mita_inline
Mita_void
Mita_checkerror (mita_void)
{
Mita_error lasterror = mita_getlasterror ();
If (lasterror! = Mita_error_ OK)
{
Printf ("error: MITA framework error with % u codes \ n", lasterror );
Exit (lasterror );
}
}
Mita_static
Mita_inline
Mita_byte
Mita_enterkey (mita_void)
{
Mita_int32 key = 0xff;
Do
{
If (kbhit ())
{
Key = getch ();
Break;
}
} While (1 );
If (Key> = 'A' & Key <= 'Z ')
Key-= 32;
Return key;
}
//////////////////////////////////////// //////////////////////////////////
Mita_static
Mita_void
Mita_callback
Example_release (mita_moduleheader * pthis)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: release resources
If (pthis)
Mita_free (pthis );
}
Mita_static
Mita_bool
Mita_callback
Example_setparam (mita_moduleheader * pthis, mita_uint32 nparamid, mita_lpcvoid lpparam)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: Add parameter settings
Return mita_false;
}
Mita_static
Mita_bool
Mita_callback
Example_getparam (mita_moduleheader * pthis, mita_uint32 nparamid, mita_lpvoid lpparam)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: Add parameters to obtain
Return mita_false;
}
Mita_size
Mita_callback
Example_getfiledescribenums (mita_moduleheader * pthis)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: Get the length of the supported file list
Return mita_null;
}
Mita_lpcafd
Mita_callback
Example_getfiledescribe (mita_moduleheader * pthis, mita_size nindex)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: get the list of supported files
// See the mita_afd struct.
// Allow users to add custom data
Return mita_null;
}
Mita_dword
Mita_callback
Example_getflags (mita_moduleheader * pthis)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: Get the tag that supports decoding.
// See mita_df_xxxx
// Note: If seek is not supported, you cannot add mita_df_seekable.
Return mita_df_default;
}
Mita_bool
Mita_callback
Example_isopen (mita_moduleheader * pthis)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: checks whether the current decoder has been initialized.
Return mita_false;
}
Mita_bool
Mita_callback
Example_iseof (mita_moduleheader * pthis)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: determines whether the decoding has ended.
Return mita_false;
}
Mita_lpctimepos
Mita_callback
Example_getcurpos (mita_moduleheader * pthis)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: Get the current decoding location
Return mita_null;
}
Mita_lpcchannelformat
Mita_callback
Example_getchannelinfo (mita_moduleheader * pthis)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: gets the channel format information of the current playback source.
Return mita_null;
}
Mita_static
Mita_inline
Mita_hstream
Getstream (mita_hinstance instance, mita_dword flag, mita_lpcfileparam lpparam, mita_lpbool pneeddelete)
{
Mita_hstream hstream;
If (! Mita_parsefileparam (instance, (mita_lpcfileparam) lpparam, flag, (mita_lpbool) pneeddelete, & hstream ))
Return mita_null;
Return hstream;
}
Mita_bool
Mita_callback
Example_issupport (mita_moduleheader * pthis, mita_lpcfileparam lpparam)
{
Mita_hstream hstream = mita_null;
Mita_bool bdelete = mita_false;
//////////////////////////////////////// //////////////////////////////////
// 1. Get the stream of audio source.
Hstream = getstream (pthis-> base. Base. _ instance, mita_pfpf_read, lpparam, & bdelete );
If (hstream = mita_null)
Return mita_false;
//////////////////////////////////////// //////////////////////////////////
// Todo: check your own format information
If (bdelete)
Mita_closehandle (hstream );
Return mita_false;
}
Mita_bool
Mita_callback
Example_decodeinfo (mita_moduleheader * pthis, mita_lpcfileparam lpparam, mita_word nflag, mita_harray hitemarray)
{
Mita_bool bneeddelete = mita_false;
Mita_hsound hsound;
Mita_hstream hstream = getstream (pthis-> base. Base. _ instance, mita_pfpf_read, lpparam, & bneeddelete );
If (hstream = mita_null)
Return mita_false;
//////////////////////////////////////// //////////////////////////////////
// 1. Create a mita_hsound object
If (! Mita_sound_create (pthis-> base. Base. _ instance, 0, & hsound ))
{
If (bneeddelete)
Mita_closehandle (hstream );
Return mita_false;
}
//////////////////////////////////////// //////////////////////////////////
// 2. Determine the decoding tag
If (nflag & mita_dif_gettag)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: Read tag
// The interfaces of mita_hsound and mita_htag will be available in the future.
}
//////////////////////////////////////// //////////////////////////////////
// 3. Determine whether only tag information is decoded
If (! (Nflag & mita_dif_getinfo ))
{
//////////////////////////////////////// //////////////////////////////////
Mita_array_pushtop (hitemarray, & hsound );
//////////////////////////////////////// //////////////////////////////////
If (bneeddelete)
Mita_closehandle (hstream );
Return mita_true;
}
//////////////////////////////////////// //////////////////////////////////
// Todo: Fill hsound Information
//////////////////////////////////////// //////////////////////////////////
// 4. release resources
If (bneeddelete)
Mita_closehandle (hstream );
//////////////////////////////////////// //////////////////////////////////
// 5. Add the mita_hsound object to the queue
Mita_array_pushtop (hitemarray, & hsound );
//////////////////////////////////////// //////////////////////////////////
Return mita_true;
}
Mita_bool
Mita_callback
Example_seek (mita_moduleheader * pthis, mita_lpctime pcurtime)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: Seek audio source.
Return mita_true;
}
Mita_bool
Mita_callback
Example_startup (mita_moduleheader * pthis, mita_lpcfileparam lpparam, mita_hsound hsound)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: add your initialization code
Return mita_true;
}
Mita_size
Mita_callback
Example_decode (mita_moduleheader * pthis, void * pframes, mita_size nframes)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: add your decoding code
Return (-1 );
}
Mita_bool
Mita_callback
Example_terminate (mita_moduleheader * pthis, mita_bool babort)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: add your end code
Return mita_false;
}
Mita_static
Mita_lpcmoduleinfo
Mita_callback
Example_getmoduleinfo (mita_imodule * pthis)
{
Return pthis-> plusobject-> getmoduleinfo (pthis-> plusobject );
}
Mita_static
Mita_bool
Mita_callback
Example_haswindow (mita_imodule * pthis, mita_dword dwtype)
{
Return pthis-> plusobject-> haswindow (pthis-> plusobject, dwtype );
}
Mita_static
Mita_bool
Mita_callback
Example_showwindow (mita_imodule * pthis, mita_dword dwtype, mita_handle hparent, mita_bool bshow)
{
Return pthis-> plusobject-> showwindow (pthis-> plusobject, dwtype, hparent, bshow );
}
Mita_static
Mita_imodule *
Mita_callback
Example_createobject (mita_istaticplus * pthis, mita_hinstance hinstance)
{
Mita_moduleheader * pexample = (mita_moduleheader *) mita_malloc (sizeof (mita_moduleheader ));
If (pexample = mita_null)
Return mita_null;
Pexample-> base. Base. plusobject = & pthis-> base;
Pexample-> base. Base. _ instance = hinstance;
Pexample-> base. Base. _ resverd = mita_module_resverd_decoder;
Pexample-> base. Base. Release = example_release;
Pexample-> base. Base. getmoduleinfo = example_getmoduleinfo;
Pexample-> base. Base. haswindow = example_haswindow;
Pexample-> base. Base. showwindow = example_showwindow;
Pexample-> base. setparam = example_setparam;
Pexample-> base. getparam = example_getparam;
Pexample-> base. getfiledescribenums = example_getfiledescribenums;
Pexample-> base. getfiledescribe = example_getfiledescribe;
Pexample-> base. getflags = example_getflags;
Pexample-> base. issupport = example_issupport;
Pexample-> base. Seek = example_seek;
Pexample-> base. decodeinfo = example_decodeinfo;
Pexample-> base. startup = example_startup;
Pexample-> base. Decode = example_decode;
Pexample-> base. Terminate = example_terminate;
Pexample-> base. iseof = example_iseof;
Pexample-> base. isopen = example_isopen;
Pexample-> base. getcurpos = example_getcurpos;
Pexample-> base. getchannelinfo = example_getchannelinfo;
//////////////////////////////////////// //////////////////////////////////
// Todo: add additional initialization operations.
Return (mita_imodule *) pexample;
}
Mita_static
Mita_lpcmoduleinfo
Mita_callback
Plus_getmoduleinfo (mita_istaticplus * pthis)
{
Return & pthis-> moduleinfo;
}
Mita_static
Mita_bool
Mita_callback
Plus_haswindow (mita_istaticplus * pthis, mita_dword dwtype)
{
Return mita_false;
}
Mita_static
Mita_bool
Mita_callback
Plus_showwindow (mita_istaticplus * pthis, mita_dword dwtype, mita_handle hparent, mita_bool bshow)
{
Return mita_false;
}
Mita_static
Mita_istaticplus
Gexampleplugin =
{
Plus_getmoduleinfo,
Plus_haswindow,
Plus_showwindow,
Example_createobject,
{
Mita_mt_decoder,
_ Iid_example,
1,
L "Mita plugin example ",
L "Mita plugin example module ",
L "Copyright (c) Hangzhou migan technology 2008-2011. All Rights Reserved .",
Mita_null
}
};
Mita_static
Mita_hzusobject
Mita_call
Example_modulemain (void)
{
Return (mita_hzusobject) & gexampleplugin;
}
//////////////////////////////////////// //////////////////////////////////
// If you want to export the DLL, you need to add an interface function
// Mita_getplusmains. nindex indicates the serial number of the module.
_ Declspec (dllexport)
Mita_modulemain
Mita_call
Mita_getplusmains (mita_size nindex)
{
Switch (nindex)
{
Case 0:
Return example_modulemain;
}
Return mita_null;
}
Void main (void)
{
Mita_hinstance hinstance;
Mita_hzugin hexampleplugin;
Mita_hmodule hexamplemodule;
Mita_hobject hexampleobject;
Mita_uuid regguid;
Mita_moduleinfo moduleinfo;
Mita_byte key;
Printf (";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;; \ n ");
Printf ("; Copyright (c) Hangzhou citrus Technology Co., Ltd. 2008-2010. All Rights Reserved .;; \ N ");
Printf (";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;; \ n ");
Printf ("; plugin decoder example; \ n ");
Printf (";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;; \ n ");
//////////////////////////////////////// //////////////////////////////////
// 1. Create a global instance handle.
Hinstance = mita_initialize (mita_null );
Mita_checkerror ();
Printf ("press a use static module loader. \ n ");
Printf ("press B use export module loader. \ n ");
Key = mita_enterkey ()-'A ';
If (Key = 0)
{
//////////////////////////////////////// //////////////////////////////////
// 2. Register Module
Mita_ins_registermodule (hinstance, example_modulemain, & regguid, & hexamplemodule );
Mita_checkerror ();
}
Else
{
//////////////////////////////////////// //////////////////////////////////
// 2. Load plugin, just this EXE file.
Mita_ins_loadplugin (hinstance, l "make_your_decoder.exe", & hexampleplugin );
Mita_checkerror ();
Mita_ins_getmodulebyindex (hinstance, 0, & hexamplemodule );
Mita_checkerror ();
}
//////////////////////////////////////// //////////////////////////////////
// 3. Create module object
Mita_module_createmoduleobject (hexamplemodule, & hexampleobject );
Mita_checkerror ();
//////////////////////////////////////// //////////////////////////////////
Mita_object_getmoduleinfo (hexampleobject, & moduleinfo );
Mita_checkerror ();
Printf ("\ n ");
Printf ("Name: % s \ n", mita_text_tosystems (moduleinfo. Name, mita_tct_default ));
Printf ("vers: % 08x \ n", moduleinfo. version );
Printf ("Desc: % s \ n", mita_text_tosystems (moduleinfo. Describe, mita_tct_default ));
Printf ("Copy: % s \ n", mita_text_tosystems (moduleinfo. Copyright, mita_tct_default ));
Printf ("\ n ");
/*
Use mita_decoder_xxxx operations.
*/
//////////////////////////////////////// //////////////////////////////////
// 4. Delete module object
Mita_closehandle (hexampleobject );
Mita_checkerror ();
//////////////////////////////////////// //////////////////////////////////
// *: This step is not required.
If (Key = 0)
{
//////////////////////////////////////// //////////////////////////////////
// 5 *. unregister module. This step is not required. When "instance handle" is released, it will automatically
// Perform the remove operation.
Mita_ins_unregistermodule (hinstance, & regguid );
Mita_checkerror ();
}
Else
{
Mita_ins_unregisterpluginmodule (hinstance, hexampleplugin, mita_null );
Mita_checkerror ();
}
//////////////////////////////////////// //////////////////////////////////
// 6. Delete global instance handle.
Mita_closehandle (hinstance );
}
# Pragma warning (POP)