FSCheckContentTypeRequest.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * This file is part of the FreeStreamer project,
  3. * (C)Copyright 2011-2018 Matias Muhonen <mmu@iki.fi> 穆马帝
  4. * See the file ''LICENSE'' for using the code.
  5. *
  6. * https://github.com/muhku/FreeStreamer
  7. */
  8. #import <Foundation/Foundation.h>
  9. /**
  10. * Content type format.
  11. */
  12. typedef NS_ENUM(NSInteger, FSFileFormat) {
  13. /**
  14. * Unknown format.
  15. */
  16. kFSFileFormatUnknown = 0,
  17. /**
  18. * M3U playlist.
  19. */
  20. kFSFileFormatM3UPlaylist,
  21. /**
  22. * PLS playlist.
  23. */
  24. kFSFileFormatPLSPlaylist,
  25. /**
  26. * XML file.
  27. */
  28. kFSFileFormatXML,
  29. /**
  30. * MP3 file.
  31. */
  32. kFSFileFormatMP3,
  33. /**
  34. * WAVE file.
  35. */
  36. kFSFileFormatWAVE,
  37. /**
  38. * AIFC file.
  39. */
  40. kFSFileFormatAIFC,
  41. /**
  42. * AIFF file.
  43. */
  44. kFSFileFormatAIFF,
  45. /**
  46. * M4A file.
  47. */
  48. kFSFileFormatM4A,
  49. /**
  50. * MPEG4 file.
  51. */
  52. kFSFileFormatMPEG4,
  53. /**
  54. * CAF file.
  55. */
  56. kFSFileFormatCAF,
  57. /**
  58. * AAC_ADTS file.
  59. */
  60. kFSFileFormatAAC_ADTS,
  61. /**
  62. * Total number of formats.
  63. */
  64. kFSFileFormatCount
  65. };
  66. /**
  67. * FSCheckContentTypeRequest is a class for checking the content type
  68. * of a URL. It makes an HTTP HEAD request and parses the header information
  69. * from the server. The resulting format is stored in the format property.
  70. *
  71. * To use the class, define the URL for checking the content type using
  72. * the url property. Then, define the onCompletion and onFailure handlers.
  73. * To start the request, use the start method.
  74. */
  75. @interface FSCheckContentTypeRequest : NSObject <NSURLSessionDelegate> {
  76. NSURLSessionTask *_task;
  77. FSFileFormat _format;
  78. NSString *_contentType;
  79. BOOL _playlist;
  80. BOOL _xml;
  81. }
  82. /**
  83. * The URL of this request.
  84. */
  85. @property (nonatomic,copy) NSURL *url;
  86. /**
  87. * Called when the content type determination is completed.
  88. */
  89. @property (copy) void (^onCompletion)(void);
  90. /**
  91. * Called if the content type determination failed.
  92. */
  93. @property (copy) void (^onFailure)(void);
  94. /**
  95. * Contains the format of the URL upon completion of the request.
  96. */
  97. @property (nonatomic,readonly) FSFileFormat format;
  98. /**
  99. * Containts the content type of the URL upon completion of the request.
  100. */
  101. @property (nonatomic,readonly) NSString *contentType;
  102. /**
  103. * The property is true if the URL contains a playlist.
  104. */
  105. @property (nonatomic,readonly) BOOL playlist;
  106. /**
  107. * The property is true if the URL contains XML data.
  108. */
  109. @property (nonatomic,readonly) BOOL xml;
  110. /**
  111. * Starts the request.
  112. */
  113. - (void)start;
  114. /**
  115. * Cancels the request.
  116. */
  117. - (void)cancel;
  118. @end