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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
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
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 void av_free_packet(AVPacket pkt);
00096
00097
00098
00099
00100
00101 public static class AVFrac extends Structure
00102 {
00103 public long val;
00104 public long num;
00105 public long den;
00106 }
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
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
00139
00140
00141 public Pointer standard;
00142 public int bitFields;
00143
00144
00145
00146
00147
00148
00149
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
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
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
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
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
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
00324
00325
00326
00327
00328
00329
00330
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;
00338
00339
00340 public int min_distance;
00341 }
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
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
00416
00417
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
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
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
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 }
00596
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
00649
00650
00651
00652
00653 public static class AVPacketList extends Structure
00654 {
00655 public AVPacket pkt;
00656 public Pointer next;
00657 }
00658
00659
00660
00661
00662
00663
00664
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
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
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
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
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
00879 public Pointer filename;
00880
00881
00882
00883
00884 }
00885
00886
00887
00888
00889
00890
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
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 interrupt_cb);
00916 int url_poll(URLPollEntry poll_table, int n, int timeout);
00917 public static final int AVSEEK_SIZE = 0x10000;
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
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
01016
01017
01018
01019
01020
01021
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
01047
01048
01049
01050
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
01110
01111
01112
01113
01114
01115
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
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132 }
01133