Пример #1
0
 /// <summary>
 /// Create new FrameGrabber from GetFrame object.
 /// </summary>
 /// <param name="getFrameObj">
 /// GetFrame object to create FrameGrabber.
 /// </param>
 /// <param name="streamInfo">
 /// Information about stream in <see cref="SARA.Avi.AviMarshal.AVISTREAMINFO"/> structure
 /// </param>
 internal FrameGrabber(IntPtr getFrameObj, AVISTREAMINFO streamInfo)
 {
     if (getFrameObj == IntPtr.Zero)
         throw new AviException("Can not create FrameGrabber from null GetFrame object.");
     _getFrameObj = getFrameObj;
     _streamInfo = streamInfo;
     AviFil32.AVIFileInit();
 }
Пример #2
0
        /// <summary>
        /// Avi stream constructor.
        /// </summary>
        /// <param name="aviStream">
        /// Handle to AviFil32 avi stream.
        /// </param>
        /// <param name="streamInfo">
        /// Stream info header.
        /// </param>
        internal AviStream(IntPtr aviStream, AVISTREAMINFO streamInfo)
        {
            if (aviStream == IntPtr.Zero)
                throw new AviException("Can not create avi stream from null stream");

            _aviStream = aviStream;
            _streamInfo = streamInfo;
            AviFil32.AVIFileInit();
        }
Пример #3
0
        /// <summary>
        /// AudioStream constructor.
        /// </summary>
        /// <param name="aviStream">
        /// Handle to AviFil32 avi stream.
        /// </param>
        /// <param name="streamInfo">
        /// Stream info header.
        /// </param>
        internal AudioStream(IntPtr aviStream, AVISTREAMINFO streamInfo)
            : base(aviStream, streamInfo)
        {
            if (streamInfo.fccType != AviFil32.StreamType.AUDIO)
            {
                AviFil32.AVIStreamRelease(_aviStream);
                AviFil32.AVIFileExit();
                _aviStream = IntPtr.Zero;

                throw new AviException("Can not create audio stream from not audio stream.");
            }
        }
Пример #4
0
        /// <summary>
        /// Get avi stream from AviFile.
        /// </summary>
        /// <param name="id">
        /// Stream id.
        /// </param>
        /// <returns>
        /// Avi stream or null when stream does not exist.
        /// </returns>
        public AviStream GetStream(int id)
        {
            IntPtr aviStream = new IntPtr();
            AVISTREAMINFO streamInfo = new AVISTREAMINFO();

            AviFil32.AVIError error = AviFil32.AVIFileGetStream(_aviFile, ref aviStream, AviFil32.StreamType.ANY, id);
            if (error != AviFil32.AVIError.AVIERR_OK)
            {
                switch (error)
                {
                    case AviFil32.AVIError.AVIERR_NODATA:
                        throw new AviException("The file does not contain a stream corresponding to specified values.");
                    case AviFil32.AVIError.AVIERR_MEMORY:
                        throw new AviException("Not enough memory.");
                    default:
                        throw new AviException("Unrecognised AVI exception (0x" + Convert.ToString((int)error, 16) + ").");
                }
            }
            if (aviStream == IntPtr.Zero)
                return null;

            error = AviFil32.AVIStreamInfo(aviStream, ref streamInfo, Marshal.SizeOf(streamInfo));
            if (error != AviFil32.AVIError.AVIERR_OK)
                throw new AviException("Unrecognised AVI exception (0x" + Convert.ToString((int)error, 16) + ").");

            switch (streamInfo.fccType)
            {
                case AviFil32.StreamType.AUDIO:
                    return new AudioStream(aviStream, streamInfo);
                case AviFil32.StreamType.MIDI:
                    return new MidiStream(aviStream, streamInfo);
                case AviFil32.StreamType.TEXT:
                    return new TextStream(aviStream, streamInfo);
                case AviFil32.StreamType.VIDEO:
                    return new VideoStream(aviStream, streamInfo);
                default:
                    throw new AviException("Unknown stream type (0x" + Convert.ToString((int)streamInfo.fccType, 16) + ").");
            }
        }
Пример #5
0
 public static extern AVIError AVIStreamInfo(IntPtr pavi, ref AVISTREAMINFO psi, int lSize);