SourceDescriptionBlock.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.Collections.ObjectModel;
  15. namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp.Rtcp
  16. {
  17. class SourceDescriptionBlock
  18. {
  19. /// <summary>
  20. /// Get the length of the block.
  21. /// </summary>
  22. public int BlockLength { get { return (blockLength + (blockLength % 4)); } }
  23. /// <summary>
  24. /// Get the synchronization source.
  25. /// </summary>
  26. public string SynchronizationSource { get; private set; }
  27. /// <summary>
  28. /// Get the list of source descriptioni items.
  29. /// </summary>
  30. public Collection<SourceDescriptionItem> Items;
  31. private int blockLength;
  32. public void Process(byte[] buffer, int offset)
  33. {
  34. SynchronizationSource = Utils.ConvertBytesToString(buffer, offset, 4);
  35. Items = new Collection<SourceDescriptionItem>();
  36. int index = 4;
  37. bool done = false;
  38. do
  39. {
  40. SourceDescriptionItem item = new SourceDescriptionItem();
  41. item.Process(buffer, offset + index);
  42. if (item.Type != 0)
  43. {
  44. Items.Add(item);
  45. index += item.ItemLength;
  46. blockLength += item.ItemLength;
  47. }
  48. else
  49. {
  50. blockLength++;
  51. done = true;
  52. }
  53. }
  54. while (!done);
  55. }
  56. }
  57. }