Exemplo n.º 1
0
        /// <summary>
        /// Read an index from disk
        /// </summary>
        /// <remarks>
        /// <para>In FFMS2, the equivalent is <c>FFMS_ReadIndex</c>.</para>
        /// </remarks>
        /// <param name="indexFile">Can be an absolute or relative path</param>
        /// <exception cref="System.IO.IOException">Trying to read an invalid index file.</exception>
        /// <exception cref="System.IO.FileNotFoundException">Trying to read an index file that does not exist.</exception>
        /// <exception cref="NotSupportedException">Trying to read an index file for a <see cref="Source">Source</see> that is not available in the ffms2.dll.</exception>
        public Index(string indexFile)
        {
            if (indexFile == null)
            {
                throw new ArgumentNullException(@"indexFile");
            }

            var err = new FFMS_ErrorInfo
            {
                BufferSize = 1024,
                Buffer     = new String((char)0, 1024)
            };

            var indexFileBytes = Encoding.UTF8.GetBytes(indexFile);

            _handle = NativeMethods.FFMS_ReadIndex(indexFileBytes, ref err);

            if (!_handle.IsInvalid)
            {
                return;
            }

            if (err.ErrorType == FFMS_Errors.FFMS_ERROR_PARSER && err.SubType == FFMS_Errors.FFMS_ERROR_FILE_READ)
            {
                throw new System.IO.IOException(err.Buffer);
            }
            if (err.ErrorType == FFMS_Errors.FFMS_ERROR_PARSER && err.SubType == FFMS_Errors.FFMS_ERROR_NO_FILE)
            {
                throw new System.IO.FileNotFoundException(err.Buffer);
            }
            if (err.ErrorType == FFMS_Errors.FFMS_ERROR_INDEX && err.SubType == FFMS_Errors.FFMS_ERROR_NOT_AVAILABLE)
            {
                throw new NotSupportedException(err.Buffer);
            }

            throw new NotImplementedException(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Unknown FFMS2 error encountered: ({0}, {1}, '{2}'). Please report this issue on FFMSSharp's GitHub.", err.ErrorType, err.SubType, err.Buffer));
        }
Exemplo n.º 2
0
 public static extern int FFMS_GetNumTracks(SafeIndexHandle Index);
Exemplo n.º 3
0
 public static extern int FFMS_GetFirstIndexedTrackOfType(SafeIndexHandle Index, int TrackType, ref FFMS_ErrorInfo ErrorInfo);
Exemplo n.º 4
0
 internal Index(SafeIndexHandle index)
 {
     _handle = index;
 }
Exemplo n.º 5
0
 public static extern int FFMS_GetErrorHandling(SafeIndexHandle Index);
Exemplo n.º 6
0
 public static extern int FFMS_IndexBelongsToFile(SafeIndexHandle Index, byte[] SourceFile, ref FFMS_ErrorInfo ErrorInfo);
Exemplo n.º 7
0
 public static extern IntPtr FFMS_CreateAudioSource(byte[] SourceFile, int Track, SafeIndexHandle Index, int DelayMode, ref FFMS_ErrorInfo ErrorInfo);
Exemplo n.º 8
0
 public static extern int FFMS_GetSourceType(SafeIndexHandle Index);
Exemplo n.º 9
0
 public static extern IntPtr FFMS_GetTrackFromIndex(SafeIndexHandle Index, int Track);
Exemplo n.º 10
0
 public static extern int FFMS_GetFirstTrackOfType(SafeIndexHandle Index, int TrackType, ref FFMS_ErrorInfo ErrorInfo);
Exemplo n.º 11
0
 public static extern int FFMS_GetNumTracks(SafeIndexHandle Index);
Exemplo n.º 12
0
 public static extern int FFMS_GetErrorHandling(SafeIndexHandle Index);
Exemplo n.º 13
0
 public static extern IntPtr FFMS_CreateVideoSource(byte[] SourceFile, int Track, SafeIndexHandle Index, int Threads, int SeekMode, ref FFMS_ErrorInfo ErrorInfo);
Exemplo n.º 14
0
 public static extern IntPtr FFMS_CreateAudioSource(byte[] SourceFile, int Track, SafeIndexHandle Index, int DelayMode, ref FFMS_ErrorInfo ErrorInfo);
Exemplo n.º 15
0
 internal Index(SafeIndexHandle index)
 {
     _handle = index;
 }
Exemplo n.º 16
0
 public static extern int FFMS_IndexBelongsToFile(SafeIndexHandle Index, byte[] SourceFile, ref FFMS_ErrorInfo ErrorInfo);
Exemplo n.º 17
0
 public static extern int FFMS_WriteIndex(byte[] IndexFile, SafeIndexHandle TrackIndices, ref FFMS_ErrorInfo ErrorInfo);
Exemplo n.º 18
0
 public static extern int FFMS_WriteIndex(byte[] IndexFile, SafeIndexHandle TrackIndices, ref FFMS_ErrorInfo ErrorInfo);
Exemplo n.º 19
0
 public static extern IntPtr FFMS_CreateVideoSource(byte[] SourceFile, int Track, SafeIndexHandle Index, int Threads, int SeekMode, ref FFMS_ErrorInfo ErrorInfo);
Exemplo n.º 20
0
 public static extern int FFMS_GetSourceType(SafeIndexHandle Index);
Exemplo n.º 21
0
 public static extern IntPtr FFMS_GetTrackFromIndex(SafeIndexHandle Index, int Track);
Exemplo n.º 22
0
        /// <summary>
        /// Read an index from disk
        /// </summary>
        /// <remarks>
        /// <para>In FFMS2, the equivalent is <c>FFMS_ReadIndex</c>.</para>
        /// </remarks>
        /// <param name="indexFile">Can be an absolute or relative path</param>
        /// <exception cref="System.IO.IOException">Trying to read an invalid index file.</exception>
        /// <exception cref="System.IO.FileNotFoundException">Trying to read an index file that does not exist.</exception>
        /// <exception cref="NotSupportedException">Trying to read an index file for a <see cref="Source">Source</see> that is not available in the ffms2.dll.</exception>
        public Index(string indexFile)
        {
            if (indexFile == null) throw new ArgumentNullException(@"indexFile");

            var err = new FFMS_ErrorInfo
            {
                BufferSize = 1024,
                Buffer = new String((char) 0, 1024)
            };

            var indexFileBytes = Encoding.UTF8.GetBytes(indexFile);
            _handle = NativeMethods.FFMS_ReadIndex(indexFileBytes, ref err);

            if (!_handle.IsInvalid) return;

            if (err.ErrorType == FFMS_Errors.FFMS_ERROR_PARSER && err.SubType == FFMS_Errors.FFMS_ERROR_FILE_READ)
                throw new System.IO.IOException(err.Buffer);
            if (err.ErrorType == FFMS_Errors.FFMS_ERROR_PARSER && err.SubType == FFMS_Errors.FFMS_ERROR_NO_FILE)
                throw new System.IO.FileNotFoundException(err.Buffer);
            if (err.ErrorType == FFMS_Errors.FFMS_ERROR_INDEX && err.SubType == FFMS_Errors.FFMS_ERROR_NOT_AVAILABLE)
                throw new NotSupportedException(err.Buffer);

            throw new NotImplementedException(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Unknown FFMS2 error encountered: ({0}, {1}, '{2}'). Please report this issue on FFMSSharp's GitHub.", err.ErrorType, err.SubType, err.Buffer));
        }