Skip to content

Commit

Permalink
Update for 1.0.9-M2
Browse files Browse the repository at this point in the history
  • Loading branch information
mondain committed Feb 21, 2017
1 parent 2cacb67 commit 864c222
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
8 changes: 4 additions & 4 deletions 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.9-M1</version>
<version>1.0.9-M2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>red5-server-common</artifactId>
Expand Down Expand Up @@ -100,6 +100,9 @@
</testResource>
</testResources>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
Expand All @@ -111,9 +114,6 @@
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependencyManagement>
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/red5/server/net/rtmp/event/Notify.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,15 @@ public Notify duplicate() throws IOException, ClassNotFoundException {
ObjectOutputStream oos = new ObjectOutputStream(baos);
writeExternal(oos);
oos.close();

byte[] buf = baos.toByteArray();
baos.close();

ByteArrayInputStream bais = new ByteArrayInputStream(buf);
ObjectInputStream ois = new ObjectInputStream(bais);

result.readExternal(ois);
ois.close();
bais.close();
// set the action if it exists
result.setAction(getAction());
return result;
}

Expand Down
23 changes: 20 additions & 3 deletions src/main/java/org/red5/server/stream/AbstractStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.red5.server.stream;

import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicReference;

import org.red5.codec.IStreamCodecInfo;
import org.red5.codec.StreamCodecInfo;
Expand Down Expand Up @@ -54,7 +55,7 @@ public abstract class AbstractStream implements IStream {
/**
* Stores the streams metadata
*/
protected Notify metaData;
private AtomicReference<Notify> metaData = new AtomicReference<>();

/**
* Stream scope
Expand Down Expand Up @@ -90,12 +91,28 @@ public IStreamCodecInfo getCodecInfo() {
}

/**
* Returns the metadata for the associated stream, if it exists.
* Returns a copy of the metadata for the associated stream, if it exists.
*
* @return stream meta data
*/
public Notify getMetaData() {
return metaData;
Notify md = metaData.get();
if (md != null) {
try {
return md.duplicate();
} catch (Exception e) {
}
}
return md;
}

/**
* Set the metadata.
*
* @param metaData stream meta data
*/
public void setMetaData(Notify metaData) {
this.metaData.set(metaData);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,15 @@ public void dispatchEvent(IEvent event) {
return;
} else if (rtmpEvent instanceof Notify) {
Notify notifyEvent = (Notify) rtmpEvent;
log.debug("Notify action: {}", notifyEvent.getAction());
if (notifyEvent.getAction() != null && notifyEvent.getAction().equals("onMetaData")) {
String action = notifyEvent.getAction();
if (log.isDebugEnabled()) {
log.debug("Notify action: {}", action);
}
if ("onMetaData".equals(action)) {
// store the metadata
try {
log.debug("Setting metadata");
metaData = notifyEvent.duplicate();
setMetaData(notifyEvent.duplicate());
} catch (Exception e) {
log.warn("Metadata could not be duplicated for this stream", e);
}
Expand Down

0 comments on commit 864c222

Please sign in to comment.