SourceDescriptionItem.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp.Rtcp
  15. {
  16. /// <summary>
  17. /// The class that describes a source description item.
  18. /// </summary>
  19. public class SourceDescriptionItem
  20. {
  21. /// <summary>
  22. /// Get the type.
  23. /// </summary>
  24. public int Type { get; private set; }
  25. /// <summary>
  26. /// Get the text.
  27. /// </summary>
  28. public string Text { get; private set; }
  29. /// <summary>
  30. /// Get the length of the item.
  31. /// </summary>
  32. public int ItemLength { get { return (Text.Length + 2); } }
  33. /// <summary>
  34. /// Initialize a new instance of the SourceDescriptionItem class.
  35. /// </summary>
  36. public SourceDescriptionItem() { }
  37. /// <summary>
  38. /// Unpack the data in a packet.
  39. /// </summary>
  40. /// <param name="buffer">The buffer containing the packet.</param>
  41. /// <param name="offset">The offset to the first byte of the packet within the buffer.</param>
  42. /// <returns>An ErrorSpec instance if an error occurs; null otherwise.</returns>
  43. public void Process(byte[] buffer, int offset)
  44. {
  45. Type = buffer[offset];
  46. if (Type != 0)
  47. {
  48. int length = buffer[offset + 1];
  49. Text = Utils.ConvertBytesToString(buffer, offset + 2, length);
  50. }
  51. }
  52. }
  53. }