forked from illuspas/Node-Media-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_rtmp_client.js
42 lines (33 loc) · 913 Bytes
/
test_rtmp_client.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
const NodeRtmpClient = require('./node_rtmp_client');
let rc = new NodeRtmpClient('rtmp://192.168.0.10/live/stream');
let rp = new NodeRtmpClient('rtmp://192.168.0.20/live/stream');
rc.on('audio', (audioData, timestamp) => {
rp.pushAudio(audioData, timestamp);
});
rc.on('video', (videoData, timestamp) => {
rp.pushVideo(videoData, timestamp);
});
rc.on('script', (scriptData, timestamp) => {
rp.pushScript(scriptData, timestamp);
});
rc.on('status', (info) => {
console.log('player on status', info);
if(info.code === 'NetStream.Play.UnpublishNotify') {
rc.stop();
}
});
rc.on('close', () => {
console.log('player on close');
rp.stop();
});
rp.on('close', () => {
console.log('publisher on close');
rc.stop();
});
rp.on('status', (info) => {
console.log('publisher on status', info);
if (info.code === 'NetStream.Publish.Start') {
rc.startPull();
}
});
rp.startPush();