Skip to content

feat: add demo to stream to a RTMP link #26

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions demo/StreamRtmp/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BUNDLE_PATH: "vendor/bundle"
BUNDLE_FORCE_RUBY_PLATFORM: 1
17 changes: 17 additions & 0 deletions demo/StreamRtmp/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
API_URL=
APP_ENV=development
CODEPUSH_KEY_IOS=
CODEPUSH_KEY_ANDROID=
APP_ID=com.saigontechnology.streamrtmp.development
APP_NAME=BaseDev
PROJECT_NAME=StreamRtmp

#Config for codepush and build
APPCENTER_TOKEN_ANDROID=
APPCENTER_TOKEN_IOS=
APPCENTER_APP_NAME_ANDROID=
APPCENTER_APP_NAME_IOS=
APPCENTER_APP_DISPLAY_NAME=
APPCENTER_RELEASE_NOTE=
APPCENTER_DISTRIBUTE_DESTINATIONS=Public
APPLE_TEAM_ID=
17 changes: 17 additions & 0 deletions demo/StreamRtmp/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
API_URL=
APP_ENV=development
CODEPUSH_KEY_IOS=
CODEPUSH_KEY_ANDROID=
APP_ID=com.saigontechnology.streamrtmp.development
APP_NAME=BaseDevelopment
PROJECT_NAME=StreamRtmp

#Config for codepush and build
APPCENTER_TOKEN_ANDROID=
APPCENTER_TOKEN_IOS=
APPCENTER_APP_NAME_ANDROID=
APPCENTER_APP_NAME_IOS=
APPCENTER_APP_DISPLAY_NAME=
APPCENTER_RELEASE_NOTE=
APPCENTER_DISTRIBUTE_DESTINATIONS=Public
APPLE_TEAM_ID=
16 changes: 16 additions & 0 deletions demo/StreamRtmp/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
API_URL=
APP_ENV=production
CODEPUSH_KEY_IOS=
CODEPUSH_KEY_ANDROID=
APP_ID=com.saigontechnology.streamrtmp
APP_NAME=Base

#Config for codepush and build
APPCENTER_TOKEN_ANDROID=
APPCENTER_TOKEN_IOS=
APPCENTER_APP_NAME_ANDROID=
APPCENTER_APP_NAME_IOS=
APPCENTER_APP_DISPLAY_NAME=
APPCENTER_RELEASE_NOTE=
APPCENTER_DISTRIBUTE_DESTINATIONS=Public
APPLE_TEAM_ID=
16 changes: 16 additions & 0 deletions demo/StreamRtmp/.env.staging
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
API_URL=
APP_ENV=staging
CODEPUSH_KEY_IOS=
CODEPUSH_KEY_ANDROID=
APP_ID=com.saigontechnology.streamrtmp.staging
APP_NAME=BaseStaging

#Config for codepush and build
APPCENTER_TOKEN_ANDROID=
APPCENTER_TOKEN_IOS=
APPCENTER_APP_NAME_ANDROID=
APPCENTER_APP_NAME_IOS=
APPCENTER_APP_DISPLAY_NAME=
APPCENTER_RELEASE_NOTE=
APPCENTER_DISTRIBUTE_DESTINATIONS=Public
APPLE_TEAM_ID=
31 changes: 31 additions & 0 deletions demo/StreamRtmp/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
root: true,
extends: [
'@react-native',
'eslint:recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'import', 'unused-imports'],
overrides: [
{
files: ['*.ts', '*.tsx', '*.js'],
rules: {
semi: 'off',
'comma-dangle': 'off',
'no-shadow': 'off',
'no-undef': 'off',
'import/no-cycle': 'warn',
'import/first': 'error',
'import/no-duplicates': 'error',
'unused-imports/no-unused-imports': 'error',
'arrow-body-style': ['error', 'as-needed'],
'@typescript-eslint/no-shadow': ['error'],
'@typescript-eslint/no-empty-interface': 'warn',
},
},
],
}
4 changes: 4 additions & 0 deletions demo/StreamRtmp/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn pretty && yarn lint:fix
9 changes: 9 additions & 0 deletions demo/StreamRtmp/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: false,
singleQuote: true,
trailingComma: 'all',
semi: false,
printWidth: 110,
}
1 change: 1 addition & 0 deletions demo/StreamRtmp/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
67 changes: 67 additions & 0 deletions demo/StreamRtmp/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, {useEffect} from 'react'
import {LogBox, PermissionsAndroid, Text} from 'react-native'
import {SafeAreaProvider} from 'react-native-safe-area-context'
import {Provider} from 'react-redux'
import {configureLocalization} from './src/locale/I18nConfig'
import MainLayout from './src/MainLayout'
import {injectStore} from './src/services/networking/axios'
import {store, persistor} from './src/store/store'
import {PersistGate} from 'redux-persist/integration/react'

