Example #1
0
        public byte[] GetStreamData()
        {
            int  streamLength;
            int  samples;
            uint result = AviInterop.AVIStreamRead(StreamPointer, sampleOffset,
                                                   AviInterop.AvistreamreadConvenient, IntPtr.Zero, 0, out streamLength, out samples);

            if (result != 0)
            {
                throw new Exception("Exception in AVIStreamRead: " + AviErrors.GetError(result));
            }

            IntPtr waveData = Marshal.AllocHGlobal(streamLength);

            result = AviInterop.AVIStreamRead(StreamPointer, sampleOffset, samples,
                                              waveData, streamLength, out streamLength, out samples);
            if (result != 0)
            {
                throw new Exception("Exception in AVIStreamRead: " + AviErrors.GetError(result));
            }

            sampleOffset += samples;
            var resultData = new byte[streamLength];

            Marshal.Copy(waveData, resultData, 0, streamLength);
            Marshal.FreeHGlobal(waveData);

            return(resultData);
        }
Example #2
0
        public AviFile(String filepath)
        {
            AviInterop.AVIFileInit();
            uint result = AviInterop.AVIFileOpen(ref aviFile, filepath, AviInterop.OfRead, 0);

            if (result > 0)
            {
                throw new Exception("Exception in AVIFileOpen: " + AviErrors.GetError(result));
            }
        }
Example #3
0
        protected AviInterop.StreamInfo GetStreamInfo()
        {
            var  streamInfo = new AviInterop.StreamInfo();
            uint result     = AviInterop.AVIStreamInfo(StreamPointer, ref streamInfo,
                                                       Marshal.SizeOf(streamInfo));

            if (result != 0)
            {
                throw new Exception("Exception in VideoStreamInfo: " + AviErrors.GetError(result));
            }

            return(streamInfo);
        }
Example #4
0
        public AudioStream GetAudioStream()
        {
            IntPtr aviStream;
            uint   result = AviInterop.AVIFileGetStream(aviFile, out aviStream, AviInterop.StreamtypeAudio,
                                                        0);

            if (result > 0)
            {
                throw new Exception("Exception in AVIFileGetStream: " + AviErrors.GetError(result));
            }

            var stream = new AudioStream(aviFile, aviStream);

            streams.Add(stream);
            return(stream);
        }