1. Introduction ...................................................................................................................... 1
1.1. 0.8 Public Beta Release ....................................................................................... 1
以比较新的0.8版本为例,实际上到了版本1.0了
I. Getting Started ................................................................................................................. 2
之所以选择red5是因为开源,功能基本与fms相同而且没有用户数限制,符合笔者目前开发的程序的需要。可以无缝移植,如果需要可以直接转到fms
新手入门,一些经常被问到的问题及其解决办法
2. Frequently Asked Questions ................................................................................... 3
2.1. Questions ...................................................................................................... 3问题
2.1.1. General .............................................................................................. 3
2.1.2. Documentation ................................................................................... 3文档
2.1.3. Configuration ...................................................................................... 3配置
2.1.4. Streaming ........................................................................................... 3视频流
2.1.5. Codecs ............................................................................................... 4编码
2.1.6. Database ............................................................................................ 4数据库
2.1.7. Scripting ............................................................................................. 4脚本
2.1.8. Shared Objects .................................................................................. 4共享对象,这个可以参见fms的教程,有互通指出
2.1.9. Legal .................................................................................................. 4声明
2.1.10. Red5 WAR version .......................................................................... 4red5 war版本
2.1.11. Misc .................................................................................................. 4
2.1.12. Troubleshooting ............................................................................... 5解决以及回答
2.2. Answers ........................................................................................................ 5
2.2.1. General .............................................................................................. 5
2.2.2. Documentation ................................................................................... 7
2.2.3. Configuration ...................................................................................... 7
2.2.4. Streaming ........................................................................................... 7
2.2.5. Codecs ............................................................................................... 8
2.2.6. Database ............................................................................................ 8
2.2.7. Scripting ............................................................................................. 8
2.2.8. Shared Objects .................................................................................. 9
2.2.9. Legal .................................................................................................. 9
2.2.10. Red5 WAR version .......................................................................... 9
2.2.11. Misc .................................................................................................. 9
2.2.12. Troubleshooting ............................................................................. 11
3. Configuration Files ................................................................................................. 13配置文件详解
3.1. Directory "conf" ........................................................................................... 13conf目录,这里解释了red5会用到的概念
3.1.1. jetty.xml ............................................................................................ 13
3.1.2. keystore ............................................................................................ 13
3.1.3. log4j.properties ................................................................................. 13
3.1.4. realm.properties (Jetty) .................................................................... 13
3.1.5. tomcat-users.xml (Tomcat) .............................................................. 13
3.1.6. red5.globals ...................................................................................... 14
3.1.7. red5.properties ................................................................................. 14
3.1.8. red5.xml ........................................................................................... 14
3.1.9. red5-common.xml ............................................................................ 14
3.1.10. red5-core.xml ................................................................................. 15
3.1.11. red5-rtmpt.xml ................................................................................ 16
3.1.12. web.xml (Tomcat) .......................................................................... 16
3.1.13. web-default.xml (Jetty) ................................................................... 16
3.2. Webapp config directory ............................................................................. 16
3.2.1. red5-web.xml .................................................................................... 16
4. Migration Guide ..................................................................................................... 18
4.1. Application callbacks毁掉函数
4.1.1. Interface IScopeHandler .................................................................. 18
4.1.2. Class ApplicationAdapter ................................................................. 18
4.1.3. Accepting / rejecting clients ............................................................. 19接受和拒绝客户端
4.2. Current connection and client ..................................................................... 19当前连接和当前连接的客户端
4.3. Additional handlers ..................................................................................... 20附加控制器
4.3.1. Handlers in configuration files ......................................................... 20
4.3.2. Handlers from application code ....................................................... 21控制器,在配置文件里的和在程序代码里的
4.4. Calls to client methods ............................................................................... 21调用客户端的代码
4.5. SharedObjects ............................................................................................ 22共享对象
4.5.1. Serverside change listeners ............................................................ 23服务器端进行侦听
4.5.2. Changing from application code ...................................................... 23来自客户端代码的改变
4.6. Persistence ................................................................................................. 25
4.7. Periodic events ........................................................................................... 26
4.8. Remoting ..................................................................................................... 27远程调用
4.8.1. Remoting server .............................................................................. 27
4.8.2. Remoting client ................................................................................ 28
4.9. Streams ....................................................................................................... 28
5. Red5 Libraries ....................................................................................................... 29red5的类库给出了很多语言的版本,
5.1. Spring scripting support .............................................................................. 29
5.2. Groovy ........................................................................................................ 29
5.3. Beanshell .................................................................................................... 29
5.4. Ruby ............................................................................................................ 29
5.5. Jython / Python ........................................................................................... 29
5.6. Java 5 Libraries .......................................................................................... 29
5.7. Script related JSR's .................................................................................... 29
5.8. Javascript / Rhino ....................................................................................... 30
6. Building Red5 ........................................................................................................ 31
6.1. Build Environment Setup ............................................................................ 31
6.1.1. Ant .................................................................................................... 31
6.1.2. Java .................................................................................................. 31
6.1.3. Red5 ................................................................................................. 31
6.2. Building ....................................................................................................... 32
6.2.1. Getting Red5 Source ....................................................................... 32
6.2.2. Getting Red5 Demo Applications Source ........................................ 32
6.2.3. Getting Red5 Flash Demo Source ................................................... 32
6.2.4. Running the ant build ...................................................................... 32
6.2.5. Current Ant Targets ......................................................................... 32
6.2.6. Ant and Ivy ...................................................................................... 34
6.3. How to build with eclipse ........................................................................... 34
6.3.1. Recommended Eclipse Plugins ....................................................... 34
6.3.2. Importing the Red5 Project .............................................................. 35
6.3.3. Updating the Red5 source from Eclipse. ......................................... 35
6.3.4. ......................................................................................................... 36
6.3.5. Ant, Ivy and Eclipse ......................................................................... 37
7. General Formatting Conventions .......................................................................... 38
7.1. Javadoc ....................................................................................................... 39
7.2. Unit Tests ................................................................................................... 39
7.3. Logging ....................................................................................................... 39
7.3.1. Levels
7.4. Exceptions .................................................................................................. 39
7.5. Formatter Profile ......................................................................................... 41
7.6. Code Template ........................................................................................... 41编码模版
8. Releasing Red5 ..................................................................................................... 43
9. Recommended System Requirements .................................................................. 44
9.1. Java Memory Tweaking ........................................................................... 44
9.2. Real World Production Run 5-31-07 and 6-1-07 ........................................ 44
II. Red5 Core Components ............................................................................................... 46在red5里创建应用
10. Create new applications in Red5 ........................................................................ 47
10.1. The application directory .......................................................................... 47
10.2. Configuration ............................................................................................. 47
10.2.1. webAppRootKey ............................................................................ 47
10.3. Handler configuration ................................................................................ 47
10.3.1. Context ........................................................................................... 47
10.3.2. Scopes ........................................................................................... 48
10.4. Handlers .................................................................................................... 49
10.5. Logging ..................................................................................................... 49
11. Logging Setup ..................................................................................................... 50
11.1. Web applications ...................................................................................... 51
11.2. Imports ...................................................................................................... 52
11.3. Logger Instantiation .................................................................................. 52
12. Deploying Red5 To Tomcat ................................................................................ 54
12.1. Preface ...................................................................................................... 54
12.2. Deployment ............................................................................................... 54
12.3. Context descriptors ................................................................................... 54
12.4. Red5 Configuration ................................................................................... 54
12.4.1. Spring contexts .............................................................................. 55
12.4.2. Default context ............................................................................... 55
12.4.3. Web context ................................................................................... 56
12.4.4. External applications ...................................................................... 58
12.5. Creating and deploying your application .................................................. 59
12.5.1. Remote application ........................................................................ 59
12.5.2. Local application ............................................................................ 60
12.5.3. Example Source ............................................................................ 60
12.6. Additional web configuration ..................................................................... 60
12.7. Troubleshooting ........................................................................................ 62
12.8. Definitions ................................................................................................. 63
12.9. Bibliography .............................................................................................. 64
13. Customize Stream Paths ..................................................................................... 65
13.1. Filename generator service ...................................................................... 65
13.2. Custom generator ..................................................................................... 65
13.3. Activate custom generator ........................................................................ 66
13.4. Change paths through configuration ........................................................ 66
14. Security ................................................................................................................ 68
14.1. Stream Security ........................................................................................ 68
14.1.1. Stream playback security ............................................................... 68
14.1.2. Stream publishing security ............................................................. 69
15. Scripting Implementations ................................................................................... 70
15.1. I. Select a scripting implementation ......................................................... 70
Red5 - Reference Documentation
v
15.2. II. Configuring Spring ................................................................................ 70
15.3. III. Creating an application script .............................................................. 72
15.3.1. 1. Application adapter .................................................................... 72
15.3.2. 2. Application services ................................................................... 74
15.4. Creating your own interpreter ................................................................... 77
15.5. Links with scripting information ................................................................ 78
16. Clustering ............................................................................................................. 79
16.1. Server Configuration ................................................................................. 79
16.1.1. Configuration Files ......................................................................... 79
16.2. Configure Edge Server ............................................................................. 79
16.2.1. Edge on a different Server from Origin .......................................... 79
16.2.2. Edge on the same Server as Origin .............................................. 80
16.3. Configure Origin Server ............................................................................ 80
16.4. Use Your Appliation .................................................................................. 80
17. Management ........................................................................................................ 81
17.1. JMX Classes ............................................................................................. 81
17.2. Spring configuration .................................................................................. 81
17.3. RMI Authentication ................................................................................... 82
17.4. JMX / RMI / SSL ....................................................................................... 83
17.5. jConsole / JMX Client ............................................................................... 83
17.5.1. Local Management ........................................................................ 83
17.5.2. Remote Management .................................................................... 83
17.5.3. SSL Remote Management ............................................................ 83
17.6. Links .......................................................................................................... 84
18. Red5 Demo Applications ..................................................................................... 85
18.1. Getting Red5 Demo Applications Server-Side and Client-Side
Source ............................................................................................................... 85
18.1.1. List Of Available Demo Applications (Server Side) ........................ 85
18.1.2. List Of Available Demo Applications (Client Side) ......................... 85
18.2. Environment Build Setup .......................................................................... 85
18.3. Building The Demo Application ................................................................ 86
18.4. Updating The Applications Registry ......................................................... 86
18.5. Demo Applications Documentation ........................................................... 87
18.5.1. Bandwidth Check Application ........................................................ 87
19. Testing Red5 ....................................................................................................... 91
19.1. Overview ................................................................................................... 91
19.2. How to Start Testing Without Reading This Chapter ................................ 91
19.3. Who Should Read This Chapter In Depth? .............................................. 92
19.4. Red5 Testing Strategy .............................................................................. 92
19.5. Red5 Testing Props .................................................................................. 92
19.6. Unit Testing .............................................................................................. 93
19.6.1. Purpose .......................................................................................... 93
19.6.2. Technology ..................................................................................... 93
19.6.3. Running Tests ................................................................................ 93
19.6.4. Creating New Tests ....................................................................... 93
19.6.5. Running unit tests from eclipse ..................................................... 94
19.6.6. Guidelines for New Unit Tests ....................................................... 94
19.6.7. Submitting New Unit Tests ............................................................ 94
19.6.8. Suggesting New Unit Tests ........................................................... 95
Red5 - Reference Documentation
vi
19.7. Integration Testing .................................................................................... 95
19.7.1. Purpose .......................................................................................... 95
19.8. System Testing ......................................................................................... 95
19.8.1. Purpose .......................................................................................... 95
19.9. Technology ............................................................................................... 96
19.10. Running Tests ........................................................................................ 96
19.11. Creating New Tests ................................................................................ 97
19.12. A Sample System Test ........................................................................... 98
19.13. Guidelines for New System Tests .......................................................... 98
19.14. Submitting New System Tests ............................................................... 98
19.15. Suggesting New System Tests .............................................................. 99
19.16. Continuous Integration ............................................................................ 99
19.16.1. Overview ...................................................................................... 99
19.16.2. Technology ................................................................................... 99
19.16.3. How To Run The Continuous Build ........................................... 100
19.16.4. How to Submit New Jobs for Continuous Building ..................... 100
19.17. How you can help with Continuous Building ........................................ 100
19.17.1. How to Set up a Continuous Build Server ................................. 100
20. Plugins ............................................................................................................... 102
20.1. Loading ................................................................................................... 102
20.2. Configuring .............................................................................................. 102
20.3. Developing .............................................................................................. 103
20.3.1. Plugin Main Class ........................................................................ 104
20.3.2. Factory Method Class .................................................................. 107
III. App Server ................................................................................................................. 109
21. JEE Container Plug-ins ..................................................................................... 110
21.1. The Containers ....................................................................................... 110
21.2. Fixing plug-in startup errors .................................................................... 110
21.2.1. Tomcat Plugin .............................................................................. 110
21.2.2. Jetty Plugin .................................................................................. 111
21.2.3. Winstone Plugin ........................................................................... 111
22. SSAS Support - Basis ....................................................................................... 112
IV. Tutorials ..................................................................................................................... 114
23. Red5 and Acegi Security .................................................................................. 115
23.1. ................................................................................................................ 119
23.1.1. Legal? .......................................................................................... 119
24. Edge Origin Clustering Configuration ................................................................ 120
24.1. Configuration Files .................................................................................. 120
24.2. Configure Edge Server ........................................................................... 120
24.2.1. Edge on a different Server from Origin ........................................ 120
24.2.2. Edge on the same Server as Origin ............................................ 121
24.3. Configure Origin Server .......................................................................... 121
25. What To Do When Red5 Freezes ..................................................................... 122
26. Red5 and Hibernate .......................................................................................... 123
26.1. Required Libraries .................................................................................. 123
26.2. Configuration ........................................................................................... 124
26.2.1. red5-hibernate.xml ....................................................................... 124
26.2.2. red5-web.xml ................................................................................ 126
26.2.3. red5-web.properties ..................................................................... 126
Red5 - Reference Documentation
vii
26.2.4. hibernateTest-ehcache.xml .......................................................... 127
26.2.5. StreamPoints.hbm.xml ................................................................. 127
26.3. Hibernate DAO Classes ......................................................................... 128
26.3.1. Users.java .................................................................................... 128
26.3.2. IUsersDAO.java ........................................................................... 129
26.3.3. IStreamPointsService.java ........................................................... 129
26.3.4. UsersDaoImpl.java ....................................................................... 129
26.3.5. UsersServiceImpl.java ................................................................. 130
26.4. Usage ...................................................................................................... 131
26.4.1. Links ............................................................................................. 131
27. Ivy setup with Eclipse ........................................................................................ 132
27.1. Update .................................................................................................... 132
28. Java 6 Update 4 Target For OSX 10.5 ............................................................. 134
29. Jruby scripting explained ................................................................................... 135
29.1. Overview ................................................................................................. 135
29.2. Basic Application .................................................................................... 135
29.2.1. Webapp Directory Structure ........................................................ 135
29.2.2. Ruby application adapter ............................................................. 136
29.3. More complicated example ..................................................................... 137
29.3.1. Build sources ............................................................................... 138
30. Creating Patches From SVN ............................................................................. 142
31. Ping .................................................................................................................... 143
32. RTMP Client ...................................................................................................... 144
32.1. Extending RTMPClient ........................................................................... 144
32.2. RTMPClient Service Callback Handlers ................................................. 144
32.3. Callback Result Handlers ....................................................................... 144
32.3.1. Callback Result Handler .............................................................. 144
32.3.2. Callback Stream Status Handler .................................................. 145
32.3.3. Callback Error Handler ................................................................ 146
32.3.4. Dispatch Event Handler ............................................................... 146
32.4. Examples ................................................................................................ 147
32.4.1. Playback Example ....................................................................... 147
32.4.2. Publish Example .......................................................................... 147
32.4.3. Shared Object Example ............................................................... 149
32.4.4. Sharedobject Listeners ................................................................ 150
32.4.5. Callback Example ........................................................................ 150
33. Scopes and Contexts ........................................................................................ 152
33.1. Overview ................................................................................................. 152
33.2. Concept of Scope ................................................................................... 152
33.3. Scope Functionality ................................................................................ 152
33.4. Context .................................................................................................... 153
34. Red5 and Spring JDBC ..................................................................................... 154
35. Deploying Red5 to Tomcat ............................................................................... 158
35.1. Preface .................................................................................................... 158
35.2. Deployment ............................................................................................. 158
35.2.1. Context descriptors ...................................................................... 158
35.3. Red5 Configuration ................................................................................. 159
35.3.1. Spring contexts ............................................................................ 159
35.3.2. Default context ............................................................................. 159
Red5 - Reference Documentation
viii
35.3.3. Web context ................................................................................. 160
35.4. Creating and deploying your application ................................................ 163
35.4.1. Remote application ...................................................................... 163
35.4.2. Local application .......................................................................... 163
35.4.3. Example Source ........................................................................... 164
35.5. Additional web configuration ................................................................... 164
35.6. Renaming the ROOT war to Red5 ......................................................... 165
35.7. Troubleshooting ...................................................................................... 166
35.8. Definitions ............................................................................................... 166
36. Using Wireshark On OSX ................................................................................. 168
V. Examples .................................................................................................................... 169
37. File Upload Servlet Example ............................................................................. 170
38. Server Side Playlists ......................................................................................... 171
A. RTMP Specification .................................................................................................... 172
B. RTMPT Specification .................................................................................................. 173
B.1. URLs ................................................................................................................ 173
B.2. Request / Response ......................................................................................... 173
B.3. Polling interval .................................................................................................. 174
B.4. Initial connect (command "open") .................................................................... 174
B.5. Client updates (command "send") ................................................................... 174
B.6. Polling requests (command "idle") ................................................................... 174
B.7. Disconnect of a session (command "close") .................................................... 174
C. AMF Specification ....................................................................................................... 175
C.1. AMF0 Specification .......................................................................................... 175
C.2. AMF3 Specification .......................................................................................... 175
D. Data Type Mappings .................................................................................................. 176
E. FLV .............................................................................................................................. 177
F. H264 ............................................................................................................................ 178
F.1. Does Red5 plan to support H.264/ACC streams in the next release, maybe
0.7.1? ...................................................................................................................... 178
F.2. why are .mp4 files also listed in oflaDemo webapp grid as possible
streams? ................................................................................................................. 178
F.3. howto convert to h.264 using ffmpeg? ............................................................. 178
F.4. Does anyone have a link to an explaination of h264 licensing? ....................... 179
F.5. Someone already created a demo? ................................................................. 180
F.6. Some more Info about Seek and possible solutions ........................................ 180
F.7. Are audio files supported? ............................................................................... 180
F.8. How do I request an h264 file? ....................................................................... 180
F.9. Does red5 support h264 live streaming? ......................................................... 181
F.10. Links ............................................................................................................... 181
G. Speex Codec .............................................................................................................. 182
G.1. Setting Up Flex SDk / Flex Builder .................................................................. 182
G.1.1. Get Flex 3 SDK .................................................................................... 182
G.1.2. Config Flex Config To Target Flash Player 10 ..................................... 182
G.2. Code Example ................................................................................................. 182
G.3. FFMpeg and Speex ......................................................................................... 183
G.4. Links ........