1 package com.hammurapi.jcapture; 2 3 import java.awt.Component; 4 import java.awt.Dimension; 5 import java.awt.Point; 6 import java.io.File; 7 import java.io.OutputStream; 8 import java.util.List; 9 10 /** 11 * This is a service interface to be implemented by video encoders. 12 * jCapture discovers encoders using java.util.ServiceLoader. 13 * 14 * All interfaces used by this interface are defined as nested for easy reference. 15 * @author Pavel 16 * 17 */ 18 public interface VideoEncoder { 19 20 interface Config { 21 22 /** 23 * 24 * @return true if encoder shall add a toolbar to the movie. 25 */ isToolBar()26 boolean isToolBar(); 27 28 /** 29 * 30 * @return true if movie shall be played in a loop. 31 */ isLoop()32 boolean isLoop(); 33 34 /** 35 * 36 * @return true if movie shall start playing after downloading. 37 */ isPlay()38 boolean isPlay(); 39 40 /** 41 * @return For scaling mouse pointer. 42 */ getScreenScale()43 double getScreenScale(); 44 45 /** 46 * For progress monitor. 47 * @return 48 */ getParentComponent()49 Component getParentComponent(); 50 getImageFormat()51 String getImageFormat(); 52 53 /** 54 * @return OS command to convert WAV to MP3 if encoder requires/benefits from it. 55 */ getMp3command()56 String getMp3command(); 57 } 58 59 /** 60 * Movie fragment is a collection of frames with associated audio. 61 * @author Pavel 62 * 63 */ 64 interface Fragment { 65 66 /** 67 * Frame contains zero or more shapes and mouse location. 68 * @author Pavel 69 * 70 */ 71 interface Frame { 72 isActive()73 boolean isActive(); 74 75 /** 76 * Image shape to be placed on the screen. 77 * @author Pavel 78 * 79 */ 80 interface Shape { 81 82 /** 83 * Base interface for shape content. 84 * @author Pavel 85 * 86 */ 87 interface ShapeContent { 88 89 /** 90 * @return true if this shape covers the entire screen area. 91 */ coversEverything()92 boolean coversEverything(); 93 } 94 95 interface Image extends ShapeContent { 96 getImage()97 MappedImage getImage(); 98 99 } 100 101 /** 102 * References already defined image. 103 * @author Pavel 104 * 105 */ 106 interface ImageReference extends ShapeContent { 107 getImage()108 Image getImage(); 109 110 } 111 getLocation()112 Point getLocation(); 113 getContent()114 ShapeContent getContent(); 115 116 } 117 118 /** 119 * Frame's shapes. 120 * @return 121 */ getShapes()122 List<Shape> getShapes(); 123 getMousePointer()124 Point getMousePointer(); 125 getSize()126 Dimension getSize(); 127 128 } 129 130 /** 131 * Fragment frames. 132 * @return 133 */ getFrames()134 List<Frame> getFrames(); 135 136 /** 137 * Audio file (WAV). 138 * @return 139 */ getAudio()140 File getAudio(); 141 142 } 143 getFileExtension()144 String getFileExtension(); 145 getMimeType()146 String getMimeType(); 147 148 /** 149 * This method shall return output format name, e.g. SWF. 150 * @return 151 */ toString()152 String toString(); 153 154 /** 155 * Encodes video to output stream. 156 * @param fragments Fragments to encode 157 * @param out Output stream 158 * @param progressMonitor Progress monitor has work allocated for each frame plus one unit of work per fragment for sound decoding plus one unit for final encoding. 159 * @param progressCounter current progress counter position. 160 * @return movie size or null if operation was cancelled 161 */ encode(Config config, Movie movie, OutputStream out)162 Dimension encode(Config config, Movie movie, OutputStream out) throws Exception; 163 164 } 165