EMMA Coverage Report (generated Tue Dec 18 20:38:46 CET 2007)
[all classes][cz.vutbr.feec.packets.rtp]

## COVERAGE SUMMARY FOR SOURCE FILE [RTPPacket.java]

name | class, % | method, % | block, % | line, %
--- | --- | --- | --- | ---
RTPPacket.java | 100% (1/1) | 90% (26/29) | 71% (366/513) | 79% (77/98)

### COVERAGE BREAKDOWN BY CLASS AND METHOD

name | class, % | method, % | block, % | line, %
--- | --- | --- | --- | ---
class RTPPacket | 100% (1/1) | 90% (26/29) | 71% (366/513) | 79% (77/98)
addGroupBlock (RTP_CSRC_Group): void |  | 0% (0/1) | 0% (0/6) | 0% (0/2)
clearData (int): void |  | 0% (0/1) | 0% (0/13) | 0% (0/3)
getGroupBlock (int): RTP_CSRC_Group |  | 0% (0/1) | 0% (0/6) | 0% (0/1)
generate (byte [], int): int |  | 100% (1/1) | 56% (131/233) | 62% (17,3/28)
parse (byte [], int, int): int |  | 100% (1/1) | 83% (94/113) | 79% (15,8/20)
<static initializer> |  | 100% (1/1) | 88% (7/8) | 87% (0,9/1)
RTPPacket (): void |  | 100% (1/1) | 100% (20/20) | 100% (6/6)
getCSRCcount (): int |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getData (): byte [] |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getDataLength (): int |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getExtension (): int |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getMarker (): int |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getPadding (): int |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getPayloadtype (): int |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getSSRC (): long |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getSeqNum (): long |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getTimeStamp (): long |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getVersion (): int |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
parseData (byte [], int, int): void |  | 100% (1/1) | 100% (35/35) | 100% (5/5)
setCSRCcount (int): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setData (byte [], int, int): void |  | 100% (1/1) | 100% (10/10) | 100% (4/4)
setExtension (int): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setMarker (int): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setPadding (int): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setPayloadtype (int): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setSSRC (long): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setSeqNum (long): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setTimeStamp (long): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setVersion (int): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)

