Files
VibeCoding/webrtc_controller_ios/web_rtc_controller_ios/Views/SelfCodecDisplayView.swift

40 lines
1.1 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import UIKit
import SwiftUI
import AVFoundation
/// UIKit AVSampleBufferDisplayLayer backing layer
/// "" H.264 Android SurfaceView
final class SampleBufferDisplayView: UIView {
override class var layerClass: AnyClass {
AVSampleBufferDisplayLayer.self
}
var sampleBufferLayer: AVSampleBufferDisplayLayer {
layer as! AVSampleBufferDisplayLayer
}
override init(frame: CGRect) {
super.init(frame: frame)
sampleBufferLayer.videoGravity = .resizeAspect
backgroundColor = .black
}
required init?(coder: NSCoder) {
super.init(coder: coder)
sampleBufferLayer.videoGravity = .resizeAspect
backgroundColor = .black
}
}
/// SwiftUI
struct SelfCodecDisplayViewRepresentable: UIViewRepresentable {
let view: SampleBufferDisplayView
func makeUIView(context: Context) -> SampleBufferDisplayView {
view
}
func updateUIView(_ uiView: SampleBufferDisplayView, context: Context) {}
}