       bundlePolicy: "max-bundle"
       iceServers: @client.options.iceServers || []
     @connection = new WebRTC.RTCPeerConnection(configuration)
-    @connection.addStream @client.stream
+    @connection.addStream @client.stream if @client.stream
     @connection.addEventListener 'icecandidate', @handleLocalICECandidate.bind(@)
     @connection.addEventListener 'addstream', (event)=> @onRemoteStreamAdded(event.stream)
     @connection.addEventListener 'removestream', @onRemoteStreamRemoved.bind(@)


    @client.trigger 'partner.created', @

  muteAudio: -> @stream?.getAudioTracks()[0].enabled = false

  muteVideo: -> @stream?.getVideoTracks()[0].enabled = false

  unmuteAudio: -> @stream?.getAudioTracks()[0].enabled = true

  unmuteVideo: -> @stream?.getVideoTracks()[0].enabled = true

  audioMuted: -> !@stream?.getAudioTracks()[0].enabled

  videoMuted: -> !@stream?.getVideoTracks()[0].enabled

  connect: ->
    @disconnect() if @connection

        partner.tryReconnect()

    setTimeout check, PARTNER_CONNECTION_TIMEOUT

  disconnect: ->
    $.each @partners || {}, (k,partner)->
      partner.disconnect()


sendedSignals = {}
