View Javadoc

1   package de.desy.acop.video.displayer;
2   
3   import java.util.Date;
4   
5   import de.desy.tine.types.IMAGE;
6   import de.desy.tine.types.IMAGE.FrameHeader;
7   import de.desy.tine.types.IMAGE.SourceHeader;
8   
9   /**
10   * <code>VideoHeaderV3</code> implements reference caching of a Video System v3
11   * (VSv3) data array known as TINE IMAGE datatype for usage with the rest of
12   * Video System v3 Java code.<br>
13   * It contains useful helper functions to decode certain properties of VSv3
14   * header into human-readable format.<br>
15   * <br>
16   * <b>Note:</b>This class is only a very basic construct and might be
17   * substantially changed in future. It fits its purpose currently but will not
18   * win a price for meaningful class design!
19   * 
20   * @deprecated functionality replaced by IMAGE class, not needed
21   *             use directly {@link de.desy.tine.types.IMAGE} instead
22   * @author sweisse, mdavid
23   */
24  
25  public final class VideoHeaderV3 implements Cloneable {
26  
27  	/**
28  	 * referenced frameHeader of private TINE IMAGE
29  	 */
30  	public FrameHeader frameHeader = null;
31  
32  	/**
33  	 * referenced sourceHeader of private TINE IMAGE
34  	 */
35  	public SourceHeader sourceHeader = null;
36  
37  	/**
38  	 * size in bytes of a VSv3 header on transport level
39  	 * 
40  	 * @deprecated use {@link de.desy.tine.types.IMAGE#HEADER_SIZE} instead
41  	 */
42  	public static final int HDRSIZE = 188;
43  
44  	/**
45  	 * maximum size in bytes of a VSv3 image (without header)
46  	 * 
47  	 * @deprecated use {@link de.desy.tine.types.IMAGE#DEFAULT_DATA_SIZE}
48  	 *             instead
49  	 */
50  	public static final int TRANSPORT_LENGTH_V3 = 1024 * 1024 * 6;
51  
52  	/**
53  	 * first magic id for VSv3 'VSV3'
54  	 * 
55  	 * @deprecated use {@link de.desy.tine.types.IMAGE#DEFAULT_BASE_TAG} instead
56  	 */
57  	public static final int CF_IMAGE_MAGIC_01 = 0x33565356; // VSV3
58  
59  	/**
60  	 * cameraPortId is put to if no camera port is set there
61  	 * 
62  	 * @deprecated use {@link de.desy.tine.types.IMAGE#DEFAULT_CAMERA_PORT_ID}
63  	 *             instead
64  	 */
65  	public static final int CF_IMAGE_NO_CAMERA_PORT_ID = 0;
66  
67  	/** second magic id for VSv3 '2008' */
68  	// SW! removed October 1, 2008, because magic02 is not so important
69  	// to have, but a cameraPortId is much more important
70  	// public static final long CF_IMAGE_MAGIC_02 = 0x38303032; // 2008
71  
72  	/**
73  	 * initial IMAGE version
74  	 * 
75  	 * @deprecated use {@link de.desy.tine.types.IMAGE#IMAGE_INITIAL_VERSION}
76  	 *             instead
77  	 */
78  	public static final int CF_IMAGE_INITIAL_VERSION = 0x1;
79  
80  	/**
81  	 * current IMAGE version
82  	 * 
83  	 * @deprecated use {@link de.desy.tine.types.IMAGE#IMAGE_VERSION} instead
84  	 */
85  	public static final int CF_IMAGE_VERSION = CF_IMAGE_INITIAL_VERSION;
86  
87  	/**
88  	 * maximum IMAGE version
89  	 * 
90  	 * @deprecated use {@link de.desy.tine.types.IMAGE#IMAGE_MAX_VERSION}
91  	 *             instead
92  	 */
93  	public static final int CF_IMAGE_MAX_VERSION = CF_IMAGE_INITIAL_VERSION;
94  
95  	/**
96  	 * referenced TINE IMAGE
97  	 */
98  	private IMAGE image;
99  
100 	/**
101 	 * default constructor - deprecated
102 	 */
103 	@SuppressWarnings("unused")
104 	private VideoHeaderV3() {
105 	}
106 
107 	/**
108 	 * The new instance of the class will be a reference to the passed image
109 	 * data.
110 	 * 
111 	 * @param img
112 	 *            image data to wrap inside this class
113 	 */
114 	public VideoHeaderV3(IMAGE img) {
115 		image = img;
116 		sourceHeader = img.getSourceHeader();
117 		frameHeader = img.getFrameHeader();
118 	}
119 
120 	/**
121 	 * returns the image reference currently cached in class.
122 	 * 
123 	 * @return image reference currently cached in class
124 	 */
125 	public IMAGE getImage() {
126 		return image;
127 	}
128 
129 	/**
130 	 * decodes timestamp of video frame into java Date class
131 	 * 
132 	 * @return date representation of
133 	 *         sourceHeader.timestamp(Seconds+Microseconds)
134 	 */
135 	public final Date getTimestampAsDate() {
136 		return new Date((sourceHeader.timestampSeconds * 1000L) + (sourceHeader.timestampMicroseconds / 1000L));
137 	}
138 
139 	/**
140 	 * in order to get the real width of the image bits appended this function
141 	 * must be used. In case if the area of interest is set, one can not
142 	 * directly look at sourceWidth because aoiWidth depict the height of the
143 	 * appended image in such case
144 	 * 
145 	 * @return the width in pixels of the appended image data bits
146 	 */
147 	public int getAppendedWidth() {
148 		if (frameHeader.aoiWidth != -1)
149 			return frameHeader.aoiWidth;
150 		else
151 			return frameHeader.sourceWidth;
152 	}
153 
154 	/**
155 	 * in order to get the real height of the image bits appended this function
156 	 * must be used. In case if the area of interest is set, one can not
157 	 * directly look at sourceHeight because aoiHeight depict the height of the
158 	 * appended image in such case
159 	 * 
160 	 * @return the height in pixels of the appended image data bits
161 	 */
162 	public int getAppendedHeight() {
163 		if (frameHeader.aoiHeight != -1)
164 			return frameHeader.aoiHeight;
165 		else
166 			return frameHeader.sourceHeight;
167 	}
168 
169 	/**
170 	 * mdavid: moved from ImageDisplayer class mdavid: removed first argument
171 	 * (source video image)
172 	 * 
173 	 * clones (1:1 copy) a video frame header and bits. It is used to have an
174 	 * unchanged video header for meta information printing and a changed header
175 	 * and bits for displaying later on.
176 	 * 
177 	 * @return cloned VideoHeaderV3 object
178 	 */
179 	public VideoHeaderV3 clone() {
180 		return new VideoHeaderV3(image.clone());
181 	}
182 
183 }