<commit_before>import Foundation
import AVFoundation

class PluginMediaStreamRenderer : NSObject, RTCEAGLVideoViewDelegate {
	
	var id: String
	var eventListener: (_ data: NSDictionary) -> Void
	var closed: Bool
	
	var webView: UIView
	var elementView: UIView
	var pluginMediaStream: PluginMediaStream?
	
	var videoView: RTCEAGLVideoView
	var rtcAudioTrack: RTCAudioTrack?
	var rtcVideoTrack: RTCVideoTrack?

	init(
		webView: UIView,
		eventListener: @escaping (_ data: NSDictionary) -> Void
	) {
		NSLog("PluginMediaStreamRenderer#init()")
		
		// Open Renderer
		self.id = UUID().uuidString;
		self.closed = false
		
		// The browser HTML view.
		self.webView = webView
		self.eventListener = eventListener
		
		// The video element view.
		self.elementView = UIView()
		
		// The effective video view in which the the video stream is shown.
		// It's placed over the elementView.
		self.videoView = RTCEAGLVideoView()
		self.videoView.isUserInteractionEnabled = false

		self.elementView.isUserInteractionEnabled = false
		self.elementView.isHidden = true
		self.elementView.backgroundColor = UIColor.clear
		self.elementView.addSubview(self.videoView)
		self.elementView.layer.masksToBounds = true

		// Place the video element view inside the WebView's superview
		self.webView.addSubview(self.elementView)
		self.webView.isOpaque = false
		self.webView.backgroundColor = UIColor.clear
		
		// https://stackoverflow.com/questions/46317061/use-safe-area-layout-programmatically
		// https://developer.apple.com/documentation/uikit/uiview/2891102-safearealayoutguide
		// https://developer.apple.com/documentation/uikit/
		let view = self.elementView;
		if #available(iOS 11.0, *) {
			let guide = webView.safeAreaLayoutGuide;
			view.topAnchor.constraint(equalTo: guide.topAnchor).isActive = true
			view.bottomAnchor.constraint(equalTo: guide.bottomAnchor).isActive = true
			view.leftAnchor.constraint(equalTo: guide.leftAnchor).isActive = true
			view.rightAnchor.constraint(equalTo: guide.rightAnchor).isActive = true
		} else {
			NSLayoutConstraint(item: view, attribute: .top, relatedBy: .equal, toItem: webView, attribute: .top, multiplier: 1.0, constant: 0).isActive = true
			NSLayoutConstraint(item: view, attribute: .bottom, relatedBy: .equal, toItem: webView, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true
			NSLayoutConstraint(item: view, attribute: .leading, relatedBy: .equal, toItem: webView, attribute: .leading, multiplier: 1.0, constant: 0).isActive = true
			NSLayoutConstraint(item: view, attribute: .trailing, relatedBy: .equal, toItem: webView, attribute: .trailing, multiplier: 1.0, constant: 0).isActive = true
		}
	}<commit_msg>Fix Backgroundcolor is now "clear" instead of "black" #514<commit_after>import Foundation
import AVFoundation

class PluginMediaStreamRenderer : NSObject, RTCEAGLVideoViewDelegate {
	
	var id: String
	var eventListener: (_ data: NSDictionary) -> Void
	var closed: Bool
	
	var webView: UIView
	var elementView: UIView
	var pluginMediaStream: PluginMediaStream?
	
	var videoView: RTCEAGLVideoView
	var rtcAudioTrack: RTCAudioTrack?
	var rtcVideoTrack: RTCVideoTrack?

	init(
		webView: UIView,
		eventListener: @escaping (_ data: NSDictionary) -> Void
	) {
		NSLog("PluginMediaStreamRenderer#init()")
		
		// Open Renderer
		self.id = UUID().uuidString;
		self.closed = false
		
		// The browser HTML view.
		self.webView = webView
		self.eventListener = eventListener
		
		// The video element view.
		self.elementView = UIView()
		
		// The effective video view in which the the video stream is shown.
		// It's placed over the elementView.
		self.videoView = RTCEAGLVideoView()
		self.videoView.isUserInteractionEnabled = false

		self.elementView.isUserInteractionEnabled = false
		self.elementView.isHidden = true
		self.elementView.backgroundColor = UIColor.black
		self.elementView.addSubview(self.videoView)
		self.elementView.layer.masksToBounds = true

		// Place the video element view inside the WebView's superview
		self.webView.addSubview(self.elementView)
		self.webView.isOpaque = false
		self.webView.backgroundColor = UIColor.clear
		
		// https://stackoverflow.com/questions/46317061/use-safe-area-layout-programmatically
		// https://developer.apple.com/documentation/uikit/uiview/2891102-safearealayoutguide
		// https://developer.apple.com/documentation/uikit/
		let view = self.elementView;
		if #available(iOS 11.0, *) {
			let guide = webView.safeAreaLayoutGuide;
			view.topAnchor.constraint(equalTo: guide.topAnchor).isActive = true
			view.bottomAnchor.constraint(equalTo: guide.bottomAnchor).isActive = true
			view.leftAnchor.constraint(equalTo: guide.leftAnchor).isActive = true
			view.rightAnchor.constraint(equalTo: guide.rightAnchor).isActive = true
		} else {
			NSLayoutConstraint(item: view, attribute: .top, relatedBy: .equal, toItem: webView, attribute: .top, multiplier: 1.0, constant: 0).isActive = true
			NSLayoutConstraint(item: view, attribute: .bottom, relatedBy: .equal, toItem: webView, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true
			NSLayoutConstraint(item: view, attribute: .leading, relatedBy: .equal, toItem: webView, attribute: .leading, multiplier: 1.0, constant: 0).isActive = true
			NSLayoutConstraint(item: view, attribute: .trailing, relatedBy: .equal, toItem: webView, attribute: .trailing, multiplier: 1.0, constant: 0).isActive = true
		}
	}
{'fraction_non_alphanumeric': 0.10527289546716004, 'fraction_numerical': 0.011655874190564292, 'mean_word_length': 4.521961184882533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1194509', 'n_tokens_mistral': 1869, 'n_tokens_neox': 1643, 'n_words': 398}