001/* ---------------------------------------------------------------------------- 002 * This file was automatically generated by SWIG (http://www.swig.org). 003 * Version 4.0.2 004 * 005 * Do not make changes to this file unless you know what you are doing--modify 006 * the SWIG interface file instead. 007 * ----------------------------------------------------------------------------- */ 008 009package com.avpkit.core; 010import com.avpkit.ferry.*; 011/** 012 * An index entry for a {IStream}.<br> 013 * <p><br> 014 * Some ContainerFormats can maintain index of where key-frames<br> 015 * (and other interesting frames) can be found in a byte-stream.<br> 016 * This is really helpful for implementing efficient seeking (for<br> 017 * example, you can find all index entries near a desired timestamp,<br> 018 * and you'll find the nearest key-frame).<br> 019 * </p><br> 020 * <p><br> 021 * We don't maintain a complete list of all ContainerFormats that support<br> 022 * index, but if they do, you can query the {IStream#getNumIndexEntries()}<br> 023 * method to find how many entires are in the index. Some ContainerFormats can<br> 024 * parse the relevant Container message if an index is embedded in the<br> 025 * container (for example, the MOV and MP4 demuxer can do this). Other<br> 026 * ContainerFormats can create an index automatically as they read the file,<br> 027 * even if an index is not embedded in the container (for example the FLV<br> 028 * demuxer does this).<br> 029 * </p><br> 030 * <br> 031 * @see IStream#findTimeStampEntryInIndex(int,int)<br> 032 * @see IStream#findTimeStampPositionInIndex(int,int)<br> 033 * @see IStream#getIndexEntry(int)<br> 034 * @see IStream#getNumIndexEntries()<br> 035 * @see IStream#getIndexEntries()<br> 036 * @since 3.4 037 */ 038public class IIndexEntry extends RefCounted { 039 // JNIHelper.swg: Start generated code 040 // >>>>>>>>>>>>>>>>>>>>>>>>>>> 041 /** 042 * This method is only here to use some references and remove 043 * a Eclipse compiler warning. 044 */ 045 @SuppressWarnings("unused") 046 private void noop() 047 { 048 IBuffer.make(null, 1); 049 } 050 051 private volatile long swigCPtr; 052 053 /** 054 * Internal Only. 055 */ 056 protected IIndexEntry(long cPtr, boolean cMemoryOwn) { 057 super(AVPKitJNI.IIndexEntry_SWIGUpcast(cPtr), cMemoryOwn); 058 swigCPtr = cPtr; 059 } 060 061 /** 062 * Internal Only. 063 */ 064 protected IIndexEntry(long cPtr, boolean cMemoryOwn, 065 java.util.concurrent.atomic.AtomicLong ref) 066 { 067 super(AVPKitJNI.IIndexEntry_SWIGUpcast(cPtr), 068 cMemoryOwn, ref); 069 swigCPtr = cPtr; 070 } 071 072 /** 073 * Internal Only. Not part of public API. 074 * 075 * Get the raw value of the native object that obj is proxying for. 076 * 077 * @param obj The java proxy object for a native object. 078 * @return The raw pointer obj is proxying for. 079 */ 080 public static long getCPtr(IIndexEntry obj) { 081 if (obj == null) return 0; 082 return obj.getMyCPtr(); 083 } 084 085 /** 086 * Internal Only. Not part of public API. 087 * 088 * Get the raw value of the native object that we're proxying for. 089 * 090 * @return The raw pointer we're proxying for. 091 */ 092 public long getMyCPtr() { 093 if (swigCPtr == 0) throw new IllegalStateException("underlying native object already deleted"); 094 return swigCPtr; 095 } 096 097 /** 098 * Create a new IIndexEntry object that is actually referring to the 099 * exact same underlying native object. 100 * 101 * @return the new Java object. 102 */ 103 @Override 104 public IIndexEntry copyReference() { 105 if (swigCPtr == 0) 106 return null; 107 else 108 return new IIndexEntry(swigCPtr, swigCMemOwn, getJavaRefCount()); 109 } 110 111 /** 112 * Compares two values, returning true if the underlying objects in native code are the same object. 113 * 114 * That means you can have two different Java objects, but when you do a comparison, you'll find out 115 * they are the EXACT same object. 116 * 117 * @return True if the underlying native object is the same. False otherwise. 118 */ 119 public boolean equals(Object obj) { 120 boolean equal = false; 121 if (obj instanceof IIndexEntry) 122 equal = (((IIndexEntry)obj).swigCPtr == this.swigCPtr); 123 return equal; 124 } 125 126 /** 127 * Get a hashable value for this object. 128 * 129 * @return the hashable value. 130 */ 131 public int hashCode() { 132 return (int)swigCPtr; 133 } 134 135 // <<<<<<<<<<<<<<<<<<<<<<<<<<< 136 // JNIHelper.swg: End generated code 137 138 /** 139 * info about this entry. 140 * @return information about this entry. 141 */ 142 143 @Override 144 public String toString() 145 { 146 StringBuilder result = new StringBuilder(); 147 148 result.append(this.getClass().getName()+"@"+hashCode()+"["); 149 result.append("position:"+getPosition()+";"); 150 result.append("timestamp:"+getTimeStamp()+";"); 151 result.append("flags:"+getFlags()+";"); 152 result.append("size:"+getSize()+";"); 153 result.append("min-distance:"+getMinDistance()+";"); 154 result.append("]"); 155 return result.toString(); 156 } 157 158 159 160 /** 161 * Create a new {IIndexEntry} with the specified<br> 162 * values.<br> 163 * <br> 164 * @param position The value to be returned from {#getPosition()}.<br> 165 * @param timeStamp The value to be returned from {#getTimeStamp()}.<br> 166 * @param flags The value to be returned from {#getFlags()}.<br> 167 * @param size The value to be returned from {#getSize()}.<br> 168 * @param minDistance The value to be returned from {#getMinDistance()}. 169 */ 170 public static IIndexEntry make(long position, long timeStamp, int flags, int size, int minDistance) { 171 long cPtr = AVPKitJNI.IIndexEntry_make(position, timeStamp, flags, size, minDistance); 172 return (cPtr == 0) ? null : new IIndexEntry(cPtr, false); 173 } 174 175 /** 176 * The position in bytes of the frame corresponding to this index entry<br> 177 * in the {IContainer}.<br> 178 * @return The byte-offset from start of the IContainer where the<br> 179 * frame for this {IIndexEntry} can be found. 180 */ 181 public long getPosition() { 182 return AVPKitJNI.IIndexEntry_getPosition(swigCPtr, this); 183 } 184 185 /** 186 * The actual time stamp, in units of {IStream#getTimeBase()}, of the frame this entry points to.<br> 187 * @return The time stamp for this entry. 188 */ 189 public long getTimeStamp() { 190 return AVPKitJNI.IIndexEntry_getTimeStamp(swigCPtr, this); 191 } 192 193 /** 194 * Flags set for this entry. See the IINDEX_FLAG* constants<br> 195 * above.<br> 196 * @return the flags. 197 */ 198 public int getFlags() { 199 return AVPKitJNI.IIndexEntry_getFlags(swigCPtr, this); 200 } 201 202 /** 203 * The size of bytes of the frame this index entry points to.<br> 204 * @return The size in bytes. 205 */ 206 public int getSize() { 207 return AVPKitJNI.IIndexEntry_getSize(swigCPtr, this); 208 } 209 210 /** 211 * Minimum number of index entries between this index entry<br> 212 * and the last keyframe in the index, used to avoid unneeded searching.<br> 213 * @return the minimum distance, in bytes. 214 */ 215 public int getMinDistance() { 216 return AVPKitJNI.IIndexEntry_getMinDistance(swigCPtr, this); 217 } 218 219 /** 220 * Is this index entry pointing to a key frame.<br> 221 * Really shorthand for <code>{#getFlags()} & {#IINDEX_FLAG_KEYFRAME}</code>.<br> 222 * @return True if this index entry is for a key frame. 223 */ 224 public boolean isKeyFrame() { 225 return AVPKitJNI.IIndexEntry_isKeyFrame(swigCPtr, this); 226 } 227 228 /** 229 * A bit mask value that may be set in {#getFlags}. 230 */ 231 public final static int IINDEX_FLAG_KEYFRAME = AVPKitJNI.IIndexEntry_IINDEX_FLAG_KEYFRAME_get(); 232}