$30 off During Our Annual Pro Sale. View Details »

AirPlayの裏舞台

Chiharu Nameki
September 12, 2022

 AirPlayの裏舞台

iOSDC Japan 2022 day2, 20min Talk

https://fortee.jp/iosdc-japan-2022/proposal/c922031a-84b2-45de-9cac-3a05998978a9

• AirPlayとはAppleのデバイスから同一ネットワーク内の他の機器でメディアを再生する機能
• 歴史
• 直感的な操作の裏で行われていること、データの流れ
• アプリへの組み込み方

Chiharu Nameki

September 12, 2022
Tweet

More Decks by Chiharu Nameki

Other Decks in Technology

Transcript

  1. AirPlayͷཪ෣୆ ߦ໦ ઍय़ʢͳΊ͖ ͪ͸ΔʣTwitter, GitHub @Ridwy Streaming Client Team, גࣜձࣾ

    AbemaTV iOSDC JAPAN 2022, day2 (9/12)
  2. • ΠϯλʔωοτςϨϏہʢ2015೥։ہʣ • ৽͍͠ະདྷͷςϨϏʮABEMAʯ Streaming Client Team ABEMAͷ֤ରԠσόΠεͷ 
 ࠶ੜػೳΛ୲౰

    ݱࡏWഋʹ޲͚ͯฃಆத શ64ࢼ߹ແྉੜதܧʂ גࣜձࣾAbemaTV iPhone, iPad, Apple TV, Android, Android TV, Web, IPTV, Switch, Chromecast, …
  3. AirPlayͱ͸ʁ AppleͷσόΠε (iPhone, iPad, iPod touch, Mac)͔Β ಉҰωοτϫʔΫ಺ʹ͋ΔଞͷػثͰ Իָ, ࣸਅ,

    ಈըΛ࠶ੜ͢Δػೳ ϛϥʔϦϯά΍֎෦σΟεϓϨΠɾεϐʔΧʔͱͯ͠ͷར༻΋Մೳ
  4. ද෣୆͔Βݟ͍͖ͯ·͠ΐ͏

  5. iPhone͔ΒApple TVͰۂΛ࠶ੜ

  6. None
  7. AirPlayͷϚʔΫΛλοϓͯ͠ ग़ྗઌΛબͿ͚ͩ

  8. iPhone͔Β2୆ͷεϐʔΧʔͰಉ͡ۂΛ࠶ੜ

  9. MacʹAirPlayΛઃఆ macOS MontereyҎ߱ɺMacʹ΋AirPlayՄೳʂ

  10. None
  11. • ϚϧνϧʔϜ࠶ੜ • ෳ਺ͷεϐʔΧʔͰಉ͡ۂΛ࠶ੜ ಉظͯ͠࠶ੜ͞ΕΔͷͰɺ޿͍෦԰͍ͬͺ͍ʹԻָΛ͔͚Δ͜ͱ͕Ͱ͖Δ • ֤෦԰ͰผͷۂΛ࠶ੜ • HomePod mini

    2୆ͰεςϨΦϖΞΛ࡞ΕΔ • Siri΍Home Kitͱͷ૬ੑ΋ྑ͍ Hey, Siri. ϦϏϯάϧʔϜͰ Upbeat Funk Pop Λ࠶ੜͯ͠ .VTJDΞϓϦͷػೳΛϑϧͰ࢖͏ʹ͸"QQMF.VTJDʹՃೖ͢΂͠
  12. iPhone͔ΒApple TVͰಈըΛ࠶ੜ

  13. None
  14. • iPhoneͰΞϓϦΛόοΫάϥ΢ϯυʹͨ͠Γɺଞͷૢ࡞Λͯ͠΋ 
 AirPlay࠶ੜ͕ଓ͘ 
 • ಈըͷ৔߹͸ Sender ͱ Receiver

    ͸ 1 : 1 ෳ਺ͷػثΛબͿͱεϐʔΧʔͱͯ͠ͷར༻ʹͳΔ AirPlayಈը࠶ੜͷಛ௃
  15. iPhoneͷࣸਅΛେը໘Ͱʂ

  16. None
  17. ը໘ϛϥʔϦϯάɾը໘֦ு ஗Ԇ͕ؾʹͳΔਓʹ͸༗ઢωοτϫʔΫ͕͓͢͢Ί

  18. AirPlayͷཪ෣୆

  19. ྺ࢙

  20. 2002೥ Mac OS X v10.2 Jaguar ϦϦʔε AppleʹΑΔZero Con f

    iguration Networkingٕज़ɺ Rendezvous (ϥϯσϒʔ)Λ౥ࡌ Zero Con f iguration Networkingٕज़ͱ͸ • ෳࡶͳωοτϫʔΫઃఆͳ͠ʢ= Zero Con f igurationʣͰ 
 ಉҰωοτϫʔΫ্ʹ͋ΔಛఆͷσόΠεΛൃݟͰ͖Δٕज़ • ଞʹ͸ϚΠΫϩιϑτͷUPnPͳͲ 

  21. 2004೥ AirMac Express ൃച • iTunesͷۂΛωοτϫʔΫܦ༝ͰετϦʔϛϯά࠶ੜ͢ΔAirTunesػೳ • σόΠεݕग़ʹ͸ Rendezvous Λར༻

    (࢓༷ඇެ։) ˞೔ຊҎ֎Ͱ͸"JS1PSU&YQSFTT
  22. 2005೥ Mac OS X v10.4 Tiger ϦϦʔε • Rendezvous →

    Bonjour ʹ໊শมߋ 
 2010೥ Apple TV ୈ̎ੈ୅ ൃച • ಈը࠶ੜʹରԠ͠ɺAirTunes → AirPlay ʹʂ
  23. 2017೥ AirPlay 2 ൃද • Apple TV͚ͩͰͳ͘ରԠεϚʔτTVͰ΋ಈը࠶ੜ͕Մೳʹ • tvOS 11.4Ҏ߱

    • ϚϧνϧʔϜ࠶ੜػೳ • 4K, HDR, αϥ΢ϯυα΢ϯυʹରԠ ಉ࣌ظʹApple TV 4Kൃച
  24. ରԠσόΠε (Receiver) • Apple TV ୈ̎ੈ୅ʙ • ରԠSmartTV • Mac

    2018೥͝ΖͷϞσϧҎ߱, macOS Monterey • HomePod • ରԠεϐʔΧʔ ೔ຊͰ͸ Sony, LG͕ରԠTVΛग़͍ͯ͠Δ ͜ͷϚʔΫ͕໨ҹʂ
  25. SmartTVͰͷಈըετϦʔϛϯάͷ੍໿ • SharePlay ະαϙʔτ • HLSͷཁ݅ • VariantؒͰηάϝϯτڥքΛ߹ΘͤΔ • ηάϝϯτ͸IϑϨʔϜ͔Β࢝ΊΔ

    • ్தͰνϟϯωϧϨΠΞ΢τ΍CODECͷมߋ͸ෆՄ • ϑϨʔϜϨʔτ͸൒෼΋͘͠͸ഒͷ੾Γସ͑ͷΈՄ ৄࡉ͸ WWDC19 507 HLS Authoring for AirPlay 2 Video Λࢀর
  26. ௚ײతͳૢ࡞ͷཪͰ ͲΜͳ͜ͱ͕͓͜ͳΘΕ͍ͯΔͷ͔ʁ

  27. 1. σόΠεͷൃݟ BonjourʹΑΔAirPlayରԠσόΠεͷൃݟ 2. ར༻ 4ͭͷར༻γφϦΦ • ࣸਅΛදࣔ • ۂΛ࠶ੜ

    • ಈըΛ࠶ੜ • ը໘ϛϥʔϦϯάɾը໘֦ு AirPlay Λߦ͏ྲྀΕ ※ γφϦΦ͝ͱʹ࣮ݱํ๏͸ҟͳΔ
  28. σόΠεͷൃݟ

  29. Bonjour ෳࡶͳઃఆͳ͠ʹɺϩʔΧϧωοτϫʔΫ಺Ͱ ໨తͷػೳʢαʔϏεʣΛఏڙ͢ΔΠϯελϯεΛݕग़͢Δ࢓૊Έ ϋʔυ΢ΣΞ͕ෳ਺ͷαʔϏεΛఏڙ͢Δࣄ͸ Α͋͘ΔͷͰɺσόΠεͰ͸ͳ͘ ʮػೳΛఏڙ͢ΔΠϯελϯεʯͱ͍͏୯ҐͰѻ͏

  30. AirPlayͷαʔϏε _airplay._tcp _raop._tcp • RAOP = AirTunes Remote Audio Output

    Protocol • AirTunesͱͷޓ׵ੑ, ָۂ࠶ੜͷΈ 

  31. Multicast DNS (mDNS)ͷϨίʔυΛ׆༻ mDNS • খ͞ͳωοτϫʔΫ಺ͰɺDNSͷ୅ΘΓʹϗετ໊͔ΒIPΞυϨεΛղܾ • ֤σόΠε্ͰϨεϙϯμʔ্ཱ͕͕͓ͪͬͯΓɺϚϧνΩϟετͰ΍ΓͱΓ͢Δ 
 mDNSͷϨίʔυʹΠϯελϯεͱαʔϏεͷϚοϐϯάΛొ࿥

    
 (Publication)
  32. AirPlay Sender AirPlayͰ͖Δਓʙʂ 🙋 ŰŖŘ 🙋 ŰŖŘ Local Network ※

    ݫີͰ͸͋Γ·ͤΜ͕͜ΜͳΠϝʔδͰ͢
  33. Bonjourݕग़ αʔϏε _airplay._tcp Λఏڙ͍ͯ͠ΔΠϯελϯε͸͍Δʁ NiceSpeaker._airplay._tcp.local ݕग़ ໊લղܾ NiceSpeaker._airplay._tcp.local ͷϗετ໊, ϙʔτ

    NiceSpeaker._airplay._tcp.local ϗετ໊: NiceSpeaker.local ϙʔτ: 1010 NiceSpeaker.local, 1010 NiceSpeaker.localͷIPΞυϨε AirPlay Sender
  34. ར༻γφϦΦຖͷཪଆ ⚠ UNDOCUMENTED ϦόʔεΤϯδχΞϦϯά͞Ε͍ͯΔॳظͷ࢓༷Λݩʹ͍ͯ͠·͢

  35. ࣸਅΛAirPlay HTTPαʔό PUT /photo ࣸਅΞϓϦ ը૾ϑΝΠϧ ※ ͜ͷػೳ͸3rd Partyʹ͸ެ։͞Ε͍ͯͳ͍

  36. ۂΛAirPlay RTSP Real Time Streaming Protocol Apple Lossless౳Ͱ ΦʔσΟόοϑΝΛѹॖ Audio

    Packets DACP Digital Audio Control Protocol play , pause, stop, …
  37. ಈըΛAirPlay ίϯςϯπ ࠶ੜঢ়ଶ CDN POST /play with Video URL HTTPαʔό

    • Sender͸ಈըͷURLΛReceiverʹ౉͠ɺReceiverଆͰϑΝΠϧΛऔಘͯ͠࠶ੜ͢Δ • ίϯςϯπ͕҉߸Խ͞Ε͍ͯΔ৔߹ɺSenderΛ௨ͯ͡伴ͷॲཧΛߦ͏
  38. ϛϥʔϦϯάɾը໘֦ு ը໘ɾԻ੠Λ 
 HWΤϯίʔμͰѹॖ Packets

  39. ΞϓϦʹAirPlayΛ૊ΈࠐΉ

  40. ࣮͸ AVPlayer ΍ WebView Λ࢖͍ͬͯΕ͹ Կ΋͠ͳͯ͘΋AirPlay͞ΕΔʂ ग़ྗܦ࿏ͷ؅ཧ͸OSͷ࢓ࣄ

  41. εϓϥογϡ΍ϓϨϏϡʔಈըͳͲɺ खݩͷ୺຤ͷUIͷதͰ࠶ੜ͞Εͯཉ͍͠΋ͷ͸ϑϥάΛ false ʹ • AVPlayer allowsExternalPlayback • WKWebView allowsAirPlayForMediaPlayback

    Ή͠ΖɺAirPlay͠ͳ͍ͨΊͷϑϥά͕͋Δ
  42. ΑΓྑ͍ମݧͷͨΊͷνϡʔχϯά

  43. AirPlayઌͷબ୒ը໘Λදࣔ 
 AVRoutePickerView Λදࣔ let routePickerView = AVRoutePickerView() // ಈը࠶ੜՄೳͳσόΠεΛ༏ઌ͢Δ

    iOS 13Ҏ߱ routePickerView.prioritizesVideoDevices = true
  44. ΞϓϦΛดͯ͡΋࠶ੜΛଓ͚Δ Info.plistͰόοΫάϥ΢ϯυ࠶ੜΛ༗ޮԽ

  45. ΞϓϦ֎͔Βͷૢ࡞ΛՄೳʹ ϩοΫը໘΍ίϯτϩʔϧηϯλʔɺAirPlayઌ … MPRemoteCommandCenter ͰΠϕϯτΛड͚औͬͯ࠶ੜΛ੍ޚ

  46. ࠶ੜதͷۂ΍ಈըͷ৘ใΛදࣔ ϝλσʔλΛ 
 MPNowPlayingInfoCenter ʹఏڙ let nowPlayingInfoCenter = MPNowPlayingInfoCenter.default() var

    nowPlayingInfo = nowPlayingInfoCenter.nowPlayingInfo ?? [String: Any]() nowPlayingInfo[MPMediaItemPropertyTitle] = metadata.title nowPlayingInfo[MPMediaItemPropertyArtwork] = metadata.artwork nowPlayingInfoCenter.nowPlayingInfo = nowPlayingInfo
  47. • AirPlayͱ͸ʁ ԻָɾࣸਅɾಈըΛଞͷػثͰ؆୯ʹ࠶ੜ + ϛϥʔϦϯάɾը໘֦ு • ྺ࢙ͱͦΕͧΕͷମݧͷཪଆ Bonjour, RTSP, …

    • ΞϓϦ΁ͷ૊ΈࠐΈํ ·ͱΊ
  48. ࢀߟࢿྉ WWDC Sessions WWDC19 Session 501 Reaching the. Big Screen

    with AirPlay 2 WWDC19 Session 507 HLS Authoring for AirPlay 2 Video Apple։ൃऀ޲͚ϖʔδ 
 https://developer.apple.com/airplay/ 
 openairplay AirPlayͷϦόʔεΤϯδχΞϦϯά 
 https://openairplay.github.io
  49. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ Big Buck Bunny Copyright (C) 2008 Blender Foundation |

    peach.blender.org Some Rights Reserved. Creative Commons Attribution 3.0 license. https://peach.blender.org/ Springish by Gillicuddy CC BY-NC 3.0 https://freemusicarchive.org/music/gillicuddy/Plays_Guitar/05-springish/ Upbeat Funk Pop by Scott Holmes Music CC BY-NC 4.0 https://freemusicarchive.org/music/Scott_Holmes/indie-pop-acoustic-background- music/upbeat-funk-pop-1/