forked from kthompson/RtpLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RtcpBye.cs
64 lines (49 loc) · 1.43 KB
/
RtcpBye.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
namespace RtpLib
{
public class RtcpBye : RtcpPacket
{
#region Public Methods
public override void ParseData(Stream stream)
{
byte[] bytes = new byte[4];
if (stream.Read(bytes, 0, bytes.Length) < bytes.Length)
throw new InvalidDataException();
this.Ssrc = (uint)IPAddress.NetworkToHostOrder(BitConverter.ToInt32(bytes, 0));
}
protected override int GetByteCount()
{
return 4;
}
protected override void ToStreamInternal(Stream stream)
{
var writer = new BinaryWriter(stream);
writer.Write((uint)IPAddress.HostToNetworkOrder((int)this.Ssrc));
}
#endregion
#region Properties
public override Rtcp.PacketType PacketType
{
get { return Rtcp.PacketType.Bye; }
}
public uint Ssrc
{
get;
set;
}
#endregion
#region ICloneable Implementation
public override object Clone()
{
var packet = this.MemberwiseClone() as RtcpBye;
packet.Header = packet.Header.Clone() as RtcpHeader;
return packet;
}
#endregion
}
}