AWSããŒã±ãããã¬ã€ã¹
ãŸãã Amazon AWS Marketplaceã«ã€ããŠå°ãã話ããããšæããŸã ã ã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³ãã¢ããããŒããããGoogle PlayãApp Storeãšã¯ç°ãªããéçºè ã¯AWSã«ãµãŒããŒã¢ããªã±ãŒã·ã§ã³ãæçš¿ããŸãã ããã§ã¯ãç¡æã®LAMPã¹ã¿ãã¯ããSAPã®ãããªãµãŒããŒããŒã¹ã®ãšã³ã¿ãŒãã©ã€ãºãœãªã¥ãŒã·ã§ã³ãŸã§ãå€ãã®èå³æ·±ããã®ãèŠã€ããããšãã§ããŸã ã
åžå Žãšé£æºããããšã®å©ç¹ã¯ãå°å ¥ã®ã¹ããŒããšå©äŸ¿æ§ã«ãããŸãã ååãšããŠãå¿ èŠãªã¢ããªã±ãŒã·ã§ã³ãµãŒããŒã¯æ¢ã«æ§æãããæé©ã«æ§æãããŠããã EC2ã€ã³ã¹ã¿ã³ã¹èªäœ ïŒAmazon EC2ä»®æ³ãµãŒããŒïŒã®èµ·åæã«èµ·åãããŸãã ã€ã³ã¹ã¿ã³ã¹ã®èµ·åã¯Webã€ã³ã¿ãŒãã§ãŒã¹ããè¡ãããè¿œå ã®ç®¡çè ã®ç¥èãšã¹ãã«ã¯å¿ èŠãããŸããã
ãã ããæäœäžã«Linux管çã¹ãã«ãå¿ èŠã«ãªãå ŽåããããŸãã ãã ããã€ã³ã¹ããŒã«ãšæ§æã®ãã¹ãŠã®æ®µéãã¹ããããããã©ãã«ã·ã¥ãŒãã£ã³ã°ãšçæã§ã¿ã³ããªã³ãæ©ãæéã1ã2æéç¯çŽããŠãäœæ¥ãéå§ããããšã¯ééããªãçŽ æŽãããããšã§ãã ãã®çµæãå¿ èŠãªæ©èœãäºåã«èšå®ããããã§ã«æ©èœããŠããã©ã€ããµãŒããŒãååŸããŸãã
åŸã§ãSSHãä»ããŠãã®ãµãŒããŒã«ãã°ã€ã³ããçŸåšã®ãã¹ãŠã®èšå®ããã¡ã€ã«ã·ã¹ãã ãªã©ããã§ãã¯ããããšã劚ãããã®ã¯äœããããŸããã ãã®çµæããµãŒããŒãžã®ãã«ã¢ã¯ã»ã¹ãå¯èœã«ãªãã貎éãªæéãç¯çŽã§ããŸããã
AWS Marketplaceã§äœæ¥ããã«ã¯ããã¡ããAmazon Web Servicesã®ã¢ã«ãŠã³ããå¿ èŠã§ãã 幞ããªããšã«ãå€ãã®éçºè ãšITå°é家ã¯ãã§ã«ãã®ãããªã¢ã«ãŠã³ããæã£ãŠããŸãã ããã§ãªãå Žåã¯ã AWSãŠã§ããµã€ãã§ãã€ã§ãå ¥æã§ããŸãã
WebRTCã¡ãã£ã¢ãµãŒããŒ
ãåç¥ã®ããã«ã WebRTCã¯ããã©ãŠã¶ããã³ã¢ãã€ã«ããã€ã¹ã§ãªãŒãã£ãªããã³ãããªããŒã¿ããã£ããã£ãåçãããã³éä¿¡ããããã®æè¡ã§ãã WebRTCã䜿çšãããšããªã³ã©ã€ã³ãããŒããã£ã¹ãããããªãã£ããããããªã³ãŒã«ãäŒè°ãã€ã³ã¿ãŒãããã©ãžãªãªã©ã RTCèªäœãå¿ èŠãªå€ãã®ãããžã§ã¯ãïŒãªã¢ã«ã¿ã€ã ã§äœé 延ã®ãªã¢ã«ã¿ã€ã éä¿¡ïŒãªã©ã®ã¢ããªã±ãŒã·ã§ã³ãäœæã§ããŸãã
WebRTCã¡ãã£ã¢ãµãŒããŒã¯ãWebRTCãã¯ãããžãŒã®æ©èœãæ¡åŒµããŸããWebRTCãã¯ãããžãŒã¯ããã®ãããªãµãŒããŒãªãã§ã¯ãã¢ããŒãã¢ã§æ©èœã ãå€ãã®æè¡çãªå¶éããããŸãã
ã¡ãã£ã¢ãµãŒããŒã¯ã次ã®ãããªã¿ã¹ã¯ã«äœ¿çšã§ããŸãã
- ãµãŒããŒã§ã®WebRTCãããªã¹ããªãŒã ã®èšé²
- ãããªã¹ããªãŒã ãªã¬ãŒ
- ãããªã¹ããªãŒã ãã©ã³ã¹ã³ãŒãã£ã³ã°
- WebRTCããRTMPãŸãã¯HLSãžã®ã¹ããªãŒã 圢åŒã®å€æ
- ãããªã¹ããªãŒã ãã¹ãããã·ã§ããã«ã¹ã©ã€ã¹ãã
- IPã«ã¡ã©ããWebRTCãããªã¹ããªãŒã ãåçãã
- ãªã©
ãã®èšäºã§ã¯ã2åã¯ãªãã¯ããã ãã§Amazon AWSã§WebRTCãµãŒããŒãèµ·åããæ¹æ³ãšãWebRTCçµç±ã§åä¿¡ãããããªã®åŠçã«é¢é£ããããã€ãã®äŸããã¹ãããæ¹æ³ã瀺ããŸãã
Webã³ãŒã«ãµãŒããŒ
Web Call Serverããã¹ãããŸã ã ããã¯ãWebRTCãRTMPãRTSPãããã³ãªã¢ã«ã¿ã€ã ãããªãæäœããããã®ãã®ä»ã®ãããã³ã«ãšãã¯ãããžãŒããµããŒãããWebRTCã¡ãã£ã¢ãµãŒããŒã§ãã
éå§åŸããã«ãèšé²ãäžç¶ãRTMPãžã®å€æãIPã«ã¡ã©ããã®åçãªã©ãã¡ãã£ã¢ãµãŒããŒã«åºæã®ããã€ãã®æ©èœããã¹ãããŸãã
AWS Marketplaceãªã¹ã
éå§ããã«ã¯ãAWSã§ã®ãã°ã€ã³ãå¿ èŠã§ããããšã¯äžèšã®ãšããã§ãã ãªã¹ãã¯ãåžå Žã«ãããµãŒããŒã¢ããªã±ãŒã·ã§ã³ã®ããŒãžã§ãã
Web Call Serverãªã¹ãã¯ãã®ãªã³ã¯ããå ¥æã§ãã次ã®ããã«ãªããŸãã é»è²ã®[ ç¶è¡ ]ãã¿ã³ã«æ³šæããŠãã ãã-ããã1åç®ã®ã¯ãªãã¯ã§ãã
次ã®ããŒãžã¯ãµãŒãã¹ã®å®å šãªèª¬æã§ãããCPUããã³ã¡ã¢ãªããšã«é©åãªã€ã³ã¹ã¿ã³ã¹ãµã€ãºãéžæããéããŠããããŒãã®ãªã¹ãã調æŽã§ããŸãã
ãŸã äœãå€æŽããããšã¯ã§ããã1ã¯ãªãã¯ã§èµ·åãã¿ã³ãã¯ãªãã¯ããã ãã§ããã¹ãŠã®èšå®ã¯ããã©ã«ãã®ãŸãŸã§ãã
Amazon-ã€ã³ã¹ã¿ã³ã¹ã¯ãåæã«äœæããã³ç Žæ£ããããšã§æåã§ãã ãããã£ãŠãäœããæ£ããæ§æãããŠããªãããééã£ãã€ã³ã¹ã¿ã³ã¹ãµã€ãºãéžæãããå Žåãåã«ãããçµäºããŠå床äœæããŸãã 幞ããªããšã«ãããã¯éåžžã®æäœã§ãããæ°åããããŸãã
å®äº
2åç®ã®ã¯ãªãã¯åŸãèµ·åãæåãããšããã¡ãã»ãŒãžã衚瀺ãããŸãã ãã®åŸãã€ã³ã¹ã¿ã³ã¹ãç«ã¡äžãããæåã®èµ·åãã¹ã«é¢é£ãããã¹ãŠã®å¿ èŠãªæé ãå®äºãããŸã§åŸ ã€å¿ èŠããããŸãã
EC2管çã³ã³ãœãŒã«ã«ç§»åãã ã€ã³ã¹ã¿ã³ã¹ã»ã¯ã·ã§ã³ã§éå§ããå 容ã確èªãããšããã®ãã¬ãŒããèŠã€ããããšãã§ããŸãã
ããã¯ã次ã®ã¢ãã¬ã¹ãå²ãåœãŠãããéå§EC2ã€ã³ã¹ã¿ã³ã¹ã§ãã
DNS: ec2-34-207-147-235.compute-1.amazonaws.com IP: 34.207.147.235
Google Chromeãã©ãŠã¶ãŒã§åæãµãŒããŒã»ããã¢ããã®ã¢ãã¬ã¹ãéããŸãã
https://ec2-34-207-147-235.compute-1.amazonaws.com:8888
Chromeã¯äžæå¿«ãªæšæ¶ãããSSL蚌ææžã®åé¡ã«ã€ããŠäžå¹³ãèšããŸãã å®éã蚌ææžãã€ã³ã¹ããŒã«ã§ããã®ã¯èªåã ãã§ãããç¬èªã®ãã¡ã€ã³ã䜿çšããŠèšŒææžãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãã
ãããã£ãŠãã詳现ã /ãç¶è¡ããªã³ã¯ãã¯ãªãã¯ããã ãã§ããµãŒããŒãæäŸãã蚌ææžã䜿çšããããChromeãã©ãŠã¶ãŒã«æ瀺ããŸãã
次ã®ã¹ãããã§ã¯ãWeb Call Serverã®ç¡æã©ã€ã»ã³ã¹ã®çªå·ãå ¥åããŸããããã¯ã ããããå ¥æã§ããŸã ã
次ã«ã管çè ãã¹ã¯ãŒããèšå®ããŠãµãŒããŒã®ããã·ã¥ããŒãã«å ¥ãããŠãŒã¶ãŒåãšãã¹ã¯ãŒãã䜿çšããŠãã°ã€ã³ããå¿ èŠããããŸãã
WebRTCã¬ã³ãŒãã®ãã¹ã
ãµãŒããŒã®äºåèšå®ãå®äºãããã¹ãã«çŽæ¥é²ãããšãã§ããŸãã ãããè¡ãã«ã¯ã ããã·ã¥ããŒãã«ãã°ã€ã³ããŠãã¹ãã±ãŒã¹ãéããŸã ã
ããšãã°ããããªã¹ããªãŒã èšé²ã䜿çšããWebRTCãããŒããã£ã¹ãã¯æ¬¡ã®ãšããã§ãã
å·ŠåŽã§ã¯ããŠã§ãã«ã¡ã©ãããããªããã£ããã£ããŸãã ãããªã¯ãµãŒããŒäžã§åæã«äžç¶ããã³èšé²ãããŸãã åæ¢ãã¿ã³ã«ãã£ãŠãããŒããã£ã¹ããåæ¢ããããšãã¹ããªãŒã ã¯ãµãŒããŒãžã®éä¿¡ãåæ¢ããèšé²ãåæ¢ããŸãã mp4圢åŒã®ãã¡ã€ã«ã®ããŠã³ããŒããžã®ãªã³ã¯ãå³åŽã«è¡šç€ºãããŸãã
WebRTCãã¹ã-ãªã¬ãŒ
WebRTCã¡ãã£ã¢ãµãŒããŒã®ãã1ã€ã®äŸ¿å©ãªã¢ããªã±ãŒã·ã§ã³ã¯ãWebRTCã¹ããªãŒã ã®1察å€ã®ãªã¬ãŒã§ãã ããã«ã¯ã åæ¹åã¹ããªãŒãã³ã°ã®äŸã䜿çšãããšäŸ¿å©ã§ãã
äžèšã®ã¹ã¯ãªãŒã³ã·ã§ããã§ã¯ã eabcãšããååã®ãããªã¹ããªãŒã ãWebRTCãã¯ãããžãŒã䜿çšããŠAmazon EC2ãµãŒããŒã«éä¿¡ãããŸãã ãããã£ãŠããããªã¹ããªãŒã ã®ååãèšå®ããã åçãã¿ã³ãæŒãããšã§å³åŽã®åãã€ã³ã¿ãŒãã§ã€ã¹ã§ãã®ååã§ã¹ããªãŒã ãåçã§ããŸããå¥ã®äŸã§ã¯ã次ã®ããã«Playerã䜿çšã§ããŸãã
ããã¯ãªã¬ãŒã§ãããããå€ãã®ãã¬ãŒã€ãŒãŠã£ã³ããŠãéãããšãã§ããåãã¬ãŒã€ãŒãŠã£ã³ããŠã¯åãWebRTCãããªã¹ããªãŒã ãåçããŸãã
RTSPã«ã¡ã©ããã®WebRTCãããŒããã£ã¹ã
ãµãŒããŒã¯ãIPã«ã¡ã©ããã¹ããªãŒã ãååŸããWebRTCçµç±ã§é ä¿¡ã§ããŸãã ãããè¡ãã«ã¯ãRTSPãä»ããŠIPã«ã¡ã©ã«ã¢ã¯ã»ã¹å¯èœã§ãããH.264ããã³AACã³ãŒããã¯ãå«ãŸããŠããå¿ èŠããããŸãã
ãã¹ãã§ã¯ãåãPlayerã䜿çšã§ããŸãããå¯äžã®éãã¯ããããªã¹ããªãŒã ã®ååãšããŠRTSP URLãæå®ããå¿ èŠãããããšã§ãã
ãã®äŸã§ã¯ã rtspã®ãœãŒã¹ããã®RTSPã¹ããªãŒã ã䜿çšããŸãã//str81.creacast.com/grandlilletv/high
RTMPã®WebRTCãªã¬ãŒ
æåŸã®4çªç®ã®äŸãšããŠãRTMPã¬ããªã±ãŒã·ã§ã³ã§WebRTCã¹ããªãŒã ãå€æããããšãæ€èšããŠãã ããã WebRTCãã¯ãããžãŒã®å¹ åºãéçºã«ãããããããå€ãã®ãµãŒãã¹ãFlashã§å®è¡ããç¶ããŠããããšã¯ç§å¯ã§ã¯ãããŸããããã®å€æã®ã¿ã¹ã¯ã¯ãWebRTCããµããŒãããªãFlashãã©ãããã©ãŒã ããã³ãµãŒããŒã§WebRTCã¹ããªãŒã ãå©çšå¯èœã«ããããšã§ãã
RTMPã®åçºè¡ãšããŠã®äŸã¯WebRTCãšåŒã°ãã1ããŒãžã§WebRTCãä»ããŠãµãŒããŒã«ã¹ããªãŒã ãéä¿¡ãïŒå·ŠåŽïŒãRTMPãšåããµãŒããŒã«ãªãã€ã¬ã¯ãããRTMPãããã³ã«ã䜿çšããŠFlash Playerã§åçããæ¹æ³ã瀺ããŸãïŒå³åŽïŒã
ãããã£ãŠã次ã®ãããªWebRTCã¡ãã£ã¢ãµãŒããŒæ©èœã瀺ããŸããã
- WebRTCã¬ã³ãŒã
- ãŠã§ãã«ã¡ã©ãªã¬ãŒ
- RTSP IPã«ã¡ã©ãªã¬ãŒ
- RTMPã«å€æ
ãŠã§ãéçº
Dashboradã§å®è¡ãããã¹ãŠã®äŸã¯ãåãªããªãŒãã³ãœãŒã¹ã®JavaScript + HTMLã§ãã
ããšãã°ãPlayerã®ãµã³ãã«ã³ãŒãã¯ãã¡ãããå ¥æã§ããŸã ã
ããããã¹ãŠã®äŸã®äœæ¥ã¯ã3ã€ã®åçŽãªJavaScripté¢æ°ã«ãªããŸã ã
1.æ¥ç¶ã確ç«ããŸãã
ãã®ã³ãŒãã¯ãWebsocketãããã³ã«ã䜿çšããŠãµãŒããŒãžã®æ¥ç¶ã確ç«ããŸãã ESTABLISHEDã¹ããŒã¿ã¹ãåãåã£ãããã»ãã·ã§ã³ãªããžã§ã¯ãã§createStreamïŒïŒãåŒã³åºããŠããããªã¹ããªãŒã ãŸãã¯åçãéä¿¡ã§ããŸãã
Flashphoner.createSession({urlServer: "wss://ec2-34-207-147-235.compute-1.amazonaws.com:8443"}).on(Flashphoner.constants.SESSION_STATUS.ESTABLISHED, function (session) { //session connected, start streaming }).on(Flashphoner.constants.SESSION_STATUS.DISCONNECTED, function () { //display status }).on(Flashphoner.constants.SESSION_STATUS.FAILED, function () { //display status });
2.ãããªã¹ããªãŒã ã®éä¿¡
ãããªã¹ããªãŒã ããµãŒããŒã«éä¿¡ããã«ã¯ã stream.publishïŒïŒã¡ãœããã䜿çšããŸãã ã³ãŒããããããããã«ãæåã®ã€ãã³ããã³ãã©ãŒã¯äœæãããStreamã§ãã³ã°ããæåŸã«publishïŒïŒãåŒã³åºãããŸãã
session.createStream({ name: "eabcd", display: localVideo, cacheLocalResources: true, receiveVideo: false, receiveAudio: false }).on(Flashphoner.constants.STREAM_STATUS.PUBLISHING, function (publishStream) { //display status }).on(Flashphoner.constants.STREAM_STATUS.UNPUBLISHED, function () { //display status }).on(Flashphoner.constants.STREAM_STATUS.FAILED, function () { //display status }).publish();
3.ãããªã¹ããªãŒã ãåçãã
ã¹ããªãŒã ãåçããã«ã¯ã playïŒïŒãåŒã³åºãå¿ èŠããããŸãã ã¹ããªãŒã ã¯ãid = remoteVideoã®divèŠçŽ ã§åçãããŸãã
session.createStream({ name: "stream222", display: remoteVideo, cacheLocalResources: true, receiveVideo: true, receiveAudio: true }).on(Flashphoner.constants.STREAM_STATUS.PLAYING, function (playStream) { //display status }).on(Flashphoner.constants.STREAM_STATUS.STOPPED, function () { //display status }).on(Flashphoner.constants.STREAM_STATUS.FAILED, function () { //display status }).play();
ãããã£ãŠããµã³ãã«ã®éçºãšé©å¿ã«ã¯ãJavaScriptãšHTMLã®åŒ·åºãªç¥èãå¿ èŠã§ããããããã®æ©èœãæ¢åã®ããŒãžã³ãŒããšã¹ã¯ãªããã«åã蟌ãããšãã§ããŸãã
ãããªã¹ããªãŒã ãåçããã³éä¿¡ããããã®ã¹ã¯ãªããã®Webéçºã«é¢ãã詳现ãªããã¥ã¡ã³ãã¯ãWeb Call Serverã®Web SDKããŒãžã«ãããŸã ã
éå¶
AWS Marketplaceã§ååŸãããã€ã³ã¹ã¿ã³ã¹ã¯ãæšæºã®SSH管çæ¹æ³ãé©çšãããéåžžã®Amazon EC2ã€ã³ã¹ã¿ã³ã¹ã§ãã
SSHã䜿çšããŠãµãŒããŒã³ã³ãœãŒã«ã«ãã°ã€ã³ããã«ã¯ãããšãã°Puttyã䜿çšããŸã
1. [ ã»ãã·ã§ã³]ã¡ãã¥ãŒã« EC2ãµãŒããŒã®IPã¢ãã¬ã¹ãŸãã¯ãã¡ã€ã³ãå ¥åããŸã ã
2.ã¡ãã¥ãŒã®æ¥ç¶/ããŒã¿ã§æšæºãŠãŒã¶ãŒåec2-userãèšå®ããŸã
3.ãã¡ã€ã«ãžã®ãã¹ãç§å¯éµã§æå®ããŸãã
ããŒç®¡çã¯ãã»ãã¥ãªãã£èšå®ã®Amazon AWSã¢ã«ãŠã³ãå ã§è¡ãããŸãã ã»ãšãã©ã®å Žåããã§ã«ã¢ã«ãŠã³ããæã£ãŠããã®ã§ãå°ãªããšã1ã€ã®ã»ãã¥ãªãã£ã°ã«ãŒããäœæããããŒãããŠã³ããŒãããŠããŸãã ããã§ãªãå Žåã¯ã Amazon AWSã®ããã¥ã¡ã³ããåç §ããŠã ç§å¯éµãäœæ/ããŠã³ããŒãããŠãã ããã
次ã«ãLinuxãµãŒããŒã®ã³ã³ãœãŒã«ã«ã¢ã¯ã»ã¹ããŠç®¡çã§ããŸãã
ããšãã°ãäžã§ç€ºããäŸã®ãããã©ã«ããŒã«ç§»åããŠãããã«ãããã¡ã€ã«ã確èªã§ããŸãã ç¹ã«ãåæ¹åã¹ããªãŒãã³ã°ã®äŸã¯æ¬¡ã®ãã¹ã«æ²¿ã£ãŠé 眮ãããŸãã
/usr/local/FlashphonerWebCallServer/client2/examples/demo/streaming/two_way_streaming
ãµã³ãã«ãã¡ã€ã«ã®ããªãŒã¯æ¬¡ã®ããã«ãªããŸãã
cd /usr/local/FlashphonerWebCallServer tree -L 1 client2
ãããã®ãµã³ãã«ã¯ããã±ãŒãžåããŠãApacheãNginxãªã©ã®WebãµãŒããŒã«ã³ããŒã§ããŸãã
ããšãã°ã次ã®ããã«ïŒ
cd /usr/local/FlashphonerWebCallServer tar -czf client2.tar.gz client2
HTTPSã䜿çšããŠãã¹ãŠããã¹ããããšããäºå®ã«æ³šæãæãããšã¯äžå¿ èŠã§ã¯ãããŸããã Chromeã§ã¯ãWebRTCã¯å®å šã§ãªãïŒHTTPïŒããŒãžã§ã®äœæ¥ãæåŠããŸãã ãããã£ãŠããµã³ãã«ãApacheãŸãã¯Nginxã«ç§»æ€ãããšãã¯ããããã®ããŒãžã«HTTPSçµç±ã§ã¢ã¯ã»ã¹ã§ããããšã確èªããŠãã ããã
åç §è³æ
- AWS WebãµãŒãã¹ -Amazon AWSãµãŒããŒ
- AWSããŒã±ãããã¬ã€ã¹ -Amazon AWSããŒã±ãã
- Web Call Server -WebRTC Media Server Web Call Serverãµã€ã
- AmazonããŒã±ãããã¬ã€ã¹ã§ã®ãŠã§ãã³ãŒã«ãµãŒããŒã®ãªã¹ã-AWSã§ã®ãŠã§ãã³ãŒã«ãµãŒããŒã®ãªã¹ã
- Player -WebRTCãåçããããã®JavaScript / HTML Playerã³ãŒãã®äŸ
- Web SDK -WebRTC Webã¢ããªã±ãŒã·ã§ã³ãéçºããããã®JavaScript API
- Puttyã¯ãWindowsçšã®SSHã¯ã©ã€ã¢ã³ãã§ãã
- AWSã»ãã¥ãªãã£ãšããŒç®¡ç -AWS Marketplaceã®ããŒç®¡ç