   shasum = crypto.createHash 'sha512'
   shasum.update buf
   return shasum.digest('hex')[0..7]
+
+# Generates stream upon request
+class AVStreamGenerator
+  constructor: (methods) ->
+    if methods?.generate?
+      @generate = methods.generate
+    if methods?.teardown?
+      @teardown = methods.teardown
+
+    methods?.init?()
+
+  generate: ->
+
+  teardown: (stream) ->
 
 class AVStream
   constructor: (id) ->

    return streams[streamId]?

  get: (streamId) ->
    return streams[streamId]

  createNewStreamId: ->
    retryCount = 0


eventListeners = {}
streams = {}
streamGenerators = {}

api =
  AVStream: AVStream
  AVStreamGenerator: AVStreamGenerator

  emit: (name, data...) ->
    if eventListeners[name]?
