@abdurrahman-dev/react-native-ivs-broadcast 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +296 -0
- package/android/build.gradle +61 -0
- package/android/src/main/AndroidManifest.xml +13 -0
- package/android/src/main/java/com/reactnativeivsbroadcast/IVSBroadcastModule.kt +433 -0
- package/android/src/main/java/com/reactnativeivsbroadcast/IVSBroadcastPackage.kt +17 -0
- package/ios/IVSBroadcast.podspec +24 -0
- package/ios/IVSBroadcastModule.h +7 -0
- package/ios/IVSBroadcastModule.m +513 -0
- package/lib/index.d.ts +78 -0
- package/lib/index.js +234 -0
- package/lib/types.d.ts +55 -0
- package/lib/types.js +2 -0
- package/package.json +57 -0
- package/src/index.ts +273 -0
- package/src/types.ts +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# react-native-ivs-broadcast
|
|
2
|
+
|
|
3
|
+
React Native için Amazon Interactive Video Service (IVS) Broadcast SDK köprü paketi. Bu paket, Amazon IVS Broadcast SDK'nın native yeteneklerini React Native projelerinde kullanmanızı sağlar.
|
|
4
|
+
|
|
5
|
+
## Özellikler
|
|
6
|
+
|
|
7
|
+
- ✅ Android 1.37.1 ve iOS 1.37.0 desteği
|
|
8
|
+
- ✅ Broadcast başlatma/durdurma/duraklatma/devam ettirme
|
|
9
|
+
- ✅ Kamera kontrolü (ön/arka kamera değiştirme)
|
|
10
|
+
- ✅ Mikrofon kontrolü (sessize alma/açma)
|
|
11
|
+
- ✅ Video ve ses konfigürasyonu
|
|
12
|
+
- ✅ Network health monitoring
|
|
13
|
+
- ✅ Real-time istatistikler (audio/video stats)
|
|
14
|
+
- ✅ Event-based API
|
|
15
|
+
|
|
16
|
+
## Kurulum
|
|
17
|
+
|
|
18
|
+
### npm
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install react-native-ivs-broadcast
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### yarn
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
yarn add react-native-ivs-broadcast
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Platform Kurulumu
|
|
31
|
+
|
|
32
|
+
### Android
|
|
33
|
+
|
|
34
|
+
1. `android/app/build.gradle` dosyanıza aşağıdaki bağımlılığı ekleyin:
|
|
35
|
+
|
|
36
|
+
```gradle
|
|
37
|
+
dependencies {
|
|
38
|
+
implementation 'com.amazonaws:ivs-broadcast:1.37.1:stages@aar'
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
2. `android/build.gradle` dosyanıza `mavenCentral()` repository'sini ekleyin:
|
|
43
|
+
|
|
44
|
+
```gradle
|
|
45
|
+
allprojects {
|
|
46
|
+
repositories {
|
|
47
|
+
mavenCentral()
|
|
48
|
+
// ... diğer repository'ler
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
3. `AndroidManifest.xml` dosyanıza gerekli izinleri ekleyin (paket içinde zaten mevcut):
|
|
54
|
+
|
|
55
|
+
```xml
|
|
56
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
57
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
58
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### iOS
|
|
62
|
+
|
|
63
|
+
1. `ios/Podfile` dosyanıza aşağıdaki satırı ekleyin:
|
|
64
|
+
|
|
65
|
+
```ruby
|
|
66
|
+
pod 'AmazonIVSBroadcast', '1.37.0'
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
2. Pod'ları yükleyin:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cd ios && pod install && cd ..
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
3. `Info.plist` dosyanıza kamera ve mikrofon izinlerini ekleyin:
|
|
76
|
+
|
|
77
|
+
```xml
|
|
78
|
+
<key>NSCameraUsageDescription</key>
|
|
79
|
+
<string>Kamerayı kullanmak için izin gerekiyor</string>
|
|
80
|
+
<key>NSMicrophoneUsageDescription</key>
|
|
81
|
+
<string>Mikrofonu kullanmak için izin gerekiyor</string>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Kullanım
|
|
85
|
+
|
|
86
|
+
### Temel Kullanım
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import IVSBroadcast from 'react-native-ivs-broadcast';
|
|
90
|
+
|
|
91
|
+
// Session oluştur
|
|
92
|
+
const session = await IVSBroadcast.createSession({
|
|
93
|
+
rtmpUrl: 'rtmp://your-stream-url.com',
|
|
94
|
+
streamKey: 'your-stream-key',
|
|
95
|
+
videoConfig: {
|
|
96
|
+
width: 1280,
|
|
97
|
+
height: 720,
|
|
98
|
+
bitrate: 2500000,
|
|
99
|
+
fps: 30,
|
|
100
|
+
},
|
|
101
|
+
audioConfig: {
|
|
102
|
+
bitrate: 128000,
|
|
103
|
+
sampleRate: 44100,
|
|
104
|
+
channels: 2,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Event listener'ları ekle
|
|
109
|
+
IVSBroadcast.addListener('onStateChanged', (state) => {
|
|
110
|
+
console.log('Broadcast state:', state);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
IVSBroadcast.addListener('onError', (error) => {
|
|
114
|
+
console.error('Broadcast error:', error);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
IVSBroadcast.addListener('onNetworkHealth', (health) => {
|
|
118
|
+
console.log('Network health:', health);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Broadcast'i başlat
|
|
122
|
+
await IVSBroadcast.startBroadcast(session.sessionId);
|
|
123
|
+
|
|
124
|
+
// Kamera değiştir
|
|
125
|
+
await IVSBroadcast.switchCamera(session.sessionId);
|
|
126
|
+
|
|
127
|
+
// Mikrofonu sessize al
|
|
128
|
+
await IVSBroadcast.setMuted(session.sessionId, true);
|
|
129
|
+
|
|
130
|
+
// Broadcast'i durdur
|
|
131
|
+
await IVSBroadcast.stopBroadcast(session.sessionId);
|
|
132
|
+
|
|
133
|
+
// Session'ı yok et
|
|
134
|
+
await IVSBroadcast.destroySession(session.sessionId);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### API Referansı
|
|
138
|
+
|
|
139
|
+
#### `createSession(config: IVSBroadcastConfig): Promise<IVSBroadcastSession>`
|
|
140
|
+
|
|
141
|
+
Yeni bir broadcast session oluşturur.
|
|
142
|
+
|
|
143
|
+
**Parametreler:**
|
|
144
|
+
- `config.rtmpUrl` (string, zorunlu): RTMP stream URL'i
|
|
145
|
+
- `config.streamKey` (string, opsiyonel): Stream key
|
|
146
|
+
- `config.videoConfig` (VideoConfig, opsiyonel): Video konfigürasyonu
|
|
147
|
+
- `config.audioConfig` (AudioConfig, opsiyonel): Audio konfigürasyonu
|
|
148
|
+
|
|
149
|
+
**Dönen değer:** `{ sessionId: string }`
|
|
150
|
+
|
|
151
|
+
#### `startBroadcast(sessionId: string): Promise<void>`
|
|
152
|
+
|
|
153
|
+
Broadcast'i başlatır.
|
|
154
|
+
|
|
155
|
+
#### `stopBroadcast(sessionId: string): Promise<void>`
|
|
156
|
+
|
|
157
|
+
Broadcast'i durdurur.
|
|
158
|
+
|
|
159
|
+
#### `pauseBroadcast(sessionId: string): Promise<void>`
|
|
160
|
+
|
|
161
|
+
Broadcast'i duraklatır.
|
|
162
|
+
|
|
163
|
+
#### `resumeBroadcast(sessionId: string): Promise<void>`
|
|
164
|
+
|
|
165
|
+
Duraklatılmış broadcast'i devam ettirir.
|
|
166
|
+
|
|
167
|
+
#### `destroySession(sessionId: string): Promise<void>`
|
|
168
|
+
|
|
169
|
+
Session'ı yok eder ve kaynakları temizler.
|
|
170
|
+
|
|
171
|
+
#### `getState(sessionId: string): Promise<BroadcastState>`
|
|
172
|
+
|
|
173
|
+
Broadcast durumunu alır.
|
|
174
|
+
|
|
175
|
+
**Dönen değer:**
|
|
176
|
+
```typescript
|
|
177
|
+
{
|
|
178
|
+
isBroadcasting: boolean;
|
|
179
|
+
isPaused: boolean;
|
|
180
|
+
error?: string;
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### `switchCamera(sessionId: string): Promise<void>`
|
|
185
|
+
|
|
186
|
+
Kamerayı değiştirir (ön ↔ arka).
|
|
187
|
+
|
|
188
|
+
#### `setCameraPosition(sessionId: string, position: 'front' | 'back'): Promise<void>`
|
|
189
|
+
|
|
190
|
+
Kamera pozisyonunu ayarlar.
|
|
191
|
+
|
|
192
|
+
#### `setMuted(sessionId: string, muted: boolean): Promise<void>`
|
|
193
|
+
|
|
194
|
+
Mikrofonu sessize alır veya açar.
|
|
195
|
+
|
|
196
|
+
#### `isMuted(sessionId: string): Promise<boolean>`
|
|
197
|
+
|
|
198
|
+
Mikrofonun sessize alınıp alınmadığını kontrol eder.
|
|
199
|
+
|
|
200
|
+
#### `updateVideoConfig(sessionId: string, config: VideoConfig): Promise<void>`
|
|
201
|
+
|
|
202
|
+
Video konfigürasyonunu günceller.
|
|
203
|
+
|
|
204
|
+
#### `updateAudioConfig(sessionId: string, config: AudioConfig): Promise<void>`
|
|
205
|
+
|
|
206
|
+
Audio konfigürasyonunu günceller.
|
|
207
|
+
|
|
208
|
+
### Event Listener'lar
|
|
209
|
+
|
|
210
|
+
#### `onStateChanged`
|
|
211
|
+
|
|
212
|
+
Broadcast durumu değiştiğinde tetiklenir.
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
IVSBroadcast.addListener('onStateChanged', (state: BroadcastState) => {
|
|
216
|
+
console.log('State:', state);
|
|
217
|
+
});
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### `onError`
|
|
221
|
+
|
|
222
|
+
Hata oluştuğunda tetiklenir.
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
IVSBroadcast.addListener('onError', (error: { message: string; code?: string }) => {
|
|
226
|
+
console.error('Error:', error);
|
|
227
|
+
});
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
#### `onNetworkHealth`
|
|
231
|
+
|
|
232
|
+
Network sağlık durumu güncellendiğinde tetiklenir.
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
IVSBroadcast.addListener('onNetworkHealth', (health: NetworkHealth) => {
|
|
236
|
+
console.log('Network quality:', health.networkQuality);
|
|
237
|
+
console.log('Uplink bandwidth:', health.uplinkBandwidth);
|
|
238
|
+
console.log('RTT:', health.rtt);
|
|
239
|
+
});
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
#### `onAudioStats`
|
|
243
|
+
|
|
244
|
+
Audio istatistikleri güncellendiğinde tetiklenir.
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
IVSBroadcast.addListener('onAudioStats', (stats: AudioStats) => {
|
|
248
|
+
console.log('Audio bitrate:', stats.bitrate);
|
|
249
|
+
console.log('Sample rate:', stats.sampleRate);
|
|
250
|
+
});
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### `onVideoStats`
|
|
254
|
+
|
|
255
|
+
Video istatistikleri güncellendiğinde tetiklenir.
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
IVSBroadcast.addListener('onVideoStats', (stats: VideoStats) => {
|
|
259
|
+
console.log('Video bitrate:', stats.bitrate);
|
|
260
|
+
console.log('FPS:', stats.fps);
|
|
261
|
+
console.log('Resolution:', stats.width, 'x', stats.height);
|
|
262
|
+
});
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Listener'ları Temizleme
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
// Belirli bir listener'ı kaldır
|
|
269
|
+
IVSBroadcast.removeListener('onStateChanged', callback);
|
|
270
|
+
|
|
271
|
+
// Tüm listener'ları kaldır
|
|
272
|
+
IVSBroadcast.removeAllListeners();
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Type Definitions
|
|
276
|
+
|
|
277
|
+
Paket TypeScript desteği ile birlikte gelir. Tüm type tanımlamaları `types.ts` dosyasında bulunur.
|
|
278
|
+
|
|
279
|
+
## Gereksinimler
|
|
280
|
+
|
|
281
|
+
- React Native >= 0.60.0
|
|
282
|
+
- Android: minSdkVersion 21
|
|
283
|
+
- iOS: 11.0+
|
|
284
|
+
|
|
285
|
+
## Lisans
|
|
286
|
+
|
|
287
|
+
MIT
|
|
288
|
+
|
|
289
|
+
## Katkıda Bulunma
|
|
290
|
+
|
|
291
|
+
Katkılarınızı bekliyoruz! Lütfen pull request göndermeden önce mevcut kod stilini takip ettiğinizden emin olun.
|
|
292
|
+
|
|
293
|
+
## Destek
|
|
294
|
+
|
|
295
|
+
Sorunlarınız için GitHub Issues kullanabilirsiniz.
|
|
296
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext {
|
|
3
|
+
buildToolsVersion = "33.0.0"
|
|
4
|
+
minSdkVersion = 21
|
|
5
|
+
compileSdkVersion = 33
|
|
6
|
+
targetSdkVersion = 33
|
|
7
|
+
kotlinVersion = "1.7.0"
|
|
8
|
+
}
|
|
9
|
+
repositories {
|
|
10
|
+
google()
|
|
11
|
+
mavenCentral()
|
|
12
|
+
}
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath("com.android.tools.build:gradle:7.3.1")
|
|
15
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
apply plugin: 'com.android.library'
|
|
20
|
+
apply plugin: 'kotlin-android'
|
|
21
|
+
|
|
22
|
+
android {
|
|
23
|
+
compileSdkVersion rootProject.ext.compileSdkVersion
|
|
24
|
+
|
|
25
|
+
defaultConfig {
|
|
26
|
+
minSdkVersion rootProject.ext.minSdkVersion
|
|
27
|
+
targetSdkVersion rootProject.ext.targetSdkVersion
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
buildTypes {
|
|
31
|
+
release {
|
|
32
|
+
minifyEnabled false
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
compileOptions {
|
|
37
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
38
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
kotlinOptions {
|
|
42
|
+
jvmTarget = '1.8'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
repositories {
|
|
47
|
+
mavenCentral()
|
|
48
|
+
google()
|
|
49
|
+
maven {
|
|
50
|
+
url "https://www.jitpack.io"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
dependencies {
|
|
55
|
+
implementation "com.facebook.react:react-native:+"
|
|
56
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
|
|
57
|
+
|
|
58
|
+
// Amazon IVS Broadcast SDK
|
|
59
|
+
implementation 'com.amazonaws:ivs-broadcast:1.37.1:stages@aar'
|
|
60
|
+
}
|
|
61
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
package="com.reactnativeivsbroadcast">
|
|
3
|
+
|
|
4
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
5
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
6
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
7
|
+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
8
|
+
|
|
9
|
+
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
|
10
|
+
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
|
|
11
|
+
<uses-feature android:name="android.hardware.microphone" android:required="false" />
|
|
12
|
+
</manifest>
|
|
13
|
+
|