1 | package cz.vutbr.feec.packets.rtp;
2 |
3 | import java.util.Vector;
4 |
5 | import cz.vutbr.feec.packets.IPacket;
6 | import cz.vutbr.feec.packets.PacketGenerateException;
7 | import cz.vutbr.feec.packets.PacketParseException;
8 | import cz.vutbr.feec.packets.PacketUtils;
9 | import cz.vutbr.feec.session.rtprtcp.internal.RTCPConstants;
10 |
11 | /**
12 | * This class encapsulates all the necessary parameters of a RTCP Packet that
13 | * needs to be handed to the Application when a RTCP Packet is received.This
14 | * class represents the least common denominator in an RTCP Packet. It is
15 | * equivalent to an abstract base class from which RTCPSenderReportPacket and
16 | * RTCPReceiverReportPacket derive from.
17 | */
18 | public class RTPPacket implements IPacket {
19 |
20 | private int version = 2;
21 | private int padding = RTCPConstants.PADDING;
22 | private int extension = RTCPConstants.EXTENSION;
23 | private int CSRCcount;
24 | private int marker = RTCPConstants.MARKER;
25 | private int payloadtype;
26 | private long seqNum;
27 | private long timeStamp;
28 | private long SSRC;
29 | private Vector<RTP_CSRC_Group> CSRCList = new Vector<RTP_CSRC_Group>();
30 | private byte[] data;
31 | private int dataLength;
32 | private int offset;
33 |
34 | public void addGroupBlock(RTP_CSRC_Group item) {
35 | CSRCList.add(item);
36 | }
37 |
38 | public RTP_CSRC_Group getGroupBlock(int index) {
39 |
40 | return CSRCList.get(index);
41 | }
42 |
43 | public byte[] getData() {
44 | return data;
45 | }
46 |
47 | public void clearData(int length) {
48 |
49 | for (int i = 0; i < length; i++) {
50 | data[i] = 0;
51 | }
52 | }
53 |
54 | public void setData(byte[] data, int offset, int length) {
55 | this.offset = offset;
56 | this.data = data;
57 | this.dataLength = length;
58 | }
59 |
60 | private void parseData(byte[] buffer, int start, int length) {
61 |
62 | int i;
63 | this.data = new byte[length - offset];
64 |
65 | for (i = offset; i < length; i++) {
66 |
67 | this.data[i - offset + this.offset] = buffer[i];
68 |
69 | }
70 |
71 | this.dataLength = i - offset;
72 | }
73 |
74 | public int getDataLength() {
75 | return dataLength;
76 | }
77 |
78 | public int getVersion() {
79 | return version;
80 | }
81 |
82 | public void setVersion(int version) {
83 | this.version = version;
84 | }
85 |
86 | public int getPadding() {
87 | return padding;
88 | }
89 |
90 | public void setPadding(int padding) {
91 | this.padding = padding;
92 | }
93 |
94 | public int getExtension() {
95 | return extension;
96 | }
97 |
98 | public void setExtension(int extension) {
99 | this.extension = extension;
100 | }
101 |
102 | public int getMarker() {
103 | return marker;
104 | }
105 |
106 | public void setMarker(int marker) {
107 | this.marker = marker;
108 | }
109 |
110 | public int getPayloadtype() {
111 | return payloadtype;
112 | }
113 |
114 | public void setPayloadtype(int payloadtype) {
115 | this.payloadtype = payloadtype;
116 | }
117 |
118 | public long getSeqNum() {
119 | return seqNum;
120 | }
121 |
122 | public void setSeqNum(long seqNum) {
123 | this.seqNum = seqNum;
124 | }
125 |
126 | public long getTimeStamp() {
127 | return timeStamp;
128 | }
129 |
130 | public void setTimeStamp(long timeStamp) {
131 | this.timeStamp = timeStamp;
132 | }
133 |
134 | public long getSSRC() {
135 | return SSRC;
136 | }
137 |
138 | public void setSSRC(long ssrc) {
139 | SSRC = ssrc;
140 | }
141 |
142 | public int generate(byte[] buffer, int offset)
143 | throws PacketGenerateException {
144 |
145 | assert PacketUtils.checkSize(this.getVersion(), 2);
146 | assert PacketUtils.checkSize(this.getPadding(), 1);
147 | assert PacketUtils.checkSize(this.getExtension(), 1);
148 | assert PacketUtils.checkSize(this.getCSRCcount(), 4);
149 | assert PacketUtils.checkSize(this.getMarker(), 1);
150 | assert PacketUtils.checkSize(this.getSeqNum(), 16);
151 | assert PacketUtils.checkSize(this.getTimeStamp(), 32);
152 | assert PacketUtils.checkSize(this.getSSRC(), 32);
153 |
154 | byte V_P_X_CSRCcount = (byte) ((this.getVersion() << 6) & 0xC0
155 | | (this.getPadding() << 5) & 0x20 | (this.getExtension() << 4)
156 | & 0x10 | this.getCSRCcount() & 0x0F);
157 | buffer[offset] = V_P_X_CSRCcount;
158 |
159 | byte M_payload = (byte) ((this.getMarker() << 7) & 0x80 | (this
160 | .getPayloadtype() & 0x7F));
161 | buffer[offset + 1] = M_payload;
162 |
163 | PacketUtils.setOctet2(buffer, offset + 2, this.getSeqNum());
164 | PacketUtils.setOctet4(buffer, offset + 4, this.getTimeStamp());
165 | PacketUtils.setOctet4(buffer, offset + 8, this.getSSRC());
166 |
167 | int item_bytes = 0;
168 | for (RTP_CSRC_Group group : CSRCList) {
169 |
170 | assert PacketUtils.checkSize(group.getCSRCidentifier(), 32);
171 | PacketUtils.setOctet4(buffer, offset + 12 + item_bytes, group
172 | .getCSRCidentifier());
173 | item_bytes = item_bytes + 4;
174 |
175 | }
176 |
177 | int length = this.getDataLength();
178 | for (int i = 0; i < length; i++) {
179 | buffer[offset + 12 + item_bytes + i] = this.getData()[i];
180 | }
181 |
182 | return (12 + (length / 4) + 4 * this.getCSRCcount());
183 | }
184 |
185 | public int parse(byte[] resultArray, int startPos, int length)
186 | throws PacketParseException {
187 | // pri kazdem je nutne vymazat stare CSSRC
188 | CSRCList.clear();
189 |
190 | int first = PacketUtils.getOctet1(resultArray, startPos);
191 | this.setVersion((first & 0xC0) >> 6);
192 | this.setPadding((first & 0x20) >> 5);
193 | this.setExtension((first & 0x10) >> 4);
194 | this.setCSRCcount(first & 0x0F);
195 |
196 | int second = PacketUtils.getOctet1(resultArray, startPos + 1);
197 | this.setMarker((second & 0x80) >> 7);
198 | this.setPayloadtype(second & 0x7F);
199 |
200 | this.setSeqNum(PacketUtils.getOctet2(resultArray, startPos + 2));
201 |
202 | this.setTimeStamp(PacketUtils.getOctet4(resultArray, startPos + 4));
203 | this.setSSRC(PacketUtils.getOctet4(resultArray, startPos + 8));
204 |
205 | for (int i = 0; i < this.getCSRCcount(); i++) {
206 |
207 | RTP_CSRC_Group item = new RTP_CSRC_Group();
208 | item.setCSRCidentifier(PacketUtils.getOctet4(resultArray, 12 + 4
209 | * i + startPos));
210 | this.addGroupBlock(item);
211 | }
212 |
213 | this.parseData(resultArray, startPos + 12 + (4 * this.getCSRCcount()),
214 | length);
215 |
216 | return 0;
217 | }
218 |
219 | /*
220 | * public int getCSSRCCount() { return CSSRCList.size(); } public void
221 | * addCSSRC(long cssrc) { CSSRCList.add(cssrc); }
222 | */
223 |
224 | public int getCSRCcount() {
225 | return CSRCcount;
226 | }
227 |
228 | public void setCSRCcount(int ccount) {
229 | CSRCcount = ccount;
230 | }
231 | }

[all classes][cz.vutbr.feec.packets.rtp]
EMMA 2.0.5312 EclEmma Fix 1 (C) Vladimir Roubtsov