Guest User

Untitled

a guest
May 27th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.59 KB | None | 0 0
  1. func errorAndCode(code: AVError.Code) -> (Int, String) {
  2. return (code.rawValue, describeAVError(code: code))
  3. }
  4.  
  5. func describeAVError(code: AVError.Code) -> String {
  6. switch code {
  7. case .unknown: return "unknown"
  8. case .outOfMemory: return "outOfMemory"
  9. case .sessionNotRunning: return "sessionNotRunning"
  10. case .deviceAlreadyUsedByAnotherSession: return "deviceAlreadyUsedByAnotherSession"
  11. case .noDataCaptured: return "noDataCaptured"
  12. case .sessionConfigurationChanged: return "sessionConfigurationChanged"
  13. case .diskFull: return "diskFull"
  14. case .deviceWasDisconnected: return "deviceWasDisconnected"
  15. case .mediaChanged: return "mediaChanged"
  16. case .maximumDurationReached: return "maximumDurationReached"
  17. case .maximumFileSizeReached: return "maximumFileSizeReached"
  18. case .mediaDiscontinuity: return "mediaDiscontinuity"
  19. case .maximumNumberOfSamplesForFileFormatReached: return "maximumNumberOfSamplesForFileFormatReached"
  20. case .deviceNotConnected: return "deviceNotConnected"
  21. case .deviceInUseByAnotherApplication: return "deviceInUseByAnotherApplication"
  22. case .deviceLockedForConfigurationByAnotherProcess: return "deviceLockedForConfigurationByAnotherProcess"
  23. case .sessionWasInterrupted: return "sessionWasInterrupted"
  24. case .mediaServicesWereReset: return "mediaServicesWereReset"
  25. case .exportFailed: return "exportFailed"
  26. case .decodeFailed: return "decodeFailed" // userInfo may contain AVErrorMediaTypeKey, AVErrorMediaSubTypeKey & AVErrorPresentationTimeStampKey, if available
  27. case .invalidSourceMedia: return "invalidSourceMedia"
  28. case .fileAlreadyExists: return "fileAlreadyExists"
  29. case .compositionTrackSegmentsNotContiguous: return "compositionTrackSegmentsNotContiguous"
  30. case .invalidCompositionTrackSegmentDuration: return "invalidCompositionTrackSegmentDuration"
  31. case .invalidCompositionTrackSegmentSourceStartTime: return "invalidCompositionTrackSegmentSourceStartTime"
  32. case .invalidCompositionTrackSegmentSourceDuration: return "invalidCompositionTrackSegmentSourceDuration"
  33. case .fileFormatNotRecognized: return "fileFormatNotRecognized"
  34. case .fileFailedToParse: return "fileFailedToParse"
  35. case .maximumStillImageCaptureRequestsExceeded: return "maximumStillImageCaptureRequestsExceeded"
  36. case .contentIsProtected: return "contentIsProtected"
  37. case .noImageAtTime: return "noImageAtTime"
  38. case .decoderNotFound: return "decoderNotFound" // userInfo may contain AVErrorMediaTypeKey & AVErrorMediaSubTypeKey, if available
  39. case .encoderNotFound: return "encoderNotFound" // userInfo may contain AVErrorMediaTypeKey & AVErrorMediaSubTypeKey, if available
  40. case .contentIsNotAuthorized: return "contentIsNotAuthorized"
  41. case .applicationIsNotAuthorized: return "applicationIsNotAuthorized"
  42. case .operationNotSupportedForAsset: return "operationNotSupportedForAsset"
  43. case .decoderTemporarilyUnavailable: return "decoderTemporarilyUnavailable" // userInfo may contain AVErrorMediaTypeKey & AVErrorMediaSubTypeKey, if available
  44. case .encoderTemporarilyUnavailable: return "encoderTemporarilyUnavailable" // userInfo may contain AVErrorMediaTypeKey & AVErrorMediaSubTypeKey, if available
  45. case .invalidVideoComposition: return "invalidVideoComposition"
  46. case .referenceForbiddenByReferencePolicy: return "referenceForbiddenByReferencePolicy"
  47. case .invalidOutputURLPathExtension: return "invalidOutputURLPathExtension"
  48. case .screenCaptureFailed: return "screenCaptureFailed"
  49. case .displayWasDisabled: return "displayWasDisabled"
  50. case .torchLevelUnavailable: return "torchLevelUnavailable"
  51. case .operationInterrupted: return "operationInterrupted"
  52. case .incompatibleAsset: return "incompatibleAsset"
  53. case .failedToLoadMediaData: return "failedToLoadMediaData"
  54. case .serverIncorrectlyConfigured: return "serverIncorrectlyConfigured"
  55. case .applicationIsNotAuthorizedToUseDevice: return "applicationIsNotAuthorizedToUseDevice"
  56. case .failedToParse: return "failedToParse"
  57. case .fileTypeDoesNotSupportSampleReferences: return "fileTypeDoesNotSupportSampleReferences" // userInfo contains AVErrorFileTypeKey
  58. case .undecodableMediaData: return "undecodableMediaData"
  59. case .airPlayControllerRequiresInternet: return "airPlayControllerRequiresInternet"
  60. case .airPlayReceiverRequiresInternet: return "airPlayReceiverRequiresInternet"
  61. case .videoCompositorFailed: return "videoCompositorFailed"
  62. case .recordingAlreadyInProgress: return "recordingAlreadyInProgress" // on iOS, AVCaptureMovieFileOutput only supports one recording at a time
  63.  
  64. default:
  65. if #available(iOS 11.2, *) {
  66. switch code {
  67. case .noSourceTrack: return "noSourceTrack"
  68. default: return "Unknown"
  69. }
  70. }
  71. else if #available(iOS 11.0, *) {
  72. switch code {
  73. case .contentIsUnavailable: return "contentIsUnavailable"
  74. case .formatUnsupported: return "formatUnsupported"
  75. case .malformedDepth: return "malformedDepth"
  76. case .contentNotUpdated: return "contentNotUpdated"
  77. case .noLongerPlayable: return "noLongerPlayable"
  78. case .noCompatibleAlternatesForExternalDisplay: return "noCompatibleAlternatesForExternalDisplay"
  79. default: return "Unknown"
  80. }
  81. }
  82. else if #available(iOS 10.0, *) {
  83. switch code {
  84. case .unsupportedOutputSettings: return "unsupportedOutputSettings"
  85. case .operationNotAllowed: return "operationNotAllowed"
  86. default: return "Unknown"
  87. }
  88. }
  89. return "Unknown"
  90. }
  91. }
Add Comment
Please, Sign In to add comment