UNPKG

sdp-jingle-json

Version:

A parser/serializer for SDP to JSON. Useful for converting SDP to other formats like Jingle for WebRTC signalling

45 lines (43 loc) 1.41 kB
<!DOCTYPE html> <html> <head> <title>SDP JSON converter</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <script src='build/sdp-jingle-json.bundle.js'></script> <style type='text/css'> html,body {margin:0px;} textarea {position:absolute;top:10px;bottom:40px;width:48%;} #sdptext {left:10px;} #jsontext {right:10px;} button {position:absolute;bottom:5px;line-height:18px;} #tojson {left:10px;} #tosdp {left:51%;} </style> <script type="text/javascript" charset="utf-8"> function toJSON() { var sdp = document.getElementById('sdptext').value; sdp = sdp.replace(/\r\n/g, '\n'); sdp = sdp.replace(/\n/g, '\r\n'); var json = SJJ.toSessionJSON(sdp, { creator: 'initiator', role: 'initiator', direction: 'outgoing' }); document.getElementById('jsontext').value = JSON.stringify(json, null, " "); } function toSDP() { var json = JSON.parse(document.getElementById('jsontext').value); document.getElementById('sdptext').value = SJJ.toSessionSDP(json, { role: 'responder', direction: 'incoming' }); } </script> </head> <body> <textarea id='sdptext' placeholder='Your SDP here'></textarea> <button id='tojson' onclick='toJSON()'>To JSON</button> <textarea id='jsontext' placeholder='Your JSON here'></textarea> <button id='tosdp' onClick='toSDP()'>To SDP</button> </body> </html>