# 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_iencoderbase;
//////////////////////////////////////// //////////////////////////////////
// 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_ef_xxxx
// Note: If seek is not supported, you cannot add mita_ef_seekable.
Return mita_df_default;
}
Mita_bool
Mita_callback
Example_isopen (mita_moduleheader * pthis)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: determines whether the current "encoder" has been initialized.
Return mita_false;
}
Mita_bool
Mita_callback
Example_iseof (mita_moduleheader * pthis)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: determines whether the encoding is complete.
Return mita_false;
}
Mita_lpctimepos
Mita_callback
Example_getcurpos (mita_moduleheader * pthis)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: Get the current encoding location
Return mita_null;
}
Mita_lpcchannelformat
Mita_callback
Example_getchannelinfo (mita_moduleheader * pthis)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: obtains the channel format information of the current encoding 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_htag
Mita_callback
Example_createtag (mita_moduleheader * pthis)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: create a file tag description object
Return mita_null;
}
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_harray hsoundarray)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: add your initialization code
Return mita_true;
}
Mita_size
Mita_callback
Example_encode (mita_moduleheader * pthis, mita_lpcvoid pframes, mita_size nframes)
{
//////////////////////////////////////// //////////////////////////////////
// Todo: add your code
Return (-1 );
}
Mita_bool
Mita_callback
Example_terminate (mita_moduleheader * pthis)
{
//////////////////////////////////////// //////////////////////////////////
// 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_encoder;
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. Seek = example_seek;
Pexample-> base. createtag = example_createtag;
Pexample-> base. startup = example_startup;
Pexample-> base. encode = example_encode;
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_encoder,
_ 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 encoder 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_encoder.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_encoder_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)