public void Constuctor_InitializesInstance() { var name = new byte[] { (byte)'h', (byte)'2', (byte)'6', (byte)'4' }; var longName = new byte[] { (byte)'h', (byte)'2', (byte)'6', (byte)'4', (byte)'_', (byte)'l', (byte)'o', (byte)'n', (byte)'g' }; fixed(byte *namePtr = name) fixed(byte *longNamePtr = longName) { var nativeInputFormat = new NativeAVInputFormat() { name = namePtr, long_name = longNamePtr, }; var ffmpegMock = new Mock <FFmpegClient>(); ffmpegMock .Setup(c => c.FindInputFormat("h264")) .Returns((IntPtr)(&nativeInputFormat)); var ffmpegClient = ffmpegMock.Object; var inputFormat = new AVInputFormat(ffmpegClient, "h264"); Assert.Equal("h264", inputFormat.Name); Assert.Equal("h264_long", inputFormat.LongName); Assert.Equal("h264_long", inputFormat.ToString()); Assert.Equal((int)&nativeInputFormat, (int)inputFormat.NativeObject); } }
/// <summary> /// Allocates all the structures needed to read an input stream. /// This does not open the needed codecs for decoding the stream[s]. /// </summary> private static AVError av_open_input_stream(out AVFormatContext ctx, ref ByteIOContext pb, string filename, ref AVInputFormat fmt, ref AVFormatParameters ap) { AVFormatContext *ptr; AVError err = av_open_input_stream(out ptr, ref pb, filename, ref fmt, ref ap); ctx = *ptr; FFmpeg.av_free(ptr); return(err); }
internal unsafe Format(AVInputFormat format) { LongName = Marshal.PtrToStringAnsi((IntPtr)format.long_name); Name = Marshal.PtrToStringAnsi((IntPtr)format.name); Codecs = FfmpegCalls.GetCodecOfCodecTag(format.codec_tag).AsReadOnly(); var extensions = Marshal.PtrToStringAnsi((IntPtr)format.extensions); FileExtensions = !string.IsNullOrEmpty(extensions) ? extensions.Split(',').ToList().AsReadOnly() : Enumerable.Empty <string>().ToList().AsReadOnly(); }
/// <summary> /// Opens a media file as input. The codecs are not opened. Only the file /// header (if present) is read. /// </summary> /// <param name="pFormatContext">the opened media file handle is put here</param> /// <param name="filename">filename to open</param> /// <param name="pAVInputFormat">if non null, force the file format to use</param> /// <param name="buf_size">optional buffer size (zero as default is OK)</param> /// <param name="pAVFormatParameters">Additional parameters needed when open the file (Null if default)</param> /// <returns>AVError</returns> public static AVError av_open_input_file(out AVFormatContext pFormatContext, string filename, ref AVInputFormat fmt, int buf_size, ref AVFormatParameters ap) { IntPtr ptr; AVError err = av_open_input_file(out ptr, filename, ref fmt, 0, ref ap); if (ptr == IntPtr.Zero) { pFormatContext = new AVFormatContext(); return(err); } pFormatContext = *(AVFormatContext *)ptr.ToPointer(); FFmpeg.av_freep(ref ptr); return(err); }
public static extern void av_register_input_format(ref AVInputFormat pAVInputFormat);
public static extern void av_register_input_format(ref AVInputFormat pAVInputFormat);
public static extern AVError avformat_open_input(out IntPtr ps, string filename, AVInputFormat* fmt, AVDictionary* options);
private static extern AVError av_open_input_file(out IntPtr pFormatContext, string filename, ref AVInputFormat fmt, int buf_size, ref AVFormatParameters ap);
private static extern AVError av_open_input_stream(out AVFormatContext *ic_ptr, ref ByteIOContext pb, string filename, ref AVInputFormat fmt, ref AVFormatParameters ap);