Пример #1
0
 public static void SetFormat(ref AMMediaType mt, ref WaveFormatEx wfx)
 {
     if (wfx != null)
     {
         int cb = Marshal.SizeOf(wfx);
         IntPtr _ptr = Marshal.AllocCoTaskMem(cb);
         try
         {
             Marshal.StructureToPtr(wfx, _ptr, true);
             SetFormat(ref mt, _ptr, cb);
             if (mt != null)
             {
                 mt.formatType = FormatType.WaveEx;
             }
         }
         finally
         {
             Marshal.FreeCoTaskMem(_ptr);
         }
     }
 }
Пример #2
0
 public void SetFormat(WaveFormatEx wfx)
 {
     if (wfx != null)
     {
         int cb = Marshal.SizeOf(wfx);
         IntPtr _ptr = Marshal.AllocCoTaskMem(cb);
         try
         {
             Marshal.StructureToPtr(wfx, _ptr, true);
             SetFormat(_ptr, cb);
             formatType = FormatType.WaveEx;
         }
         finally
         {
             Marshal.FreeCoTaskMem(_ptr);
         }
     }
 }
Пример #3
0
 public WaveFormatExtensible()
 {
     Format = new WaveFormatEx();
 }
    public static AMMediaType E_AC3(InputstreamInfo streamInfo)
    {
      WaveFormatEx wf = new WaveFormatEx();
      wf.wFormatTag = 8192;
      wf.nBlockAlign = 24;
      wf.wBitsPerSample = 32;
      wf.cbSize = 0;

      AMMediaType amt = new AMMediaType();
      AssignStreamInfoFields(streamInfo, ref wf, ref amt);
      amt.majorType = MediaType.Audio;
      amt.subType = MEDIASUBTYPE_DOLBY_DDPLUS;
      amt.temporalCompression = false;
      amt.fixedSizeSamples = true;
      amt.SetFormat(wf);
      return amt;
    }
    public static AMMediaType AAC_LC(InputstreamInfo streamInfo)
    {
      WaveFormatEx wf = new WaveFormatEx();
      wf.wFormatTag = 255;
      wf.nBlockAlign = 1;
      wf.wBitsPerSample = 16;
      wf.cbSize = 0;

      AMMediaType amt = new AMMediaType();
      AssignStreamInfoFields(streamInfo, ref wf, ref amt);
      amt.majorType = MediaType.Audio;
      amt.subType = MEDIASUBTYPE_ADTS; // Works better than RAW_AAC1 (tested with Amazon Prime and 7TV)
      amt.temporalCompression = false;
      amt.fixedSizeSamples = true;
      amt.SetFormat(wf);
      return amt;
    }
 private static void AssignStreamInfoFields(InputstreamInfo streamInfo, ref WaveFormatEx wf, ref AMMediaType amt)
 {
   wf.nChannels = (ushort)streamInfo.Channels;
   wf.nSamplesPerSec = (int)streamInfo.SampleRate;
   if (wf.nSamplesPerSec == 0)
     wf.nSamplesPerSec = 48000; // Fallback if missing, otherwise audio decoder filter will not connect
   wf.nAvgBytesPerSec = streamInfo.Bandwidth / 8;
   amt.sampleSize = streamInfo.Bandwidth;
 }