Guest User

Untitled

a guest
Jan 21st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.89 KB | None | 0 0
  1. """
  2. A port of the main.asc from the live application included in FMS's sample
  3. applications.
  4. """
  5.  
  6. import os.path
  7. import uuid
  8. import sys
  9. import urllib
  10.  
  11. from twisted.python import log
  12.  
  13. from rtmpy import server
  14.  
  15.  
  16. class Client(server.Client):
  17.     """
  18.    Lets you handle each user, or client, connection to an application
  19.    instance. The server automatically creates a Client object when a user
  20.    connects to an application; the object is destroyed when the user
  21.    disconnects from the application.
  22.  
  23.    @note: The functions in this class are just copies from live/main.asc -
  24.        they don't do anything important (it seems).
  25.    """
  26.  
  27.     def FCPublish(self, streamname):
  28.         """
  29.        Called by FME when publishing a stream. We make sure that an
  30.        L{FLVWriter} is subscribed to the correct streamname.
  31.  
  32.        Note that the method name is case-sensitive.
  33.  
  34.        @param streamname: The name of the stream.
  35.        @type streamname: C{str}
  36.        """
  37.         self.call('onFCPublish', {
  38.             'code': 'NetStream.Publish.Start',
  39.             'description': streamname
  40.         })
  41.  
  42.     def FCUnpublish(self, streamname):
  43.         """
  44.        Called by FME when unpublishing a stream.
  45.  
  46.        Note that the method name is case-sensitive.
  47.  
  48.        @param streamname: The name of the stream.
  49.        @type streamname: C{str}
  50.        """
  51.         self.call('onFCPublish', {
  52.             'code': 'NetStream.Unpublish.Success',
  53.             'description': streamname
  54.         })
  55.  
  56.     def checkBandwidth(self):
  57.         """
  58.        """
  59.         self.call('onBWDone')
  60.  
  61.  
  62. class LiveStreamingApplication(server.Application):
  63.     """
  64.    """
  65.  
  66.     client = Client
  67.  
  68.  
  69.  
  70.  
  71. if __name__ == '__main__:
  72.    from twisted.internet import reactor
  73.  
  74.    app = LiveStreamingApplication()
  75.  
  76.    reactor.listenTCP(1935, server.ServerFactory({
  77.        'live': app
  78.    }))
Add Comment
Please, Sign In to add comment