87,899
社区成员
发帖
与我相关
我的任务
分享
{
"event": "_offer",
"data": {
"sdp": {
"type": "offer",
"sdp": "v=0\r\no=- 5858625497721718597 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE audio video\r\na=msid-semantic: WMS cuuI1YLMPlphveIyD0cw9rnVu88KzpPwNnp9\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:poxanURWAqo65Tol\r\na=ice-pwd:FQ8JpKYuL0oh0/xWiWDMUifj\r\na=fingerprint:sha-256 1B:08:85:66:05:F7:9A:71:FF:41:FF:2E:A1:67:DF:08:D4:EC:5F:BC:71:BE:F4:D3:88:14:E8:8C:4E:4A:AC:B7\r\na=setup:actpass\r\na=mid:audio\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=sendrecv\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=fmtp:111 minptime=10; useinbandfec=1\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:126 telephone-event/8000\r\na=maxptime:60\r\na=ssrc:2498301942 cname:/FIg34jCU6taKkoU\r\na=ssrc:2498301942 msid:cuuI1YLMPlphveIyD0cw9rnVu88KzpPwNnp9 cb187244-6d02-4b0f-b429-6e8d62ffeedc\r\na=ssrc:2498301942 mslabel:cuuI1YLMPlphveIyD0cw9rnVu88KzpPwNnp9\r\na=ssrc:2498301942 label:cb187244-6d02-4b0f-b429-6e8d62ffeedc\r\nm=video 9 UDP/TLS/RTP/SAVPF 100 116 117 96\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:poxanURWAqo65Tol\r\na=ice-pwd:FQ8JpKYuL0oh0/xWiWDMUifj\r\na=fingerprint:sha-256 1B:08:85:66:05:F7:9A:71:FF:41:FF:2E:A1:67:DF:08:D4:EC:5F:BC:71:BE:F4:D3:88:14:E8:8C:4E:4A:AC:B7\r\na=setup:actpass\r\na=mid:video\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:4 urn:3gpp:video-orientation\r\na=sendrecv\r\na=rtcp-mux\r\na=rtpmap:100 VP8/90000\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=rtcp-fb:100 goog-remb\r\na=rtpmap:116 red/90000\r\na=rtpmap:117 ulpfec/90000\r\na=rtpmap:96 rtx/90000\r\na=fmtp:96 apt=100\r\na=ssrc-group:FID 3140684193 887668563\r\na=ssrc:3140684193 cname:/FIg34jCU6taKkoU\r\na=ssrc:3140684193 msid:cuuI1YLMPlphveIyD0cw9rnVu88KzpPwNnp9 c3868367-d990-41fd-85b1-de7e1f0416e7\r\na=ssrc:3140684193 mslabel:cuuI1YLMPlphveIyD0cw9rnVu88KzpPwNnp9\r\na=ssrc:3140684193 label:c3868367-d990-41fd-85b1-de7e1f0416e7\r\na=ssrc:887668563 cname:/FIg34jCU6taKkoU\r\na=ssrc:887668563 msid:cuuI1YLMPlphveIyD0cw9rnVu88KzpPwNnp9 c3868367-d990-41fd-85b1-de7e1f0416e7\r\na=ssrc:887668563 mslabel:cuuI1YLMPlphveIyD0cw9rnVu88KzpPwNnp9\r\na=ssrc:887668563 label:c3868367-d990-41fd-85b1-de7e1f0416e7\r\n"
}
}
}
var s = '{"event": "_offer", "data": { "sdp": {"type": "offer", "sdp": "v=0\\r\\no=- 5858625497721718597 2 IN IP4 127.0.0.1\\r\\ns=-\\r\\nt=0 0\\r\\na=group:BUNDLE audio video\\r\\na=msid-semantic: WMS cuuI1YLMPlphveIyD0cw9rnVu88KzpPwNnp9\\r\\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 126\\r\\nc=IN IP4 0.0.0.0\\r\\na=rtcp:9 IN IP4 0.0.0.0\\r\\na=ice-ufrag:poxanURWAqo65Tol\\r\\na=ice-pwd:FQ8JpKYuL0oh0/xWiWDMUifj\\r\\na=fingerprint:sha-256 1B:08:85:66:05:F7:9A:71:FF:41:FF:2E:A1:67:DF:08:D4:EC:5F:BC:71:BE:F4:D3:88:14:E8:8C:4E:4A:AC:B7\\r\\na=setup:actpass\\r\\na=mid:audio\\r\\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\\r\\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\\r\\na=sendrecv\\r\\na=rtcp-mux\\r\\na=rtpmap:111 opus/48000/2\\r\\na=fmtp:111 minptime=10; useinbandfec=1\\r\\na=rtpmap:103 ISAC/16000\\r\\na=rtpmap:104 ISAC/32000\\r\\na=rtpmap:9 G722/8000\\r\\na=rtpmap:0 PCMU/8000\\r\\na=rtpmap:8 PCMA/8000\\r\\na=rtpmap:106 CN/32000\\r\\na=rtpmap:105 CN/16000\\r\\na=rtpmap:13 CN/8000\\r\\na=rtpmap:126 telephone-event/8000\\r\\na=maxptime:60\\r\\na=ssrc:2498301942 cname:/FIg34jCU6taKkoU\\r\\na=ssrc:2498301942 msid:cuuI1YLMPlphveIyD0cw9rnVu88KzpPwNnp9 cb187244-6d02-4b0f-b429-6e8d62ffeedc\\r\\na=ssrc:2498301942 mslabel:cuuI1YLMPlphveIyD0cw9rnVu88KzpPwNnp9\\r\\na=ssrc:2498301942 label:cb187244-6d02-4b0f-b429-6e8d62ffeedc\\r\\nm=video 9 UDP/TLS/RTP/SAVPF 100 116 117 96\\r\\nc=IN IP4 0.0.0.0\\r\\na=rtcp:9 IN IP4 0.0.0.0\\r\\na=ice-ufrag:poxanURWAqo65Tol\\r\\na=ice-pwd:FQ8JpKYuL0oh0/xWiWDMUifj\\r\\na=fingerprint:sha-256 1B:08:85:66:05:F7:9A:71:FF:41:FF:2E:A1:67:DF:08:D4:EC:5F:BC:71:BE:F4:D3:88:14:E8:8C:4E:4A:AC:B7\\r\\na=setup:actpass\\r\\na=mid:video\\r\\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\\r\\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\\r\\na=extmap:4 urn:3gpp:video-orientation\\r\\na=sendrecv\\r\\na=rtcp-mux\\r\\na=rtpmap:100 VP8/90000\\r\\na=rtcp-fb:100 ccm fir\\r\\na=rtcp-fb:100 nack\\r\\na=rtcp-fb:100 nack pli\\r\\na=rtcp-fb:100 goog-remb\\r\\na=rtpmap:116 red/90000\\r\\na=rtpmap:117 ulpfec/90000\\r\\na=rtpmap:96 rtx/90000\\r\\na=fmtp:96 apt=100\\r\\na=ssrc-group:FID 3140684193 887668563\\r\\na=ssrc:3140684193 cname:/FIg34jCU6taKkoU\\r\\na=ssrc:3140684193 msid:cuuI1YLMPlphveIyD0cw9rnVu88KzpPwNnp9 c3868367-d990-41fd-85b1-de7e1f0416e7\\r\\na=ssrc:3140684193 mslabel:cuuI1YLMPlphveIyD0cw9rnVu88KzpPwNnp9\\r\\na=ssrc:3140684193 label:c3868367-d990-41fd-85b1-de7e1f0416e7\\r\\na=ssrc:887668563 cname:/FIg34jCU6taKkoU\\r\\na=ssrc:887668563 msid:cuuI1YLMPlphveIyD0cw9rnVu88KzpPwNnp9 c3868367-d990-41fd-85b1-de7e1f0416e7\\r\\na=ssrc:887668563 mslabel:cuuI1YLMPlphveIyD0cw9rnVu88KzpPwNnp9\\r\\na=ssrc:887668563 label:c3868367-d990-41fd-85b1-de7e1f0416e7\\r\\n"}}}';
var o = eval('(' + s + ')');
alert(o.event)
JSON.parse(str.replace(/\r\n/g,'\\r\\n'))
要先将里面的\r\n转换成字符串\r\n