Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

PiP で実現するミラティブの配信コメントバー / pip-streaming-comment...

PiP で実現するミラティブの配信コメントバー / pip-streaming-comment-bar

naru-jpn

March 15, 2022
Tweet

More Decks by naru-jpn

Other Decks in Programming

Transcript

  1. 2022.3.15 - iOS Tech Talk Naruki Chigira @_naru_jpn / Horizon

    Forbidden West ʹϋϚͬͯ·͢ PiP Ͱ࣮ݱ͢ΔϛϥςΟϒͷ഑৴ίϝϯτόʔ
  2. iOS 15 Ҏલ ɾAVPictureInPictureController ͸ iOS 9.0 ͔Β͋Δ ɾAVPictureInPictureController ͸

    PiP ͷ࣮૷ʹ࢖͏Ϋϥε ɾAVPlayerLayer ্Ͱ࠶ੜ͢Δಈըʹ͔͠ରԠ͍ͯ͠ͳ͔ͬͨ
  3. iOS 15 ͰͰ͖ΔΑ͏ʹͳͬͨ͜ͱ ɾiOS 15.0 Ͱ AVPictureInPictureController ͷػೳ͕֦ு͞Εͯ ɹAVSampleBufferDisplayLayer ʹ΋ରԠͨ͠ʢ2021೥7݄ʣ

    ɾϐΫνϟɾΠϯɾϐΫνϟͷࣗ༝౓͕૿ͨ͠ ɾࣾ಺Ͱ R&D ͷػӡ͕ߴ·͖ͬͯͨʢ2021೥10݄ॳ಄ʣ ɾ഑৴ίϝϯτόʔͷࢼ࡞඼͕Ͱ͖͸͡Ίͨʢ2021೥10݄຤ʣ WWDC2021 What's new in AVKit
  4. ϐΫνϟɾΠϯɾϐΫνϟͷಈ࡞ͷ֓ཁ AVPictureInPictureController ɾϐΫνϟɾΠϯɾϐΫνϟͷ؅ཧΛ͢Δ // ද͍ࣔͨ͠ AVSampleBufferDisplayLayer Λࢦఆͯ͠ੜ੒ let controller =

    AVPictureInPictureController( contentSource: .init( sampleBufferDisplayLayer: sampleBufferDisplayLayer, playbackDelegate: self ) )
  5. CMSampleBuffer ΛͲ͏΍ͬͯߋ৽͢Δ͔ ɾϛϥςΟϒͰ͸ UIKit ͷඳը݁ՌΛ CMSampleBuffer ʹॻ͖ࠐΜͰ͍Δ let imageBuffer =

    CMSampleBufferGetImageBuffer(sampleBuffer)! let pixelBuffer = imageBuffer as CVPixelBuffer let renderer = UIGraphicsImageRenderer(size: renderingSize) let image = renderer.image { context in view.layer.draw(in: context) } if let cgImage = image.cgImage { cicontext.render(CIImage(cgImage: cgImage), to: pixelBuffer) } ɾUIView → UIImage → CVPixelBuffer → CMSampleBuffer