Skip to content

Instantly share code, notes, and snippets.

@FredrikSjoberg
Last active May 24, 2018 09:14
Show Gist options
  • Save FredrikSjoberg/72cb267b106fdf03366b7f7792479391 to your computer and use it in GitHub Desktop.
Save FredrikSjoberg/72cb267b106fdf03366b7f7792479391 to your computer and use it in GitHub Desktop.
AVError.code descriptions
func errorAndCode(code: AVError.Code) -> (Int, String) {
return (code.rawValue, describeAVError(code: code))
}
func describeAVError(code: AVError.Code) -> String {
switch code {
case .unknown: return "unknown"
case .outOfMemory: return "outOfMemory"
case .sessionNotRunning: return "sessionNotRunning"
case .deviceAlreadyUsedByAnotherSession: return "deviceAlreadyUsedByAnotherSession"
case .noDataCaptured: return "noDataCaptured"
case .sessionConfigurationChanged: return "sessionConfigurationChanged"
case .diskFull: return "diskFull"
case .deviceWasDisconnected: return "deviceWasDisconnected"
case .mediaChanged: return "mediaChanged"
case .maximumDurationReached: return "maximumDurationReached"
case .maximumFileSizeReached: return "maximumFileSizeReached"
case .mediaDiscontinuity: return "mediaDiscontinuity"
case .maximumNumberOfSamplesForFileFormatReached: return "maximumNumberOfSamplesForFileFormatReached"
case .deviceNotConnected: return "deviceNotConnected"
case .deviceInUseByAnotherApplication: return "deviceInUseByAnotherApplication"
case .deviceLockedForConfigurationByAnotherProcess: return "deviceLockedForConfigurationByAnotherProcess"
case .sessionWasInterrupted: return "sessionWasInterrupted"
case .mediaServicesWereReset: return "mediaServicesWereReset"
case .exportFailed: return "exportFailed"
case .decodeFailed: return "decodeFailed" // userInfo may contain AVErrorMediaTypeKey, AVErrorMediaSubTypeKey & AVErrorPresentationTimeStampKey, if available
case .invalidSourceMedia: return "invalidSourceMedia"
case .fileAlreadyExists: return "fileAlreadyExists"
case .compositionTrackSegmentsNotContiguous: return "compositionTrackSegmentsNotContiguous"
case .invalidCompositionTrackSegmentDuration: return "invalidCompositionTrackSegmentDuration"
case .invalidCompositionTrackSegmentSourceStartTime: return "invalidCompositionTrackSegmentSourceStartTime"
case .invalidCompositionTrackSegmentSourceDuration: return "invalidCompositionTrackSegmentSourceDuration"
case .fileFormatNotRecognized: return "fileFormatNotRecognized"
case .fileFailedToParse: return "fileFailedToParse"
case .maximumStillImageCaptureRequestsExceeded: return "maximumStillImageCaptureRequestsExceeded"
case .contentIsProtected: return "contentIsProtected"
case .noImageAtTime: return "noImageAtTime"
case .decoderNotFound: return "decoderNotFound" // userInfo may contain AVErrorMediaTypeKey & AVErrorMediaSubTypeKey, if available
case .encoderNotFound: return "encoderNotFound" // userInfo may contain AVErrorMediaTypeKey & AVErrorMediaSubTypeKey, if available
case .contentIsNotAuthorized: return "contentIsNotAuthorized"
case .applicationIsNotAuthorized: return "applicationIsNotAuthorized"
case .operationNotSupportedForAsset: return "operationNotSupportedForAsset"
case .decoderTemporarilyUnavailable: return "decoderTemporarilyUnavailable" // userInfo may contain AVErrorMediaTypeKey & AVErrorMediaSubTypeKey, if available
case .encoderTemporarilyUnavailable: return "encoderTemporarilyUnavailable" // userInfo may contain AVErrorMediaTypeKey & AVErrorMediaSubTypeKey, if available
case .invalidVideoComposition: return "invalidVideoComposition"
case .referenceForbiddenByReferencePolicy: return "referenceForbiddenByReferencePolicy"
case .invalidOutputURLPathExtension: return "invalidOutputURLPathExtension"
case .screenCaptureFailed: return "screenCaptureFailed"
case .displayWasDisabled: return "displayWasDisabled"
case .torchLevelUnavailable: return "torchLevelUnavailable"
case .operationInterrupted: return "operationInterrupted"
case .incompatibleAsset: return "incompatibleAsset"
case .failedToLoadMediaData: return "failedToLoadMediaData"
case .serverIncorrectlyConfigured: return "serverIncorrectlyConfigured"
case .applicationIsNotAuthorizedToUseDevice: return "applicationIsNotAuthorizedToUseDevice"
case .failedToParse: return "failedToParse"
case .fileTypeDoesNotSupportSampleReferences: return "fileTypeDoesNotSupportSampleReferences" // userInfo contains AVErrorFileTypeKey
case .undecodableMediaData: return "undecodableMediaData"
case .airPlayControllerRequiresInternet: return "airPlayControllerRequiresInternet"
case .airPlayReceiverRequiresInternet: return "airPlayReceiverRequiresInternet"
case .videoCompositorFailed: return "videoCompositorFailed"
case .recordingAlreadyInProgress: return "recordingAlreadyInProgress" // on iOS, AVCaptureMovieFileOutput only supports one recording at a time
default:
if #available(iOS 11.2, *) {
switch code {
case .noSourceTrack: return "noSourceTrack"
default: return "Unknown"
}
}
else if #available(iOS 11.0, *) {
switch code {
case .contentIsUnavailable: return "contentIsUnavailable"
case .formatUnsupported: return "formatUnsupported"
case .malformedDepth: return "malformedDepth"
case .contentNotUpdated: return "contentNotUpdated"
case .noLongerPlayable: return "noLongerPlayable"
case .noCompatibleAlternatesForExternalDisplay: return "noCompatibleAlternatesForExternalDisplay"
default: return "Unknown"
}
}
else if #available(iOS 10.0, *) {
switch code {
case .unsupportedOutputSettings: return "unsupportedOutputSettings"
case .operationNotAllowed: return "operationNotAllowed"
default: return "Unknown"
}
}
return "Unknown"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment