Перейти к содержанию

Обработка ошибок iOS SDK

При получении статуса потока kFPWCSStreamStatusFailed, метод FPWCSApi2Stream.getStatusInfo возвращает код возникшей ошибки, который может быть преобразован в текстовое описание при помощи метода streamStatusToString. Аналогичным образом обрабатываются и ошибки при совершении звонка.

Список ошибок

Ошибка Описание
kFPWCSStreamStatusInfo
kFPWCSStreamStatusInfoFailedByIceError Failed by ICE error
kFPWCSStreamStatusInfoFailedByIceTimeout Failed by ICE timeout
kFPWCSStreamStatusInfoFailedByKeepAlive Failed by ICE keep alive
kFPWCSStreamStatusInfoFailedByDtlsFingerprintError Failed by DTLS fingerprint error
kFPWCSStreamStatusInfoFailedByDtlsError Failed by DTLS error
kFPWCSStreamStatusInfoFailedByHlsWriterError Failed by HLS writer error
FPWCSStreamStatusInfoFailedByRtmpWriterError Failed by RTMP writer error
kFPWCSStreamStatusInfoFailedByRtpActivity Failed by RTP activity
kFPWCSStreamStatusInfoStoppedBySessionDisconnect Stopped by session disconnect
kFPWCSStreamStatusInfoStoppedByRestTerminate Stopped by REST API /terminate query
kFPWCSStreamStatusInfoStoppedByPublisherStop Stopped by publisher stop
kFPWCSStreamStatusInfoStoppedByUser Stopped by user
kFPWCSStreamStatusInfoFailedByError Failed by error
kFPWCSStreamStatusInfoFailedToAddStreamToProxy Failed to add stream to proxy
kFPWCSStreamStatusInfoDistributorStopped Distributor stopped
kFPWCSStreamStatusInfoPublishStreamIsNotReady Publish stream is not ready
kFPWCSStreamStatusInfoStreamNotFound Stream not found
kFPWCSStreamStatusInfoStreamNameAlreadyInUse Stream name is already in use
kFPWCSStreamStatusInfoMediasessionIdNull MediaSessionId is null
kFPWCSStreamStatusInfoMediasessionIdAlreadyInUse MediaSessionId is already in use
kFPWCSStreamStatusInfoSessionNotReady Session not ready
kFPWCSStreamStatusInfoSessionDoesNotExist Session does not exist
kFPWCSStreamStatusInfoRtspHasWrongFormat Rtsp has wrong format
kFPWCSStreamStatusInfoFileHasWrongFormat File has wrong format
kFPWCSStreamStatusInfoFailedToConnectToRtspStream Failed to connect to rtsp stream
kFPWCSStreamStatusInfoRtspStreamNotFound Rtsp stream not found
kFPWCSStreamStatusInfoRtspAgentShutdown RtspAgent shutdown
kFPWCSStreamStatusInfoStreamFailed Stream failed
kFPWCSStreamStatusInfoNoCommonCodecs No common codecs
kFPWCSStreamStatusInfoBadUri Bad URI
kFPWCSStreamStatusInfoGotExceptionWhileStreamingFile Got exception while streaming file
kFPWCSStreamStatusInfoRequestedStreamShutdown Requested stream shutdown
kFPWCSStreamStatusInfoFailedToReadFile Failed to read file
kFPWCSStreamStatusInfoFileNotFound File not found
kFPWCSStreamStatusInfoFailedToConnectToOriginStream Failed to connect to origin stream
kFPWCSStreamStatusInfoCdnStreamNotFound CDN stream not found
kFPWCSStreamStatusInfoFailedToGetAgentStorage Failed to get agent storage
kFPWCSStreamStatusInfoAgentServicingOriginStreamIsShuttingDown Agent servicing origin stream is shutting down
kFPWCSStreamStatusInfoTerminatedByKeepAlive Terminated by keep-alive
kFPWCSStreamStatusInfoTranscodingRequiredButDisabled Transcoding is required, but disabled
kFPWCSCallStatusInfo
kFPWCSCallStatusInfoNormalCallClearing Normal call hangup
kFPWCSCallStatusInfoFailedBySessionCreation Failed by session creation
kFPWCSCallStatusInfoFailedByIceError Failed by ICE error
kFPWCSCallStatusInfoFailedByRtpActivity Failed by RTP activity
kFPWCSCallStatusInfoFailedByRtmpWriterError Failed by RTMP writer error
kFPWCSCallStatusInfoFailedByDtlsFingerprintError Failed by DTLS fingerprint error
kFPWCSCallStatusInfoFailedByDtlsError Failed by DTLS error
kFPWCSCallStatusInfoFailedByError Failed by error
kFPWCSCallStatusInfoFailedByRequestTimeout Failed by request timeout
kFPWCSCallStatusInfoTranscodingRequiredButDisabled Transcoding is required, but disabled

Пример кода обработки ошибок

В качестве примера рассмотрим код примера Two Way Streaming, файл имплементации ViewController.m

FPWCSApi2Model.streamStatusToString(), FPWCSApi2Stream.getStatus(), FPWCSApi2Stream.getStatusInfo()

view.text = [FPWCSApi2Model streamStatusToString:[stream getStatus]];
switch ([stream getStatus]) {
    case kFPWCSStreamStatusFailed:
    {
        view.textColor = [UIColor redColor];
        switch ([stream getStatusInfo]) {
            case kFPWCSStreamStatusInfoSessionDoesNotExist:
                view.text = @"Actual session does not exist";
                break;
            case kFPWCSStreamStatusInfoStoppedByPublisherStop:
                view.text = @"Related publisher stopped its stream or lost connection";
                break;
            case kFPWCSStreamStatusInfoSessionNotReady:
                view.text = @"Session is not initialized or terminated on play ordinary stream";
                break;
            case kFPWCSStreamStatusInfoRtspStreamNotFound:
                view.text = @"Rtsp stream is not found, agent received '404-Not Found'";
                break;
            case kFPWCSStreamStatusInfoFailedToConnectToRtspStream:
                view.text = @"Failed to connect to rtsp stream";
                break;
            case kFPWCSStreamStatusInfoFileNotFound:
                view.text = @"File does not exist, check filename";
                break;
            case kFPWCSStreamStatusInfoFileHasWrongFormat:
                view.text = @"Failed to play vod stream, this format is not supported";
                break;
            case kFPWCSStreamStatusInfoStreamNameAlreadyInUse:
                view.text = @"Server already has a publish stream with the same name, try using different one";
                break;
        }
        break;
    }
    ...
}