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 * Represents one raw (undecoded) picture in a video stream, plus a timestamp<br> 013 * for when to display that video picture relative to other items in a {IContainer}.<br> 014 * <p><br> 015 * All timestamps for this object are always in Microseconds.<br> 016 * </p> 017 */ 018public class IVideoPicture extends IMediaData { 019 // JNIHelper.swg: Start generated code 020 // >>>>>>>>>>>>>>>>>>>>>>>>>>> 021 /** 022 * This method is only here to use some references and remove 023 * a Eclipse compiler warning. 024 */ 025 @SuppressWarnings("unused") 026 private void noop() 027 { 028 IBuffer.make(null, 1); 029 } 030 031 private volatile long swigCPtr; 032 033 /** 034 * Internal Only. 035 */ 036 protected IVideoPicture(long cPtr, boolean cMemoryOwn) { 037 super(AVPKitJNI.IVideoPicture_SWIGUpcast(cPtr), cMemoryOwn); 038 swigCPtr = cPtr; 039 } 040 041 /** 042 * Internal Only. 043 */ 044 protected IVideoPicture(long cPtr, boolean cMemoryOwn, 045 java.util.concurrent.atomic.AtomicLong ref) 046 { 047 super(AVPKitJNI.IVideoPicture_SWIGUpcast(cPtr), 048 cMemoryOwn, ref); 049 swigCPtr = cPtr; 050 } 051 052 /** 053 * Internal Only. Not part of public API. 054 * 055 * Get the raw value of the native object that obj is proxying for. 056 * 057 * @param obj The java proxy object for a native object. 058 * @return The raw pointer obj is proxying for. 059 */ 060 public static long getCPtr(IVideoPicture obj) { 061 if (obj == null) return 0; 062 return obj.getMyCPtr(); 063 } 064 065 /** 066 * Internal Only. Not part of public API. 067 * 068 * Get the raw value of the native object that we're proxying for. 069 * 070 * @return The raw pointer we're proxying for. 071 */ 072 public long getMyCPtr() { 073 if (swigCPtr == 0) throw new IllegalStateException("underlying native object already deleted"); 074 return swigCPtr; 075 } 076 077 /** 078 * Create a new IVideoPicture object that is actually referring to the 079 * exact same underlying native object. 080 * 081 * @return the new Java object. 082 */ 083 @Override 084 public IVideoPicture copyReference() { 085 if (swigCPtr == 0) 086 return null; 087 else 088 return new IVideoPicture(swigCPtr, swigCMemOwn, getJavaRefCount()); 089 } 090 091 /** 092 * Compares two values, returning true if the underlying objects in native code are the same object. 093 * 094 * That means you can have two different Java objects, but when you do a comparison, you'll find out 095 * they are the EXACT same object. 096 * 097 * @return True if the underlying native object is the same. False otherwise. 098 */ 099 public boolean equals(Object obj) { 100 boolean equal = false; 101 if (obj instanceof IVideoPicture) 102 equal = (((IVideoPicture)obj).swigCPtr == this.swigCPtr); 103 return equal; 104 } 105 106 /** 107 * Get a hashable value for this object. 108 * 109 * @return the hashable value. 110 */ 111 public int hashCode() { 112 return (int)swigCPtr; 113 } 114 115 // <<<<<<<<<<<<<<<<<<<<<<<<<<< 116 // JNIHelper.swg: End generated code 117 118 119 /** 120 * info about this packet 121 * @return information about this packet 122 */ 123 124 @Override 125 public String toString() 126 { 127 StringBuilder result = new StringBuilder(); 128 129 result.append(this.getClass().getName()+"@"+hashCode()+"["); 130 result.append("pixel type:"+getPixelType()+";"); 131 result.append("width:"+getWidth()+";"); 132 result.append("height:"+getHeight()+";"); 133 result.append("time stamp:"+getTimeStamp()+";"); 134 result.append("complete:"+isComplete()+";"); 135 result.append("size:"+getSize()+";"); 136 result.append("key:"+isKey()+";"); 137 IRational timeBase = IRational.make(1,(int)Global.DEFAULT_PTS_PER_SECOND); 138 result.append("time base:"+timeBase+";"); 139 if (timeBase != null) timeBase.delete(); 140 result.append("]"); 141 return result.toString(); 142 } 143 144 145 /** 146 * Is this a key frame?<br> 147 * <br> 148 * @return is this a key frame 149 */ 150 public boolean isKeyFrame() { 151 return AVPKitJNI.IVideoPicture_isKeyFrame(swigCPtr, this); 152 } 153 154 /** 155 * Reset if this is a key frame or not. Note that regardless of how<br> 156 * this flag is set, an IVideoPicture always contains raw video data (hence the<br> 157 * key setting isn't really that important).<br> 158 * <br> 159 * @param aIsKey True if a key frame; false if not. 160 */ 161 public void setKeyFrame(boolean aIsKey) { 162 AVPKitJNI.IVideoPicture_setKeyFrame(swigCPtr, this, aIsKey); 163 } 164 165 /** 166 * Is this picture completely decoded?<br> 167 * <br> 168 * @return is this picture completely decoded? 169 */ 170 public boolean isComplete() { 171 return AVPKitJNI.IVideoPicture_isComplete(swigCPtr, this); 172 } 173 174 /** 175 * Total size in bytes of the decoded picture.<br> 176 * <br> 177 * @return number of bytes of decoded picture 178 */ 179 public int getSize() { 180 return AVPKitJNI.IVideoPicture_getSize(swigCPtr, this); 181 } 182 183 /** 184 * What is the width of the picture.<br> 185 * <br> 186 * @return the width of the picture 187 */ 188 public int getWidth() { 189 return AVPKitJNI.IVideoPicture_getWidth(swigCPtr, this); 190 } 191 192 /** 193 * What is the height of the picture<br> 194 * <br> 195 * @return the height of the picture 196 */ 197 public int getHeight() { 198 return AVPKitJNI.IVideoPicture_getHeight(swigCPtr, this); 199 } 200 201 /** 202 * Returns the pixel format of the picture.<br> 203 * <br> 204 * @return the pixel format of the picture. 205 */ 206 public IPixelFormat.Type getPixelType() { 207 return IPixelFormat.Type.swigToEnum(AVPKitJNI.IVideoPicture_getPixelType(swigCPtr, this)); 208 } 209 210 /** 211 * What is the Presentation Time Stamp (in Microseconds) of this picture.<br> 212 * <br> 213 * The PTS is is scaled so that 1 PTS = <br> 214 * 1/1,000,000 of a second.<br> 215 * <br> 216 * @return the presentation time stamp (pts) 217 */ 218 public long getPts() { 219 return AVPKitJNI.IVideoPicture_getPts(swigCPtr, this); 220 } 221 222 /** 223 * Set the Presentation Time Stamp (in Microseconds) for this picture.<br> 224 * <br> 225 * @see #getPts()<br> 226 * <br> 227 * @param value the new timestamp 228 */ 229 public void setPts(long value) { 230 AVPKitJNI.IVideoPicture_setPts(swigCPtr, this, value); 231 } 232 233 /** 234 * This value is the quality setting this VideoPicture had when it was<br> 235 * decoded, or is the value to use when this picture is next<br> 236 * encoded (if reset with setQuality()<br> 237 * <br> 238 * @return The quality. 239 */ 240 public int getQuality() { 241 return AVPKitJNI.IVideoPicture_getQuality(swigCPtr, this); 242 } 243 244 /** 245 * Set the Quality to a new value. This will be used the<br> 246 * next time this VideoPicture is encoded by a StreamCoder<br> 247 * <br> 248 * @param newQuality The new quality. 249 */ 250 public void setQuality(int newQuality) { 251 AVPKitJNI.IVideoPicture_setQuality(swigCPtr, this, newQuality); 252 } 253 254 /** 255 * Return the size of each line in the VideoPicture data. Usually there<br> 256 * are no more than 4 lines, but the first line no that returns 0<br> 257 * is the end of the road.<br> 258 * <br> 259 * @param lineNo The line you want to know the (byte) size of.<br> 260 * <br> 261 * @return The size (in bytes) of that line in data. 262 */ 263 public int getDataLineSize(int lineNo) { 264 return AVPKitJNI.IVideoPicture_getDataLineSize(swigCPtr, this, lineNo); 265 } 266 267 /** 268 * After modifying the raw data in this buffer, call this function to<br> 269 * let the object know it is now complete.<br> 270 * <br> 271 * @param aIsComplete Is this VideoPicture complete<br> 272 * @param format The pixel format of the data in this picture. Must match<br> 273 * what the picture was originally constructed with.<br> 274 * @param width The width of the data in this picture. Must match what<br> 275 * the picture was originally constructed with.<br> 276 * @param height The height of the data in this picture. Must match what<br> 277 * the picture was originally constructed with.<br> 278 * @param pts The presentation timestamp of the picture that is now complete.<br> 279 * The caller must ensure this PTS is in units of 1/1,000,000 seconds. 280 */ 281 public void setComplete(boolean aIsComplete, IPixelFormat.Type format, int width, int height, long pts) { 282 AVPKitJNI.IVideoPicture_setComplete(swigCPtr, this, aIsComplete, format.swigValue(), width, height, pts); 283 } 284 285 /** 286 * Copy the contents of the given picture into this picture. All<br> 287 * buffers are copied by value, not be reference.<br> 288 * <br> 289 * @param srcPicture The picture you want to copy.<br> 290 * <br> 291 * @return true if a successful copy; false if not. 292 */ 293 public boolean copy(IVideoPicture srcPicture) { 294 return AVPKitJNI.IVideoPicture_copy(swigCPtr, this, IVideoPicture.getCPtr(srcPicture), srcPicture); 295 } 296 297 /** 298 * Render this picture on configured surface. <br> 299 * Works only with HW accelerated {com.avpkit.core.IPixelFormat}.<br> 300 * {com.avpkit.core.IStreamCoder#setHardwareDecoding(IPixelFormat.Type, Object)} <br> 301 * must be called before opening decoder. 302 */ 303 public void render(boolean drop, long timeStamp) { 304 AVPKitJNI.IVideoPicture_render__SWIG_0(swigCPtr, this, drop, timeStamp); 305 } 306 307 /** 308 * Render this picture on configured surface. <br> 309 * Works only with HW accelerated {com.avpkit.core.IPixelFormat}.<br> 310 * {com.avpkit.core.IStreamCoder#setHardwareDecoding(IPixelFormat.Type, Object)} <br> 311 * must be called before opening decoder. 312 */ 313 public void render(boolean drop) { 314 AVPKitJNI.IVideoPicture_render__SWIG_1(swigCPtr, this, drop); 315 } 316 317 /** 318 * Render this picture on configured surface. <br> 319 * Works only with HW accelerated {com.avpkit.core.IPixelFormat}.<br> 320 * {com.avpkit.core.IStreamCoder#setHardwareDecoding(IPixelFormat.Type, Object)} <br> 321 * must be called before opening decoder. 322 */ 323 public void render() { 324 AVPKitJNI.IVideoPicture_render__SWIG_2(swigCPtr, this); 325 } 326 327 /** 328 * Get a new picture object.<br> 329 * <p><br> 330 * You can specify -1 for width and height, in which case all getData() methods<br> 331 * will return error until AVPKIT decodes something into this frame. In general<br> 332 * you should always try to specify the width and height.<br> 333 * </p><br> 334 * <p><br> 335 * Note that any buffers this objects needs will be<br> 336 * lazily allocated (i.e. we won't actually grab all<br> 337 * the memory until we need it).<br> 338 * </p><br> 339 * <p>This is useful because<br> 340 * it allows you to hold a IVideoPicture object that remembers<br> 341 * things like format, width, and height, but know<br> 342 * that it doesn't actually take up a lot of memory until<br> 343 * the first time someone tries to access that memory.<br> 344 * </p><br> 345 * @param format The pixel format (for example, YUV420P).<br> 346 * @param width The width of the picture, in pixels, or -1 if you want AVPKIT to guess when decoding.<br> 347 * @param height The height of the picture, in pixels, or -1 if you want AVPKIT to guess when decoding.<br> 348 * @return A new object, or null if we can't allocate one. 349 */ 350 public static IVideoPicture make(IPixelFormat.Type format, int width, int height) { 351 long cPtr = AVPKitJNI.IVideoPicture_make__SWIG_0(format.swigValue(), width, height); 352 return (cPtr == 0) ? null : new IVideoPicture(cPtr, false); 353 } 354 355 /** 356 * Get a new picture by copying the data in an existing frame.<br> 357 * @param src The picture to copy.<br> 358 * @return The new picture, or null on error. 359 */ 360 public static IVideoPicture make(IVideoPicture src) { 361 long cPtr = AVPKitJNI.IVideoPicture_make__SWIG_1(IVideoPicture.getCPtr(src), src); 362 return (cPtr == 0) ? null : new IVideoPicture(cPtr, false); 363 } 364 365 /** 366 * Get the picture type.<br> 367 * <p><br> 368 * This will be set on decoding to tell you what type of<br> 369 * packet this was decoded from, and when encoding<br> 370 * is a request to the encoder for how to encode the picture.<br> 371 * </p><br> 372 * <p><br> 373 * The request may be ignored by your codec.<br> 374 * </p><br> 375 * @return the picture type. 376 */ 377 public IVideoPicture.PictType getPictureType() { 378 return IVideoPicture.PictType.swigToEnum(AVPKitJNI.IVideoPicture_getPictureType(swigCPtr, this)); 379 } 380 381 /** 382 * Set the picture type.<br> 383 * <br> 384 * @param type The type.<br> 385 * <br> 386 * @see #getPictureType() 387 */ 388 public void setPictureType(IVideoPicture.PictType type) { 389 AVPKitJNI.IVideoPicture_setPictureType(swigCPtr, this, type.swigValue()); 390 } 391 392 public void setSideData(IVideoPicture.FrameDataType type, IBuffer buffer) { 393 AVPKitJNI.IVideoPicture_setSideData(swigCPtr, this, type.swigValue(), IBuffer.getCPtr(buffer), buffer); 394 } 395 396 /** 397 * Get a new picture object, by wrapping an existing<br> 398 * {com.avpkit.ferry.IBuffer}.<br> 399 * <p><br> 400 * Use this method if you have existing video data that you want<br> 401 * to have us wrap and pass to FFmpeg. Note that if decoding<br> 402 * into this video picture and the decoded data actually takes more<br> 403 * space than is in this buffer, this object will release the reference<br> 404 * to the passed in buffer and allocate a new buffer instead so the decode<br> 405 * can continue.<br> 406 * </p><br> 407 * <p><br> 408 * Due to some decoders assembly optimizations, you should ensure the<br> 409 * IBuffer you pass in has at least 8 more bytes than would typically<br> 410 * be required based on the format, width and height.<br> 411 * </p><br> 412 * @param buffer The {com.avpkit.ferry.IBuffer} to wrap.<br> 413 * @param format The pixel format (for example, YUV420P).<br> 414 * @param width The width of the picture, in pixels.<br> 415 * @param height The height of the picture, in pixels.<br> 416 * @return A new object, or null if we can't allocate one. 417 */ 418 public static IVideoPicture make(IBuffer buffer, IPixelFormat.Type format, int width, int height) { 419 long cPtr = AVPKitJNI.IVideoPicture_make__SWIG_2(IBuffer.getCPtr(buffer), buffer, format.swigValue(), width, height); 420 return (cPtr == 0) ? null : new IVideoPicture(cPtr, false); 421 } 422 423 /** 424 * The different types of images that we can set. <br> 425 * <br> 426 * @see #getPictureType() 427 */ 428 public enum PictType { 429 DEFAULT_TYPE(AVPKitJNI.IVideoPicture_DEFAULT_TYPE_get()), 430 I_TYPE(AVPKitJNI.IVideoPicture_I_TYPE_get()), 431 P_TYPE(AVPKitJNI.IVideoPicture_P_TYPE_get()), 432 B_TYPE(AVPKitJNI.IVideoPicture_B_TYPE_get()), 433 S_TYPE(AVPKitJNI.IVideoPicture_S_TYPE_get()), 434 SI_TYPE(AVPKitJNI.IVideoPicture_SI_TYPE_get()), 435 SP_TYPE(AVPKitJNI.IVideoPicture_SP_TYPE_get()), 436 BI_TYPE(AVPKitJNI.IVideoPicture_BI_TYPE_get()); 437 438 public final int swigValue() { 439 return swigValue; 440 } 441 442 public static PictType swigToEnum(int swigValue) { 443 PictType[] swigValues = PictType.class.getEnumConstants(); 444 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) 445 return swigValues[swigValue]; 446 for (PictType swigEnum : swigValues) 447 if (swigEnum.swigValue == swigValue) 448 return swigEnum; 449 throw new IllegalArgumentException("No enum " + PictType.class + " with value " + swigValue); 450 } 451 452 @SuppressWarnings("unused") 453 private PictType() { 454 this.swigValue = SwigNext.next++; 455 } 456 457 @SuppressWarnings("unused") 458 private PictType(int swigValue) { 459 this.swigValue = swigValue; 460 SwigNext.next = swigValue+1; 461 } 462 463 @SuppressWarnings("unused") 464 private PictType(PictType swigEnum) { 465 this.swigValue = swigEnum.swigValue; 466 SwigNext.next = this.swigValue+1; 467 } 468 469 private final int swigValue; 470 471 private static class SwigNext { 472 private static int next = 0; 473 } 474 } 475 476 public enum FrameDataType { 477 /** 478 * The data is the AVPanScan struct defined in libavcodec. 479 */ 480 AV_FRAME_DATA_PANSCAN, 481 /** 482 * ATSC A53 Part 4 Closed Captions.<br> 483 * A53 CC bitstream is stored as uint8_t in AVFrameSideData.data.<br> 484 * The number of bytes of CC data is AVFrameSideData.size. 485 */ 486 AV_FRAME_DATA_A53_CC, 487 /** 488 * Stereoscopic 3d metadata.<br> 489 * The data is the AVStereo3D struct defined in libavutil/stereo3d.h. 490 */ 491 AV_FRAME_DATA_STEREO3D, 492 /** 493 * The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h. 494 */ 495 AV_FRAME_DATA_MATRIXENCODING, 496 /** 497 * Metadata relevant to a downmix procedure.<br> 498 * The data is the AVDownmixInfo struct defined in libavutil/downmix_info.h. 499 */ 500 AV_FRAME_DATA_DOWNMIX_INFO, 501 /** 502 * ReplayGain information in the form of the AVReplayGain struct. 503 */ 504 AV_FRAME_DATA_REPLAYGAIN, 505 /** 506 * This side data contains a 3x3 transformation matrix describing an affine<br> 507 * transformation that needs to be applied to the frame for correct<br> 508 * presentation.<br> 509 * <br> 510 * See libavutil/display.h for a detailed description of the data. 511 */ 512 AV_FRAME_DATA_DISPLAYMATRIX, 513 /** 514 * Active Format Description data consisting of a single byte as specified<br> 515 * in ETSI TS 101 154 using AVActiveFormatDescription enum. 516 */ 517 AV_FRAME_DATA_AFD, 518 /** 519 * Motion vectors exported by some codecs (on demand through the export_mvs<br> 520 * flag set in the libavcodec AVCodecContext flags2 option).<br> 521 * The data is the AVMotionVector struct defined in<br> 522 * libavutil/motion_vector.h. 523 */ 524 AV_FRAME_DATA_MOTION_VECTORS, 525 /** 526 * Recommmends skipping the specified number of samples. This is exported<br> 527 * only if the "skip_manual" AVOption is set in libavcodec.<br> 528 * This has the same format as AV_PKT_DATA_SKIP_SAMPLES.<br> 529 * {@code 530 u32le number of samples to skip from start of this packet 531 u32le number of samples to skip from end of this packet 532 u8 reason for start skip 533 u8 reason for end skip (0=padding silence, 1=convergence) 534 } 535 */ 536 AV_FRAME_DATA_SKIP_SAMPLES, 537 /** 538 * This side data must be associated with an audio frame and corresponds to<br> 539 * enum AVAudioServiceType defined in avcodec.h. 540 */ 541 AV_FRAME_DATA_AUDIO_SERVICE_TYPE, 542 /** 543 * Mastering display metadata associated with a video frame. The payload is<br> 544 * an AVMasteringDisplayMetadata type and contains information about the<br> 545 * mastering display color volume. 546 */ 547 AV_FRAME_DATA_MASTERING_DISPLAY_METADATA, 548 /** 549 * The GOP timecode in 25 bit timecode format. Data format is 64-bit integer.<br> 550 * This is set on the first frame of a GOP that has a temporal reference of 0. 551 */ 552 AV_FRAME_DATA_GOP_TIMECODE, 553 /** 554 * The data represents the AVSphericalMapping structure defined in<br> 555 * libavutil/spherical.h. 556 */ 557 AV_FRAME_DATA_SPHERICAL, 558 /** 559 * Content light level (based on CTA-861.3). This payload contains data in<br> 560 * the form of the AVContentLightMetadata struct. 561 */ 562 AV_FRAME_DATA_CONTENT_LIGHT_LEVEL, 563 /** 564 * The data contains an ICC profile as an opaque octet buffer following the<br> 565 * format described by ISO 15076-1 with an optional name defined in the<br> 566 * metadata key entry "name". 567 */ 568 AV_FRAME_DATA_ICC_PROFILE; 569 570 public final int swigValue() { 571 return swigValue; 572 } 573 574 public static FrameDataType swigToEnum(int swigValue) { 575 FrameDataType[] swigValues = FrameDataType.class.getEnumConstants(); 576 if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) 577 return swigValues[swigValue]; 578 for (FrameDataType swigEnum : swigValues) 579 if (swigEnum.swigValue == swigValue) 580 return swigEnum; 581 throw new IllegalArgumentException("No enum " + FrameDataType.class + " with value " + swigValue); 582 } 583 584 @SuppressWarnings("unused") 585 private FrameDataType() { 586 this.swigValue = SwigNext.next++; 587 } 588 589 @SuppressWarnings("unused") 590 private FrameDataType(int swigValue) { 591 this.swigValue = swigValue; 592 SwigNext.next = swigValue+1; 593 } 594 595 @SuppressWarnings("unused") 596 private FrameDataType(FrameDataType swigEnum) { 597 this.swigValue = swigEnum.swigValue; 598 SwigNext.next = this.swigValue+1; 599 } 600 601 private final int swigValue; 602 603 private static class SwigNext { 604 private static int next = 0; 605 } 606 } 607 608}