blob: 2facd8c82cb528ef96a7c75d54d313cd1d4de18e [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;
32 }
33
34 ALOGE("sf error code: %d", err);
35 return AMEDIA_ERROR_UNKNOWN;
36}
37
38status_t reverse_translate_error(media_status_t err) {
39
40 if (err == AMEDIA_OK) {
41 return OK;
42 } else if (err == AMEDIA_ERROR_END_OF_STREAM) {
43 return ERROR_END_OF_STREAM;
44 } else if (err == AMEDIA_ERROR_IO) {
45 return ERROR_IO;
46 }
47
48 ALOGE("ndk error code: %d", err);
49 return UNKNOWN_ERROR;
50}