NIMDocTranscodingInfo.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. //
  2. // NIMDocTranscodingInfo.h
  3. // NIMLib
  4. //
  5. // Created by Netease.
  6. // Copyright © 2016年 Netease. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "NIMPlatform.h"
  10. NS_ASSUME_NONNULL_BEGIN
  11. /**
  12. * 转码源文件格式
  13. */
  14. typedef NS_ENUM(NSInteger, NIMDocTranscodingFileType){
  15. /**
  16. * ppt
  17. */
  18. NIMDocTranscodingFileTypePPT = 1,
  19. /**
  20. * pptx
  21. */
  22. NIMDocTranscodingFileTypePPTX = 2,
  23. /**
  24. * pdf
  25. */
  26. NIMDocTranscodingFileTypePDF = 3,
  27. };
  28. /**
  29. * 转码目标图像文件类型
  30. */
  31. typedef NS_ENUM(NSInteger, NIMDocTranscodingImageType){
  32. /**
  33. * 未知图像文件类型
  34. */
  35. NIMDocTranscodingImageTypeUnknown = 0,
  36. /**
  37. * 转码为 jpg 图片
  38. */
  39. NIMDocTranscodingImageTypeJPG = 10,
  40. /**
  41. * 转码为 png 图片
  42. */
  43. NIMDocTranscodingImageTypePNG = 11,
  44. };
  45. /**
  46. * 转码图像清晰度
  47. */
  48. typedef NS_ENUM(NSInteger, NIMDocTranscodingQuality){
  49. /**
  50. * 高清转码质量
  51. */
  52. NIMDocTranscodingQualityHigh = 1,
  53. /**
  54. * 中等转码质量
  55. */
  56. NIMDocTranscodingQualityMedium = 2,
  57. /**
  58. * 低清转码质量
  59. */
  60. NIMDocTranscodingQualityLow = 3,
  61. };
  62. /**
  63. * 转码过程状态
  64. */
  65. typedef NS_ENUM(NSInteger, NIMDocTranscodingState){
  66. /**
  67. * 未知转码状态
  68. */
  69. NIMDocTranscodingStateUnknown = 0,
  70. /**
  71. * 转码准备中
  72. */
  73. NIMDocTranscodingStatePreparing = 1,
  74. /**
  75. * 转码进行中
  76. */
  77. NIMDocTranscodingStateOngoing = 2,
  78. /**
  79. * 转码超时
  80. */
  81. NIMDocTranscodingStateTimeout = 3,
  82. /**
  83. * 转码完成
  84. */
  85. NIMDocTranscodingStateCompleted = 4,
  86. /**
  87. * 转码失败
  88. */
  89. NIMDocTranscodingStateFailed = 5,
  90. };
  91. /**
  92. 转码文档信息
  93. */
  94. @interface NIMDocTranscodingInfo : NSObject
  95. /**
  96. 转码文档标识 id
  97. */
  98. @property (nonatomic,copy,readonly) NSString *docId;
  99. /**
  100. 转码文档名称
  101. */
  102. @property (nonatomic,copy,readonly) NSString *docName;
  103. /**
  104. 转码源文档的文件类型
  105. */
  106. @property (nonatomic,assign,readonly) NIMDocTranscodingFileType sourceType;
  107. /**
  108. 转码源文档大小
  109. */
  110. @property (nonatomic,assign,readonly) UInt64 sourceSize;
  111. /**
  112. 转码目标图片的文件类型
  113. */
  114. @property (nonatomic,assign,readonly) NIMDocTranscodingImageType targetType;
  115. /**
  116. 转码过程状态
  117. */
  118. @property (nonatomic,assign,readonly) NIMDocTranscodingState state;
  119. /**
  120. 转码源文档文件的下载地址
  121. */
  122. @property (nonatomic,copy,readonly) NSString *sourceFileUrl;
  123. /**
  124. 转码文档总页数
  125. */
  126. @property (nonatomic,assign,readonly) NSUInteger numberOfPages;
  127. /**
  128. 发起文档转码时的附带信息
  129. */
  130. @property (nullable,nonatomic,copy,readonly) NSString *ext;
  131. /**
  132. 文档转码内部状态码, 0 表示成功, 可用于在转码失败时定位具体失败原因。已知的一些失败原因 2: 找不到文件; 3: 文件类型错误; 4: 转码请求出现异常; 5: 转码服务器连接错误 6: 转码服务器内部错误; 7: 文档转码图片出错; 8: 图片质量处理错误; 9: 页数超限; 10: nos回调错误; 11: 文档解析错误(如加密的PDF无法解析; 100: 未知错误
  133. */
  134. @property (nonatomic,assign,readonly) NSInteger transcodingFlag;
  135. /**
  136. 获取某清晰度的转码后文件总字节大小
  137. @param quality 转码质量
  138. @return 转码后该质量的图片文件总字节大小
  139. */
  140. - (UInt64)transcodedTotalSize:(NIMDocTranscodingQuality)quality;
  141. /**
  142. 获取某清晰度转码后图片的长宽信息
  143. @param quality 转码质量
  144. @return 转码后图片的长宽信息
  145. */
  146. - (CGSize)transcodedImagesSize:(NIMDocTranscodingQuality)quality;
  147. /**
  148. 获取转码后某清晰度的文件页码对应的下载 url
  149. @param pageNumber 文件页码
  150. @param quality 图片质量
  151. @return 图片下载 url
  152. */
  153. - (nullable NSString *)transcodedUrl:(NSUInteger)pageNumber
  154. ofQuality:(NIMDocTranscodingQuality)quality;
  155. @end
  156. NS_ASSUME_NONNULL_END