Code clean up
[platform/core/api/mediacodec.git] / include / media_codec_util.h
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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 #ifndef __TIZEN_MEDIA_CODEC_UTIL_H__
18 #define __TIZEN_MEDIA_CODEC_UTIL_H__
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <glib.h>
23 #include <tizen.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 typedef enum {
30         CODEC_RET_SUCCESS         =  0,
31         CODEC_RET_FAIL            = -1,
32         CODEC_RET_NOT_SUPPORT     = -2,
33         CODEC_RET_INVALID_ARG     = -3,
34         CODEC_RET_INVALID_CONFIG  = -4,
35         CODEC_RET_CORRUPTED_BS    = -5,
36         CODEC_RET_SMALL_IMG_BUF   = -6,
37         CODEC_RET_HW_ERROR        = -7,
38         CODEC_RET_NOT_AVAILABLE   = -8,
39         CODEC_RET_NOT_EXPECTED    = -9,
40         CODEC_RET_UNKNOWN_ERR     = -100,
41 } CodecRet;
42
43 typedef struct _mc_sem_t mc_sem_t;
44
45 struct _mc_sem_t {
46         GCond cond;
47         GMutex mutex;
48         int counter;
49 };
50
51 mc_sem_t *mc_sem_new();
52 void mc_sem_free(mc_sem_t *sem);
53 void mc_sem_down(mc_sem_t *sem);
54 void mc_sem_up(mc_sem_t *sem);
55
56 void mc_hex_dump(char *desc, void *addr, int len);
57
58 #define MC_FREEIF(x)    \
59         do {                            \
60                 if (x)                  \
61                         g_free(x);      \
62                 x = NULL;               \
63         } while (0)
64
65 #ifdef __cplusplus
66 }
67 #endif
68
69 #endif /* __TIZEN_MEDIA_CODEC_UTIL_H__ */