001/******************************************************************************* 002 * Copyright (c) 2024, 2026, Olivier Ayache. All rights reserved. 003 * 004 * This file is part of AVPKit. 005 * 006 * AVPKit is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU Lesser General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * AVPKit is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public License 017 * along with AVPKit. If not, see <http://www.gnu.org/licenses/>. 018 *******************************************************************************/ 019 020package com.avpkit.mediatool.event; 021 022import java.awt.image.BufferedImage; 023import java.util.concurrent.TimeUnit; 024 025import com.avpkit.mediatool.IMediaGenerator; 026import com.avpkit.core.IVideoPicture; 027 028/** 029 * An implementation of {@link IVideoPictureEvent}. 030 * 031 * @author aclarke 032 * 033 */ 034public class VideoPictureEvent extends ARawMediaMixin implements 035 IVideoPictureEvent 036{ 037 038 /** 039 * Creates a {@link VideoPictureEvent}. If <code>image</code> is not null and 040 * <code>picture</code> is not null, then <code>image</code> prevails. 041 * 042 * @param source the source of this event. 043 * @param picture the raw {@link IVideoPicture} for this event. Can be null if 044 * <code>image</code> is not null. 045 * @param image the raw {@link BufferedImage} for this event. Can be null if 046 * <code>picture</code> is not null. 047 * @param timeStamp if <code>image</code> is not null, this is the timeStamp 048 * of <code>image</code> 049 * @param timeUnit if <code>image</code> is not null, this is the timeUnit of 050 * <code>timeStamp</code> 051 * @param streamIndex the stream this event occurred on, or null if unknown. 052 * @throws IllegalArgumentException if both <code>picture</code> and 053 * <code>image</code> are null. 054 */ 055 public VideoPictureEvent(IMediaGenerator source, IVideoPicture picture, 056 BufferedImage image, long timeStamp, TimeUnit timeUnit, 057 Integer streamIndex) 058 { 059 super(source, picture, image, timeStamp, timeUnit, streamIndex); 060 } 061 062 /** 063 * Creates a {@link VideoPictureEvent}. 064 * 065 * @param source the source of this event. 066 * @param picture the raw {@link IVideoPicture} for this event. 067 * @param streamIndex the stream this event occurred on, or null if unknown. 068 * @throws IllegalArgumentException if picture is null. 069 */ 070 public VideoPictureEvent(IMediaGenerator source, IVideoPicture picture, 071 Integer streamIndex) 072 { 073 this(source, picture, null, 0, null, streamIndex); 074 } 075 076 /** 077 * Creates a {@link VideoPictureEvent}. 078 * 079 * @param source the source of this event. 080 * @param image the raw {@link BufferedImage} for this event. 081 * @param timeStamp the timeStamp of <code>image</code> 082 * @param timeUnit the timeUnit of <code>timeStamp</code> 083 * @param streamIndex the stream this event occurred on, or null if unknown. 084 * @throws IllegalArgumentException if image is null. 085 */ 086 public VideoPictureEvent(IMediaGenerator source, BufferedImage image, 087 long timeStamp, TimeUnit timeUnit, Integer streamIndex) 088 { 089 this(source, null, image, timeStamp, timeUnit, streamIndex); 090 } 091 092 /** 093 * An implementation of {@link IVideoPictureEvent#getMediaData()}. 094 * 095 * @see IVideoPictureEvent#getMediaData() 096 */ 097 @Override 098 public IVideoPicture getMediaData() 099 { 100 return (IVideoPicture) super.getMediaData(); 101 } 102 103 /** 104 * An implementation of {@link IVideoPictureEvent#getPicture()}. 105 * 106 * @see IVideoPictureEvent#getPicture() 107 */ 108 public IVideoPicture getPicture() 109 { 110 return getMediaData(); 111 } 112 113 /** 114 * An implementation of {@link IVideoPictureEvent#getImage()}. 115 * 116 * @see IVideoPictureEvent#getImage() 117 */ 118 public BufferedImage getImage() 119 { 120 return getJavaData(); 121 } 122 123 /** 124 * An implementation of {@link IVideoPictureEvent#getJavaData()}. 125 * 126 * @see IVideoPictureEvent#getJavaData() 127 */ 128 public BufferedImage getJavaData() 129 { 130 return (BufferedImage) super.getJavaData(); 131 } 132}