VisClient/net/sf/ffmpeg_java/AVFormatLibrary.java

Go to the documentation of this file.
00001 package net.sf.ffmpeg_java;
00002 
00003 import com.sun.jna.Callback;
00004 import com.sun.jna.Native;
00005 import com.sun.jna.NativeLong;
00006 import com.sun.jna.Pointer;
00007 import com.sun.jna.Structure;
00008 import com.sun.jna.ptr.IntByReference;
00009 import com.sun.jna.ptr.LongByReference;
00010 import com.sun.jna.ptr.PointerByReference;
00011 
00017 public interface AVFormatLibrary extends FFMPEGLibrary 
00018 {
00019 
00020     public static final AVFormatLibrary INSTANCE = (AVFormatLibrary) Native.loadLibrary(
00021                 System.getProperty("avformat.lib",
00022                         System.getProperty("os.name").startsWith("Windows") ? "avformat-52" : "avformat"), 
00023                 AVFormatLibrary.class);
00024 
00025 //------------------------------------------------------------------------------------------------------------------------
00026 // avformat.h
00027     
00028 /*    public static final int LIBAVFORMAT_VERSION_INT = ((52<<16)+(31<<8)+1);
00029     public static final String LIBAVFORMAT_VERSION     = "52.31.1";
00030     public static final int LIBAVFORMAT_BUILD       = LIBAVFORMAT_VERSION_INT;
00031 
00032     public static final String LIBAVFORMAT_IDENT       = "Lavf" + LIBAVFORMAT_VERSION;
00033 */    
00034     
00035         //      typedef struct AVPacket {
00036         //    int64_t pts;                            ///< presentation time stamp in time_base units
00037         //    int64_t dts;                            ///< decompression time stamp in time_base units
00038         //    uint8_t *data;
00039         //    int   size;
00040         //    int   stream_index;
00041         //    int   flags;
00042         //    int   duration;                         ///< presentation duration in time_base units (0 if not available)
00043         //    void  (*destruct)(struct AVPacket *);
00044         //    void  *priv;
00045         //    int64_t pos;                            ///< byte position in stream, -1 if unknown
00046         //} AVPacket;
00047         
00048     interface Destruct extends Callback 
00049     {
00050         void callback(AVPacket pkt);
00051     }
00052 
00053         public static class AVPacket extends Structure
00054         {
00055                 public long pts;                           
00056                 public long dts;                           
00057                 public Pointer data;
00058                 public int   size;
00059                 public int   stream_index;
00060                 public int   flags;
00061                 public int   duration;                        
00062                 public Destruct destruct;
00063                 public Pointer priv;
00064                 public long pos;   
00065                 public long convergence_duration;
00066         
00067                 public AVPacket(){};
00068                 public AVPacket(Pointer p){
00069                         useMemory(p);
00070                         read();
00071                 }
00072         }
00073         
00074         public static final int PKT_FLAG_KEY   = 0x0001;
00075         
00076         void av_destruct_packet_nofree(AVPacket pkt);
00077         void av_destruct_packet(AVPacket pkt);
00078         void av_init_packet(AVPacket pkt);
00079         int av_new_packet(AVPacket pkt, int size);
00080         int av_get_packet(ByteIOContext s, AVPacket pkt, int size);
00081         int av_dup_packet(AVPacket pkt);
00082 
00083         
00084 //      /**
00085 //       * Free a packet
00086 //       *
00087 //       * @param pkt packet to free
00088 //       */
00089 //      static inline void av_free_packet(AVPacket *pkt)
00090 //      {
00091 //          if (pkt && pkt->destruct) {
00092 //              pkt->destruct(pkt);
00093 //          }
00094 //      }
00095         void av_free_packet(AVPacket pkt);      // TODO: this won't work with JNA, since it is inlined.
00096         
00097         //      typedef struct AVFrac {
00098         //    int64_t val, num, den;
00099         //} AVFrac attribute_deprecated;
00100         
00101         public static class AVFrac extends Structure
00102         {
00103             public long val;
00104             public long num;
00105             public long den;
00106         }
00107         
00108 //      /** this structure contains the data a format has to probe a file */
00109 //      typedef struct AVProbeData {
00110 //          const char *filename;
00111 //          unsigned char *buf;
00112 //          int buf_size;
00113 //      } AVProbeData;
00114 //
00115 //      #define AVPROBE_SCORE_MAX 100               ///< max score, half of that is used for file extension based detection
00116 //      #define AVPROBE_PADDING_SIZE 32             ///< extra allocated bytes at the end of the probe buffer
00117 
00119         public static class AVProbeData extends Structure
00120         {
00121             public Pointer filename;
00122             public Pointer buf;
00123             public int buf_size;
00124         }
00125 
00126         public static final int AVPROBE_SCORE_MAX =100;               
00127         public static final int AVPROBE_PADDING_SIZE =32;             
00128 
00129         public static class AVFormatParameters extends Structure
00130         {
00131             public AVRational time_base;
00132             public int sample_rate;
00133             public int channels;
00134             public int width;
00135             public int height;
00136             public int pix_fmt;
00137             public int channel; 
00138         //#if LIBAVFORMAT_VERSION_INT < (52<<16)
00139             //public Pointer device; /**< video, audio or DV device */
00140         //#endif
00141             public Pointer standard; 
00142                 public int bitFields;   // bit fields not supported by JNA
00143 //          int mpeg2ts_raw:1;  /**< force raw MPEG2 transport stream output, if possible */
00144 //          int mpeg2ts_compute_pcr:1; /**< compute exact PCR for each transport
00145 //                                        stream packet (only meaningful if
00146 //                                        mpeg2ts_raw is TRUE) */
00147 //          int initial_pause:1;       /**< do not begin to play the stream
00148 //                                        immediately (RTSP only) */
00149 //          int prealloced_context:1;
00150             public int video_codec_id;
00151             public int audio_codec_id;
00152         }
00153         
00154         public static final int AVFMT_NOFILE        =0x0001;
00155         public static final int AVFMT_NEEDNUMBER    =0x0002; 
00156         public static final int AVFMT_SHOW_IDS      =0x0008; 
00157         public static final int AVFMT_RAWPICTURE    =0x0020; 
00159         public static final int AVFMT_GLOBALHEADER  =0x0040; 
00160         public static final int AVFMT_NOTIMESTAMPS  =0x0080; 
00161         public static final int AVFMT_GENERIC_INDEX =0x0100; 
00164 //      typedef struct AVOutputFormat {
00165 //          const char *name;
00166 //          const char *long_name;
00167 //          const char *mime_type;
00168 //          const char *extensions; /**< comma separated filename extensions */
00169 //          /** size of private data so that it can be allocated in the wrapper */
00170 //          int priv_data_size;
00171 //          /* output support */
00172 //          enum CodecID audio_codec; /**< default audio codec */
00173 //          enum CodecID video_codec; /**< default video codec */
00174 //          int (*write_header)(struct AVFormatContext *);
00175 //          int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
00176 //          int (*write_trailer)(struct AVFormatContext *);
00177 //          /** can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_GLOBALHEADER */
00178 //          int flags;
00179 //          /** currently only used to set pixel format if not YUV420P */
00180 //          int (*set_parameters)(struct AVFormatContext *, AVFormatParameters *);
00181 //          int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush);
00182 //
00183 //          /**
00184 //           * list of supported codec_id-codec_tag pairs, ordered by "better choice first"
00185 //           * the arrays are all CODEC_ID_NONE terminated
00186 //           */
00187 //          const struct AVCodecTag **codec_tag;
00188 //
00189 //          enum CodecID subtitle_codec; /**< default subtitle codec */
00190 //
00191 //          /* private fields */
00192 //          struct AVOutputFormat *next;
00193 //      } AVOutputFormat;
00194         
00195         public static class AVOutputFormat extends Structure
00196         {
00197             public String name;
00198             public String long_name;
00199             public String mime_type;
00200             public String extensions; 
00201             public int priv_data_size;
00202             public int audio_codec; 
00203             public int video_codec; 
00204             public Pointer write_header;
00205             public Pointer write_packet;
00206             public Pointer write_trailer;
00207             public int flags;
00208             public Pointer set_parameters;
00209             public Pointer interleave_packet;
00210             public Pointer codec_tag;
00211             public int subtitle_codec; 
00212             public Pointer next;
00213 
00214             public AVOutputFormat() {
00215                 super();
00216             }
00217             
00218             public AVOutputFormat(Pointer p)
00219                 {       super();
00220                         useMemory(p);
00221                         read();
00222                 }
00223         }
00224         
00225 //      typedef struct AVInputFormat {
00226 //          const char *name;
00227 //          const char *long_name;
00228 //          /** size of private data so that it can be allocated in the wrapper */
00229 //          int priv_data_size;
00230 //          /**
00231 //           * tell if a given file has a chance of being parsed by this format.
00232 //           * The buffer provided is guranteed to be AVPROBE_PADDING_SIZE bytes big
00233 //           * so you dont have to check for that unless you need more.
00234 //           */
00235 //          int (*read_probe)(AVProbeData *);
00236 //          /** read the format header and initialize the AVFormatContext
00237 //             structure. Return 0 if OK. 'ap' if non NULL contains
00238 //             additional paramters. Only used in raw format right
00239 //             now. 'av_new_stream' should be called to create new streams.  */
00240 //          int (*read_header)(struct AVFormatContext *,
00241 //                             AVFormatParameters *ap);
00242 //          /** read one packet and put it in 'pkt'. pts and flags are also
00243 //             set. 'av_new_stream' can be called only if the flag
00244 //             AVFMTCTX_NOHEADER is used. */
00245 //          int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
00246 //          /** close the stream. The AVFormatContext and AVStreams are not
00247 //             freed by this function */
00248 //          int (*read_close)(struct AVFormatContext *);
00249 //          /**
00250 //           * seek to a given timestamp relative to the frames in
00251 //           * stream component stream_index
00252 //           * @param stream_index must not be -1
00253 //           * @param flags selects which direction should be preferred if no exact
00254 //           *              match is available
00255 //           * @return >= 0 on success (but not necessarily the new offset)
00256 //           */
00257 //          int (*read_seek)(struct AVFormatContext *,
00258 //                           int stream_index, int64_t timestamp, int flags);
00259 //          /**
00260 //           * gets the next timestamp in AV_TIME_BASE units.
00261 //           */
00262 //          int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
00263 //                                    int64_t *pos, int64_t pos_limit);
00264 //          /** can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER */
00265 //          int flags;
00266 //          /** if extensions are defined, then no probe is done. You should
00267 //             usually not use extension format guessing because it is not
00268 //             reliable enough */
00269 //          const char *extensions;
00270 //          /** general purpose read only value that the format can use */
00271 //          int value;
00272 //
00273 //          /** start/resume playing - only meaningful if using a network based format
00274 //             (RTSP) */
00275 //          int (*read_play)(struct AVFormatContext *);
00276 //
00277 //          /** pause playing - only meaningful if using a network based format
00278 //             (RTSP) */
00279 //          int (*read_pause)(struct AVFormatContext *);
00280 //
00281 //          const struct AVCodecTag **codec_tag;
00282 //
00283 //          /* private fields */
00284 //          struct AVInputFormat *next;
00285 //      } AVInputFormat;
00286         
00287         public static class AVInputFormat extends Structure
00288         {
00289             public String name;
00290             public String long_name;
00291             public int priv_data_size;
00292             public Pointer read_probe;
00293             public Pointer read_header;
00294             public Pointer read_packet;
00295             public Pointer read_close;
00296             public Pointer read_seek;
00297             public Pointer read_timestamp;
00298             public int flags;
00299             public String extensions;
00300             public int value;
00301             public Pointer read_play;
00302             public Pointer read_pause;
00303             public Pointer codec_tag;
00304             public Pointer next;
00305 
00306             public AVInputFormat() {
00307                 super();
00308             }
00309             
00310             public AVInputFormat(Pointer p)
00311                 {       super();
00312                         useMemory(p);
00313                         read();
00314                 }
00315         }
00316         
00317         //enum AVStreamParseType:
00318     public static final int AVSTREAM_PARSE_NONE = 0;
00319     public static final int AVSTREAM_PARSE_FULL = 1;       
00320     public static final int AVSTREAM_PARSE_HEADERS = 2;    
00321     public static final int AVSTREAM_PARSE_TIMESTAMPS = 3; 
00323 //    typedef struct AVIndexEntry {
00324 //        int64_t pos;
00325 //        int64_t timestamp;
00326 //    #define AVINDEX_KEYFRAME 0x0001
00327 //        int flags:2;
00328 //        int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs 32 byte due to possible 8byte align).
00329 //        int min_distance;         /**< min distance between this and the previous keyframe, used to avoid unneeded searching */
00330 //    } AVIndexEntry;
00331     
00332    public static class AVIndexEntry extends Structure
00333         {
00334         public long pos;
00335         public long timestamp;
00336                 public static final int AVINDEX_KEYFRAME = 0x0001;
00337         public int bit_fields; // JNA does not support bit fields
00338 //        int flags:2;
00339 //        int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs 32 byte due to possible 8byte align).
00340         public int min_distance;         
00341     }
00342         
00343 //      typedef struct AVStream {
00344 //   int index;    /**< stream index in AVFormatContext */
00345 //   int id;       /**< format specific stream id */
00346 //   AVCodecContext *codec; /**< codec context */
00347 //   /**
00348 //    * real base frame rate of the stream.
00349 //    * this is the lowest framerate with which all timestamps can be
00350 //    * represented accurately (it is the least common multiple of all
00351 //    * framerates in the stream), Note, this value is just a guess!
00352 //    * for example if the timebase is 1/90000 and all frames have either
00353 //    * approximately 3600 or 1800 timer ticks then r_frame_rate will be 50/1
00354 //    */
00355 //   AVRational r_frame_rate;
00356 //   void *priv_data;
00357 //
00358 //   /* internal data used in av_find_stream_info() */
00359 //   int64_t first_dts;
00360 //#if LIBAVFORMAT_VERSION_INT < (52<<16)
00361 //   int codec_info_nb_frames;
00362 //#endif
00363 //   /** encoding: PTS generation when outputing stream */
00364 //   struct AVFrac pts;
00365 //
00366 //   /**
00367 //    * this is the fundamental unit of time (in seconds) in terms
00368 //    * of which frame timestamps are represented. for fixed-fps content,
00369 //    * timebase should be 1/framerate and timestamp increments should be
00370 //    * identically 1.
00371 //    */
00372 //   AVRational time_base;
00373 //   int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
00374 //   /* ffmpeg.c private use */
00375 //   int stream_copy; /**< if set, just copy stream */
00376 //   enum AVDiscard discard; ///< selects which packets can be discarded at will and do not need to be demuxed
00377 //   //FIXME move stuff to a flags field?
00378 //   /** quality, as it has been removed from AVCodecContext and put in AVVideoFrame
00379 //    * MN: dunno if that is the right place for it */
00380 //   float quality;
00381 //   /** decoding: pts of the first frame of the stream, in stream time base. */
00382 //   int64_t start_time;
00383 //   /** decoding: duration of the stream, in stream time base. */
00384 //   int64_t duration;
00385 //
00386 //   char language[4]; /** ISO 639 3-letter language code (empty string if undefined) */
00387 //
00388 //   /* av_read_frame() support */
00389 //   enum AVStreamParseType need_parsing;
00390 //   struct AVCodecParserContext *parser;
00391 //
00392 //   int64_t cur_dts;
00393 //   int last_IP_duration;
00394 //   int64_t last_IP_pts;
00395 //   /* av_seek_frame() support */
00396 //   AVIndexEntry *index_entries; /**< only used if the format does not
00397 //                                   support seeking natively */
00398 //   int nb_index_entries;
00399 //   unsigned int index_entries_allocated_size;
00400 //
00401 //   int64_t nb_frames;                 ///< number of frames in this stream if known or 0
00402 //
00403 //#define MAX_REORDER_DELAY 4
00404 //   int64_t pts_buffer[MAX_REORDER_DELAY+1];
00405 //} AVStream;
00406 
00407         public static class AVStream extends Structure
00408         {
00409            public int index;   
00410            public int id;      
00411            public Pointer codec; 
00412            public AVRational r_frame_rate;
00413            public Pointer priv_data;
00414            public long first_dts;
00415         //#if LIBAVFORMAT_VERSION_INT < (52<<16)
00416            //public int codec_info_nb_frames;
00417         //#endif
00418            public AVFrac pts;
00419            public AVRational time_base;
00420            public int pts_wrap_bits; 
00421            public int stream_copy; 
00422            public int discard; 
00423            public float quality;
00424            public long start_time;
00425            public long duration;
00426            public byte[] language = new byte[4]; 
00427            public int need_parsing;
00428            public Pointer parser;
00429            public long cur_dts;
00430            public int last_IP_duration;
00431            public long last_IP_pts;
00432            public Pointer index_entries; 
00433            public int nb_index_entries;
00434            public int index_entries_allocated_size;
00435            public long nb_frames;              
00436            public static final int MAX_REORDER_DELAY = 4;
00437            public long[] pts_buffer = new long[MAX_REORDER_DELAY+1];
00438            
00439                 public AVStream()
00440                 {
00441                         super();
00442                 }
00443                 
00444                 public AVStream(Pointer p)
00445                 {       super();
00446                         useMemory(p);
00447                         read();
00448                 }
00449                 public AVStream(AVStream s) {
00450                         this(s.getPointer());
00451                 }
00452                 
00453         }
00454         
00455         public static final int AVFMTCTX_NOHEADER      = 0x0001; 
00458         public static final int MAX_STREAMS = 20;
00459         
00460 //      /* format I/O context */
00461 //      typedef struct AVFormatContext {
00462 //          const AVClass *av_class; /**< set by av_alloc_format_context */
00463 //          /* can only be iformat or oformat, not both at the same time */
00464 //          struct AVInputFormat *iformat;
00465 //          struct AVOutputFormat *oformat;
00466 //          void *priv_data;
00467 //          ByteIOContext pb;
00468 //          unsigned int nb_streams;
00469 //          AVStream *streams[MAX_STREAMS];
00470 //          char filename[1024]; /**< input or output filename */
00471 //          /* stream info */
00472 //          int64_t timestamp;
00473 //          char title[512];
00474 //          char author[512];
00475 //          char copyright[512];
00476 //          char comment[512];
00477 //          char album[512];
00478 //          int year;  /**< ID3 year, 0 if none */
00479 //          int track; /**< track number, 0 if none */
00480 //          char genre[32]; /**< ID3 genre */
00481 //
00482 //          int ctx_flags; /**< format specific flags, see AVFMTCTX_xx */
00483 //          /* private data for pts handling (do not modify directly) */
00484 //          /** This buffer is only needed when packets were already buffered but
00485 //             not decoded, for example to get the codec parameters in mpeg
00486 //             streams */
00487 //          struct AVPacketList *packet_buffer;
00488 //
00489 //          /** decoding: position of the first frame of the component, in
00490 //             AV_TIME_BASE fractional seconds. NEVER set this value directly:
00491 //             it is deduced from the AVStream values.  */
00492 //          int64_t start_time;
00493 //          /** decoding: duration of the stream, in AV_TIME_BASE fractional
00494 //             seconds. NEVER set this value directly: it is deduced from the
00495 //             AVStream values.  */
00496 //          int64_t duration;
00497 //          /** decoding: total file size. 0 if unknown */
00498 //          int64_t file_size;
00499 //          /** decoding: total stream bitrate in bit/s, 0 if not
00500 //             available. Never set it directly if the file_size and the
00501 //             duration are known as ffmpeg can compute it automatically. */
00502 //          int bit_rate;
00503 //
00504 //          /* av_read_frame() support */
00505 //          AVStream *cur_st;
00506 //          const uint8_t *cur_ptr;
00507 //          int cur_len;
00508 //          AVPacket cur_pkt;
00509 //
00510 //          /* av_seek_frame() support */
00511 //          int64_t data_offset; /** offset of the first packet */
00512 //          int index_built;
00513 //
00514 //          int mux_rate;
00515 //          int packet_size;
00516 //          int preload;
00517 //          int max_delay;
00518 //
00519 //      #define AVFMT_NOOUTPUTLOOP -1
00520 //      #define AVFMT_INFINITEOUTPUTLOOP 0
00521 //          /** number of times to loop output in formats that support it */
00522 //          int loop_output;
00523 //
00524 //          int flags;
00525 //      #define AVFMT_FLAG_GENPTS       0x0001 ///< generate pts if missing even if it requires parsing future frames
00526 //      #define AVFMT_FLAG_IGNIDX       0x0002 ///< ignore index
00527 //      #define AVFMT_FLAG_NONBLOCK     0x0004 ///< do not block when reading packets from input
00528 //
00529 //          int loop_input;
00530 //          /** decoding: size of data to probe; encoding unused */
00531 //          unsigned int probesize;
00532 //
00533 //          /**
00534 //           * maximum duration in AV_TIME_BASE units over which the input should be analyzed in av_find_stream_info()
00535 //           */
00536 //          int max_analyze_duration;
00537 //
00538 //          const uint8_t *key;
00539 //          int keylen;
00540 //      } AVFormatContext;
00541         
00542         public static class AVFormatContext extends Structure
00543         {
00544                 public Pointer av_class;
00545                 public Pointer iformat;
00546                 public Pointer oformat;
00547                 public Pointer priv_data;
00548                 public Pointer pb;
00549                 public int nb_streams;
00550                 public static final int MAX_STREAMS = 20;
00551                 // don't know how to do an array of pointers with JNA, so we'll just do 20 pointers:
00552                 public Pointer streams0;
00553                 public Pointer streams1;
00554                 public Pointer streams2;
00555                 public Pointer streams3;
00556                 public Pointer streams4;
00557                 public Pointer streams5;
00558                 public Pointer streams6;
00559                 public Pointer streams7;
00560                 public Pointer streams8;
00561                 public Pointer streams9;
00562                 public Pointer streams10;
00563                 public Pointer streams11;
00564                 public Pointer streams12;
00565                 public Pointer streams13;
00566                 public Pointer streams14;
00567                 public Pointer streams15;
00568                 public Pointer streams16;
00569                 public Pointer streams17;
00570                 public Pointer streams18;
00571                 public Pointer streams19;
00572                 public Pointer [] getStreams()
00573                 {       return new Pointer [] {
00574                                 streams0,
00575                                 streams1,
00576                                 streams2,
00577                                 streams3,
00578                                 streams4,
00579                                 streams5,
00580                                 streams6,
00581                                 streams7,
00582                                 streams8,
00583                                 streams9,
00584                                 streams10,
00585                                 streams11,
00586                                 streams12,
00587                                 streams13,
00588                                 streams14,
00589                                 streams15,
00590                                 streams16,
00591                                 streams17,
00592                                 streams18,
00593                                 streams19
00594                         };
00595                 }               //public Pointer[] streams = new Pointer[MAX_STREAMS]; //           AVStream *streams[MAX_STREAMS];
00596                 //public Pointer[] streams = new Pointer[MAX_STREAMS]; //           AVStream *streams[MAX_STREAMS];
00597                 public byte[] filename = new byte[1024]; 
00598                 public long timestamp;
00599                 public byte[] title = new byte[512];
00600                 public byte[] author = new byte[512];
00601                 public byte[] copyright = new byte[512];
00602                 public byte[] comment = new byte[512];
00603                 public byte[] album = new byte[512];
00604                 public int year;  
00605                 public int track; 
00606                 public byte[] genre = new byte[32]; 
00607                 public int ctx_flags; 
00608                 public Pointer packet_buffer;
00609                 public long start_time;
00610                 public long duration;
00611                 public long file_size;
00612                 public int bit_rate;
00613                 public Pointer cur_st;
00614                 public Pointer cur_ptr;
00615                 public int cur_len;
00616                 public AVPacket cur_pkt;
00617                 public long data_offset;
00618                 public int index_built;
00619                 public int mux_rate;
00620                 public int packet_size;
00621                 public int preload;
00622                 public int max_delay;
00623                         public static final int AVFMT_NOOUTPUTLOOP = -1;
00624                         public static final int AVFMT_INFINITEOUTPUTLOOP = 0;
00625                 public int loop_output;
00626                 public int flags;
00627                         public static final int AVFMT_FLAG_GENPTS       =0x0001; 
00628                         public static final int AVFMT_FLAG_IGNIDX       =0x0002; 
00629                         public static final int AVFMT_FLAG_NONBLOCK     =0x0004; 
00630                 public int loop_input;
00631                 public int probesize;
00632                 public int max_analyze_duration;
00633                 public Pointer key;
00634                 public int keylen;
00635                 
00636                 public AVFormatContext()
00637                 {
00638                         super();
00639                 }
00640                 
00641                 public AVFormatContext(Pointer p)
00642                 {       super();
00643                         useMemory(p);
00644                         read();
00645                 }
00646         }
00647         
00648 //      typedef struct AVPacketList {
00649 //          AVPacket pkt;
00650 //          struct AVPacketList *next;
00651 //      } AVPacketList;
00652         
00653         public static class AVPacketList extends Structure
00654         {
00655             public AVPacket pkt;
00656             public Pointer next;
00657         }
00658         
00659 //      extern AVInputFormat *first_iformat;
00660 //      extern AVOutputFormat *first_oformat;
00661         
00662         // TODO: JNA does not support global variable access
00663         
00664         //enum CodecID av_guess_image2_codec(const char *filename);
00665         int av_guess_image2_codec(String filename);
00666         
00667         
00668         void av_register_input_format(AVInputFormat format);
00669         void av_register_output_format(AVOutputFormat format);
00670         AVOutputFormat guess_stream_format(String short_name,
00671                                             String filename, String mime_type);
00672         AVOutputFormat guess_format(String short_name,
00673                                      String filename, String mime_type);
00674         
00675         
00676         int av_guess_codec(AVOutputFormat fmt, String short_name,
00677             String filename, String mime_type, int type);
00678 
00679         void av_hex_dump(Pointer f, Pointer buf, int size);
00680         void av_hex_dump_log(Pointer avcl, int level, Pointer buf, int size);
00681         void av_pkt_dump(Pointer f, AVPacket pkt, int dump_payload);
00682         
00683         void av_pkt_dump_log(Pointer avcl, int level, AVPacket pkt, int dump_payload);
00684         
00685 
00686         void av_register_all();
00687         
00688         int av_codec_get_id(PointerByReference tags, int tag);
00689         int av_codec_get_tag(PointerByReference tags, int id);
00690         
00691         AVInputFormat av_find_input_format(String short_name);
00692 
00693         AVInputFormat av_probe_input_format(AVProbeData pd, int is_opened);
00694 
00699         int av_open_input_stream(PointerByReference ic_ptr,
00700                         ByteIOContext pb, String filename,
00701                         AVInputFormat fmt, AVFormatParameters ap);
00713         int av_open_input_file(PointerByReference ic_ptr, String filename,
00714                         AVInputFormat fmt,
00715                 int buf_size,
00716                 AVFormatParameters ap);
00717 
00718         AVFormatContext av_alloc_format_context();
00719         int av_find_stream_info(AVFormatContext ic);
00720         int av_read_packet(AVFormatContext s, AVPacket pkt);
00740         int av_read_frame(AVFormatContext s, AVPacket pkt);
00752         int av_seek_frame(AVFormatContext s, int stream_index, long timestamp, int flags);
00757         int av_read_play(AVFormatContext s);
00763         int av_read_pause(AVFormatContext s);
00764         void av_close_input_file(AVFormatContext s);
00765         AVStream av_new_stream(AVFormatContext s, int id);
00766         void av_set_pts_info(AVStream s, int pts_wrap_bits,
00767                              int pts_num, int pts_den);
00768 
00769         
00770         public static final int AVSEEK_FLAG_BACKWARD =1; 
00771         public static final int AVSEEK_FLAG_BYTE     =2; 
00772         public static final int AVSEEK_FLAG_ANY      =4; 
00773         
00774         
00775         int av_find_default_stream_index(AVFormatContext s);
00776         int av_index_search_timestamp(AVStream st, long timestamp, int flags);
00777         int av_add_index_entry(AVStream st,
00778                                long pos, long timestamp, int size, int distance, int flags);
00779         int av_seek_frame_binary(AVFormatContext s, int stream_index, long target_ts, int flags);
00780         void av_update_cur_dts(AVFormatContext s, AVStream ref_st, long timestamp);
00781         long av_gen_search(AVFormatContext s, int stream_index, long target_ts, long pos_min, long pos_max, long pos_limit, long ts_min, long ts_max, int flags, LongByReference ts_ret, Pointer read_timestamp);
00782         int av_set_parameters(AVFormatContext s, AVFormatParameters ap);
00783         int av_write_header(AVFormatContext s);
00784         int av_write_frame(AVFormatContext s, AVPacket pkt);
00785         int av_interleaved_write_frame(AVFormatContext s, AVPacket pkt);
00786         int av_interleave_packet_per_dts(AVFormatContext s, AVPacket out, AVPacket pkt, int flush);
00787         int av_write_trailer(AVFormatContext s);
00788         void dump_format(AVFormatContext ic,
00789                          int index,
00790                          String url,
00791                          int is_output);
00793         int parse_image_size(IntByReference width_ptr, IntByReference height_ptr, String str);
00795         int parse_frame_rate(IntByReference frame_rate, IntByReference frame_rate_base, String arg);
00796         long parse_date(String datestr, int duration);
00797         long av_gettime();
00798         public static final int FFM_PACKET_SIZE = 4096;
00799         long ffm_read_write_index(int fd);
00800         void ffm_write_write_index(int fd, long pos);
00801         void ffm_set_write_index(AVFormatContext s, long pos, long file_size);
00802         int find_info_tag(Pointer arg, int arg_size, String tag1, String info);
00803         int av_get_frame_filename(Pointer buf, int buf_size,
00804                                   String path, int number);
00805         int av_filename_number_test(String filename);
00806         int avf_sdp_create(Pointer ac, int n_files, Pointer buff, int size);
00807 
00808 //      #ifdef HAVE_AV_CONFIG_H
00809 
00810 //      #include "os_support.h"
00811 //
00812 //      void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem);
00813 //
00814 //      #ifdef __GNUC__
00815 //      #define dynarray_add(tab, nb_ptr, elem)\
00816 //      do {\
00817 //          typeof(tab) _tab = (tab);\
00818 //          typeof(elem) _elem = (elem);\
00819 //          (void)sizeof(**_tab == _elem); /* check that types are compatible */\
00820 //          __dynarray_add((unsigned long **)_tab, nb_ptr, (unsigned long)_elem);\
00821 //      } while(0)
00822 //      #else
00823 //      #define dynarray_add(tab, nb_ptr, elem)\
00824 //      do {\
00825 //          __dynarray_add((unsigned long **)(tab), nb_ptr, (unsigned long)(elem));\
00826 //      } while(0)
00827 //      #endif
00828 
00829         // TODO: __dynarray_add and dynarray_add with JNA
00830         
00831 //      time_t mktimegm(struct tm *tm);
00832 //      struct tm *brktimegm(time_t secs, struct tm *tm);
00833         // TODO: mktimegm with JNA
00834         // TODO: brktimegm with JNA
00835         
00836         String small_strptime(String p, String fmt,
00837                                    Pointer dt);
00838 
00839         int resolve_host(Pointer sin_addr, String hostname);
00840 
00841         void url_split(Pointer proto, int proto_size,
00842                        Pointer authorization, int authorization_size,
00843                        Pointer hostname, int hostname_size,
00844                        IntByReference port_ptr,
00845                        Pointer path, int path_size,
00846                        String url);
00847 
00848         int match_ext(String filename, String extensions);
00849         
00850         
00851 // end avformat.h
00852 //------------------------------------------------------------------------------------------------------------------------
00853 
00854 //------------------------------------------------------------------------------------------------------------------------
00855 // avio.h
00856 
00857 
00858 //      struct URLContext {
00859 //          struct URLProtocol *prot;
00860 //          int flags;
00861 //          int is_streamed;  /**< true if streamed (no seek possible), default = false */
00862 //          int max_packet_size;  /**< if non zero, the stream is packetized with this max packet size */
00863 //          void *priv_data;
00864 //      #if LIBAVFORMAT_VERSION_INT >= (52<<16)
00865 //          char *filename; /**< specified filename */
00866 //      #else
00867 //          char filename[1]; /**< specified filename */
00868 //      #endif
00869 //      };
00870         
00871         public static class URLContext extends Structure
00872         {
00873             public Pointer prot;
00874             public int flags;
00875             public int is_streamed;  
00876             public int max_packet_size;  
00877             public Pointer priv_data;
00878         //#if LIBAVFORMAT_VERSION_INT >= (52<<16)
00879             public Pointer filename; 
00880         //#else
00881             //public byte filename; /**< specified filename */
00882         //#endif
00883             // TODO: not sure how this should be mapped for JNA.  This is most likely a variable length structure with the filename following the structure.
00884         }
00885         
00886 //      typedef struct URLPollEntry {
00887 //          URLContext *handle;
00888 //          int events;
00889 //          int revents;
00890 //      } URLPollEntry;
00891         
00892         public static class URLPollEntry extends Structure
00893         {
00894             public Pointer handle;
00895             public int events;
00896             public int revents;
00897         } 
00898 
00899         public static final int URL_RDONLY =0;
00900         public static final int URL_WRONLY =1;
00901         public static final int URL_RDWR   =2;
00902 
00903         //typedef int URLInterruptCB(void);
00904 
00905         int url_open(PointerByReference h, String filename, int flags);
00906         int url_read(URLContext h, Pointer buf, int size);
00907         int url_write(URLContext h, Pointer buf, int size);
00908         long url_seek(URLContext h, long pos, int whence);
00909         int url_close(URLContext h);
00910         int url_exist(String filename);
00911         long url_filesize(URLContext h);
00912 
00913         int url_get_max_packet_size(URLContext h);
00914         void url_get_filename(URLContext h, Pointer buf, int buf_size);
00915         void url_set_interrupt_cb(Pointer/*URLInterruptCB*/ interrupt_cb);
00916         int url_poll(URLPollEntry poll_table, int n, int timeout);
00917         public static final int AVSEEK_SIZE = 0x10000;
00918 
00919 //      typedef struct URLProtocol {
00920 //          const char *name;
00921 //          int (*url_open)(URLContext *h, const char *filename, int flags);
00922 //          int (*url_read)(URLContext *h, unsigned char *buf, int size);
00923 //          int (*url_write)(URLContext *h, unsigned char *buf, int size);
00924 //          offset_t (*url_seek)(URLContext *h, offset_t pos, int whence);
00925 //          int (*url_close)(URLContext *h);
00926 //          struct URLProtocol *next;
00927 //      } URLProtocol;
00928 
00929         
00930 //      extern URLProtocol *first_protocol;
00931 //      extern URLInterruptCB *url_interrupt_cb;
00932         // TODO: JNA does not allow access to global variables
00933 
00934         //int register_protocol(URLProtocol protocol);
00935 
00936         
00937         
00938 //      typedef struct {
00939 //          unsigned char *buffer;
00940 //          int buffer_size;
00941 //          unsigned char *buf_ptr, *buf_end;
00942 //          void *opaque;
00943 //          int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
00944 //          int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
00945 //          offset_t (*seek)(void *opaque, offset_t offset, int whence);
00946 //          offset_t pos; /**< position in the file of the current buffer */
00947 //          int must_flush; /**< true if the next seek should flush */
00948 //          int eof_reached; /**< true if eof reached */
00949 //          int write_flag;  /**< true if open for writing */
00950 //          int is_streamed;
00951 //          int max_packet_size;
00952 //          unsigned long checksum;
00953 //          unsigned char *checksum_ptr;
00954 //          unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
00955 //          int error;         ///< contains the error code or 0 if no error happened
00956 //      } ByteIOContext;
00957 
00958         public static class ByteIOContext extends Structure
00959         {
00960                 public Pointer buffer;
00961                 public int buffer_size;
00962                 public Pointer buf_ptr;
00963                 public Pointer buf_end;
00964                 public Pointer opaque;
00965                 public Pointer read_packet;
00966                 public Pointer write_packet;
00967                 public Pointer seek;
00968                 public long pos; 
00969                 public int must_flush; 
00970                 public int eof_reached; 
00971                 public int write_flag; 
00972                 public int is_streamed;
00973                 public int max_packet_size;
00974                 public NativeLong checksum;     
00975                 public Pointer checksum_ptr;
00976                 public Pointer update_checksum;
00977                 public int error;
00978                 public Pointer read_pause;
00979                 public Pointer read_seek;
00980         }
00981 
00982         int init_put_byte(Pointer s,
00983             Pointer buffer,
00984             int buffer_size,
00985             int write_flag,
00986             Pointer opaque,
00987             Pointer read_packet,
00988             Pointer write_packet,
00989             Pointer seek);
00990 
00991         void put_byte(ByteIOContext s, int b);
00992         void put_buffer(ByteIOContext s, Pointer buf, int size);
00993         void put_le64(ByteIOContext s, long val);
00994         void put_be64(ByteIOContext s, long val);
00995         void put_le32(ByteIOContext s, int val);
00996         void put_be32(ByteIOContext s, int val);
00997         void put_le24(ByteIOContext s, int val);
00998         void put_be24(ByteIOContext s, int val);
00999         void put_le16(ByteIOContext s, int val);
01000         void put_be16(ByteIOContext s, int val);
01001         void put_tag(ByteIOContext s, String tag);
01002         
01003         void put_strz(ByteIOContext s, String buf);
01004         
01005         long url_fseek(ByteIOContext s, long offset, int whence);
01006         void url_fskip(ByteIOContext s, long offset);
01007         long url_ftell(ByteIOContext s);
01008         long url_fsize(ByteIOContext s);
01009         int url_feof(ByteIOContext s);
01010         int url_ferror(ByteIOContext s);
01011         
01012         public static final int URL_EOF = -1;
01013         int url_fgetc(ByteIOContext s);
01014         
01015 //      /** @warning currently size is limited */
01016 //      #ifdef __GNUC__
01017 //      int url_fprintf(ByteIOContext s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
01018 //      #else
01019 //      int url_fprintf(ByteIOContext s, const char *fmt, ...);
01020 //      #endif
01021 // TODO: don't know how to map url_fprintf with JNA, given variable parameters.
01022         
01025         Pointer url_fgets(ByteIOContext s, Pointer buf, int buf_size);
01026         
01027         void put_flush_packet(ByteIOContext s);
01028         
01029         int get_buffer(ByteIOContext s, Pointer buf, int size);
01030         int get_partial_buffer(ByteIOContext s, Pointer buf, int size);
01031         
01034         int get_byte(ByteIOContext s);
01035         int get_le24(ByteIOContext s);
01036         int get_le32(ByteIOContext s);
01037         long get_le64(ByteIOContext s);
01038         int get_le16(ByteIOContext s);
01039         
01040         Pointer get_strz(ByteIOContext s, Pointer buf, int maxlen);
01041         int get_be16(ByteIOContext s);
01042         int get_be24(ByteIOContext s);
01043         int get_be32(ByteIOContext s);
01044         long get_be64(ByteIOContext s);
01045         
01046 //      static inline int url_is_streamed(ByteIOContext s)
01047 //      {
01048 //      return s->is_streamed;
01049 //      }
01050         // TODO: cannot call inlined functions with JNA.
01051         
01052         int url_fdopen(ByteIOContext s, Pointer h);
01053         
01055         int url_setbufsize(ByteIOContext s, int buf_size);
01056         
01059         int url_fopen(ByteIOContext s, String filename, int flags);
01060         int url_fclose(ByteIOContext s);
01061         URLContext url_fileno(ByteIOContext s);
01062         
01071         int url_fget_max_packet_size(Pointer s);
01072         
01073         int url_open_buf(ByteIOContext s, Pointer buf, int buf_size, int flags);
01074         
01076         int url_close_buf(ByteIOContext s);
01077         
01084         int url_open_dyn_buf(ByteIOContext s);
01085         
01095         int url_open_dyn_packet_buf(ByteIOContext s, int max_packet_size);
01096         
01104         int url_close_dyn_buf(ByteIOContext s, PointerByReference pbuffer);
01105         
01106         NativeLong get_checksum(ByteIOContext s);
01107         void init_checksum(ByteIOContext s, Pointer update_checksum, NativeLong checksum);
01108         
01109         /* file.c */
01110 //      extern URLProtocol file_protocol;
01111 //      extern URLProtocol pipe_protocol;
01112 //      
01113 //      /* udp.c */
01114 //      extern URLProtocol udp_protocol;
01115         // TODO: JNA does not allow access to global variables
01116         
01117         int udp_set_remote_url(URLContext h, String uri);
01118         int udp_get_local_port(URLContext h);
01119         int udp_get_file_handle(URLContext h);
01120         
01121 //      /* tcp.c  */
01122 //      extern URLProtocol tcp_protocol;
01123 //      
01124 //      /* http.c */
01125 //      extern URLProtocol http_protocol;
01126         // TODO: JNA does not allow access to global variables
01127         
01128 // end avio.h
01129 //------------------------------------------------------------------------------------------------------------------------
01130 
01131         
01132 }
01133 

Generated on Tue Apr 7 17:57:19 2009 for visclient by  doxygen 1.5.1