-
Notifications
You must be signed in to change notification settings - Fork 200
/
ErrorCodeMap.cpp
90 lines (80 loc) · 3.76 KB
/
ErrorCodeMap.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// Created by lifujun on 2019/3/14.
//
#define LOG_TAG "ErrorCodeMap"
#include "ErrorCodeMap.h"
#include <mutex>
#include "media_player_error_def.h"
#include "utils/frame_work_log.h"
using namespace Cicada;
ErrorCodeMap &ErrorCodeMap::getInstance()
{
static ErrorCodeMap sInstance{};
return sInstance;
}
ErrorCodeMap::ErrorCodeMap()
{
init();
}
ErrorCodeMap::~ErrorCodeMap()
{
}
void ErrorCodeMap::init()
{
//==========================
// 2、apsaraplayer;
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_NATIVE_START, 0x20020000));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_READ_PACKET, 0x20020001));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_BUFFER_STUFFED, 0x20020002));
// 3、demuxer、datasource
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_DEMUXER_START, 0x20030000));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_DEMUXER_OPENURL, 0x20030001));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_DEMUXER_NO_VALID_STREAM, 0x20030002));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_DEMUXER_OPENSTREAM, 0x20030003));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_LOADING_TIMEOUT, 0x20030004));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_DATASOURCE_EMPTYURL, 0x20030005));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_DECODE_BASE, 0x20040000));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_DECODE_VIDEO, 0x20040001));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_DECODE_AUDIO, 0x20040002));
// 4. network
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_NETWORK_UNKNOWN, 0x20050000));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_NETWORK_UNSUPPORTED, 0x20050001));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_NETWORK_RESOLVE, 0x20050002));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_NETWORK_CONNECT_TIMEOUT, 0x20050003));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_NETWORK_COULD_NOT_CONNECT, 0x20050004));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_NETWORK_HTTP_403, 0x20050005));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_NETWORK_HTTP_404, 0x20050006));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_NETWORK_HTTP_4XX, 0x20050007));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_NETWORK_HTTP_5XX, 0x20050008));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_NETWORK_HTTP_RANGE, 0x20050009));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_NETWORK_HTTP_400, 0x2005000A));
//5. codec
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_CODEC_UNKNOWN, 0x20060000));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_CODEC_VIDEO_NOT_SUPPORT, 0x20060001));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_CODEC_AUDIO_NOT_SUPPORT, 0x20060002));
//6. internal
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_INERNAL_UNKNOWN, 0x20070000));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_INERNAL_EXIT, 0x20070001));
//7.general
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_GENERAL_UNKNOWN, 0x20080000));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_GENERAL_EPERM, 0x20080001));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_GENERAL_ENOENT, 0x20080002));
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_GENERAL_EIO, 0x20080005));
//8.render
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_RENDER_AUDIO_OPEN_DEVICE_FAILED, 0x20090001));
//
codeMap.insert(pair<int, int>(MEDIA_PLAYER_ERROR_UNKNOWN, 0x30000000 - 1));
}
int ErrorCodeMap::getValue(int orignalValue)
{
if (codeMap.count(orignalValue) > 0) {
return codeMap.at(orignalValue);
} else {
AF_LOGE("not mapped errorCode : %d ", orignalValue);
return orignalValue;
}
}
bool ErrorCodeMap::containsCode(int orignalValue)
{
return (codeMap.count(orignalValue) > 0);
}