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

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

name | class, % | method, % | block, % | line, %
--- | --- | --- | --- | ---
ByePacket.java | 100% (1/1) | 83% (20/24) | 68% (316/467) | 78% (68,9/88)

### COVERAGE BREAKDOWN BY CLASS AND METHOD

name | class, % | method, % | block, % | line, %
--- | --- | --- | --- | ---
class ByePacket | 100% (1/1) | 83% (20/24) | 68% (316/467) | 78% (68,9/88)
getSSRC (int): Long |  | 0% (0/1) | 0% (0/6) | 0% (0/1)
getSSRCCount (): int |  | 0% (0/1) | 0% (0/4) | 0% (0/1)
hashCode (): int |  | 0% (0/1) | 0% (0/31) | 0% (0/4)
toString (): String |  | 0% (0/1) | 0% (0/42) | 0% (0/6)
generate (byte [], int): int |  | 100% (1/1) | 62% (97/157) | 76% (16/21)
<static initializer> |  | 100% (1/1) | 88% (7/8) | 87% (0,9/1)
parse (byte [], int, int): int |  | 100% (1/1) | 95% (88/93) | 95% (18/19)
equals (Object): boolean |  | 100% (1/1) | 96% (51/53) | 89% (8/9)
ByePacket (): void |  | 100% (1/1) | 100% (17/17) | 100% (5/5)
addSSRC (Long): void |  | 100% (1/1) | 100% (6/6) | 100% (2/2)
getLength (): int |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getLengthBlock (): 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)
getReason (): String |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getReasonLength (): int |  | 100% (1/1) | 100% (4/4) | 100% (1/1)
getSourceCount (): int |  | 100% (1/1) | 100% (4/4) | 100% (1/1)
getVersion (): int |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
setLength (int): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setLengthBlock (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)
setReasonText (String): 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.rtcp;
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 | import org.apache.commons.lang.builder.EqualsBuilder;
11 | import org.apache.commons.lang.builder.ToStringBuilder;
12 | import org.apache.commons.lang.builder.HashCodeBuilder;
13 |
14 | /**
15 | * The Class ByePacket.
16 | */
17 | public class ByePacket implements IPacket {
18 |
19 | private int version = RTCPConstants.VERSION;
20 |
21 | private int padding = RTCPConstants.PADDING;
22 |
23 | private int payloadtype = RTCPConstants.RTCP_BYE;
24 |
25 | private int length;
26 |
27 | private int lengthBlock;
28 |
29 | private String rfL;
30 |
31 | private int lengthRfL;
32 |
33 |
34 | public void addSSRC(Long ssrc_csrc) {
35 | ssrcList.add(ssrc_csrc);
36 | }
37 |
38 | public int getVersion() {
39 | return version;
40 | }
41 |
42 | public void setVersion(int version) {
43 | this.version = version;
44 | }
45 |
46 | public int getPadding() {
47 | return padding;
48 | }
49 |
50 | public void setPadding(int padding) {
51 | this.padding = padding;
52 | }
53 |
54 | public int getSourceCount() {
55 | return ssrcList.size();
56 | }
57 |
58 | public int getPayloadtype() {
59 | return payloadtype;
60 | }
61 |
62 | public void setPayloadtype(int payloadtype) {
63 | this.payloadtype = payloadtype;
64 | }
65 |
66 | public int getLength() {
67 | return length;
68 | }
69 |
70 | public void setLength(int length) {
71 | this.length = length;
72 | }
73 |
74 | public int getLengthBlock() {
75 | return lengthBlock;
76 | }
77 |
78 | public void setLengthBlock(int lengthBlok) {
79 | this.lengthBlock = lengthBlok;
80 | }
81 |
82 | public String getReason() {
83 | return rfL;
84 | }
85 |
86 | public void setReasonText(String rfL) {
87 | this.rfL = rfL;
88 | }
89 |
90 | public int getReasonLength() {
91 |
92 | return this.getReason().length();
93 | }
94 |
95 | private Vector<Long> ssrcList = new Vector<Long>();
96 |
97 | public Long getSSRC(int index) {
98 | return ssrcList.get(index);
99 | }
100 |
101 | public int getSSRCCount() {
102 | return ssrcList.size();
103 | }
104 |
105 | public int generate(byte[] buffer, int offset)
106 | throws PacketGenerateException {
107 |
108 | assert PacketUtils.checkSize(this.getVersion(), 2);
109 | assert PacketUtils.checkSize(this.getPadding(), 1);
110 | assert PacketUtils.checkSize(this.getSourceCount(), 5);
111 | assert PacketUtils.checkSize(this.getPayloadtype(), 8);
112 | assert PacketUtils.checkSize(this.getLength(), 16);
113 | assert PacketUtils.checkSize(this.getLengthBlock(), 8);
114 | // assert PacketUtils.checkSize(this.getRfL()., 24);
115 |
116 | byte V_P_SC = (byte) ((this.getVersion() << 6) & 0xC0
117 | | (this.getPadding() << 5) & 0x20 | this.getSourceCount() & 0x1F);
118 | buffer[offset] = V_P_SC;
119 |
120 | PacketUtils.setOctet1(buffer, offset + 1, this.getPayloadtype());
121 | PacketUtils.setOctet2(buffer, offset + 2, this.getLength());
122 |
123 | int len = 4;
124 | for (Long ssrc : ssrcList) {
125 | PacketUtils.setOctet4(buffer, offset+len, ssrc);
126 | len += 4;
127 | }
128 |
129 | PacketUtils.setOctet1(buffer, offset + len, this
130 | .getLengthBlock());
131 | len++;
132 | PacketUtils.setOctets(buffer, offset + len, this.getReason(),
133 | this.getReasonLength());
134 |
135 | return len + getReasonLength();
136 | }
137 |
138 | public int parse(byte[] buffer, int offset, int length)
139 | throws PacketParseException {
140 | int first = PacketUtils.getOctet1(buffer, offset);
141 | this.setVersion((first & 0xC0) >> 6);
142 | this.setPadding((first & 0x20) >> 5);
143 | long parsedSourceCount = first & 0x1F;
144 |
145 | this.setPayloadtype(PacketUtils.getOctet1(buffer, offset + 1));
146 | this.setLength(PacketUtils.getOctet2(buffer, offset + 2));
147 | int len = 4;
148 | ssrcList.clear();
149 | for (int i = 0; i < parsedSourceCount; i++) {
150 | long ssrc = PacketUtils.getOctet4(buffer, offset+len);
151 | len +=4;
152 | this.addSSRC(ssrc);
153 | }
154 |
155 | this.setLengthBlock(PacketUtils.getOctet1(buffer, offset + len));
156 | len += 1;
157 |
158 | // TODO overit spravnost
159 | this.setReasonText(PacketUtils.getOctets(buffer, offset + len, 3));
160 | len += 3;
161 |
162 | if(parsedSourceCount != ssrcList.size()) {
163 | throw new PacketParseException("Neodpovida specifikovany pocet SSRC");
164 | }
165 |
166 | return len;
167 | }
168 |
169 | /**
170 | * @see java.lang.Object#equals(Object)
171 | */
172 | public boolean equals(Object object) {
173 | if (!(object instanceof ByePacket)) {
174 | return false;
175 | }
176 | ByePacket rhs = (ByePacket) object;
177 | return new EqualsBuilder().append(this.ssrcList, rhs.ssrcList)
178 | .append(this.lengthRfL, rhs.lengthRfL).append(this.length,
179 | rhs.length).append(this.rfL, rhs.rfL).append(
180 | this.padding,rhs.padding).append(this.lengthBlock, rhs.lengthBlock)
181 | .append(this.payloadtype, rhs.payloadtype).append(this.version,
182 | rhs.version).isEquals();
183 | }
184 |
185 | /**
186 | * @see java.lang.Object#toString()
187 | */
188 | public String toString() {
189 | return new ToStringBuilder(this).append("groupList", this.ssrcList).append("lengthBlok", this.lengthBlock)
190 | .append("lengthRfL", this.lengthRfL).append("rfL", this.rfL)
191 | .append("version", this.version)
192 | .append("padding", this.padding).append("itemsCount",
193 | this.getSSRCCount()).append("length", this.length)
194 | .append("payloadtype", this.payloadtype).toString();
195 | }
196 |
197 | /**
198 | * @see java.lang.Object#hashCode()
199 | */
200 | public int hashCode() {
201 | return new HashCodeBuilder(-12978201, 2019746375).append(this.lengthRfL).append(this.ssrcList)
202 | .append(this.length).append(this.rfL).append(this.lengthBlock)
203 | .append(this.padding).append(this.payloadtype).append(
204 | this.version).toHashCode();
205 | }
206 | }

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