Skip to content

Commit

Permalink
Return 405 Method Not Allowed in RECORD
Browse files Browse the repository at this point in the history
As per RFC 2326 11.3.1, server should return 405 Method Not Allowed if
RECORD request is issued when in PLAY mode.
  • Loading branch information
iizukanao committed Jan 27, 2017
1 parent ecbf5bc commit 080d526
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions rtsp.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1427,11 +1427,11 @@ class RTSPServer
@respondWithUnsupportedTransport callback, {CSeq: req.headers.cseq}
return

mode = 'play'
client.mode = 'PLAY'
if (match = /;mode=([^;]*)/.exec req.headers.transport)?
mode = match[1].toUpperCase() # PLAY or RECORD
client.mode = match[1].toUpperCase() # PLAY or RECORD

if mode is 'RECORD'
if client.mode is 'RECORD'
sdpInfo = client.announceSDPInfo
if (match = /\/([^/]+)$/.exec req.uri)?
setupStreamId = match[1] # e.g. "streamid=0"
Expand Down Expand Up @@ -1857,6 +1857,16 @@ class RTSPServer

respondRecord: (socket, req, callback) ->
client = @clients[socket.clientID]
if client.mode isnt 'RECORD'
logger.debug "client mode is not RECORD (got #{client.mode})"
res = """
RTSP/1.0 405 Method Not Allowed
CSeq: #{req.headers.cseq}
""".replace /\n/g, "\r\n"
return callback null, res

streamId = RTSPServer.getStreamIdFromUri req.uri
logger.info "[#{TAG}:client=#{client.id}] started uploading stream #{streamId}"
stream = avstreams.getOrCreate streamId
Expand Down

0 comments on commit 080d526

Please sign in to comment.