Exemple #1
0
 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))
Exemple #2
0
 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,
         )
     )
Exemple #3
0
 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)]))))
Exemple #4
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
Exemple #5
0
 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,
         )
     )
Exemple #6
0
 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,
         )
     )
Exemple #7
0
 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))
Exemple #8
0
 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))
Exemple #9
0
 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))
Exemple #10
0
 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))
Exemple #11
0
 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
                 })
             ]))))
Exemple #12
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
Exemple #13
0
 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))
Exemple #14
0
 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))
Exemple #15
0
 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,
                             }
                         ),
                     ],
                 ),
             ),
         )
     )
Exemple #16
0
 def sendOnBWDone(self, info):
     self.writeMessage(self.rtmp.make(info[1][0], (Rtmp.RTMP_TYPE_COMMAND, ("onBWDone", 0, [Amf.encode(None)]))))
Exemple #17
0
 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))
Exemple #18
0
 def sendOnBWDone(self, info):
     self.writeMessage(
         self.rtmp.make(info[1][0], (Rtmp.RTMP_TYPE_COMMAND,
                                     ("onBWDone", 0, [Amf.encode(None)]))))
Exemple #19
0
 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))
Exemple #20
0
 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)]))
         )
     )