mosmondor

faad c# wrapper

Nov 30th, 2013
946
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Runtime.InteropServices;
  5.  
  6. namespace AACtoPCM
  7. {
  8.     public class libfaad
  9.     {
  10.         #region Structures
  11.  
  12.         [StructLayout(LayoutKind.Sequential)]    
  13.         public struct NeAACDecConfiguration
  14.             {
  15.                 public char defObjectType;
  16.                 public int defSampleRate;
  17.                 public char outputFormat;
  18.                 public char downMatrix;
  19.                 public char useOldADTSFormat;
  20.             }
  21.  
  22.         [StructLayout(LayoutKind.Sequential)]    
  23.         public struct NeAACDecFrameInfo
  24.             {
  25.                 public Int32 bytesconsumed;
  26.                 public Int32 samples;
  27.                 public char channels;
  28.                 public char error;
  29.                 public Int32 samplerate;
  30.                 public char sbr;
  31.                 public char object_type;
  32.                 public char header_type;
  33.                 public char num_front_channels;
  34.                 public char num_side_channels;
  35.                 public char num_back_channels;
  36.                 public char num_lfe_channels;
  37.                 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
  38.                 public char[] channel_position;
  39.                 public char ps;
  40.             }
  41.  
  42.  
  43.         #endregion
  44.  
  45.         const string libPath = "libfaad2.dll";
  46.  
  47.         #region Methods
  48.  
  49.             [DllImport(libPath)]public static extern IntPtr NeAACDecOpen();
  50.  
  51.             [DllImport(libPath)]public static extern IntPtr NeAACDecGetCurrentConfiguration(IntPtr hpDecoder);
  52.        
  53.             [DllImport(libPath)]public static extern char NeAACDecSetConfiguration(IntPtr hpDecoder, IntPtr config);
  54.        
  55.             [DllImport(libPath)]public static extern int NeAACDecInit(IntPtr hpDecoder, byte[] buffer, int buffer_size, IntPtr samplerate, IntPtr channels);
  56.        
  57.             [DllImport(libPath)]public static extern char NeAACDecInit2 (IntPtr hpDecoder, IntPtr pBuffer, int SizeOfDecoderSpecificInfo, IntPtr samplerate, IntPtr channels);
  58.        
  59.             [DllImport(libPath)]public static extern IntPtr NeAACDecDecode(IntPtr hpDecoder, out NeAACDecFrameInfo hInfo, byte[] buffer, int buffer_size);
  60.        
  61.             [DllImport(libPath)]public static extern void NeAACDecClose(IntPtr hpDecoder);
  62.        
  63.             [DllImport(libPath, CharSet=CharSet.Ansi)]public static extern string NeAACDecGetErrorMessage(char errcode);
  64.        
  65.             [DllImport(libPath)]public static extern char NeAACDecAudioSpecificConfig(IntPtr pBuffer, int buffer_size, IntPtr mp4ASC);
  66.  
  67.         #endregion
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment