From b97e1d46fd5554e1684788aa7402729591f5021d Mon Sep 17 00:00:00 2001 From: Tiago Jacobs Date: Tue, 29 Mar 2022 18:23:10 -0300 Subject: [PATCH] Update readme, add support to undefined callbacks --- README.md | 3 +-- example/src/App.tsx | 4 ++-- .../Classes/ScreenBroadcaster.swift | 5 +++++ ios-common/Classes/WebRTCClient.swift | 18 +++++++++++++----- package.json | 2 +- src/index.tsx | 6 +++--- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index cd5f126..0589ae9 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,7 @@ import { BigBlueButtonMobile } from "bigbluebutton-mobile-sdk"; // ... - diff --git a/example/src/App.tsx b/example/src/App.tsx index 89c85fb..abd20f9 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { Alert, StyleSheet, Text, View } from 'react-native'; -import { BigbluebuttonMobile } from 'bigbluebutton-mobile-sdk'; +import { BigBlueButtonMobile } from 'bigbluebutton-mobile-sdk'; import type { INativeEvent } from './types'; export default function App() { @@ -32,7 +32,7 @@ export default function App() { return ( {loadComponent ? ( - handleOnError(content)} diff --git a/ios-broadcast-upload-extension/Classes/ScreenBroadcaster.swift b/ios-broadcast-upload-extension/Classes/ScreenBroadcaster.swift index b08d332..f5aa01e 100644 --- a/ios-broadcast-upload-extension/Classes/ScreenBroadcaster.swift +++ b/ios-broadcast-upload-extension/Classes/ScreenBroadcaster.swift @@ -64,6 +64,11 @@ open class ScreenBroadcaster { let imageBuffer:CVImageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)! let timeStampNs: Int64 = Int64(CMTimeGetSeconds(CMSampleBufferGetPresentationTimeStamp(sampleBuffer)) * 1000000000) let rtcPixlBuffer = RTCCVPixelBuffer(pixelBuffer: imageBuffer) + + if(!webRTCClient.getIsRatioDefined()) { + webRTCClient.setRatio(originalWidth: rtcPixlBuffer.width, originalHeight: rtcPixlBuffer.height) + } + let rtcVideoFrame = RTCVideoFrame(buffer: rtcPixlBuffer, rotation: ._0, timeStampNs: timeStampNs) self.webRTCClient.push(videoFrame: rtcVideoFrame) self.logger.info("video pushed") diff --git a/ios-common/Classes/WebRTCClient.swift b/ios-common/Classes/WebRTCClient.swift index da4cf0e..a85bbb2 100644 --- a/ios-common/Classes/WebRTCClient.swift +++ b/ios-common/Classes/WebRTCClient.swift @@ -38,6 +38,7 @@ open class WebRTCClient: NSObject { private var videoSource: RTCVideoSource? private var videoCapturer: RTCVideoCapturer? private var localVideoTrack: RTCVideoTrack? + private var isRatioDefined:Bool=false @available(*, unavailable) override init() { @@ -134,17 +135,24 @@ open class WebRTCClient: NSObject { }*/ private func createVideoTrack() -> RTCVideoTrack { - let targetWidth:Int32 = 600; - let targetHeight:Int32 = targetWidth * Int32(UIScreen.main.fixedCoordinateSpace.bounds.height / UIScreen.main.fixedCoordinateSpace.bounds.width) - - videoSource = WebRTCClient.factory.videoSource(forScreenCast: true) videoCapturer = RTCVideoCapturer(delegate: videoSource!) - videoSource!.adaptOutputFormat(toWidth: targetWidth, height: targetHeight, fps: 15) let videoTrack = WebRTCClient.factory.videoTrack(with: videoSource!, trackId: "video0") videoTrack.isEnabled = true return videoTrack } + + public func setRatio(originalWidth: Int32, originalHeight: Int32) { + let targetWidth:Int32 = 600; + let targetHeight:Int32 = targetWidth * Int32(originalHeight / originalWidth) + + videoSource!.adaptOutputFormat(toWidth: targetWidth, height: targetHeight, fps: 15) + self.isRatioDefined = true; + } + + public func getIsRatioDefined() -> Bool { + return self.isRatioDefined; + } } // MARK: RTCPeerConnectionDelegate Methods diff --git a/package.json b/package.json index 83fc43a..324f5dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bigbluebutton-mobile-sdk", - "version": "0.1.9", + "version": "0.1.10", "description": "This repository contains BigBlueButton react-native component, that's used in our [sample implementation](https://github.com/bigbluebutton/bigbluebutton-mobile).", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/src/index.tsx b/src/index.tsx index 5318eda..3c00d4f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -19,7 +19,7 @@ const renderPlatformSpecificComponents = () => android: null, }); -export const BigbluebuttonMobile = ({ +export const BigBlueButtonMobile = ({ url, style, onError, @@ -45,9 +45,9 @@ export const BigbluebuttonMobile = ({ onLoadEnd={(content: any) => { /*in case of success, the property code is not defined*/ if (typeof content.nativeEvent.code !== 'undefined') { - onError(content); + if (onError) onError(content); } else { - onSuccess(content); + if (onSuccess) onSuccess(content); } }} />