{"id":6319,"date":"2019-11-05T13:09:04","date_gmt":"2019-11-05T04:09:04","guid":{"rendered":"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/?p=6319"},"modified":"2019-11-05T13:09:04","modified_gmt":"2019-11-05T04:09:04","slug":"webrtc%e3%83%96%e3%83%ad%e3%82%b0%e7%ac%ac%e4%b8%80%e5%9b%9e","status":"publish","type":"post","link":"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/archives\/6319","title":{"rendered":"WebRTC\u30d6\u30ed\u30b0\u7b2c\u4e00\u56de"},"content":{"rendered":"<div class=\"veu_autoEyeCatchBox\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"450\" src=\"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/ReDois-photo-1024x614.png\" class=\"attachment-large size-large wp-post-image\" alt=\"\" srcset=\"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/ReDois-photo-1024x614.png 1024w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/ReDois-photo-300x180.png 300w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/ReDois-photo-768x461.png 768w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/ReDois-photo.png 2000w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 14pt;\">\u306f\u3058\u3081\u307e\u3057\u3066\uff01OIS\u306e\u81ea\u793e\u88fd\u54c1\u300eReDois\u300f\u958b\u767a\u62c5\u5f53\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 14pt;\">\u300eReDois\u300f\u306f\u3001WebRTC\u3068\u547c\u3070\u308c\u308b\u6280\u8853\u3092\u5229\u7528\u3057\u3001\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u914d\u4fe1\u3092\u5b9f\u73fe\u3057\u3066\u3044\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-6320\" src=\"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/ReDois-photo-1024x614.png\" alt=\"\" width=\"750\" height=\"450\" srcset=\"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/ReDois-photo-1024x614.png 1024w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/ReDois-photo-300x180.png 300w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/ReDois-photo-768x461.png 768w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/ReDois-photo.png 2000w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 14pt;\">\u79c1\u304b\u3089\u306f\u3001\u3053\u306eWebRTC\u306b\u95a2\u3059\u308b\u60c5\u5831\u306b\u3064\u3044\u3066\u767a\u4fe1\u3057\u3066\u3044\u3053\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"font-size: 14pt;\">\u4eca\u56de\u306f\u3001<strong>WebRTC\u306e\u57fa\u672c\u3068\u3057\u3066\u3001P2P\u3067\u306e\u63a5\u7d9a<\/strong>\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 14pt;\">WebRTC\u516c\u5f0f\u3088\u308a\u516c\u958b\u3055\u308c\u3066\u3044\u308b<a href=\"https:\/\/webrtc.github.io\/samples\/src\/content\/peerconnection\/munge-sdp\/\">\u30b5\u30f3\u30d7\u30eb\u30da\u30fc\u30b8<\/a>\u3092\u4f7f\u3044\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306e\u89e3\u8aac\u3082\u4ea4\u3048\u306a\u304c\u3089\u898b\u3066\u3044\u3053\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"font-size: 14pt;\">\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f<a href=\"https:\/\/github.com\/webrtc\/samples\/blob\/gh-pages\/src\/content\/peerconnection\/munge-sdp\/js\/main.js\">\u3053\u3061\u3089<\/a>\u306b\u306a\u308a\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"font-size: 14pt;\">\u3053\u306e\u30b5\u30f3\u30d7\u30eb\u30da\u30fc\u30b8\u3067\u306f\u3001\u5de6\u4e0a\u304b\u3089\u9806\u306b\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3066\u3044\u3051\u3070\u81ea\u5206\u540c\u58eb\u3067WebRTC\u63a5\u7d9a\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"font-size: 14pt;\">\u305d\u308c\u305e\u308c\u306e\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u305f\u3068\u304d\u3001\u5177\u4f53\u7684\u306b\u3069\u306e\u3088\u3046\u306a\u52d5\u4f5c\u3092\u3057\u3066\u3044\u308b\u306e\u304b\u6398\u308a\u4e0b\u3052\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<h2><span style=\"font-size: 18pt;\"><strong>\u2460[Get media]\u30dc\u30bf\u30f3<\/strong><\/span><\/h2>\n<p><span style=\"font-size: 18.6667px;\">\u6700\u521d\u306b\u3001\u30de\u30a4\u30af\u3084\u30ab\u30e1\u30e9\u304b\u3089\u30b9\u30c8\u30ea\u30fc\u30e0\u3092\u53d6\u5f97\u3057\u3001\u305d\u308c\u3092\u753b\u9762\u306b\u8868\u793a\u3057\u307e\u3059<\/span><\/p>\n<pre class=\"lang:default highlight:0 decode:true\">  async function getMedia() {\r\n    (\u4e2d\u7565)\r\n    try {\r\n      const userMedia = await navigator.mediaDevices.getUserMedia(constraints);\r\n      gotStream(userMedia);\r\n    } catch (e) {\r\n      console.log('navigator.getUserMedia error: ', e);\r\n    }\r\n  }\r\n\r\n  function gotStream(stream) {\r\n    console.log('Received local stream');\r\n    localVideo.srcObject = stream;\r\n    localStream = stream;\r\n  }\r\n<\/pre>\n<p><span style=\"font-size: 14pt;\">\u5177\u4f53\u7684\u306b\u306f\u3001<br \/>\nnavigator.mediaDevices.getUserMedia()\u30e1\u30bd\u30c3\u30c9\u3067MediaStream\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\u3057\u3001\u3053\u308c\u3092\u753b\u9762\u4e0a\u306evideo\u8981\u7d20\u306b\u30bb\u30c3\u30c8\u3059\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u30de\u30a4\u30af\u3084\u30ab\u30e1\u30e9\u306e\u97f3\u58f0\u30fb\u6620\u50cf\u3092\u30d6\u30e9\u30a6\u30b6\u4e0a\u3067\u518d\u751f\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"font-size: 14pt;\">(\u30b5\u30f3\u30d7\u30eb\u30da\u30fc\u30b8\u3067\u306f\u3001localVideo\u304c\u793a\u3059video\u8981\u7d20\u306fmuted\u5c5e\u6027\u3092\u6301\u3063\u3066\u3044\u308b\u306e\u3067\u97f3\u58f0\u306f\u518d\u751f\u3055\u308c\u307e\u305b\u3093)<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-6324 size-large\" src=\"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf-1024x507.png\" alt=\"\" width=\"750\" height=\"371\" srcset=\"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf-1024x507.png 1024w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf-300x149.png 300w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf-768x381.png 768w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf.png 1895w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"font-size: 18pt;\"><strong>\u2461[Create peer connection]\u30dc\u30bf\u30f3<\/strong><\/span><\/h2>\n<p><span style=\"font-size: 14pt;\">WebRTC\u63a5\u7d9a\u306e\u8981\u3068\u306a\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u3042\u308b\u3001RTCPeerConnection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/span><\/p>\n<pre class=\"lang:default highlight:0 decode:true\">  function createPeerConnection() {\r\n    (\u4e2d\u7565)\r\n    const servers = null;\r\n\r\n\r\n    window.localPeerConnection = localPeerConnection = new RTCPeerConnection(servers);\r\n    console.log('Created local peer connection object localPeerConnection');\r\n    localPeerConnection.onicecandidate = e =&gt; onIceCandidate(localPeerConnection, e);\r\n    sendChannel = localPeerConnection.createDataChannel('sendDataChannel', dataChannelOptions);\r\n    sendChannel.onopen = onSendChannelStateChange;\r\n    sendChannel.onclose = onSendChannelStateChange;\r\n    sendChannel.onerror = onSendChannelStateChange;\r\n\r\n    window.remotePeerConnection = remotePeerConnection = new RTCPeerConnection(servers);\r\n    console.log('Created remote peer connection object remotePeerConnection');\r\n    remotePeerConnection.onicecandidate = e =&gt; onIceCandidate(remotePeerConnection, e);\r\n    remotePeerConnection.ontrack = gotRemoteStream;\r\n    remotePeerConnection.ondatachannel = receiveChannelCallback;\r\n\r\n    localStream.getTracks()\r\n      .forEach(track =&gt; localPeerConnection.addTrack(track, localStream));\r\n    console.log('Adding Local Stream to peer connection');\r\n  }\r\n<\/pre>\n<p><span style=\"font-size: 14pt;\">\u4eca\u56de\u306f\u81ea\u5206\u540c\u58eb\u3067\u306e\u63a5\u7d9a\u306a\u306e\u3067\u3001\u30ed\u30fc\u30ab\u30eb\u30fb\u30ea\u30e2\u30fc\u30c8\u5171\u306b\u3053\u306e\u5834\u3067RTCPeerConnection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/span><br \/>\n<span style=\"font-size: 14pt;\">RTCPeerConnection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3059\u308b\u4ed6\u306b\u3001\u2460\u3067\u53d6\u5f97\u3057\u305fMediaStream\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304b\u3089MediaStream.getTracks()\u30e1\u30bd\u30c3\u30c9\u3067MediaStreamTrack\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\u3057\u3001RTCPeerConnection.addTrack()\u30e1\u30bd\u30c3\u30c9\u3067\u3053\u308c\u304b\u3089\u9001\u4fe1\u3059\u308b\u97f3\u58f0\u30fb\u6620\u50cf\u3092\u30bb\u30c3\u30c8\u3057\u3066\u3044\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"font-size: 18pt;\"><strong>\u2462[Create offer]\u30dc\u30bf\u30f3<\/strong><\/span><\/h2>\n<p><span style=\"font-size: 14pt;\">SDP\u3068\u547c\u3070\u308c\u308b\u6587\u66f8\u3092offer\u5074(\u4eca\u56de\u306f\u30ed\u30fc\u30ab\u30eb\u5074)\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002SDP\u306b\u3064\u3044\u3066\u306e\u8a73\u7d30\u306a\u8aac\u660e\u306f\u4eca\u56de\u7701\u304d\u307e\u3059\u304c\u3001WebRTC\u63a5\u7d9a\u306b\u306f\u304a\u4e92\u3044\u306e\u5185\u90e8\u60c5\u5831\u3092\u3084\u308a\u3068\u308a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u3001SDP\u306f\u305d\u308c\u3092\u8868\u73fe\u3059\u308b\u30d7\u30ed\u30c8\u30b3\u30eb\u3067\u3059\u3002<\/span><\/p>\n<pre class=\"lang:default highlight:0 decode:true \"> async function createOffer() {\r\n    try {\r\n      const offer = await localPeerConnection.createOffer(offerOptions);\r\n      gotDescription1(offer);\r\n    } catch (e) {\r\n      onCreateSessionDescriptionError(e);\r\n    }\r\n  }\r\n<\/pre>\n<pre class=\"lang:default highlight:0 decode:true \">function gotDescription1(description) {\r\n    offerSdpTextarea.disabled = false;\r\n    offerSdpTextarea.value = description.sdp;\r\n  }<\/pre>\n<p><span style=\"font-size: 14pt;\">SDP offer\u306fRTCPeerConnection.createOffer()\u30e1\u30bd\u30c3\u30c9\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002<\/span><br \/>\n<span style=\"font-size: 14pt;\">\u3053\u3053\u3067\u306f\u66f4\u306b\u3001\u4f5c\u6210\u3057\u305fSDP\u3092textarea\u8981\u7d20\u3067\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-6325\" src=\"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf2-1024x507.png\" alt=\"\" width=\"750\" height=\"371\" srcset=\"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf2-1024x507.png 1024w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf2-300x148.png 300w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf2-768x380.png 768w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf2.png 1895w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"font-size: 18pt;\"><strong>\u2463[Set offer]\u30dc\u30bf\u30f3<\/strong><\/span><\/h2>\n<p><span style=\"font-size: 14pt;\">\u4f5c\u6210\u3057\u305fSDP offer\u3092RTCPeerConnection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002<\/span><\/p>\n<pre class=\"lang:default highlight:0 decode:true \">async function setOffer() {\r\n    let sdp = offerSdpTextarea.value;\r\n    const offer = {\r\n      type: 'offer',\r\n      sdp: sdp\r\n    };\r\n    console.log(`Modified Offer from localPeerConnection\\n${sdp}`);\r\n\r\n    try {\r\n      \/\/ eslint-disable-next-line no-unused-vars\r\n      const ignore = await localPeerConnection.setLocalDescription(offer);\r\n      onSetSessionDescriptionSuccess();\r\n    } catch (e) {\r\n      onSetSessionDescriptionError(e);\r\n    }\r\n\r\n    try {\r\n      \/\/ eslint-disable-next-line no-unused-vars\r\n      const ignore = await remotePeerConnection.setRemoteDescription(offer);\r\n      onSetSessionDescriptionSuccess();\r\n    } catch (e) {\r\n      onSetSessionDescriptionError(e);\r\n    }\r\n  }\r\n<\/pre>\n<p><span style=\"font-size: 14pt;\">\u30ed\u30fc\u30ab\u30eb\u5074\u306fRTCPeerConnection.setLocalDescription()\u3001\u30ea\u30e2\u30fc\u30c8\u5074\u306fRTCPeerConnection.setRemoteDescription()\u3067SDP offer\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002<\/span><br \/>\n<span style=\"font-size: 14pt;\">\u4eca\u56de\u306f\u81ea\u5206\u540c\u58eb\u306e\u63a5\u7d9a\u306a\u306e\u3067\u6c17\u306b\u3057\u306a\u304f\u3066\u3088\u3044\u306e\u3067\u3059\u304c\u3001\u672c\u6765\u30ea\u30e2\u30fc\u30c8\u306fSDP offer\u3092\u77e5\u3089\u306a\u3044\u306f\u305a\u306a\u306e\u3067\u3001SDP\u3092\u4f1d\u9054\u3059\u308b\u305f\u3081\u306b\u30b7\u30b0\u30ca\u30ea\u30f3\u30b0\u30b5\u30fc\u30d0\u30fc\u3068\u547c\u3070\u308c\u308b\u3082\u306e\u304c\u5fc5\u8981\u306b\u306a\u3063\u3066\u304d\u307e\u3059\u3002\u3053\u308c\u306b\u3064\u3044\u3066\u306f\u6b21\u56de\u4ee5\u964d\u3067\u8a73\u3057\u304f\u89e3\u8aac\u3059\u308b\u3001\u304b\u3082\u2026\uff1f<\/span><\/p>\n<p><span style=\"font-size: 14pt;\">\u307e\u305f\u3001SDP offer\u3092\u30bb\u30c3\u30c8\u3057\u305f\u5f8c\u3001\u30ea\u30e2\u30fc\u30c8\u5074\u306eonTrack\u30a4\u30d9\u30f3\u30c8\u304c\u767a\u706b\u3057\u307e\u3059\u3002\u30a4\u30d9\u30f3\u30c8\u767a\u706b\u6642\u306e\u51e6\u7406gotRemoteStream()\u306f\u2461\u3067\u30ea\u30e2\u30fc\u30c8\u5074\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/span><\/p>\n<pre class=\"lang:default highlight:0 decode:true \">function gotRemoteStream(e) {\r\n    if (remoteVideo.srcObject !== e.streams[0]) {\r\n      remoteVideo.srcObject = e.streams[0];\r\n      console.log('Received remote stream');\r\n    }\r\n  }\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 14pt;\">onTrack\u30a4\u30d9\u30f3\u30c8\u304c\u767a\u706b\u3059\u308b\u3068\u3001\u901a\u4fe1\u76f8\u624b\u304c\u9001\u4fe1\u3059\u308bMediaStream\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u914d\u5217\u3092\u53d7\u3051\u53d6\u308c\u308b\u306e\u3067\u3001\u305d\u308c\u3092\u30ea\u30e2\u30fc\u30c8\u5074\u306evideo\u8981\u7d20\u306b\u30bb\u30c3\u30c8\u3057\u3066\u3044\u307e\u3059\u3002<\/span><br \/>\n<span style=\"font-size: 14pt;\">\u305f\u3060\u3057\u3001\u3053\u306e\u6642\u70b9\u3067\u306fWebRTC\u63a5\u7d9a\u304c\u78ba\u7acb\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u30bb\u30c3\u30c8\u3057\u305f\u97f3\u58f0\u30fb\u6620\u50cf\u304c\u518d\u751f\u3055\u308c\u308b\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"font-size: 18pt;\"><strong>\u2464[Create answer]\u30dc\u30bf\u30f3<\/strong><\/span><\/h2>\n<p><span style=\"font-size: 14pt;\">SDP\u3092answer\u5074(\u4eca\u56de\u306f\u30ea\u30e2\u30fc\u30c8\u5074)\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002<\/span><br \/>\n<span style=\"font-size: 14pt;\">offer\u3068answer\u306b\u3064\u3044\u3066\u306e\u8aac\u660e\u3082\u6b21\u56de\u4ee5\u964d\u3092\u304a\u697d\u3057\u307f\u306b\u2026!!<\/span><\/p>\n<pre class=\"lang:default highlight:0 decode:true \">async function createAnswer () {\r\n\u3000\u3000\u3000(\u4e2d\u7565)\r\n    try {\r\n      const answer = await remotePeerConnection.createAnswer();\r\n      gotDescription2(answer);\r\n    } catch (e) {\r\n      onCreateSessionDescriptionError(e);\r\n    }\r\n  }\r\n<\/pre>\n<pre class=\"lang:default highlight:0 decode:true \">function gotDescription2(description) {\r\n    answerSdpTextarea.disabled = false;\r\n    answerSdpTextarea.value = description.sdp;\r\n  }\r\n<\/pre>\n<p><span style=\"font-size: 14pt;\">SDP answer\u306fRTCPeerConnection.createAnswer()\u30e1\u30bd\u30c3\u30c9\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002<\/span><br \/>\n<span style=\"font-size: 14pt;\">\u2462\u540c\u69d8\u3001\u4f5c\u6210\u3057\u305fSDP\u3092textarea\u8981\u7d20\u3067\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"font-size: 18pt;\"><strong>\u2465[Set answer]\u30dc\u30bf\u30f3<\/strong><\/span><\/h2>\n<p><span style=\"font-size: 14pt;\">\u4f5c\u6210\u3057\u305fSDP answer\u3092RTCPeerConnection\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002<\/span><\/p>\n<pre class=\"lang:default highlight:0 decode:true \">async function setAnswer() {\r\n    let sdp = answerSdpTextarea.value;\r\n    const answer = {\r\n      type: 'answer',\r\n      sdp: sdp\r\n    };\r\n\r\n    try {\r\n      \/\/ eslint-disable-next-line no-unused-vars\r\n      const ignore = await remotePeerConnection.setLocalDescription(answer);\r\n      onSetSessionDescriptionSuccess();\r\n    } catch (e) {\r\n      onSetSessionDescriptionError(e);\r\n    }\r\n\r\n    console.log(`Modified Answer from remotePeerConnection\\n${sdp}`);\r\n    try {\r\n      \/\/ eslint-disable-next-line no-unused-vars\r\n      const ignore = await localPeerConnection.setRemoteDescription(answer);\r\n      onSetSessionDescriptionSuccess();\r\n    } catch (e) {\r\n      onSetSessionDescriptionError(e);\r\n    }\r\n  }\r\n<\/pre>\n<p><span style=\"font-size: 14pt;\">\u30ed\u30fc\u30ab\u30eb\u5074\u306fRTCPeerConnection.setRemoteDescription()\u3001\u30ea\u30e2\u30fc\u30c8\u5074\u306fRTCPeerConnection.setLocalDescription()\u3067SDP answer\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002<\/span><br \/>\n<span style=\"font-size: 14pt;\">\u3053\u3053\u307e\u3067\u5b8c\u4e86\u3059\u308b\u3068\u5f8c\u306fWebRTC\u304c\u52dd\u624b\u306b\u63a5\u7d9a\u8a66\u884c\u3092\u884c\u3063\u3066\u304f\u308c\u3001\u6210\u529f\u3059\u308b\u3068\u30ea\u30e2\u30fc\u30c8\u5074\u306evideo\u8981\u7d20\u3067\u97f3\u58f0\u30fb\u6620\u50cf\u306e\u518d\u751f\u304c\u59cb\u307e\u308a\u307e\u3059\u3002<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-6326\" src=\"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf3-1024x507.png\" alt=\"\" width=\"750\" height=\"371\" srcset=\"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf3-1024x507.png 1024w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf3-300x148.png 300w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf3-768x380.png 768w, https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/11\/\u77f3\u91ce\u30c7\u30fc\u30bf3.png 1897w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/p>\n<p><span style=\"font-size: 14pt;\">\u63a5\u7d9a\u6210\u529f\uff01<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"font-size: 18pt;\"><strong>\u2466[Hang up]\u30dc\u30bf\u30f3<\/strong><\/span><\/h2>\n<p><span style=\"font-size: 14pt;\">WebRTC\u63a5\u7d9a\u3092\u7d42\u4e86\u3057\u307e\u3059\u3002<\/span><\/p>\n<pre class=\"lang:default highlight:0 decode:true \">function hangup() {\r\n    remoteVideo.srcObject = null;\r\n    console.log('Ending call');\r\n    localStream.getTracks().forEach(track =&gt; track.stop());\r\n    sendChannel.close();\r\n    if (receiveChannel) {\r\n      receiveChannel.close();\r\n    }\r\n    localPeerConnection.close();\r\n    remotePeerConnection.close();\r\n    (\u4ee5\u4e0b\u7565)<\/pre>\n<p><span style=\"font-size: 14pt;\">\u30ed\u30fc\u30ab\u30eb\u30fb\u30ea\u30e2\u30fc\u30c8\u5171\u306bRTCPeerConnection.close()\u30e1\u30bd\u30c3\u30c9\u3067WebRTC\u63a5\u7d9a\u3092\u9589\u3058\u307e\u3059\u3002<\/span><br \/>\n<span style=\"font-size: 14pt;\">\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 14pt;\">\u3055\u3066\u3001\u3044\u304b\u304c\u3067\u3057\u305f\u3067\u3057\u3087\u3046\u304b\u3002<\/span><\/p>\n<p><span style=\"font-size: 14pt;\">\u5358\u7d14\u306aP2P\u3067\u3042\u308c\u3070\u3001WebRTC\u306f\u8ab0\u3067\u3082\u7c21\u5358\u306b\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u512a\u308c\u3082\u306e\u3067\u3059\u3002<\/span><\/p>\n<p><span style=\"font-size: 14pt;\">\u4eca\u5f8c\u3082\u300eReDois\u300f\u3084WebRTC\u306b\u3064\u3044\u3066\u7d99\u7d9a\u7684\u306b\u767a\u4fe1\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"font-size: 14pt;\">\u304a\u697d\u3057\u307f\u306b\uff01<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.ois-yokohama.co.jp\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-6056 alignnone\" src=\"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-content\/uploads\/2019\/06\/ois_logo-300x137.jpg\" alt=\"\u30aa\u30ea\u30a8\u30f3\u30bf\u30eb\u30a4\u30f3\u30d5\u30a9\u30fc\u30e1\u30a4\u30b7\u30e7\u30f3\u30b5\u30fc\u30d3\u30b9\uff08OIS\uff09\" width=\"300\" height=\"137\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \u306f\u3058\u3081\u307e\u3057\u3066\uff01OIS\u306e\u81ea\u793e\u88fd\u54c1\u300eReDois\u300f\u958b\u767a\u62c5\u5f53\u3067\u3059\u3002 &nbsp; \u300eReDois\u300f\u306f\u3001WebRTC\u3068\u547c\u3070\u308c\u308b\u6280\u8853\u3092\u5229\u7528\u3057\u3001\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u914d\u4fe1\u3092\u5b9f\u73fe\u3057\u3066\u3044\u307e\u3059\u3002 &nbsp; &nbsp; \u79c1\u304b\u3089\u306f\u3001 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":6320,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"vkexunit_cta_each_option":"","footnotes":""},"categories":[46,758,6],"tags":[757,755,756],"class_list":["post-6319","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ois","category-redois","category-engineer","tag-ois","tag-redois","tag-webrtc"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-json\/wp\/v2\/posts\/6319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-json\/wp\/v2\/comments?post=6319"}],"version-history":[{"count":9,"href":"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-json\/wp\/v2\/posts\/6319\/revisions"}],"predecessor-version":[{"id":6332,"href":"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-json\/wp\/v2\/posts\/6319\/revisions\/6332"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-json\/wp\/v2\/media\/6320"}],"wp:attachment":[{"href":"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-json\/wp\/v2\/media?parent=6319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-json\/wp\/v2\/categories?post=6319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ois-yokohama.co.jp\/oisblog2018\/wp-json\/wp\/v2\/tags?post=6319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}