Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebRTC streamer application skeleton
+ First commit
- Loading branch information
1 parent
f2efcf5
commit dc1ed69
Showing
9 changed files
with
527 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ hs_err_pid* | |
|
||
.classpath | ||
.project | ||
.recommenders | ||
.settings/ | ||
target/ | ||
generated/ | ||
|
96 changes: 96 additions & 0 deletions
96
code-examples/server-side/red5-misc-examples/simple-webrtc-streamer/Readme.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Exposing server side to http clients - HTTP Servlet Example | ||
--- | ||
|
||
|
||
|
||
|
||
## About | ||
--- | ||
|
||
|
||
|
||
This example demonstrates how you can open a HTTP channel between a red5 server side application and a http client. The application registers a simple [java servlet](https://en.wikipedia.org/wiki/Java_servlet) `SampleHttpSevlet`class on the red5 web application. | ||
|
||
The servlet exposes & activates itself through the `web.xml` file which is located at `RED5_HOME/webapps/{appname}/WEB-INF/web.xml`. If you take a look at the servlet class `SampleHttpSevlet.java`, you will see how the red5 application object is injected into it using `@Autowired` annotation. | ||
|
||
We can then invoke custom application methods and standard [MultiThreadedApplicationAdapter](http://red5.org/javadoc/red5-server/org/red5/server/adapter/MultiThreadedApplicationAdapter.html) methods from the servlet itself. The servlet itself is capable to handling web requests from Http clients. Thus we can connect http client to application adapter easily. | ||
|
||
|
||
|
||
|
||
## Build & Deploy | ||
--- | ||
|
||
|
||
### Build | ||
--- | ||
|
||
To build this application : open a shell prompt in the application's project directory (where the pom.xml file resides). run the following maven command in your shell -> | ||
|
||
``` | ||
mvn clean package | ||
``` | ||
|
||
The above command will generate a `war` file in the `target` directory inside the project directory. | ||
|
||
|
||
### Deploy | ||
--- | ||
|
||
To deploy the war to red5 / red5 pro server : | ||
|
||
1. Stop server if it is running. | ||
|
||
2. Extract the content of the `war file` to directory by war name. | ||
|
||
> The java war file is simply a `archive file` similar to `zip` format. you can extract it using a archive tool such as [7zip](#http://www.7-zip.org/), [Winrar trial](#http://www.rarlab.com/download.htm) etc | ||
3. Copy the folder into `RED5_HOME/webapps/` directory. | ||
|
||
4. Start server. | ||
|
||
|
||
## How To Use Example | ||
--- | ||
|
||
|
||
Once you have the server application running, access the servlet running on server from your browser as: | ||
|
||
``` | ||
http://{host}:5080/http-servlet-demo/endpoint | ||
``` | ||
|
||
> Where ` {host}` is where you are running the server. Ex: for local testing it will be `localhost`. | ||
|
||
The http call will return the following response from the servlet : | ||
|
||
|
||
``` | ||
Application context path = /default | ||
``` | ||
|
||
|
||
|
||
## Eclipse | ||
--- | ||
|
||
You can edit the server side code in your eclipse JEE IDE such as Luna, Mars, Neon etc. To import the code into your IDE: | ||
|
||
1. Navigate to the repository folder | ||
2. Execute maven command `mvn eclipse:eclipse`. This will generate files necessary for eclipse to read the maven project properly. | ||
3. In eclipse go to `File -> Import -> Existing Maven Projects` and click `Next`. | ||
4. Browse and select `the project root` and Click `Finish` to import the project. | ||
|
||
|
||
|
||
## Additional Notes | ||
--- | ||
|
||
NA | ||
|
||
|
||
|
||
|
||
|
219 changes: 219 additions & 0 deletions
219
code-examples/server-side/red5-misc-examples/simple-webrtc-streamer/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.red5pro</groupId> | ||
<artifactId>simple-webrtc-streamer</artifactId> | ||
<packaging>war</packaging> | ||
<version>1.0.0</version> | ||
<name>simple-webrtc-streamer</name> | ||
<url>http://maven.apache.org</url> | ||
<description>Red5 application demonstrating the basic skeleton of a webrtc enabled webapp</description> | ||
<properties> | ||
<finalName>simple-webrtc-streamer</finalName> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<red5-server.version>1.0.10-M6</red5-server.version> | ||
<servlet.version>3.1.0</servlet.version> | ||
<spring.version>4.2.5.RELEASE</spring.version> | ||
<mina.version>2.0.19</mina.version> | ||
<slf4j.version>1.7.18</slf4j.version> | ||
<logback.version>1.1.6</logback.version> | ||
<tomcatplugin.version>2.0.8</tomcatplugin.version> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
<build> | ||
<defaultGoal>package</defaultGoal> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.5.1</version> | ||
<configuration> | ||
<fork>true</fork> | ||
<source>${maven.compiler.source}</source> | ||
<target>${maven.compiler.target}</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>2.4</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>2.4</version> | ||
<configuration> | ||
<warName>${finalName}</warName> | ||
<packagingIncludes>*.html,*.swf,*.js,*.swz,WEB-INF/*.properties,WEB-INF/*.xml,WEB-INF/classes/**</packagingIncludes> | ||
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<version>3.0.1</version> | ||
<extensions>true</extensions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>${slf4j.version}</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.red5</groupId> | ||
<artifactId>red5-server</artifactId> | ||
<version>${red5-server.version}</version> | ||
<type>jar</type> | ||
<scope>compile</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.apache.mina</groupId> | ||
<artifactId>mina-integration-beans</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>org.apache.mina</groupId> | ||
<artifactId>mina-integration-jmx</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.mina</groupId> | ||
<artifactId>mina-parent</artifactId> | ||
<version>${mina.version}</version> | ||
<type>pom</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-beans</artifactId> | ||
<version>${spring.version}</version> | ||
<type>jar</type> | ||
<scope>compile</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>commons-logging</groupId> | ||
<artifactId>commons-logging</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-core</artifactId> | ||
<version>${spring.version}</version> | ||
<type>jar</type> | ||
<scope>compile</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>commons-logging</groupId> | ||
<artifactId>commons-logging</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
<version>${spring.version}</version> | ||
<type>jar</type> | ||
<scope>compile</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>commons-logging</groupId> | ||
<artifactId>commons-logging</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context-support</artifactId> | ||
<version>${spring.version}</version> | ||
<type>jar</type> | ||
<scope>compile</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>commons-logging</groupId> | ||
<artifactId>commons-logging</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.red5</groupId> | ||
<artifactId>red5-server</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.red5</groupId> | ||
<artifactId>tomcatplugin</artifactId> | ||
<version>${tomcatplugin.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<version>${servlet.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>jcl-over-slf4j</artifactId> | ||
<version>${slf4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>jul-to-slf4j</artifactId> | ||
<version>${slf4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>log4j-over-slf4j</artifactId> | ||
<version>${slf4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-core</artifactId> | ||
<version>${logback.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>${logback.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.mina</groupId> | ||
<artifactId>mina-core</artifactId> | ||
<version>${mina.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-beans</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context-support</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-core</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
46 changes: 46 additions & 0 deletions
46
...e-webrtc-streamer/src/main/java/com/red5/application/examples/webrtclive/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.red5.application.examples.webrtclive; | ||
|
||
import org.red5.server.adapter.MultiThreadedApplicationAdapter; | ||
import org.red5.server.api.IConnection; | ||
import org.red5.server.api.scope.IScope; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
||
public class Application extends MultiThreadedApplicationAdapter { | ||
|
||
private static Logger log = LoggerFactory.getLogger(Application.class); | ||
|
||
|
||
@Override | ||
public boolean appStart(IScope app) { | ||
WebSocketUtils.configureApplicationScopeWebSocket(app); | ||
log.info("Application started"); | ||
return super.appStart(app); | ||
} | ||
|
||
|
||
|
||
@Override | ||
public boolean appConnect(IConnection arg0, Object[] arg1) { | ||
log.info("Client connecting"); | ||
return super.appConnect(arg0, arg1); | ||
} | ||
|
||
|
||
|
||
@Override | ||
public void appDisconnect(IConnection arg0) { | ||
log.info("Client disconnecting"); | ||
super.appDisconnect(arg0); | ||
} | ||
|
||
|
||
|
||
@Override | ||
public void appStop(IScope app) { | ||
WebSocketUtils.deConfigureApplicationScopeSocket(app); | ||
log.info("Application stopped"); | ||
super.appStop(app); | ||
} | ||
} |
Oops, something went wrong.