faacEncConfigurationPtr FAACAPI faacEncGetCurrentConfiguration( faacEncHandle hEncoder);
I am trying to create a simple wrapper for this C ++ library; I have never done more than a very simple p / invoke interop before - as a single function call with primitive arguments.
So, given the above C ++ function, for example, what should I do to handle the return type and parameter?
FAACAPI is defined as: #define FAACAPI __stdcall
defined by faacEncConfigurationPtr:
typedef struct faacEncConfiguration { int version; char *name; char *copyright; unsigned int mpegVersion; unsigned long bitRate; unsigned int inputFormat; int shortctl; psymodellist_t *psymodellist; int channel_map[64]; } faacEncConfiguration, *faacEncConfigurationPtr;
AFAIK does this mean that the return type of the function is a reference to this structure?
And faacEncHandle:
typedef struct { unsigned int numChannels; unsigned long sampleRate; ... SR_INFO *srInfo; double *sampleBuff[MAX_CHANNELS]; ... double *freqBuff[MAX_CHANNELS]; double *overlapBuff[MAX_CHANNELS]; double *msSpectrum[MAX_CHANNELS]; CoderInfo coderInfo[MAX_CHANNELS]; ChannelInfo channelInfo[MAX_CHANNELS]; PsyInfo psyInfo[MAX_CHANNELS]; GlobalPsyInfo gpsyInfo; faacEncConfiguration config; psymodel_t *psymodel; AACQuantCfg aacquantCfg; FFT_Tables fft_tables; int bitDiff; } faacEncStruct, *faacEncHandle;
So, inside this structure we see many other types ... hmm.
Essentially, I'm trying to figure out how to deal with these types in my managed shell?
Do I need to create versions of these types / structures in C #? Something like that:
[StructLayout(LayoutKind.Sequential)] struct faacEncConfiguration { uint useTns; ulong bitRate; ... }
If so, can the runtime automatically "map" these objects to each other? And, should I create these "mapped" types for all types in these types of return types / hierarchy of parameter types, until I get all the primitives?
I know that this is a wide topic, any advice on how to quickly get up to speed, what I need to learn how to do it, are very much appreciated! Thanks!