tags:

views:

257

answers:

0

Hi All

I am trying to create an ASF file using 3 streams :

1) A regular script stream

2) A regular Audio stream (WaveEx)

3) A custom stream consisting of packets that represent a certain kind of compressed screen data (Motorolla Netopia if you are familiar with it). The data is just a byte[] array.

Writing the first 2 streams works perfectly. Also, if I try to write raw screen data (bitmaps) , it works OK. The problem starts when I don’t write bitmaps, but rather the compressed samples I mentioned. . I get all kinds of exceptions. (E_UNEXPECTED, catastrophic failure etc.)

Here is a short summary of how I am trying the 3rd stream to the ASF file :

1) I set the input properties of the 3rd stream to null (_writer.SetInputProps(StreamNumber, null));

2) I use the following code to actually write each sample into the stream :

  INSSBuffer inssBuff = null;

  NSSBuffer nssbuff = null;

  // (asfBuffer is just a struct which contains the actual buffer to be written and the stream number to write it to)

  this._writer.AllocateSample((uint)asfBuffer.Buffer.Length, out inssBuff);

  nssbuff = new NSSBuffer(inssBuff);

  nssbuff.Write(asfBuffer.Buffer, 0, asfBuffer.Buffer.Length);

  nssbuff.Length = (uint)asfBuffer.Buffer.Length;

  //Get the advanced writer.

  IWMWriterAdvanced advancedWriter = (IWMWriterAdvanced)_writer;

  //This is the keyframe flag. If my custom sample is a keyframe, this is true.

  uint flag = (isKeyFrame) ? (uint)WriterFlags.WM_SF_CLEANPOINT : 0;

  //Write the sample with position which is incremented by 100 every sample.

  advancedWriter.WriteStreamSample((ushort)asfBuffer.StreamInputNumber, ((ulong)this._position * 10000), 0, 0, flag, inssBuff);

Is this code sufficient to write such a stream?

Thanks for any assistance you can provide.