TVCClientInner.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // TVCClientInner.m
  3. // TVCClientSDK
  4. //
  5. // Created by tomzhu on 16/10/20.
  6. // Copyright © 2016年 tencent. All rights reserved.
  7. //
  8. #import "TVCClientInner.h"
  9. @implementation TVCHttpsDelegate
  10. //- (void)dealloc
  11. //{
  12. // NSLog(@"dealloc TVCHttpsDelegate");
  13. //}
  14. - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler
  15. {
  16. //1)获取trust object
  17. SecTrustRef trust = challenge.protectionSpace.serverTrust;
  18. SecTrustResultType result;
  19. NSString *host = [[task currentRequest] valueForHTTPHeaderField:@"host"];
  20. if (host.length > 0) {
  21. //指定域名
  22. SecPolicyRef policyOverride = SecPolicyCreateSSL(true, (__bridge CFStringRef)host);
  23. NSMutableArray *policies = [NSMutableArray array];
  24. [policies addObject:(__bridge_transfer id)policyOverride];
  25. SecTrustSetPolicies(trust, (__bridge CFArrayRef)policies);
  26. }
  27. //2)SecTrustEvaluate对trust进行验证
  28. OSStatus status = SecTrustEvaluate(trust, &result);
  29. if (status == errSecSuccess &&
  30. (result == kSecTrustResultProceed ||
  31. result == kSecTrustResultUnspecified)) {
  32. //3)验证成功,生成NSURLCredential凭证cred,告知challenge的sender使用这个凭证来继续连接
  33. NSURLCredential *cred = [NSURLCredential credentialForTrust:trust];
  34. // [challenge.sender useCredential:cred forAuthenticationChallenge:challenge];
  35. completionHandler(NSURLSessionAuthChallengeUseCredential, cred);
  36. } else {
  37. //5)验证失败,取消这次验证流程
  38. // [challenge.sender cancelAuthenticationChallenge:challenge];
  39. completionHandler(NSURLSessionAuthChallengeUseCredential, nil);
  40. }
  41. }
  42. @end
  43. @implementation TVCUGCResult
  44. - (instancetype)init
  45. {
  46. self = [super init];
  47. if (self) {
  48. _videoFileId = @"";
  49. _imageFileId = @"";
  50. _uploadAppid = @"";
  51. _uploadBucket = @"";
  52. _videoPath = @"";
  53. _imagePath = @"";
  54. _videoSign = @"";
  55. _imageSign = @"";
  56. _uploadSession = @"";
  57. _userAppid = @"";
  58. _tmpSecretId = @"";
  59. _tmpSecretKey = @"";
  60. _tmpToken = @"";
  61. _tmpExpiredTime = 0;
  62. _currentTS = 0;
  63. }
  64. return self;
  65. }
  66. - (NSString*)description
  67. {
  68. return [NSString stringWithFormat:@"videoFileId=%@ iamgeFileId=%@ uploadAppid=%@ uploadBucket=%@ videoPath=%@ imagePath=%@ uploadSession=%@ uploadRegion=%@", _videoFileId, _imageFileId, _uploadAppid, _uploadBucket, _videoPath, _imagePath, _uploadSession, _uploadRegion];
  69. }
  70. @end
  71. @implementation TVCUploadContext
  72. - (void)dealloc
  73. {
  74. NSLog(@"dealloc TVCUploadContext");
  75. }
  76. - (instancetype)init
  77. {
  78. self = [super init];
  79. if (self) {
  80. _lastStatus = TVC_OK;
  81. _desc = @"";
  82. _isUploadCover = NO;
  83. _isUploadVideo = NO;
  84. _videoSize = 0;
  85. _coverSize = 0;
  86. _currentUpload = 0;
  87. _reqTime = 0;
  88. _initReqTime = 0;
  89. _isShouldRetry = NO;
  90. _resumeData = nil;
  91. }
  92. return self;
  93. }
  94. - (NSString*)description
  95. {
  96. return [NSString stringWithFormat:@"cug=%@", [_cugResult description]];
  97. }
  98. @end
  99. @implementation TVCReportInfo
  100. - (instancetype)init
  101. {
  102. self = [super init];
  103. if (self) {
  104. _reqType = 0;
  105. _errCode = 0;
  106. _errMsg = @"";
  107. _reqTime = 0;
  108. _reqTimeCost = 0;
  109. _fileSize = 0;
  110. _fileType = @"";
  111. _fileName = @"";
  112. _fileId = @"";
  113. _appId = 0;
  114. _reqServerIp = @"";
  115. _reportId = @"";
  116. _reqKey = @"";
  117. _vodSessionKey = @"";
  118. _retryCount = 0;
  119. _reporting = NO;
  120. }
  121. return self;
  122. }
  123. @end