def sendNetStreamDataStart(self, stream, stream_id=None): output = BytesOutput(True) Amf.write(output, Amf.encode("onStatus")) Amf.write(output, Amf.encode({"code": "NetStream.Data.Start"})) self.writeMessage( self.rtmp.make(5, (Rtmp.RTMP_TYPE_NOTIFY, output.getBytes()), 0, stream_id))
def sendNetStreamSeekNotify(self, stream, timestamp=0, stream_id=None): self.writeMessage( self.rtmp.make( stream.channel_id, ( Rtmp.RTMP_TYPE_COMMAND, ( "onStatus", 0, [ Amf.encode(None), Amf.encode( { "level": "status", "code": "NetStream.Seek.Notify", "description": "Seeking %d (stream ID: %d)." % (stream.seek_time, stream.id), "details": stream.stream.getPath(), "clientid": self.id, } ), ], ), ), timestamp, stream_id, ) )
def sendCreateStreamResponse(self, info, stream_id): self.writeMessage( self.rtmp.make( info[1][0], (Rtmp.RTMP_TYPE_COMMAND, ("_result", info[0], [Amf.encode(None), Amf.encode(stream_id)]))))
def sendNetStreamPlayReset(self, stream, timestamp=0, stream_id=None): self.writeMessage( self.rtmp.make( 4, ( Rtmp.RTMP_TYPE_COMMAND, ( "onStatus", 0, [ Amf.encode(None), Amf.encode( { "level": "status", "code": "NetStream.Play.Reset", "description": "Playing and resetting %s." % stream.stream.getPath(), "details": stream.stream.getPath(), "clientid": self.id, } ), ], ), ), timestamp, stream_id, ) ) # 4 - stream.channel_id
def sendNetStreamUnpauseNotify(self, stream, timestamp=0, stream_id=None): self.writeMessage( self.rtmp.make( stream.channel_id, ( Rtmp.RTMP_TYPE_COMMAND, ( "onStatus", 0, [ Amf.encode(None), Amf.encode( { "level": "status", "code": "NetStream.Unpause.Notify", "description": "Unpausing %s." % stream.stream.getPath(), "details": stream.stream.getPath(), "clientid": self.id, } ), ], ), ), timestamp, stream_id, ) )
def sendNetStreamPlayStreamNotFound(self, stream, file): self.writeMessage( self.rtmp.make( stream.channel_id, ( Rtmp.RTMP_TYPE_COMMAND, ( "onStatus", 0, [ Amf.encode(None), Amf.encode( { "level": "status", "code": "NetStream.Play.StreamNotFound", "details": file, "clientid": self.id, } ), ], ), ), 0, stream.id, ) )
def sendRtmpSampleAccess(self, stream, stream_id=None): output = BytesOutput(True) Amf.write(output, Amf.encode("|RtmpSampleAccess")) Amf.write(output, Amf.encode(False)) Amf.write(output, Amf.encode(False)) self.writeMessage( self.rtmp.make(5, (Rtmp.RTMP_TYPE_NOTIFY, output.getBytes()), 0, stream_id))
def sendMetaData(self, stream, stream_id=None): # self.writeMessage(self.rtmp.make(stream.channel_id, (Rtmp.RTMP_TYPE_COMMAND, ("onMetaData", 0, [ # Amf.encode(None), # Amf.encode(stream.stream.getMetadata()) # ])), 0, stream_id)) output = BytesOutput(True) Amf.write(output, Amf.encode("onMetaData")) Amf.write(output, Amf.encode(stream.stream.getMetadata())) self.writeMessage(self.rtmp.make(stream.channel_id, (Rtmp.RTMP_TYPE_NOTIFY, output.getBytes()), 0, stream_id))
def sendNetStreamPlayStreamNotFound(self, stream, file): self.writeMessage( self.rtmp.make(stream.channel_id, (Rtmp.RTMP_TYPE_COMMAND, ("onStatus", 0, [ Amf.encode(None), Amf.encode({ 'level': "status", 'code': "NetStream.Play.StreamNotFound", 'details': file, 'clientid': self.id }) ])), 0, stream.id))
def sendMetaData(self, stream, stream_id=None): #self.writeMessage(self.rtmp.make(stream.channel_id, (Rtmp.RTMP_TYPE_COMMAND, ("onMetaData", 0, [ # Amf.encode(None), # Amf.encode(stream.stream.getMetadata()) #])), 0, stream_id)) output = BytesOutput(True) Amf.write(output, Amf.encode("onMetaData")) Amf.write(output, Amf.encode(stream.stream.getMetadata())) self.writeMessage( self.rtmp.make(stream.channel_id, (Rtmp.RTMP_TYPE_NOTIFY, output.getBytes()), 0, stream_id))
def sendNetConnectionConnectSuccess(self, info): self.writeMessage( self.rtmp.make( info[1][0], (Rtmp.RTMP_TYPE_COMMAND, ("_result", info[0], [ Amf.encode({ 'fmsVer': self.handler.server.getVersion(), 'capabilities': 31.0, 'mode': 1 }), Amf.encode({ 'level': "status", 'code': "NetConnection.Connect.Success", 'description': "Connection succeeded.", 'objectEncoding': 0.0 }) ]))))
def sendNetStreamPlayReset(self, stream, timestamp=0, stream_id=None): self.writeMessage( self.rtmp.make(4, (Rtmp.RTMP_TYPE_COMMAND, ("onStatus", 0, [ Amf.encode(None), Amf.encode({ 'level': "status", 'code': "NetStream.Play.Reset", 'description': "Playing and resetting %s." % stream.stream.getPath(), 'details': stream.stream.getPath(), 'clientid': self.id }) ])), timestamp, stream_id)) #4 - stream.channel_id
def sendNetStreamUnpauseNotify(self, stream, timestamp=0, stream_id=None): self.writeMessage( self.rtmp.make(stream.channel_id, (Rtmp.RTMP_TYPE_COMMAND, ("onStatus", 0, [ Amf.encode(None), Amf.encode({ 'level': "status", 'code': "NetStream.Unpause.Notify", 'description': "Unpausing %s." % stream.stream.getPath(), 'details': stream.stream.getPath(), 'clientid': self.id }), ])), timestamp, stream_id))
def sendNetStreamSeekNotify(self, stream, timestamp=0, stream_id=None): self.writeMessage( self.rtmp.make(stream.channel_id, (Rtmp.RTMP_TYPE_COMMAND, ("onStatus", 0, [ Amf.encode(None), Amf.encode({ 'level': "status", 'code': "NetStream.Seek.Notify", 'description': "Seeking %d (stream ID: %d)." % (stream.seek_time, stream.id), 'details': stream.stream.getPath(), 'clientid': self.id }) ])), timestamp, stream_id))
def sendNetConnectionConnectSuccess(self, info): self.writeMessage( self.rtmp.make( info[1][0], ( Rtmp.RTMP_TYPE_COMMAND, ( "_result", info[0], [ Amf.encode({"fmsVer": self.handler.server.getVersion(), "capabilities": 31.0, "mode": 1}), Amf.encode( { "level": "status", "code": "NetConnection.Connect.Success", "description": "Connection succeeded.", "objectEncoding": 0.0, } ), ], ), ), ) )
def sendOnBWDone(self, info): self.writeMessage(self.rtmp.make(info[1][0], (Rtmp.RTMP_TYPE_COMMAND, ("onBWDone", 0, [Amf.encode(None)]))))
def sendRtmpSampleAccess(self, stream, stream_id=None): output = BytesOutput(True) Amf.write(output, Amf.encode("|RtmpSampleAccess")) Amf.write(output, Amf.encode(False)) Amf.write(output, Amf.encode(False)) self.writeMessage(self.rtmp.make(5, (Rtmp.RTMP_TYPE_NOTIFY, output.getBytes()), 0, stream_id))
def sendOnBWDone(self, info): self.writeMessage( self.rtmp.make(info[1][0], (Rtmp.RTMP_TYPE_COMMAND, ("onBWDone", 0, [Amf.encode(None)]))))
def sendNetStreamDataStart(self, stream, stream_id=None): output = BytesOutput(True) Amf.write(output, Amf.encode("onStatus")) Amf.write(output, Amf.encode({"code": "NetStream.Data.Start"})) self.writeMessage(self.rtmp.make(5, (Rtmp.RTMP_TYPE_NOTIFY, output.getBytes()), 0, stream_id))
def sendCreateStreamResponse(self, info, stream_id): self.writeMessage( self.rtmp.make( info[1][0], (Rtmp.RTMP_TYPE_COMMAND, ("_result", info[0], [Amf.encode(None), Amf.encode(stream_id)])) ) )