[Speex-dev] speex in C# please help
Mohammed Ibrahim
snouto at gmail.com
Thu Feb 8 07:36:40 PST 2007
hello guys this is my code for the C# wrapper.
=================================
using System;
using System.Runtime.InteropServices;
using System.IO;
namespace Speex
{
///<summary>
///the following class is the win32 SPEEX API that retrieve
///methods and structures from the libspeex file
///</summary>
public unsafe class Speex_win32
{
#region Speex Constants
//global speex file that contains the api(s)
public const string libpath = "libspeex.dll";
public const int Frame_Size = 160;
public const int Max_Frame_Size = 2000;
public const int Speex_Get_Frame_Size = 3;
public const int Speex_Set_Quality = 4;
public const int Speex_nb_Mode = 3;
//create the structure that will hold the speexbits
public struct SpeexBits
{
public char *chars; /* "raw" data */
public int nbBits; /* Total number of bits stored in thestream*/
public int charPtr; /* Position of the byte "cursor" */
public int bitPtr; /* Position of the bit "cursor" within thecurrent char */
public int owner; /* Does the struct "own" the "raw" buffer(member "chars") */
public int overflow; /* Set to one if we try to read past thevalid data */
public int buf_size; /* Allocated size for buffer */
public int reserved1; /* Reserved for future use */
public void *reserved2; /* Reserved for future use */
}
[StructLayout(LayoutKind.Sequential)]
public struct SpeexMode
{
public void *mode;
public IntPtr query;
public char *modename;
public int modeid;
public int bitstream_version;
public IntPtr enc_init;
public IntPtr enc_destroy;
public IntPtr enc;
public IntPtr dec_init;
public IntPtr dec_destroy;
public IntPtr dec;
public IntPtr enc_ctl;
public IntPtr dec_ctl;
}
#endregion
#region Exported Methods
[DllImport(libpath)]
public static extern void *speex_encoder_init(ref SpeexMode modein);
[DllImport(libpath,EntryPoint="speex_lib_get_mode")]
public static extern IntPtr speex_lib_get_mode (int modein);
[DllImport(libpath)]
public static extern int speex_encoder_ctl(void *state , int request , void *ptr);
[DllImport(libpath)]
public static extern int speex_encoder_settings(void *state , int complexity , int samplingrate,int quality , int bitrate);
[DllImport(libpath)]
public static extern int speex_encoder_int(void *state , short *input , SpeexBits *bits);
//exported bit operation methods
[DllImport(libpath)]
public static extern void speex_bits_init(SpeexBits *bits);
[DllImport(libpath)]
public static extern int speex_bits_write(SpeexBits *bits , IntPtr bytes , int Max_length);
[DllImport(libpath)]
public static extern int speex_bits_reset(SpeexBits *bits);
[DllImport(libpath)]
public static extern void *speex_decoder_init(int modein);
[DllImport(libpath)]
public static extern int speex_decoder_ctl(void *state , int request , void *ptr);
[DllImport(libpath)]
public static extern int speex_decoder_int(void *state , short *input , SpeexBits *bits);
#endregion
}
}
when i call the speex_lib_get_mode(int modein);
in my managed code i have an exception with the message "unable to find an entrypoint for the speex_lib_get_mode in the libspeex.dll file"
please help is there anything something wrong in my wrapper please help or correct my file please.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20070208/9ba521bb/attachment.html
More information about the Speex-dev
mailing list