Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(*): add support for new architecture #67

Merged
merged 28 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
65fd60c
feat(*): add support for new architecture
ThibaultBee Aug 17, 2023
06f6fc9
feat(android): replace embed rtmpdroid with the packed version
ThibaultBee Dec 21, 2023
c9837bb
fix(lib): remove sample rate that are not supported by FLV
ThibaultBee Dec 21, 2023
b080510
feat(ios): add support for new architecture
ThibaultBee Jan 2, 2024
15b4742
feat(android): use rtmpdroid 1.2.1 to fix a synchronization issue bet…
ThibaultBee Jan 4, 2024
d384a43
chore(ci): add a workflow to test yarn pack in dry run mode
ThibaultBee Feb 16, 2024
fa6966c
fix(ts): support emit for ts
ThibaultBee Feb 16, 2024
a1c3a04
fix(ios): fix error on ci due to errno::EEXIST - File exists @ syserr…
ThibaultBee Feb 16, 2024
e8dc4c3
feat(*): upgrade to RN 0.73.4
ThibaultBee Feb 16, 2024
d872df0
feat(android): request Android permissions
ThibaultBee Dec 22, 2023
7e80979
Merge pull request #74 from apivideo/feat/android_permissions
ThibaultBee Feb 19, 2024
e6f736f
feat(*): resolution is now a type (width, height)
ThibaultBee Feb 19, 2024
3487010
feat(*): add a promise to return startStreaming
ThibaultBee Feb 20, 2024
cce7037
fix(android): fix example icons
olivierapivideo Feb 20, 2024
d0d3231
feat(example): display warning if startStreaming fails
olivierapivideo Feb 20, 2024
2106f24
feat: add Predefined resolutions
olivierapivideo Feb 20, 2024
e6e99b5
fix(src): fix 480p resolution
ThibaultBee Feb 20, 2024
85c1d38
fix(*): fix yarn lint errors
ThibaultBee Feb 20, 2024
46c3470
feat(src): display unknown resolution in the returned error
ThibaultBee Feb 20, 2024
e2e4991
docs(README.md): update with new architecture
ThibaultBee Feb 21, 2024
f5375d6
feat(example): make warnings bigger
olivierapivideo Feb 21, 2024
872a665
fix(): move PredefinedResolution to index.tsx
olivierapivideo Feb 21, 2024
eb17ff9
fix(android): upgrade build.gradle to fix an issue when importing the…
ThibaultBee Feb 27, 2024
e26a9a9
fix(android): properly handle preview aspect ratio
ThibaultBee Feb 28, 2024
8dd2aae
chore(ios): set iOS minimum target to 12.0
ThibaultBee Mar 1, 2024
3a7f6a0
docs(README.md): update infos for permissions
ThibaultBee Mar 1, 2024
efd904d
chore(package): upgrade to reactnative 0.73.6
ThibaultBee Apr 16, 2024
3ae0597
fix(android): workaround on orientation for Android
ThibaultBee Apr 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading