Skip to content

Commit

Permalink
Merge pull request #67 from apivideo/feature/new_arch_support
Browse files Browse the repository at this point in the history
feat(*): add support for new architecture
  • Loading branch information
ThibaultBee authored May 2, 2024
2 parents aa6138b + 3ae0597 commit 86df97a
Show file tree
Hide file tree
Showing 157 changed files with 28,503 additions and 8,691 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/android-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build Android

on: [push]

jobs:
build:
strategy:
matrix:
newArchEnabled: [false, true]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 17
- name: Install package npm dependencies
run: yarn --frozen-lockfile
shell: bash
- name: Install example npm dependencies
run: yarn example --frozen-lockfile
shell: bash
- name: Build Android test app
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
arguments: -PnewArchEnabled=${{matrix.newArchEnabled}} :app:assembleRelease
build-root-directory: example/android
timeout-minutes: 60
63 changes: 0 additions & 63 deletions .github/workflows/build.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/create-documentation-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:
- name: Check out current repository code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Create the documentation pull request
uses: apivideo/api.video-create-readme-file-pull-request-action@main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-release-from-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
update-documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Create draft release if needed
uses: apivideo/api.video-release-from-changelog-action@main
with:
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/ios-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build iOS

on: [push]

jobs:
build:
strategy:
matrix:
extraEnv: [RCT_NEW_ARCH_ENABLED=0, RCT_NEW_ARCH_ENABLED=1]
runs-on: macos-13
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install latest Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'
- name: Install package npm dependencies
run: yarn --frozen-lockfile
shell: bash
- name: Install example npm dependencies
run: yarn example --frozen-lockfile
shell: bash
- name: Install Ruby gems
run: gem install cocoapods -v 1.15.2
- name: Install Pods
run: ${{matrix.extraEnv}} pod install
working-directory: example/ios
- name: Build iOS test app
run: xcodebuild -workspace Example.xcworkspace -scheme Example -destination "platform=iOS Simulator,name=iPhone 14" CODE_SIGNING_ALLOWED=NO COMPILER_INDEX_STORE_ENABLE=NO build
working-directory: example/ios
timeout-minutes: 60
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'
- run: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
update-documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Update readme.io documentation
uses: apivideo/[email protected]
with:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Verify package

on: [push]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
- name: Install dependencies
run: yarn install
- name: Lint
run: yarn lint
pack:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
- name: Install dependencies
run: yarn install
- name: Pack in dry run mode
run: yarn pack --dry-run
15 changes: 13 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,26 @@ DerivedData
*.ipa
*.xcuserstate
project.xcworkspace
.xcode.env.local

# Android/IJ
#
.idea
.classpath
.cxx
.gradle
.idea
.project
.settings
local.properties
android.iml

# Cocoapods
#
example/ios/Pods

# Ruby
example/vendor/

# node.js
#
node_modules/
Expand All @@ -54,7 +62,10 @@ android/app/libs
android/keystores/debug.keystore

# Expo
.expo/*
.expo/

# Turborepo
.turbo/

# generated by bob
lib/
53 changes: 21 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
- [Getting started](#getting-started)
- [Installation](#installation)
- [Permissions](#permissions)
- [Android](#android)
- [iOS](#ios)
- [Code sample](#code-sample)
- [Documentation](#documentation)
- [Props \& Methods](#props--methods)
- [Example App](#example-app)
- [Setup](#setup)
- [Android](#android)
- [iOS](#ios)
- [Android](#android-1)
- [iOS](#ios-1)
- [Plugins](#plugins)
- [FAQ](#faq)

Expand All @@ -41,13 +43,10 @@ meta:
</documentation_only>-->
## Project description

This module is made for broadcasting rtmp live stream from smartphone camera
This module is made for broadcasting RTMP live stream from smartphone camera

## Getting started

:warning: **The React Native Live Stream SDK is designed for 0.69.1 version of React Native. Using the SDK with >0.69.1 of React Native can cause unexpected behaviour**


### Installation

```sh
Expand All @@ -60,33 +59,25 @@ or
yarn add @api.video/react-native-livestream
```

_Note: if you are on iOS, you will need two extra steps:_

1. Don't forget to install the native dependencies with Cocoapods

```sh
cd ios && pod install
```

1. This project contains swift code, and if it's your first dependency with swift code, you need to create an empty swift file in your project (with the bridging header) from XCode. [Find how to do that](https://github.com/apivideo/api.video-reactnative-live-stream/blob/main/docs/install_swift_dependency.md)

### Permissions

To be able to broadcast, you must:
#### Android

Permissions `android.permission.RECORD_AUDIO`, `android.permission.CAMERA` and `android.permission.INTERNET` are in the library manifest and will be requested by this library at runtime. You don't have to request them in your application.

1. On Android: ask for internet, camera and microphone permissions:
For the PlayStore, your application might declare this in its `AndroidManifest.xml`

```xml

<manifest>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
</manifest>
```

Your application must dynamically require android.permission.CAMERA and android.permission.RECORD_AUDIO.
#### iOS

2. On iOS: update Info.plist with a usage description for camera and microphone
Update `Info.plist` with a usage description for camera and microphone

```xml
<key>NSCameraUsageDescription</key>
Expand All @@ -96,29 +87,27 @@ Your application must dynamically require android.permission.CAMERA and android.
<string>Your own description of the purpose</string>
```

3. On react-native you must handle the permissions requests before starting your livestream. If permissions are not accepted you will not be able to broadcast.

### Code sample

```jsx
import React, { useRef, useState } from 'react';
import { View, TouchableOpacity } from 'react-native';
import { LiveStreamView } from '@api.video/react-native-livestream';
import { ApiVideoLiveStreamView } from '@api.video/react-native-livestream';

const App = () => {
const ref = useRef(null);
const [streaming, setStreaming] = useState(false);

return (
<View style={{ flex: 1, alignItems: 'center' }}>
<LiveStreamView
<ApiVideoLiveStreamView
style={{ flex: 1, backgroundColor: 'black', alignSelf: 'stretch' }}
ref={ref}
camera="back"
enablePinchedZoom={true}
video={{
fps: 30,
resolution: '720p',
resolution: '720p', // Alternatively, you can specify the resolution in pixels: { width: 1280, height: 720 }
bitrate: 2*1024*1024, // # 2 Mbps
gopDuration: 1, // 1 second
}}
Expand Down Expand Up @@ -169,16 +158,16 @@ export default App;
### Props & Methods
```ts
type LiveStreamProps = {
type ApiVideoLiveStreamProps = {
// Styles for the view containing the preview
style: ViewStyle;
// camera facing orientation
camera?: 'front' | 'back';
video: {
// frame rate
fps: number;
// resolution
resolution: '240p' | '360p' | '480p' | '720p' | '1080p';
// resolution.
resolution: Resolution | PredefinedResolution;
// video bitrate. depends on resolutions.
bitrate: number;
// duration between 2 key frames in seconds
Expand All @@ -204,7 +193,7 @@ type LiveStreamProps = {
onDisconnect?: () => void;
};

type LiveStreamMethods = {
type ApiVideoLiveStreamMethods = {
// Start the stream
// streamKey: your live stream RTMP key
// url: RTMP server url, default: rtmp://broadcast.api.video/s
Expand Down
Loading

0 comments on commit 86df97a

Please sign in to comment.