forked from Qiliang/react-native-pili
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Streaming.js
101 lines (87 loc) · 2.78 KB
/
Streaming.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* Created by buhe on 16/4/29.
*/
import React, {
Component,
PropTypes
} from 'react';
import {
requireNativeComponent,
View,
} from 'react-native';
import StreamingConst from './StreamingConst';
class Streaming extends Component {
constructor(props, context) {
super(props, context);
this._onReady = this._onReady.bind(this);
this._onConnecting = this._onConnecting.bind(this);
this._onStreaming = this._onStreaming.bind(this);
this._onShutdown = this._onShutdown.bind(this);
this._onIOError = this._onIOError.bind(this);
this._onDisconnected = this._onDisconnected.bind(this);
}
_onReady(event) {
this.props.onReady && this.props.onReady(event.nativeEvent);
}
_onConnecting(event) {
this.props.onConnecting && this.props.onConnecting(event.nativeEvent);
}
_onStreaming(event) {
this.props.onStreaming && this.props.onStreaming(event.nativeEvent);
}
_onShutdown(event) {
this.props.onShutdown && this.props.onShutdown(event.nativeEvent);
}
_onIOError(event) {
this.props.onIOError && this.props.onIOError(event.nativeEvent);
}
_onDisconnected(event) {
this.props.onDisconnected && this.props.onDisconnected(event.nativeEvent);
}
render() {
const nativeProps = Object.assign({}, this.props);
Object.assign(nativeProps, {
onReady: this._onReady,
onConnecting: this._onConnecting,
onStreaming: this._onStreaming,
onShutdown: this._onShutdown,
onIOError: this._onIOError,
onDisconnected: this._onDisconnected,
});
return (
<RCTStreaming
{...nativeProps}
/>
)
}
}
Streaming.propTypes = {
rtmpURL: PropTypes.string,
camera: PropTypes.oneOf(['front','back']),
muted: PropTypes.bool,
zoom: PropTypes.number,
focus: PropTypes.bool,
profile: PropTypes.shape({ // 是否符合指定格式的物件
video: PropTypes.shape({
fps: PropTypes.number.isRequired,
bps: PropTypes.number.isRequired,
maxFrameInterval: PropTypes.number.isRequired
}).isRequired,
audio: PropTypes.shape({
rate: PropTypes.number.isRequired,
bitrate: PropTypes.number.isRequired,
}).isRequired,
encodingSize: PropTypes.oneOf([StreamingConst.encodingSize._240, StreamingConst.encodingSize._480, StreamingConst.encodingSize._544, StreamingConst.encodingSize._720, StreamingConst.encodingSize._1088]).isRequired
}).isRequired,
started: PropTypes.bool,
settings: PropTypes.object,
onReady: PropTypes.func,
onConnecting: PropTypes.func,
onStreaming: PropTypes.func,
onShutdown: PropTypes.func,
onIOError: PropTypes.func,
onDisconnected: PropTypes.func,
...View.propTypes,
}
const RCTStreaming = requireNativeComponent('RCTStreaming', Streaming);
module.exports = Streaming;