RtcpAppPacket.cs 2.7 KB

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