Hi every one.I'm trying to wirte a g729 codec plugin using bcg729 in
windows7.I consult the easy_codec plugin and write the plugin.The plugin
is complied and loaded ok.The problem i encountered is below:
main(wireshark\codecs\codecs.c):
static GHashTable *registered_codecs = NULL;
...
gboolean
register_codec(const char *name, codec_init_fn init_fn, codec_release_fn
release_fn,
codec_get_channels_fn channels_fn, codec_get_frequency_fn frequency_fn,
codec_decode_fn decode_fn)
{
...
}
myplugin(bcg729_codec_plugin.c):
WS_DLL_PUBLIC_DEF void register_codec_module(void)
{
register_codec("g729", codec_g729_init, codec_g729_release,
codec_g729_get_channels, codec_g729_get_frequency, codec_g729_decode);
}
The problem is when the main load the plugin and call plugin's
register_cdec_moule fucntion, they don't share the same
registered_codecs instance.
This problem can be demonstrated by below code:
test.c:
#include <stdio.h>
extern void increase();
extern void subcall();
int main(void)
{
printf("main start:\n");
increase();
subcall();
printf("main end:\n");
}
increase.c:
#include <stdio.h>
static s_value = 0;
void increase()
{
s_value++;
printf("s_value=[%d]\n", s_value);
}
subcall.c:
#include <stdio.h>
#define EXPORT __declspec(dllexport)
extern void increase();
void EXPORT subcall(void)
{
printf("subcall start:\n");
increase();
printf("subcall end:\n");
}
build.bat:
cl -c increase.c
link /lib increase.obj
cl /LD subcall.c increase.lib
cl test.c subcall.lib increase.lib
The result of test is:
main start:
s_value=[1]
subcall start:
s_value=[1]
subcall end:
main end:
Can anyont give me some tips on how to fix this issue.Thanks.Sorry for
my poor english.