         )
       , (error) ->
         console.log("Error sending offer: "+error)
-      )
+      ,constraints)
     peer_connection
+
+  mergeConstraints: (cons1, cons2) ->
+    merged = cons1
+    for name in cons2.mandatory
+      merged.mandatory[name] = cons2.mandatory[name]
+    merged.optional = merged.optional.concat(cons2.optional)
+    merged
 
 
   # Peers exchange session descriptions which contains information

          , (error) ->
            console.log("Error creating answer: ", error)
            console.log(peer)
          )
      ,(error) ->
        console.log("setRemoteDescription error: ", error)
      )

    console.log('config',config)
    if (config.sendOffer)
      console.log("Creating RTC offer to " + peer_id)
      offerConstraints = {
        "optional": [
          { "OfferToReceiveAudio": true },
          { "OfferToReceiveVideo": true },
        ]
      }
      constraints = @mergeConstraints(offerConstraints, sdpConstraints)

      peer_connection.createOffer((local_description) =>
        console.log("Local offer description is: " + local_description)
        peer_connection.setLocalDescription(local_description
