blob: ba3b919ab4229bd393c3afa803cec9403b0d91fd [file] [log] [blame]
Robert Shiha303ec82018-09-19 16:29:43 -07001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <media/NdkMediaError.h>
18#include <media/stagefright/MediaErrors.h>
19#include <utils/Errors.h>
20#include <utils/Log.h>
21
22using namespace android;
23
24media_status_t translate_error(status_t err) {
25
26 if (err == OK) {
27 return AMEDIA_OK;
28 } else if (err == ERROR_END_OF_STREAM) {
29 return AMEDIA_ERROR_END_OF_STREAM;
30 } else if (err == ERROR_IO) {
31 return AMEDIA_ERROR_IO;
Marco Nelissen2a6618d2018-10-22 12:58:07 -070032 } else if (err == ERROR_MALFORMED) {
33 return AMEDIA_ERROR_MALFORMED;
34 } else if (err == INVALID_OPERATION) {
35 return AMEDIA_ERROR_INVALID_OPERATION;
36 } else if (err == UNKNOWN_ERROR) {
37 return AMEDIA_ERROR_UNKNOWN;
Robert Shiha303ec82018-09-19 16:29:43 -070038 }
39
40 ALOGE("sf error code: %d", err);
41 return AMEDIA_ERROR_UNKNOWN;
42}
43
44status_t reverse_translate_error(media_status_t err) {
45
46 if (err == AMEDIA_OK) {
47 return OK;
48 } else if (err == AMEDIA_ERROR_END_OF_STREAM) {
49 return ERROR_END_OF_STREAM;
50 } else if (err == AMEDIA_ERROR_IO) {
51 return ERROR_IO;
Marco Nelissen5dcf85a2018-10-11 09:49:02 -070052 } else if (err == AMEDIA_ERROR_WOULD_BLOCK) {
53 return WOULD_BLOCK;
Marco Nelissen2a6618d2018-10-22 12:58:07 -070054 } else if (err == AMEDIA_ERROR_MALFORMED) {
55 return ERROR_MALFORMED;
56 } else if (err == AMEDIA_ERROR_INVALID_OPERATION) {
57 return INVALID_OPERATION;
58 } else if (err == AMEDIA_ERROR_UNKNOWN) {
59 return UNKNOWN_ERROR;
Robert Shiha303ec82018-09-19 16:29:43 -070060 }
61
62 ALOGE("ndk error code: %d", err);
63 return UNKNOWN_ERROR;
64}