Package org.red5.server.net.rtmpt
Class RTMPTServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.red5.server.net.rtmpt.RTMPTServlet
-
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
public class RTMPTServlet extends javax.servlet.http.HttpServlet
Servlet that handles all RTMPT requests.- Author:
- The Red5 Project, Joachim Bauch ([email protected]), Paul Gregoire ([email protected])
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
RTMPTServlet.RequestInfo
Used to store request information per thread.
-
Field Summary
Fields Modifier and Type Field Description protected org.springframework.web.context.WebApplicationContext
applicationContext
Web app contextprotected static org.slf4j.Logger
log
protected ThreadLocal<RTMPTServlet.RequestInfo>
requestInfo
Thread local for request info storage
-
Constructor Summary
Constructors Constructor Description RTMPTServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
protected RTMPTConnection
getConnection()
Returns a connection based on the current client session id.protected void
handleBadRequest(String message, javax.servlet.http.HttpServletResponse resp)
Return an error message to the client.protected void
handleClose(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
Close a RTMPT session.protected void
handleIdle(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
Poll RTMPT session for updates.protected void
handleOpen(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
Start a new RTMPT session.protected void
handleSend(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
Add data for an established session.boolean
isEnforceContentTypeCheck()
protected void
removeConnection(String sessionId)
Removes a connection matching the given session id from the connection manager.protected void
returnMessage(byte message, javax.servlet.http.HttpServletResponse resp)
Return a single byte to the client.protected void
returnMessage(String message, javax.servlet.http.HttpServletResponse resp)
Return a message to the client.protected void
returnMessage(RTMPTConnection conn, org.apache.mina.core.buffer.IoBuffer buffer, javax.servlet.http.HttpServletResponse resp)
Return raw data to the client.protected void
returnPendingMessages(RTMPTConnection conn, javax.servlet.http.HttpServletResponse resp)
Send pending messages to client.protected void
service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
Main entry point for the servlet.void
setEnforceContentTypeCheck(boolean enforceContentTypeCheck)
void
setHandler(RTMPTHandler handler)
Set the RTMPTHandler to use in this servlet.void
setIdent2(String ident2)
Set the fcs/ident2 stringvoid
setManager(org.red5.server.net.IConnectionManager<org.red5.server.net.rtmp.RTMPConnection> manager)
protected void
setRequestInfo(javax.servlet.http.HttpServletRequest req)
Sets the request info for the current request.void
setTargetResponseSize(int targetResponseSize)
Sets the target size for responsesprotected void
skipData(javax.servlet.http.HttpServletRequest req)
Skip data sent by the client.-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
-
-
-
-
Field Detail
-
log
protected static org.slf4j.Logger log
-
requestInfo
protected ThreadLocal<RTMPTServlet.RequestInfo> requestInfo
Thread local for request info storage
-
applicationContext
protected transient org.springframework.web.context.WebApplicationContext applicationContext
Web app context
-
-
Method Detail
-
handleBadRequest
protected void handleBadRequest(String message, javax.servlet.http.HttpServletResponse resp) throws IOException
Return an error message to the client.- Parameters:
message
- Messageresp
- Servlet response- Throws:
IOException
- on IO error
-
returnMessage
protected void returnMessage(byte message, javax.servlet.http.HttpServletResponse resp) throws IOException
Return a single byte to the client.- Parameters:
message
- Messageresp
- Servlet response- Throws:
IOException
- I/O exception
-
returnMessage
protected void returnMessage(String message, javax.servlet.http.HttpServletResponse resp) throws IOException
Return a message to the client.- Parameters:
message
- Messageresp
- Servlet response- Throws:
IOException
- I/O exception
-
returnMessage
protected void returnMessage(RTMPTConnection conn, org.apache.mina.core.buffer.IoBuffer buffer, javax.servlet.http.HttpServletResponse resp) throws IOException
Return raw data to the client.- Parameters:
conn
- RTMP connectionbuffer
- Raw data as byte bufferresp
- Servlet response- Throws:
IOException
- I/O exception
-
setRequestInfo
protected void setRequestInfo(javax.servlet.http.HttpServletRequest req)
Sets the request info for the current request. Request info contains the session id and request number gathered from the incoming request. The URI is in this form /[method]/[session id]/[request number] ie. /send/CAFEBEEF01/7- Parameters:
req
- Servlet request
-
skipData
protected void skipData(javax.servlet.http.HttpServletRequest req) throws IOException
Skip data sent by the client.- Parameters:
req
- Servlet request- Throws:
IOException
- I/O exception
-
returnPendingMessages
protected void returnPendingMessages(RTMPTConnection conn, javax.servlet.http.HttpServletResponse resp)
Send pending messages to client.- Parameters:
conn
- RTMP connectionresp
- Servlet response
-
handleOpen
protected void handleOpen(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOException
Start a new RTMPT session.- Parameters:
req
- Servlet requestresp
- Servlet response- Throws:
IOException
- I/O exception
-
handleClose
protected void handleClose(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOException
Close a RTMPT session.- Parameters:
req
- Servlet requestresp
- Servlet response- Throws:
IOException
- I/O exception
-
handleSend
protected void handleSend(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOException
Add data for an established session.- Parameters:
req
- Servlet requestresp
- Servlet response- Throws:
IOException
- I/O exception
-
handleIdle
protected void handleIdle(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOException
Poll RTMPT session for updates.- Parameters:
req
- Servlet requestresp
- Servlet response- Throws:
IOException
- I/O exception
-
service
protected void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOException
Main entry point for the servlet.- Overrides:
service
in classjavax.servlet.http.HttpServlet
- Parameters:
req
- Request objectresp
- Response object- Throws:
IOException
- I/O exception
-
destroy
public void destroy()
- Specified by:
destroy
in interfacejavax.servlet.Servlet
- Overrides:
destroy
in classjavax.servlet.GenericServlet
-
getConnection
protected RTMPTConnection getConnection()
Returns a connection based on the current client session id.- Returns:
- RTMPTConnection
-
removeConnection
protected void removeConnection(String sessionId)
Removes a connection matching the given session id from the connection manager.- Parameters:
sessionId
- session id
-
setManager
public void setManager(org.red5.server.net.IConnectionManager<org.red5.server.net.rtmp.RTMPConnection> manager)
- Parameters:
manager
- the manager to set
-
setHandler
public void setHandler(RTMPTHandler handler)
Set the RTMPTHandler to use in this servlet.- Parameters:
handler
- handler
-
setIdent2
public void setIdent2(String ident2)
Set the fcs/ident2 string- Parameters:
ident2
- ident2 string
-
setTargetResponseSize
public void setTargetResponseSize(int targetResponseSize)
Sets the target size for responses- Parameters:
targetResponseSize
- the targetResponseSize to set
-
isEnforceContentTypeCheck
public boolean isEnforceContentTypeCheck()
- Returns:
- the enforceContentTypeCheck
-
setEnforceContentTypeCheck
public void setEnforceContentTypeCheck(boolean enforceContentTypeCheck)
- Parameters:
enforceContentTypeCheck
- the enforceContentTypeCheck to set
-
-