RtcpReceiverReportPacket.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 RtcpReceiverReportPacket :RtcpPacket
  19. {
  20. public string SynchronizationSource { get; private set; }
  21. public Collection<ReportBlock> ReportBlocks { get; private set; }
  22. public byte[] ProfileExtension { get; private set; }
  23. public override void Parse(byte[] buffer, int offset)
  24. {
  25. base.Parse(buffer, offset);
  26. SynchronizationSource = Utils.ConvertBytesToString(buffer, offset + 4, 4);
  27. ReportBlocks = new Collection<ReportBlock>();
  28. int index = 8;
  29. while (ReportBlocks.Count < ReportCount)
  30. {
  31. ReportBlock reportBlock = new ReportBlock();
  32. reportBlock.Process(buffer, offset + index);
  33. ReportBlocks.Add(reportBlock);
  34. index += reportBlock.BlockLength;
  35. }
  36. if (index < Length)
  37. {
  38. ProfileExtension = new byte[Length - index];
  39. for (int extensionIndex = 0; index < Length; index++)
  40. {
  41. ProfileExtension[extensionIndex] = buffer[offset + index];
  42. extensionIndex++;
  43. }
  44. }
  45. }
  46. public override string ToString()
  47. {
  48. StringBuilder sb = new StringBuilder();
  49. sb.AppendFormat("Receiver Report.\n");
  50. sb.AppendFormat("Version : {0} .\n", Version);
  51. sb.AppendFormat("Padding : {0} .\n", Padding);
  52. sb.AppendFormat("Report Count : {0} .\n", ReportCount);
  53. sb.AppendFormat("PacketType: {0} .\n", Type);
  54. sb.AppendFormat("Length : {0} .\n", Length);
  55. sb.AppendFormat("SynchronizationSource : {0} .\n", SynchronizationSource);
  56. sb.AppendFormat(".\n");
  57. return sb.ToString();
  58. }
  59. }
  60. }