Skip to content

Commit

Permalink
Refactored AMF decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
mondain committed Aug 10, 2016
1 parent 4be5386 commit ed2e098
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.red5</groupId>
<artifactId>red5-parent</artifactId>
<version>1.0.8-M6</version>
<version>1.0.8-M7</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>red5-server</artifactId>
Expand Down
41 changes: 41 additions & 0 deletions src/test/java/org/red5/test/selftest/EchoApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* RED5 Open Source Flash Server - http://code.google.com/p/red5/
*
* Copyright 2006-2013 by respective authors (see below). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.red5.test.selftest;

import org.red5.server.adapter.MultiThreadedApplicationAdapter;

/**
* Echo sample application.
*
* @author The Red5 Project
* @author Joachim Bauch (jojo@struktur.de)
*/
public class EchoApplication extends MultiThreadedApplicationAdapter {

/**
* Return passed parameter back to client.
*
* @param param Parameter to return.
* @return Passed parameter.
*/
public Object echo(Object param) {
return param;
}

}
91 changes: 91 additions & 0 deletions src/test/java/org/red5/test/selftest/ExternalizableClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* RED5 Open Source Flash Server - http://code.google.com/p/red5/
*
* Copyright 2006-2013 by respective authors (see below). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


package org.red5.test.selftest;

import org.red5.io.amf3.IDataInput;
import org.red5.io.amf3.IDataOutput;
import org.red5.io.amf3.IExternalizable;

public class ExternalizableClass implements IExternalizable {

private boolean[] a = new boolean[2];
private byte[] b = new byte[5];
private double c;
private float d;
private int[] e = new int[3];
private String[] f = new String[2];
private Object ob;
private short[] g = new short[3];
private long[] h = new long[2];
private String i;
private String j;

public void readExternal(IDataInput input) {
a[0] = input.readBoolean();
a[1] = input.readBoolean();
b[0] = input.readByte();
b[1] = input.readByte();
b[2] = input.readByte();
b[3] = input.readByte();
b[4] = input.readByte();
// TODO: input.readBytes
c = input.readDouble();
d = input.readFloat();
e[0] = input.readInt();
e[1] = input.readInt();
e[2] = input.readInt();
f[0] = input.readMultiByte(7, "iso-8859-1");
f[1] = input.readMultiByte(14, "utf-8");
ob = input.readObject();
g[0] = input.readShort();
g[1] = input.readShort();
g[2] = input.readShort();
h[0] = input.readUnsignedInt();
h[1] = input.readUnsignedInt();
i = input.readUTF();
j = input.readUTFBytes(12);
}

public void writeExternal(IDataOutput output) {
output.writeBoolean(a[0]);
output.writeBoolean(a[1]);
output.writeByte(b[0]);
output.writeByte(b[1]);
output.writeByte(b[2]);
output.writeByte(b[3]);
output.writeByte(b[4]);
output.writeDouble(c);
output.writeFloat(d);
output.writeInt(e[0]);
output.writeInt(e[1]);
output.writeInt(e[2]);
output.writeMultiByte(f[0], "iso-8859-1");
output.writeMultiByte(f[1], "utf-8");
output.writeObject(ob);
output.writeShort(g[0]);
output.writeShort(g[1]);
output.writeShort(g[2]);
output.writeUnsignedInt(h[0]);
output.writeUnsignedInt(h[1]);
output.writeUTF(i);
output.writeUTFBytes(j);
}

}
26 changes: 26 additions & 0 deletions src/test/java/org/red5/test/selftest/RemoteClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* RED5 Open Source Flash Server - http://code.google.com/p/red5/
*
* Copyright 2006-2013 by respective authors (see below). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.red5.test.selftest;

public class RemoteClass {

public String attribute1;

public int attribute2;
}
5 changes: 4 additions & 1 deletion src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" ?>
<configuration>
<appender class="ch.qos.logback.core.ConsoleAppender" name="CONSOLE">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<encoder>
<pattern>[%p] [%thread] %logger - %msg%n</pattern>
</encoder>
Expand All @@ -12,7 +15,7 @@
<pattern>%d{ISO8601} [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
<root level="WARN">
<root level="TRACE">
<appender-ref ref="CONSOLE" />
<!--
<appender-ref ref="FILE" />
Expand Down

0 comments on commit ed2e098

Please sign in to comment.