interface TextWithDefaultProps extends Text {
defaultProps?: {
allowFontScaling?: boolean
underlineColorAndroid?: 'transparent'
}
}
/* eslint-disable @typescript-eslint/no-extra-semi */
;(Text as unknown as TextWithDefaultProps).defaultProps = {
...(Text as unknown as TextWithDefaultProps).defaultProps,
allowFontScaling: false,
underlineColorAndroid: 'transparent',
}
LogBox.ignoreAllLogs(true)

injectStore(store)
configureLocalization('en')

/**
* @name requestCameraAndAudioPermission
* @description Function to request permission for Audio and Camera
*/
const requestCameraAndAudioPermission = async () => {
try {
const granted = await PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.CAMERA,
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
])
if (
granted['android.permission.RECORD_AUDIO'] === PermissionsAndroid.RESULTS.GRANTED &&
granted['android.permission.CAMERA'] === PermissionsAndroid.RESULTS.GRANTED
) {
console.log('You can use the cameras & mic')
} else {
console.log('Permission denied')
}
} catch (err) {
console.warn(err)
}
}

function App(): React.JSX.Element {
useEffect(() => {
requestCameraAndAudioPermission()
}, [])

return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<SafeAreaProvider>
<MainLayout />
</SafeAreaProvider>
</PersistGate>
</Provider>
)
}

export default App
13 changes: 13 additions & 0 deletions demo/StreamRtmp/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source "https://rubygems.org"

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"

# Cocoapods 1.15 introduced a bug which break the build. We will remove the upper
# bound in the template on Cocoapods with next React Native release.
gem 'cocoapods', '>= 1.13', '< 1.15'
gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
gem 'fastlane'

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
103 changes: 103 additions & 0 deletions demo/StreamRtmp/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.7)
base64
nkf
rexml
activesupport (7.0.8.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
base64 (0.2.0)
claide (1.1.0)
cocoapods (1.14.3)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.14.3)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 2.1, < 3.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.6.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (>= 2.3.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.23.0, < 2.0)
cocoapods-core (1.14.3)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
netrc (~> 0.11)
public_suffix (~> 4.0)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (2.1)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
cocoapods-trunk (1.6.0)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.2.3)
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
ffi (1.16.3)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.14.4)
concurrent-ruby (~> 1.0)
json (2.7.2)
minitest (5.22.3)
molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
nkf (0.2.0)
public_suffix (4.0.7)
rexml (3.2.6)
ruby-macho (2.5.1)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.24.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)

PLATFORMS
ruby

DEPENDENCIES
activesupport (>= 6.1.7.5, < 7.1.0)
cocoapods (>= 1.13, < 1.15)

RUBY VERSION
ruby 2.7.5p203

BUNDLED WITH
2.1.4
15 changes: 15 additions & 0 deletions demo/StreamRtmp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
React Native RTMP Streaming Demo
This repository demonstrates how to create a React Native app that connects to an RTMP (Real-Time Messaging Protocol) URL for live streaming. The app allows users to start a live video stream by connecting to an RTMP server, which is commonly used for video streaming platforms. This example covers the setup of video streaming using an RTMP-compatible video player in React Native and provides configuration guidance for connecting to an RTMP URL.

Features:

Connect and stream video to an RTMP URL
Supports live video broadcast for streaming applications
Technologies Used:

React Native
RTMP streaming protocol

**Video Demo**

https://github.com/user-attachments/assets/89cb93a2-6d32-4c87-98f6-df46afa41689
14 changes: 14 additions & 0 deletions demo/StreamRtmp/__tests__/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @format
*/

import 'react-native'
import React from 'react'
import App from '../App'

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer'

it('renders correctly', () => {
renderer.create(<App />)
})
17 changes: 17 additions & 0 deletions demo/StreamRtmp/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @format
*/

import 'react-native'
import React from 'react'
import App from '../App'

// Note: import explicitly to use the types shipped with jest.
import {it} from '@jest/globals'

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer'

it('renders correctly', () => {
renderer.create(<App />)
})
Loading