-
Notifications
You must be signed in to change notification settings - Fork 0
/
RTP.js
37 lines (31 loc) · 1.05 KB
/
RTP.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
var RTPpacket = require('./RTPpacket'),
udp = require('dgram');
module.exports = {
rtp_packet: null,
RTPsocket: null, //UDP socket to be used to send RTP packets
IP: null,
port: null,
MediaType: null,
FrameNo: null,
TimeStamp: null,
Payload: null,
PayloadLength: null,
init: function(IP, port) {
this.IP = IP;
this.port = port;
this.RTPsocket = udp.createSocket('udp4');
this.rtp_packet = RTPpacket;
this.rtp_packet.init(this.MediaType, this.FrameNo, this.TimeStamp, this.Payload, this.PayloadLength);
},
CreateHMAC: function(hmac) {
hmac.write(this.rtp_packet.getpacket());
this.rtp_packet.sethmac(hmac.digest());
},
//Build and send the packet as a DatagramPacket over the UDP socket
SendRTPPacketTo: function(clientIP, clientPort) {
this.RTPsocket.send(this.rtp_packet.gethmacpacket(), 0, this.rtp_packet.getlength(), clientPort, clientIP);
},
close: function() {
this.RTPsocket.close();
}
};