RtcpByePacket.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System.Collections.ObjectModel;
  2. /*
  3. Copyright (C) <2007-2016> <Kay Diefenthal>
  4. SatIp.RtspSample is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. SatIp.RtspSample is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with SatIp.RtspSample. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. using System.Text;
  16. namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp.Rtcp
  17. {
  18. public class RtcpByePacket :RtcpPacket
  19. {
  20. public Collection<string> SynchronizationSources { get; private set; }
  21. public string ReasonForLeaving { get; private set; }
  22. public override void Parse(byte[] buffer, int offset)
  23. {
  24. base.Parse(buffer, offset);
  25. SynchronizationSources = new Collection<string>();
  26. int index = 4;
  27. while (SynchronizationSources.Count < ReportCount)
  28. {
  29. SynchronizationSources.Add(Utils.ConvertBytesToString(buffer, offset + index, 4));
  30. index += 4;
  31. }
  32. if (index < Length)
  33. {
  34. int reasonLength = buffer[offset + index];
  35. ReasonForLeaving = Utils.ConvertBytesToString(buffer, offset + index + 1, reasonLength);
  36. }
  37. }
  38. public override string ToString()
  39. {
  40. StringBuilder sb = new StringBuilder();
  41. sb.AppendFormat("ByeBye .\n");
  42. sb.AppendFormat("Version : {0} .\n", Version);
  43. sb.AppendFormat("Padding : {0} .\n", Padding);
  44. sb.AppendFormat("Report Count : {0} .\n", ReportCount);
  45. sb.AppendFormat("PacketType: {0} .\n", Type);
  46. sb.AppendFormat("Length : {0} .\n", Length);
  47. sb.AppendFormat("SynchronizationSources : {0} .\n", SynchronizationSources);
  48. sb.AppendFormat("ReasonForLeaving : {0} .\n", ReasonForLeaving);
  49. sb.AppendFormat(".\n");
  50. return sb.ToString();
  51. }
  52. }
  53. }