/// <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)); }
public static extern int FFMS_GetNumTracks(SafeIndexHandle Index);
public static extern int FFMS_GetFirstIndexedTrackOfType(SafeIndexHandle Index, int TrackType, ref FFMS_ErrorInfo ErrorInfo);
internal Index(SafeIndexHandle index) { _handle = index; }
public static extern int FFMS_GetErrorHandling(SafeIndexHandle Index);
public static extern int FFMS_IndexBelongsToFile(SafeIndexHandle Index, byte[] SourceFile, ref FFMS_ErrorInfo ErrorInfo);
public static extern IntPtr FFMS_CreateAudioSource(byte[] SourceFile, int Track, SafeIndexHandle Index, int DelayMode, ref FFMS_ErrorInfo ErrorInfo);
public static extern int FFMS_GetSourceType(SafeIndexHandle Index);
public static extern IntPtr FFMS_GetTrackFromIndex(SafeIndexHandle Index, int Track);
public static extern int FFMS_GetFirstTrackOfType(SafeIndexHandle Index, int TrackType, ref FFMS_ErrorInfo ErrorInfo);
public static extern IntPtr FFMS_CreateVideoSource(byte[] SourceFile, int Track, SafeIndexHandle Index, int Threads, int SeekMode, ref FFMS_ErrorInfo ErrorInfo);
public static extern int FFMS_WriteIndex(byte[] IndexFile, SafeIndexHandle TrackIndices, ref FFMS_ErrorInfo ErrorInfo);
/// <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)); }