Featuer Enhancement : A Media Player library in Tizen Native API 69/32969/2
authorHyunil Park <hyunil46.park@samsung.com>
Wed, 31 Dec 2014 02:54:59 +0000 (11:54 +0900)
committerHyunil Park <hyunil46.park@samsung.com>
Fri, 2 Jan 2015 03:06:36 +0000 (12:06 +0900)
Change-Id: I8dfabdbdb44c4892a27ac68e1e85a056e5d328fd

21 files changed:
AUTHORS [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0644]
LICENSE.APLv2 [new file with mode: 0644]
NOTICE [new file with mode: 0644]
capi-media-codec.manifest [new file with mode: 0644]
capi-media-codec.pc.in [new file with mode: 0644]
doc/media_codec_doc.h [new file with mode: 0644]
include/media_codec.h [new file with mode: 0644]
include/media_codec_port.h [new file with mode: 0644]
include/media_codec_private.h [new file with mode: 0644]
include/media_codec_queue.h [new file with mode: 0644]
include/media_codec_spec_emul.h [new file with mode: 0644]
include/media_codec_util.h [new file with mode: 0644]
packaging/capi-media-codec.spec [new file with mode: 0644]
src/media_codec.c [new file with mode: 0644]
src/media_codec_port.c [new file with mode: 0644]
src/media_codec_queue.c [new file with mode: 0644]
src/media_codec_util.c [new file with mode: 0644]
test/CMakeLists.txt [new file with mode: 0644]
test/media_codec_test.c [new file with mode: 0644]
test/tags [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..b01c60f
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Kangho Hur <kanho.hur@samsung.com>
+Seungkeun Lee <sngn.lee@samsung.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fb97f90
--- /dev/null
@@ -0,0 +1,98 @@
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-media-codec")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+SET(dependents "dlog glib-2.0 mm-common capi-media-tool libtbm libdri2 gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-app-1.0" )
+SET(pc_dependents "capi-base-common capi-media-tool gstreamer-1.0 gstreamer-plugins-base-1.0 gstreamer-app-1.0" )
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${dependents})
+FOREACH(flag ${${fw_name}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "-I./include -I./include/headers ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+    ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+
+aux_source_directory(src SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
+
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+
+SET_TARGET_PROPERTIES(${fw_name}
+     PROPERTIES
+     VERSION ${FULLVER}
+     SOVERSION ${MAJORVER}
+     CLEAN_DIRECT_OUTPUT 1
+)
+
+INSTALL(TARGETS ${fw_name} DESTINATION lib)
+INSTALL(
+        DIRECTORY ${INC_DIR}/ DESTINATION include/media
+        FILES_MATCHING
+        PATTERN "media_codec_*.h" EXCLUDE
+        PATTERN "${INC_DIR}/*.h"
+        )
+
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${pc_dependents})
+SET(PC_LDFLAGS -l${fw_name})
+SET(PC_CFLAGS -I\${includedir}/media)
+
+CONFIGURE_FILE(
+    ${fw_name}.pc.in
+    ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
+    @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+
+ADD_SUBDIRECTORY(test)
+
+IF(UNIX)
+
+ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
+ADD_CUSTOM_COMMAND(
+        DEPENDS clean
+        COMMENT "distribution clean"
+        COMMAND find
+        ARGS    .
+        -not -name config.cmake -and \(
+        -name tester.c -or
+        -name Testing -or
+        -name CMakeFiles -or
+        -name cmake.depends -or
+        -name cmake.check_depends -or
+        -name CMakeCache.txt -or
+        -name cmake.check_cache -or
+        -name *.cmake -or
+        -name Makefile -or
+        -name core -or
+        -name core.* -or
+        -name gmon.out -or
+        -name install_manifest.txt -or
+        -name *.pc -or
+        -name *~ \)
+        | grep -v TC | xargs rm -rf
+        TARGET  distclean
+        VERBATIM
+)
+
+ENDIF(UNIX)
+
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100644 (file)
index 0000000..bbe9d02
--- /dev/null
@@ -0,0 +1,206 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+\r
+\r
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..ccdad52
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
diff --git a/capi-media-codec.manifest b/capi-media-codec.manifest
new file mode 100644 (file)
index 0000000..e3deed8
--- /dev/null
@@ -0,0 +1,8 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+       <assign>
+               <filesystem path="/usr/bin/player_test" label="_" exec_label="none" />
+       </assign>
+</manifest>
diff --git a/capi-media-codec.pc.in b/capi-media-codec.pc.in
new file mode 100644 (file)
index 0000000..5d02f8d
--- /dev/null
@@ -0,0 +1,15 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include/media
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@ 
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
+
diff --git a/doc/media_codec_doc.h b/doc/media_codec_doc.h
new file mode 100644 (file)
index 0000000..28971c8
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_MEDIA_CODEC_DOC_H__
+#define __TIZEN_MEDIA_CODEC_DOC_H__
+
+
+/**
+ * @file media_codec_doc.h
+ * @brief This file contains high level documentation of the CAPI MEDIA CODEC API.
+ */
+
+/**
+ * @defgroup CAPI_MEDIA_CODEC_MODULE Media Codec
+ * @brief  The @ref CAPI_MEDIA_CODEC_MODULE  APIs provides functions for encodinging and decoding using media data
+ * @ingroup CAPI_MEDIA_FRAMEWORK
+ *
+ * @section CAPI_MEDIA_CODEC_MODULE_HEADER Required Header
+ *   \#include <media_codec.h>
+ *
+ * @section CAPI_MEDIA_CODEC_MODULE_OVERVIEW Overview
+ *
+ * MEDIA CODEC API allows :
+ * The API allows you to direct access to the media codec on device. It operates on "raw" data, so any file headers
+ * must be stripped off. media_packet is used for zero-copy.
+ *
+ */
+
+#endif // __TIZEN_MEDIA_CODEC_DOC_H__
diff --git a/include/media_codec.h b/include/media_codec.h
new file mode 100644 (file)
index 0000000..284656f
--- /dev/null
@@ -0,0 +1,445 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_MEDIA_CODEC_H__
+#define __TIZEN_MEDIA_CODEC_H__
+
+#include <tizen.h>
+#include <stdint.h>
+#include <media_packet.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* @file media_codec.h
+* @brief This file contains the capi media codec API.
+*/
+
+/**
+* @addtogroup CAPI_MEDIA_CODEC_MODULE
+* @{
+*/
+
+/**
+ * @brief Media Codec type handle.
+ * @since_tizen 2.3
+ */
+typedef struct mediacodec_s *mediacodec_h;
+
+/**
+ * @brief Enumeration of  media codec support  type
+ * @since_tizen 2.3
+ * @remarks If this codec is to be used as an encoder or decoder, the codec flag must be set to #MEDIACODEC_ENCODER or
+ *          #MEDIACODEC_DECODER. If user doesn't set optional flag, default flags will be set to #MEDIACODEC_SUPPORT_TYPE_HW.
+ */
+typedef enum
+{
+    MEDIACODEC_ENCODER          = 0x1,      /**< This flag is for using the encoder */
+    MEDIACODEC_DECODER          = 0x2,      /**< This flag is for using the decoder */
+    MEDIACODEC_SUPPORT_TYPE_HW  = 0x4,      /**< This is an optional flag for using the h/w codec */
+    MEDIACODEC_SUPPORT_TYPE_SW  = 0x8,      /**< This is an optional flag for using the s/w codec */
+} mediacodec_support_type_e;
+
+/**
+ * @brief Enumerations of  media codec type
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+    MEDIACODEC_NONE     = 0x0,
+    MEDIACODEC_L16      = 0x1010,
+    MEDIACODEC_ALAW     = 0x1020,
+    MEDIACODEC_ULAW     = 0x1030,
+    MEDIACODEC_AMR      = 0x1040,
+    MEDIACODEC_G729     = 0x1050,
+    MEDIACODEC_AAC      = 0x1060,
+    MEDIACODEC_MP3      = 0x1070,
+
+    MEDIACODEC_H261     = 0x2010,
+    MEDIACODEC_H263     = 0x2020,
+    MEDIACODEC_H264     = 0x2030,
+    MEDIACODEC_MJPEG    = 0x2040,
+    MEDIACODEC_MPEG1    = 0x2050,
+    MEDIACODEC_MPEG2    = 0x2060,
+    MEDIACODEC_MPEG4    = 0x2070,
+} mediacodec_codec_type_e;
+
+/**
+ * @brief Enumeration of  media codec error
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+    MEDIACODEC_ERROR_NONE                       = TIZEN_ERROR_NONE,                     /**< Successful */
+    MEDIACODEC_ERROR_OUT_OF_MEMORY              = TIZEN_ERROR_OUT_OF_MEMORY,            /**< Out of memory */
+    MEDIACODEC_ERROR_INVALID_PARAMETER          = TIZEN_ERROR_INVALID_PARAMETER,        /**< Invalid parameter */
+    MEDIACODEC_ERROR_INVALID_OPERATION          = TIZEN_ERROR_INVALID_OPERATION,        /**< Invalid operation */
+    MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE    = TIZEN_ERROR_NOT_SUPPORTED,            /**< Not supported */
+    MEDIACODEC_ERROR_PERMISSION_DENIED          = TIZEN_ERROR_PERMISSION_DENIED,        /**< Permission denied */
+    MEDIACODEC_ERROR_INVALID_STATE              = TIZEN_ERROR_MEDIACODEC | 0x01,        /**< Invalid state */
+    MEDIACODEC_ERROR_INVALID_INBUFFER           = TIZEN_ERROR_MEDIACODEC | 0x02,        /**< Invalid input buffer */
+    MEDIACODEC_ERROR_INVALID_OUTBUFFER          = TIZEN_ERROR_MEDIACODEC | 0x03,        /**< Invalid output buffer */
+    MEDIACODEC_ERROR_INTERNAL                   = TIZEN_ERROR_MEDIACODEC | 0x04,        /**< Internal error */
+    MEDIACODEC_ERROR_NOT_INITIALIZED            = TIZEN_ERROR_MEDIACODEC | 0x05,        /**< Not initialized mediacodec */
+    MEDIACODEC_ERROR_INVALID_STREAM             = TIZEN_ERROR_MEDIACODEC | 0x06,        /**< Invalid stream */
+    MEDIACODEC_ERROR_CODEC_NOT_FOUND            = TIZEN_ERROR_MEDIACODEC | 0x07,        /**< Not supported format */
+    MEDIACODEC_ERROR_DECODE                     = TIZEN_ERROR_MEDIACODEC | 0x08,        /**< Error while decoding data */
+    MEDIACODEC_ERROR_NO_FREE_SPACE              = TIZEN_ERROR_MEDIACODEC | 0x09,        /**< Out of storage */
+    MEDIACODEC_ERROR_STREAM_NOT_FOUND           = TIZEN_ERROR_MEDIACODEC | 0x0a,        /**< Cannot find stream */
+    MEDIACODEC_ERROR_NOT_SUPPORTED_FORMAT       = TIZEN_ERROR_MEDIACODEC | 0x0b,        /**< Not supported format */
+    MEDIACODEC_ERROR_BUFFER_NOT_AVAILABLE       = TIZEN_ERROR_MEDIACODEC | 0x0c,        /**< Not available buffer */
+} mediacodec_error_e;
+
+/**
+ * @brief Called when the input buffer(pkt) used up.
+ * @since_tizen 2.3
+ * @details It will be invoked when mediacodec has used input buffer.
+ * @param[in] pkt  The media packet handle
+ * @param[in] user_data  The user data passed from the callback registration function
+ * @pre It will be invoked when input buffer process completed if you register this callback using mediacodec_set_input_buffer_used_cb().
+ * @see mediacodec_set_input_buffer_used_cb()
+ * @see mediacodec_unset_input_buffer_used_cb()
+ */
+typedef void (*mediacodec_input_buffer_used_cb)(media_packet_h pkt, void *user_data);
+
+/**
+ * @brief Called when the output buffer is available.
+ * @since_tizen 2.3
+ * @details It will be invoked when mediacodec has output buffer.
+ * @param[in] pkt  The media packet handle
+ * @param[in] user_data  The user data passed from the callback registration function
+ * @pre It will be invoked when mediacodec process completed(had output buffer) if you register this callback using mediacodec_set_fill_buffer_cb().
+ * @see mediacodec_set_output_buffer_available_cb()
+ * @see mediacodec_unset_output_buffer_available_cb()
+ */
+typedef void (*mediacodec_output_buffer_available_cb)(media_packet_h pkt, void *user_data);
+
+/**
+ * @brief Called when the error has occured
+ * @since_tizen 2.3
+ * @details It will be invoked when the error has occured.
+ * @param[in] error_code  The error code
+ * @param[in] user_data  The user data passed from the callback registration function
+ * @pre It will be invoked when the error has occured if you register this callback using mediacodec_set_error_cb().
+ * @see mediacodec_set_error_cb()
+ * @see mediacodec_unset_error_cb()
+ */
+typedef void (*mediacodec_error_cb)(mediacodec_error_e error, void *user_data);
+
+/**
+ * @brief Called when there is no data to decode/encode
+ * @since_tizen 2.3
+ * @details It will be invoked when the end-of-stream is reached.
+ * @param[in] user_data  The user data passed from the callback registration function
+ * @pre It will be invoked when the eos event generate if you register this callback using mediacodec_set_eos_cb().
+ * @see mediacodec_set_eos_cb()
+ * @see mediacodec_unset_eos_cb()
+ */
+typedef void (*mediacodec_eos_cb)(void *user_data);
+
+/**
+ * @brief Creates a mediacodec handle for decoding/encoding
+ * @since_tizen 2.3
+ * @remarks you must release @a mediacodec using mediacodec_destroy().\n
+ *          Although you can create multiple mediacodec handles at the same time,
+ *          the mediacodec cannot guarantee proper operation because of limited resources, like
+ *          audio or display device.
+ *
+ * @param[out]  mediacodec  A new handle to mediacodec
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
+ */
+int mediacodec_create(mediacodec_h *mediacodec);
+
+/**
+ * @brief Destroys the mediacodec handle and releases all its resources.
+ * @since_tizen 2.3
+ * @remarks To completely shutdown the mediacodec operation, call this function with a valid player handle from any
+ *          mediacodec
+ *
+ * @param[in]  mediacodec  The handle to mediacodec to be destroyed.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
+ */
+int mediacodec_destroy(mediacodec_h mediacodec);
+
+/**
+ * @brief Sets the codec type and decoder/encoder.
+ * @since_tizen 2.3
+ * @remarks If this codec is to be used as a decoder, pass the #MEDIACODEC_DECODER flag.
+ *          If this codec is to be used as an encoder, pass the #MEDIACODEC_ENCODER flag.
+ *          By default, It is used hardware default setting. If user want software setting, pass the
+ *          #MEDIACODEC_SUPPORT_TYPE_SW flags.
+ * @param[in] mediacodec  The handle of mediacodec
+ * @param[in] codec_id  The identifier of the codec type of the decoder/encoder
+ * @param[in] flags  The encoding/decoding scheme.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #MEDIACODEC_ERROR_CODEC_NOT_FOUND Codec not found
+ */
+int mediacodec_set_codec(mediacodec_h mediacodec, mediacodec_codec_type_e codec_id, mediacodec_support_type_e flags);
+
+/**
+ * @brief Sets the default info for the video decoder
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @param[in] width  The width for video decoding.
+ * @param[in] height  The height for video decoding.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
+ */
+int mediacodec_set_vdec_info(mediacodec_h mediacodec, int width, int height);
+
+/**
+ * @brief Sets the default info for the video encoder
+ * @since_tizen 2.3
+ * @remarks The frame rate is the speed of recording and the speed of playback.
+ *          If user wants the default setting for ratecontrol, set @a target_bits to @c 0.
+ * @param[in] mediacodec  The handle to mediacodec
+ * @param[in] width  The width for video encoding.
+ * @param[in] height  The height for video encoding.
+ * @param[in] fps  The frame rate in frames per second.
+ * @param[in] target_bits The target bitrates in bits per second.(a unit of kbit)
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
+ */
+int mediacodec_set_venc_info(mediacodec_h mediacodec, int width, int height, int fps, int target_bits);
+
+/**
+ * @brief Sets the default info for the audio decoder
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @param[in] samplerate  The samplerate for audio decoding.
+ * @param[in] channel  The channels for audio decoding.
+  * @param[in] bit  The bits resolution for audio decoding.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
+ */
+int mediacodec_set_adec_info(mediacodec_h mediacodec, int samplerate, int channel, int bit);
+
+/**
+ * @brief Sets the default info for the audio encdoer
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @param[in] samplerate  The samplerate for audio encoding.
+ * @param[in] channel  The channels for audio encoding.
+  * @param[in] bit  The bits resolution for audio encoding.
+  * @param[in] bitrate  The bitrate for audio encoding.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
+ */
+int mediacodec_set_aenc_info(mediacodec_h mediacodec, int samplerate, int channel, int bit, int bitrate);
+
+/**
+ * @brief Prepares @a mediacodec for encoding/decoding.
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
+ * @pre The mediacodec should call mediacodec_set_codec()and mediacodec_set_vdec_info()/mediacodec_set_venc_info() before calling mediacodec_prepare()
+ *      If the decoder is set by mediacodec_set_codec(), mediacodec_set_vdec_info() should be called. If the encoder is set by
+ *      mediacodec_set_codec(), mediacodec_set_venc_info() should be called.
+ */
+int mediacodec_prepare(mediacodec_h mediacodec);
+
+/**
+ * @brief Unprepares @a mediacodec for encoding/decoding.
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
+ */
+int mediacodec_unprepare(mediacodec_h mediacodec);
+
+/**
+ * @brief Decodes/Encodes a packet. The function passed undecoded/unencoded packet to the input queue and decode/encode a
+ *          frame sequentially.
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @param[in] inbuf  The current input format for the decoder/encoder
+ * @param[in] timeOutUs  The timeout in microseconds. \n
+ *                       The input buffer wait up to "timeOutUs" microseconds.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
+ */
+int mediacodec_process_input (mediacodec_h mediacodec, media_packet_h inbuf, uint64_t timeOutUs);
+
+/**
+ * @brief Gets the decoded or encoded packet from the output queue.
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @param[in] outbuf  The current output of the decoder/encoder. this function passed decoded/encoded frame to output
+ *                    queue.
+ * @param[in] timeOutUs  The timeout in microseconds. \n
+ *                       The input buffer wait up to "timeOutUs" microseconds.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIACODEC_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIACODEC_ERROR_INVALID_OPERATION Invalid operation
+ */
+int mediacodec_get_output (mediacodec_h mediacodec, media_packet_h *outbuf, uint64_t timeOutUs);
+
+/**
+ * @brief set empty buffer callback the media codec for process, asynchronously.
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @param[in] callback  The callback function to register
+ * @param[in] user_data  The user data to be passed to the callback function
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre        mediacodec_set_input_buffer_used_cb should be called before mediacodec_preare().
+ * @post mediacodec_input_buffer_used_cb will be invoked.
+ * @see mediacodec_set_input_buffer_used_cb()
+ * @see mediacodec_unset_input_buffer_used_cb()
+ */
+int mediacodec_set_input_buffer_used_cb(mediacodec_h mediacodec, mediacodec_input_buffer_used_cb callback, void* user_data);
+
+/**
+ * @brief unset input buffer used callback the media codec for process, asynchronously.
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see mediacodec_set_input_buffer_used_cb()
+ */
+int mediacodec_unset_input_buffer_used_cb(mediacodec_h mediacodec);
+
+/**
+ * @brief set output buffer available callback the media codec for process, asynchronously.
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @param[in] callback  The callback function to register
+ * @param[in] user_data  The user data to be passed to the callback function
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre        mediacodec_set_output_buffer_available_cb should be called before mediacodec_preare().
+ * @post mediacodec_output_buffer_available_cb will be invoked.
+ * @see mediacodec_set_output_buffer_available_cb()
+ * @see mediacodec_unset_output_buffer_available_cb()
+ */
+int mediacodec_set_output_buffer_available_cb(mediacodec_h mediacodec, mediacodec_output_buffer_available_cb callback, void* user_data);
+
+/**
+ * @brief unset output buffer available callback the media codec for process, asynchronously.
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see mediacodec_set_output_buffer_available_cb()
+ */
+int mediacodec_unset_output_buffer_available_cb(mediacodec_h mediacodec);
+
+/**
+ * @brief set error callback the media codec for process, asynchronously.
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @param[in] callback  The callback function to register
+ * @param[in] user_data  The user data to be passed to the callback function
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre        mediacodec_set_error_cb should be called before mediacodec_preare().
+ * @post mediacodec_error_cb will be invoked.
+ * @see mediacodec_set_error_cb()
+ * @see mediacodec_unset_error_cb()
+ */
+int mediacodec_set_error_cb(mediacodec_h mediacodec, mediacodec_error_cb callback, void* user_data);
+
+/**
+ * @brief unset error callback the media codec for process, asynchronously.
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see mediacodec_set_error_cb()
+ */
+int mediacodec_unset_error_cb(mediacodec_h mediacodec);
+
+/**
+ * @brief set eos callback the media codec for process, asynchronously.
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @param[in] callback  The callback function to register
+ * @param[in] user_data  The user data to be passed to the callback function
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre        mediacodec_set_eos_cb should be called before mediacodec_preare().
+ * @post mediacodec_eos_cb will be invoked.
+ * @see mediacodec_set_eos_cb()
+ * @see mediacodec_unset_eos_cb()
+ */
+int mediacodec_set_eos_cb(mediacodec_h mediacodec, mediacodec_eos_cb callback, void* user_data);
+
+/**
+ * @brief unset eos callback the media codec for process, asynchronously.
+ * @since_tizen 2.3
+ * @param[in] mediacodec  The handle to mediacodec
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #MEDIACODEC_ERROR_NONE Successful
+ * @retval #MEDIACODEC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see mediacodec_set_event_handler_cb()
+ */
+int mediacodec_unset_eos_cb(mediacodec_h mediacodec);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_MEDIA_CODEC_H__ */
+
diff --git a/include/media_codec_port.h b/include/media_codec_port.h
new file mode 100644 (file)
index 0000000..c44048e
--- /dev/null
@@ -0,0 +1,283 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_MEDIA_CODEC_PORT_H__
+#define __TIZEN_MEDIA_CODEC_PORT_H__
+
+#include <tizen.h>
+#include <glib.h>
+#include <dlfcn.h>
+#include <gst/gst.h>
+
+#include <media_codec.h>
+#include <media_codec_queue.h>
+#include <media_codec_spec_emul.h>
+
+
+/*===========================================================================================
+|                                                                                                                                                                                      |
+|  GLOBAL DEFINITIONS AND DECLARATIONS FOR MODULE                                                                                      |
+|                                                                                                                                                                                      |
+========================================================================================== */
+
+/*---------------------------------------------------------------------------
+|    GLOBAL #defines:                                                                                                                    |
+---------------------------------------------------------------------------*/
+#define OUT_BUF_SIZE    9000000
+#define CHECK_BIT(x, y) (((x) >> (y)) & 0x01)
+#define GET_IS_ENCODER(x) CHECK_BIT(x, 0)
+#define GET_IS_DECODER(x) CHECK_BIT(x, 1)
+#define GET_IS_HW(x) CHECK_BIT(x, 2)
+#define GET_IS_SW(x) CHECK_BIT(x, 3)
+
+//#define GET_IS_OMX(x) CHECK_BIT(x, 4)
+//#define GET_IS_GEN(x) CHECK_BIT(x, 5)
+
+
+/*---------------------------------------------------------------------------
+|    GLOBAL CONSTANT DEFINITIONS:                                                                                          |
+---------------------------------------------------------------------------*/
+/**
+ * @brief Enumerations of media codec port's retrun value
+ */
+typedef enum
+{
+    MC_ERROR_NONE               =    0,
+    MC_ERROR                    =   -1,     /**< codec happens error */
+    MC_MEMORY_ERROR             =   -2,     /**< codec memory is not enough */
+    MC_PARAM_ERROR              =   -3,     /**< codec parameter is error */
+    MC_INVALID_ARG              =   -4,     /** < codec has invalid arguments */
+    MC_PERMISSION_DENIED        =   -5,
+    MC_INVALID_STATUS           =   -6,     /**< codec works at invalid status */
+    MC_NOT_SUPPORTED            =   -7,     /**< codec can't support this specific video format */
+    MC_INVALID_IN_BUF           =   -8,
+    MC_INVALID_OUT_BUF          =   -9,
+    MC_INTERNAL_ERROR           =   -10,
+    MC_HW_ERROR                 =   -11,    /**< codec happens hardware error */
+    MC_NOT_INITIALIZED          =   -12,
+    MC_INVALID_STREAM           =   -13,
+    MC_CODEC_NOT_FOUND          =   -14,
+    MC_ERROR_DECODE             =   -15,
+    MC_OUTPUT_BUFFER_EMPTY      =   -16,
+    MC_OUTPUT_BUFFER_OVERFLOW   =   -17,    /**< codec output buffer is overflow */
+    MC_MEMORY_ALLOCED           =   -18,    /**< codec has got memory and can decode one frame */
+} mc_ret_e;
+
+/*---------------------------------------------------------------------------
+|    GLOBAL DATA TYPE DEFINITIONS:                                                                                         |
+---------------------------------------------------------------------------*/
+/**
+ * @brief Called when the dequeue input buffer done
+ * @details It will be invoked when mediacodec has released dequeue buffer.
+ * @param[in]   user_data  The user data passed from the callback registration function
+ * @pre It will be invoked when dequeue buffer process completed if you register this callback using mediacodec_set_dequeue_input_buffer_cb().
+ * @see mediacodec_set_dequeue_input_buffer_cb()
+ * @see mediacodec_unset_dequeue_input_buffer_cb()
+ */
+
+typedef struct _mc_decoder_info_t mc_decoder_info_t;
+typedef struct _mc_encoder_info_t mc_encoder_info_t;
+
+typedef struct _mc_handle_t mc_handle_t;
+
+/* gst port layer */
+typedef struct _mc_gst_port_t mc_gst_port_t;
+typedef struct _mc_gst_core_t mc_gst_core_t;
+
+typedef void (*mc_dequeue_input_buffer_cb)(media_packet_h pkt, void *user_data);
+typedef void (*mc_empty_buffer_cb)(media_packet_h pkt, void *user_data);
+typedef void (*mc_fill_buffer_cb)(media_packet_h pkt, void *user_data);
+typedef void (*mc_error_cb)(mediacodec_error_e error, void *user_data);
+typedef void (*mc_eos_cb)(void *user_data);
+
+typedef enum {
+    _MEDIACODEC_EVENT_TYPE_COMPLETE,
+    _MEDIACODEC_EVENT_TYPE_EMPTYBUFFER,
+    _MEDIACODEC_EVENT_TYPE_FILLBUFFER,
+    _MEDIACODEC_EVENT_TYPE_ERROR,
+    _MEDIACODEC_EVENT_TYPE_EOS,
+    _MEDIACODEC_EVENT_TYPE_INTERNAL_FILLBUFFER,
+    _MEDIACODEC_EVENT_TYPE_NUM
+} _mediacodec_event_e;
+
+
+typedef enum _mc_codec_port_type_e
+{
+       CODEC_PORT_TYPE_GENERAL,
+       CODEC_PORT_TYPE_OMX,
+       CODEC_PORT_TYPE_GST,
+       CODEC_PORT_TYPE_MAX,
+} mc_codec_port_type_e;
+
+struct _mc_decoder_info_t
+{
+    int width;
+    int height;
+    int actwidth;
+    int actheight;
+
+    int samplerate;
+    int channel;
+    int bit;
+};
+
+struct _mc_encoder_info_t
+{
+    int frame_width;
+    int frame_height;
+    int bitrate;
+    int fps;
+    int qp_min;
+    int qp_max;
+    int vbvbuffer_size;
+    int level;
+    int profile;
+
+    int samplerate;
+    int channel;
+    int bit;
+};
+
+struct _mc_gst_port_t
+{
+    mc_gst_core_t *core;
+    unsigned int num_buffers;
+    unsigned int buffer_size;
+    unsigned int index;
+    bool is_allocated;
+    media_packet_h *buffers;
+    //GSem
+    GQueue *queue;
+    GMutex *mutex;
+    GCond *buffer_cond;
+};
+
+struct _mc_gst_core_t
+{
+    GstState state;
+    bool output_allocated;
+    bool encoder;
+    bool video;
+    bool is_hw;
+
+    mediacodec_codec_type_e codec_id;
+    media_format_h output_fmt;
+    mc_gst_port_t *ports[2];
+
+    /* gst stuffs */
+    GstElement* pipeline;
+    GstElement* appsrc;
+    GstElement* converter;
+    GstElement* fakesink;
+    GstElement* codec;
+
+    gulong signal_handoff;
+    gint bus_whatch_id;
+
+    mc_aqueue_t *available_queue;
+    GQueue *output_queue;
+
+    mc_decoder_info_t *dec_info;
+    mc_encoder_info_t *enc_info;
+
+    void* user_cb[_MEDIACODEC_EVENT_TYPE_NUM];
+    void* user_data[_MEDIACODEC_EVENT_TYPE_NUM];
+
+    gchar *factory_name;
+    gchar *mime;
+};
+
+/* Codec Private data */
+struct _mc_handle_t
+{
+    void *hcodec;                               /**< codec handle */
+    int state;                                  /**<  mc current state */
+    mediacodec_port_type_e port_type;
+    bool is_encoder;
+    bool is_video;
+    bool is_hw;
+    bool is_codec_config;                           /** < codec config data for first frame(SPS - using in AVC) */
+    bool output_allocated;
+    bool is_prepared;
+
+    int frame_count;
+    int out_buf_cnt;
+    int *out_buf_ref;
+
+    mediacodec_codec_type_e codec_id;
+
+    /* for gst port */
+    mc_gst_port_t *gst_ports[2];
+    mc_gst_core_t *gst_core;
+
+    /* for Decoder */
+    mc_decoder_info_t *dec_info;
+
+    /* for Encoder */
+    mc_encoder_info_t *enc_info;
+
+    /* for process done cb */
+    void* user_cb[_MEDIACODEC_EVENT_TYPE_NUM];
+    void* user_data[_MEDIACODEC_EVENT_TYPE_NUM];
+
+    mc_codec_spec_t g_media_codec_spec_emul[MC_MAX_NUM_CODEC];
+};
+
+/*===========================================================================================
+|                                                                                                                                                                                      |
+|  GLOBAL FUNCTION PROTOTYPES                                                                                                                            |
+|                                                                                                                                                                                      |
+========================================================================================== */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int mc_create(MMHandleType *mediacodec);
+int mc_destroy(MMHandleType mediacodec);
+
+int mc_set_codec(MMHandleType mediacodec, mediacodec_codec_type_e codec_id, mediacodec_support_type_e flags);
+
+int mc_set_vdec_info(MMHandleType mediacodec, int width, int height);
+int mc_set_venc_info(MMHandleType mediacodec, int width, int height, int fps, int target_bits);
+
+int mc_set_adec_info(MMHandleType mediacodec, int samplerate, int channel, int bit);
+int mc_set_aenc_info(MMHandleType mediacodec, int samplerate, int channel, int bit,  int bitrate);
+
+int mc_prepare(MMHandleType mediacodec);
+int mc_unprepare(MMHandleType mediacodec);
+int mc_reset(MMHandleType mediacodec);
+
+int mc_process_input(MMHandleType mediacodec, media_packet_h inbuf, uint64_t timeOutUs);
+int mc_get_output(MMHandleType mediacodec, media_packet_h *outbuf, uint64_t timeOutUs);
+
+int mc_set_empty_buffer_cb(MMHandleType mediacodec, mediacodec_input_buffer_used_cb callback, void* user_data);
+int mc_unset_empty_buffer_cb(MMHandleType mediacodec);
+
+int mc_set_fill_buffer_cb(MMHandleType mediacodec, mediacodec_output_buffer_available_cb callback, void* user_data);
+int mc_unset_fill_buffer_cb(MMHandleType mediacodec);
+
+int mc_set_error_cb(MMHandleType mediacodec, mediacodec_error_cb callback, void* user_data);
+int mc_unset_error_cb(MMHandleType mediacodec);
+
+int mc_set_eos_cb(MMHandleType mediacodec, mediacodec_eos_cb callback, void* user_data);
+int mc_unset_eos_cb(MMHandleType mediacodec);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_MEDIA_CODEC_PORT_H__ */
diff --git a/include/media_codec_private.h b/include/media_codec_private.h
new file mode 100644 (file)
index 0000000..7bc76fc
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_MEDIA_CODEC_PRIVATE_H__
+#define __TIZEN_MEDIA_CODEC_PRIVATE_H__
+
+#include <tizen.h>
+#include <stdint.h>
+
+#include <media_codec.h>
+
+#include <mm_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_MEDIACODEC"
+
+
+#define MEDIACODEC_CHECK_CONDITION(condition,error,msg)     \
+                if(condition) {} else \
+                { LOGE("[%s] %s(0x%08x)",__FUNCTION__, msg,error); return error;}; \
+
+#define MEDIACODEC_INSTANCE_CHECK(mediacodec)   \
+        MEDIACODEC_CHECK_CONDITION(mediacodec != NULL, MEDIACODEC_ERROR_INVALID_PARAMETER,"MEDIACODEC_ERROR_INVALID_PARAMETER")
+
+#define MEDIACODEC_STATE_CHECK(mediacodec,expected_state)       \
+        MEDIACODEC_CHECK_CONDITION(mediacodec->state == expected_state,MEDIACODEC_ERROR_INVALID_STATE,"MEDIACODEC_ERROR_INVALID_STATE")
+
+#define MEDIACODEC_NULL_ARG_CHECK(arg)      \
+        MEDIACODEC_CHECK_CONDITION(arg != NULL,MEDIACODEC_ERROR_INVALID_PARAMETER,"MEDIACODEC_ERROR_INVALID_PARAMETER")
+
+/**
+ * @brief Enumeration of media codec state
+ * @since_tizen 2.3
+ */
+typedef enum
+{
+    MEDIACODEC_STATE_NONE = 0,      /**< Media codec is not created */
+    MEDIACODEC_STATE_IDLE,          /**< Media codec is created, but not prepared */
+    MEDIACODEC_STATE_READY,         /**< Media codec is ready to process */
+    MEDIACODEC_STATE_EXCUTE,        /**< Media codec is executing media */
+} mediacodec_state_e;
+
+typedef enum
+{
+    MEDIACODEC_SUPPORT_TYPE_OMX = 0x10,     /**< This is optional flag for using openmax il */
+    MEDIACODEC_SUPPORT_TYPE_GEN = 0x20      /**< This is optional flag for using general codec */
+} mediacodec_internal_support_type_e;
+
+typedef enum
+{
+    MEDIACODEC_PORT_TYPE_GENERAL,
+    MEDIACODEC_PORT_TYPE_OMX,
+    MEDIACODEC_PORT_TYPE_GST,
+    MEDIACODEC_PORT_TYPE_MAX,
+} mediacodec_port_type_e;
+
+/**
+ * @brief Media Codec's format for configuring codec.
+ */
+typedef struct _mediacodecformat_s {
+    // Video
+    int fps;
+    int height;
+    int width;
+    float aspect;
+    bool vfr;
+    int level;
+    int profile;
+
+    // Audio
+    int channels;
+    int samplerate;
+    int bitrate;
+
+    // Codec Extra Data
+    void * extradata;
+    unsigned int extrasize;
+} mediacodec_format_s;
+
+typedef struct _mediacodec_s {
+    MMHandleType mc_handle;
+    int state;
+    bool is_omx;
+    char *m_mime;
+
+    mediacodec_input_buffer_used_cb empty_buffer_cb;
+    void* empty_buffer_cb_userdata;
+    mediacodec_output_buffer_available_cb fill_buffer_cb;
+    void* fill_buffer_cb_userdata;
+    mediacodec_error_cb error_cb;
+    void* error_cb_userdata;
+    mediacodec_eos_cb eos_cb;
+    void* eos_cb_userdata;
+
+} mediacodec_s;
+
+bool __mediacodec_state_validate(mediacodec_h mediacodec, mediacodec_state_e threshold);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_MEDIA_CODEC_PRIVATE_H__ */
diff --git a/include/media_codec_queue.h b/include/media_codec_queue.h
new file mode 100644 (file)
index 0000000..c9bf23d
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_MEDIA_CODEC_QUEUE_H__
+#define __TIZEN_MEDIA_CODEC_QUEUE_H__
+
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _async_queue {
+    GMutex *mutex;
+    GCond *condition;
+    GList *head;
+    GList *tail;
+    guint length;
+    gboolean enabled;
+} async_queue_t;
+
+typedef struct _mc_aqueue {
+    GThread *thread;
+    gint running;
+    async_queue_t *input;
+    async_queue_t *output;
+} mc_aqueue_t;
+
+async_queue_t *mc_async_queue_new();
+
+void mc_async_queue_free(async_queue_t *async_queue);
+
+void mc_async_queue_push(async_queue_t *async_queue, gpointer data);
+
+gpointer mc_async_queue_pop(async_queue_t *async_queue);
+
+void mc_async_queue_disable (async_queue_t *async_queue);
+
+void mc_async_queue_enable (async_queue_t *async_queue);
+
+void mc_async_queue_flush(async_queue_t *async_queue);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_MEDIA_CODEC_QUEUE_H__ */
diff --git a/include/media_codec_spec_emul.h b/include/media_codec_spec_emul.h
new file mode 100644 (file)
index 0000000..40df2a2
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_MEDIA_CODEC_EMUL_H__
+#define __TIZEN_MEDIA_CODEC_EMUL_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <media_codec_private.h>
+
+#define MC_MAX_NUM_CODEC 4
+#define MC_MAX_NUM_MAP  4
+#define MC_MAX_FACTORY_STRLEN   20
+
+enum { DECODER, ENCODER };
+enum { SOFTWARE, HARDWARE };
+
+//typedef struct _mc_codec_mimetype_t mc_codec_mimetype_t;
+typedef struct _mc_codec_spec_t mc_codec_spec_t;
+typedef struct _mc_codec_map_t mc_codec_map_t;
+typedef struct _mc_codec_type_t mc_codec_type_t;
+
+struct _mc_codec_spec_t
+{
+    mediacodec_codec_type_e mime;
+    mediacodec_support_type_e codec_type;
+    mediacodec_support_type_e support_type;
+    mediacodec_port_type_e port_type;
+};
+
+struct _mc_codec_type_t
+{
+    char *factory_name;
+    media_format_mimetype_e out_format;
+    char *mime;
+};
+
+struct _mc_codec_map_t
+{
+    mediacodec_codec_type_e id;
+    bool hardware;
+    mc_codec_type_t type;
+};
+
+static const mc_codec_spec_t spec_emul[MC_MAX_NUM_CODEC] =
+{
+    {MEDIACODEC_H264,  MEDIACODEC_DECODER, MEDIACODEC_SUPPORT_TYPE_SW, MEDIACODEC_PORT_TYPE_GST},
+    {MEDIACODEC_H263,  MEDIACODEC_ENCODER, MEDIACODEC_SUPPORT_TYPE_SW, MEDIACODEC_PORT_TYPE_GST},
+    {MEDIACODEC_AAC,  MEDIACODEC_ENCODER, MEDIACODEC_SUPPORT_TYPE_SW, MEDIACODEC_PORT_TYPE_GST},
+    {MEDIACODEC_AAC,  MEDIACODEC_DECODER, MEDIACODEC_SUPPORT_TYPE_SW, MEDIACODEC_PORT_TYPE_GST}
+};
+
+static const mc_codec_map_t encoder_map[] =
+{
+#ifdef ENABLE_FFMPEG_CODEC
+    {MEDIACODEC_H263, SOFTWARE, {"ffenc_h263p", MEDIA_FORMAT_H263P, "video/x-raw-yuv"}},
+    {MEDIACODEC_AAC,  SOFTWARE, {"ffenc_aac", MEDIA_FORMAT_AAC, "audio/x-raw-int"}}
+#else
+    {MEDIACODEC_H263, SOFTWARE, {"maru_h263penc", MEDIA_FORMAT_H263P, "video/x-raw-yuv"}},
+    {MEDIACODEC_AAC,  SOFTWARE, {"maru_aacenc", MEDIA_FORMAT_AAC, "audio/x-raw-int"}}
+#endif
+};
+
+static const mc_codec_map_t decoder_map[] =
+{
+#ifdef ENABLE_FFMPEG_CODEC
+    {MEDIACODEC_H264, SOFTWARE, {"ffdec_h264", MEDIA_FORMAT_I420, "video/x-h264"}},
+    {MEDIACODEC_AAC,  SOFTWARE, {"ffdec_aac", MEDIA_FORMAT_PCM, "audio/mpeg"}}
+#else
+    {MEDIACODEC_H264, SOFTWARE, {"maru_h264dec", MEDIA_FORMAT_I420, "video/x-h264"}},
+    {MEDIACODEC_AAC,  SOFTWARE, {"maru_aacdec", MEDIA_FORMAT_PCM, "audio/mpeg"}}
+#endif
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_MEDIA_CODEC_EMUL_H__ */
diff --git a/include/media_codec_util.h b/include/media_codec_util.h
new file mode 100644 (file)
index 0000000..21e9947
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_MEDIA_CODEC_UTIL_H__
+#define __TIZEN_MEDIA_CODEC_UTIL_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <tizen.h>
+//#include <mm_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum
+{
+    CODEC_RET_SUCCESS         =  0,
+    CODEC_RET_FAIL            = -1,
+    CODEC_RET_NOT_SUPPORT     = -2,
+    CODEC_RET_INVALID_ARG     = -3,
+    CODEC_RET_INVALID_CONFIG  = -4,
+    CODEC_RET_CORRUPTED_BS    = -5,
+    CODEC_RET_SMALL_IMG_BUF   = -6,
+    CODEC_RET_HW_ERROR        = -7,
+    CODEC_RET_NOT_AVAILABLE   = -8,
+    CODEC_RET_NOT_EXPECTED    = -9,
+    CODEC_RET_UNKNOWN_ERR     = -100,
+} CodecRet;
+
+typedef struct mc_sem mc_sem;
+
+struct mc_sem
+{
+    GCond *condition;
+    GMutex *mutex;
+    int counter;
+};
+
+void *mc_aligned_malloc(int size, int alignment);
+void mc_aligned_free(void *mem);
+
+mc_sem *mc_sem_new();
+void mc_sem_free(mc_sem *sem);
+void mc_sem_down(mc_sem *sem);
+void mc_sem_up(mc_sem *sem);
+
+#define MC_FREEIF(x) \
+if ( x ) \
+    g_free( x ); \
+x = NULL;
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_MEDIA_CODEC_UTIL_H__ */
diff --git a/packaging/capi-media-codec.spec b/packaging/capi-media-codec.spec
new file mode 100644 (file)
index 0000000..85a7363
--- /dev/null
@@ -0,0 +1,83 @@
+Name:       capi-media-codec
+Summary:    A Media Codec library in Tizen Native API
+Version:    0.1.1
+Release:    0
+Group:      Multimedia/API
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(mm-common)
+BuildRequires:  pkgconfig(capi-base-common)
+BuildRequires:  pkgconfig(appcore-efl)
+BuildRequires:  pkgconfig(capi-media-tool)
+BuildRequires:  pkgconfig(libtbm)
+BuildRequires:  pkgconfig(gstreamer-1.0)
+BuildRequires:  pkgconfig(gstreamer-plugins-base-1.0)
+BuildRequires:  pkgconfig(gstreamer-app-1.0)
+BuildRequires:  pkgconfig(libdri2)
+
+Requires(post): /sbin/ldconfig
+Requires(post): libprivilege-control
+Requires(postun): /sbin/ldconfig
+
+%description
+A Media Player library in Tizen Native API
+
+%package devel
+Summary:  A Media Player library in Tizen Native API (Development)
+Group:    Multimedia/API
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+%devel_desc
+%prep
+%setup -q
+
+
+%build
+%if 0%{?sec_build_binary_debug_enable}
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%endif
+%ifarch %{arm}
+export CFLAGS="$CFLAGS -DENABLE_FFMPEG_CODEC"
+%endif
+
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+mkdir -p %{buildroot}/usr/bin
+mkdir -p %{buildroot}/opt/usr/devel
+cp test/media_codec_test %{buildroot}/opt/usr/devel
+cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}
+
+%make_install
+
+%post
+/sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%manifest capi-media-codec.manifest
+%{_libdir}/libcapi-media-codec.so.*
+%{_datadir}/license/%{name}
+/opt/usr/devel/*
+#%{_bindir}/*
+
+%files devel
+%{_includedir}/media/*.h
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/libcapi-media-codec.so
+
+
diff --git a/src/media_codec.c b/src/media_codec.c
new file mode 100644 (file)
index 0000000..75988a3
--- /dev/null
@@ -0,0 +1,512 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <media_codec.h>
+#include <media_codec_private.h>
+#include <media_codec_port.h>
+
+#include <dlog.h>
+
+static gboolean  __mediacodec_empty_buffer_cb(media_packet_h pkt, void *user_data);
+static gboolean __mediacodec_fill_buffer_cb(media_packet_h pkt, void *user_data);
+static gboolean __mediacodec_error_cb(mediacodec_error_e error, void *user_data);
+static gboolean __mediacodec_eos_cb(void *user_data);
+
+/*
+* Internal Implementation
+*/
+int __convert_error_code(int code, char* func_name)
+{
+    int ret = MEDIACODEC_ERROR_INVALID_OPERATION;
+    char* msg = "MEDIACOODEC_INVALID_OPERATION";
+    switch(code)
+    {
+        case MC_ERROR_NONE:
+            ret = MEDIACODEC_ERROR_NONE;
+            msg = "MEDIACODEC_ERROR_NONE";
+            break;
+        case MC_PARAM_ERROR:
+        case MC_INVALID_ARG:
+            ret = MEDIACODEC_ERROR_INVALID_PARAMETER;
+            msg = "MEDIACODEC_ERROR_INVALID_PARAMETER";
+            break;
+        case MC_PERMISSION_DENIED:
+            ret = MEDIACODEC_ERROR_PERMISSION_DENIED;
+            msg = "MEDIACODEC_ERROR_PERMISSION_DENIED";
+            break;
+        case MC_INVALID_STATUS:
+            ret = MEDIACODEC_ERROR_INVALID_STATE;
+            msg = "MEDIACODEC_ERROR_INVALID_STATE";
+            break;
+        case MC_NOT_SUPPORTED:
+            ret = MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE;
+            msg = "MEDIACODEC_ERROR_NOT_SUPPORTED_ON_DEVICE";
+            break;
+        case MC_ERROR:
+        case MC_INTERNAL_ERROR:
+        case MC_HW_ERROR:
+            ret = MEDIACODEC_ERROR_INVALID_OPERATION;
+            msg = "MEDIACODEC_ERROR_INVALID_OPERATION";
+            break;
+        case MC_INVALID_STREAM:
+            ret = MEDIACODEC_ERROR_INVALID_STREAM;
+            msg = "MEDIACODEC_ERROR_INVALID_STREAM";
+            break;
+        case MC_CODEC_NOT_FOUND:
+            ret = MEDIACODEC_ERROR_CODEC_NOT_FOUND;
+            msg = "MEDIACODEC_ERROR_CODEC_NOT_FOUND";
+            break;
+        case MC_ERROR_DECODE:
+            ret = MEDIACODEC_ERROR_DECODE;
+            msg = "MEDIACODEC_ERROR_DECODE";
+            break;
+        case MC_INVALID_IN_BUF:
+            ret = MEDIACODEC_ERROR_INVALID_INBUFFER;
+            msg = "MEDIACODEC_ERROR_INVALID_INBUFFER";
+            break;
+        case MC_INVALID_OUT_BUF:
+            ret = MEDIACODEC_ERROR_INVALID_OUTBUFFER;
+            msg = "MEDIACODEC_ERROR_INVALID_OUTBUFFER";
+            break;
+        case MC_NOT_INITIALIZED:
+            ret = MEDIACODEC_ERROR_NOT_INITIALIZED;
+            msg = "MEDIACODEC_ERROR_NOT_INITIALIZED";
+            break;
+        case MC_OUTPUT_BUFFER_EMPTY:
+        case MC_OUTPUT_BUFFER_OVERFLOW:
+            ret = MEDIACODEC_ERROR_BUFFER_NOT_AVAILABLE;
+            msg = "MEDIACODEC_ERROR_BUFFER_NOT_AVAILABLE";
+            break;
+        default:
+            ret = MEDIACODEC_ERROR_INTERNAL;
+            msg = "MEDIACODEC_ERROR_INTERNAL";
+            break;
+    }
+    LOGD("[%s] %s(0x%08x) : core fw error(0x%x)", func_name, msg, ret, code);
+    return ret;
+}
+
+bool __mediacodec_state_validate(mediacodec_h mediacodec, mediacodec_state_e threshold)
+{
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+
+    if(handle->state < threshold)
+        return FALSE;
+    return TRUE;
+}
+
+
+int mediacodec_create(mediacodec_h *mediacodec)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s *handle;
+    int ret;
+
+    LOGD ("mediacodec_create..\n");
+
+    handle = (mediacodec_s*)malloc( sizeof(mediacodec_s));
+    if (handle != NULL)
+    {
+        memset(handle, 0 , sizeof(mediacodec_s));
+    }
+    else
+    {
+        LOGE("MEDIACODEC_ERROR_OUT_OF_MEMORY(0x%08x)", MEDIACODEC_ERROR_OUT_OF_MEMORY);
+        return MEDIACODEC_ERROR_OUT_OF_MEMORY;
+    }
+
+    ret = mc_create(&handle->mc_handle);
+    if (ret != MEDIACODEC_ERROR_NONE)
+    {
+        LOGE("MEDIACODEC_ERROR_INVALID_OPERATION(0x%08x)", MEDIACODEC_ERROR_INVALID_OPERATION);
+        handle->state = MEDIACODEC_STATE_NONE;
+        free(handle);
+        handle = NULL;
+        return MEDIACODEC_ERROR_INVALID_OPERATION;
+    }
+    else
+    {
+        *mediacodec = (mediacodec_h) handle;
+        handle->state = MEDIACODEC_STATE_IDLE;
+        LOGD("new handle : %p", *mediacodec);
+    }
+
+    /* set callback */
+    mc_set_empty_buffer_cb(handle->mc_handle, (mediacodec_input_buffer_used_cb)__mediacodec_empty_buffer_cb, handle);
+    mc_set_fill_buffer_cb(handle->mc_handle, (mediacodec_output_buffer_available_cb)__mediacodec_fill_buffer_cb, handle);
+    mc_set_error_cb(handle->mc_handle, (mediacodec_error_cb)__mediacodec_error_cb, handle);
+    mc_set_eos_cb(handle->mc_handle, (mediacodec_eos_cb)__mediacodec_eos_cb, handle);
+
+    return MEDIACODEC_ERROR_NONE;
+
+}
+
+int mediacodec_destroy(mediacodec_h mediacodec)
+{
+    LOGD ("[%s] Start, handle to destroy : %p", __FUNCTION__, mediacodec);
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+
+    int ret = mc_destroy(handle->mc_handle);
+    if (ret != MEDIACODEC_ERROR_NONE) {
+        LOGD("MEDIACODEC_ERROR_INVALID_OPERATION(0x%08x)", MEDIACODEC_ERROR_INVALID_OPERATION);
+        return MEDIACODEC_ERROR_INVALID_OPERATION;
+    }
+    else
+    {
+        handle->state = MEDIACODEC_STATE_NONE;
+        free(handle);
+        handle = NULL;
+        return MEDIACODEC_ERROR_NONE;
+    }
+}
+
+int mediacodec_set_codec(mediacodec_h mediacodec, mediacodec_codec_type_e codec_id, mediacodec_support_type_e flags)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+    MEDIACODEC_STATE_CHECK(handle, MEDIACODEC_STATE_IDLE);
+
+    int ret = mc_set_codec(handle->mc_handle, codec_id, flags);
+
+    if (ret != MEDIACODEC_ERROR_NONE)
+    {
+        return __convert_error_code(ret,(char*)__FUNCTION__);
+    }
+    else
+    {
+        handle->state = MEDIACODEC_STATE_IDLE;
+        return MEDIACODEC_ERROR_NONE;
+    }
+}
+
+int mediacodec_set_vdec_info(mediacodec_h mediacodec, int width, int height)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+    MEDIACODEC_STATE_CHECK(handle, MEDIACODEC_STATE_IDLE);
+
+    int ret = mc_set_vdec_info(handle->mc_handle, width, height);
+
+    if (ret != MEDIACODEC_ERROR_NONE)
+    {
+        return __convert_error_code(ret,(char*)__FUNCTION__);
+    }
+    else
+    {
+        handle->state = MEDIACODEC_STATE_IDLE;
+        return MEDIACODEC_ERROR_NONE;
+    }
+}
+
+int mediacodec_set_venc_info(mediacodec_h mediacodec, int width, int height, int fps, int target_bits)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+    MEDIACODEC_STATE_CHECK(handle, MEDIACODEC_STATE_IDLE);
+
+    int ret = mc_set_venc_info(handle->mc_handle, width, height, fps, target_bits);
+
+    if (ret != MEDIACODEC_ERROR_NONE)
+    {
+        return __convert_error_code(ret,(char*)__FUNCTION__);
+    }
+    else
+    {
+        handle->state = MEDIACODEC_STATE_IDLE;
+        return MEDIACODEC_ERROR_NONE;
+    }
+}
+
+int mediacodec_set_adec_info(mediacodec_h mediacodec, int samplerate, int channel, int bit)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+    MEDIACODEC_STATE_CHECK(handle, MEDIACODEC_STATE_IDLE);
+
+    int ret = mc_set_adec_info(handle->mc_handle, samplerate, channel, bit);
+
+    if (ret != MEDIACODEC_ERROR_NONE)
+    {
+        return __convert_error_code(ret,(char*)__FUNCTION__);
+    }
+    else
+    {
+        handle->state = MEDIACODEC_STATE_IDLE;
+        return MEDIACODEC_ERROR_NONE;
+    }
+}
+
+int mediacodec_set_aenc_info(mediacodec_h mediacodec, int samplerate, int channel, int bit, int bitrate)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+    MEDIACODEC_STATE_CHECK(handle, MEDIACODEC_STATE_IDLE);
+
+    int ret = mc_set_aenc_info(handle->mc_handle, samplerate, channel, bit, bitrate);
+
+    if (ret != MEDIACODEC_ERROR_NONE)
+    {
+        return __convert_error_code(ret,(char*)__FUNCTION__);
+    }
+    else
+    {
+        handle->state = MEDIACODEC_STATE_IDLE;
+        return MEDIACODEC_ERROR_NONE;
+    }
+}
+
+int mediacodec_prepare(mediacodec_h mediacodec)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+    MEDIACODEC_STATE_CHECK(handle, MEDIACODEC_STATE_IDLE);
+
+    int ret = mc_prepare(handle->mc_handle);
+
+    if (ret != MEDIACODEC_ERROR_NONE)
+    {
+        return __convert_error_code(ret,(char*)__FUNCTION__);
+    }
+    else
+    {
+        handle->state = MEDIACODEC_STATE_READY;
+        return MEDIACODEC_ERROR_NONE;
+    }
+}
+
+int mediacodec_unprepare(mediacodec_h mediacodec)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+
+    int ret = mc_unprepare(handle->mc_handle);
+
+    if (ret != MEDIACODEC_ERROR_NONE)
+    {
+        return __convert_error_code(ret,(char*)__FUNCTION__);
+    }
+    else
+    {
+        handle->state = MEDIACODEC_STATE_IDLE;
+        return MEDIACODEC_ERROR_NONE;
+    }
+}
+
+int mediacodec_process_input(mediacodec_h mediacodec, media_packet_h inbuf, uint64_t timeOutUs)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+    MEDIACODEC_STATE_CHECK(handle, MEDIACODEC_STATE_READY);
+
+    int ret = mc_process_input(handle->mc_handle, inbuf, timeOutUs);
+
+    if (ret != MEDIACODEC_ERROR_NONE)
+    {
+        return __convert_error_code(ret,(char*)__FUNCTION__);
+    }
+    else
+    {
+        //handle->state = MEDIACODEC_STATE_EXCUTE;
+        return MEDIACODEC_ERROR_NONE;
+    }
+}
+
+int mediacodec_get_output(mediacodec_h mediacodec, media_packet_h *outbuf, uint64_t timeOutUs)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+    MEDIACODEC_STATE_CHECK(handle, MEDIACODEC_STATE_READY);
+
+    int ret = mc_get_output(handle->mc_handle, outbuf, timeOutUs);
+
+    if (ret != MEDIACODEC_ERROR_NONE)
+    {
+        return __convert_error_code(ret,(char*)__FUNCTION__);
+    }
+    else
+    {
+        //handle->state = MEDIACODEC_STATE_EXCUTE;
+        return MEDIACODEC_ERROR_NONE;
+    }
+}
+
+int mediacodec_set_input_buffer_used_cb(mediacodec_h mediacodec, mediacodec_input_buffer_used_cb callback, void* user_data)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+    MEDIACODEC_STATE_CHECK(handle, MEDIACODEC_STATE_IDLE);
+
+    handle->empty_buffer_cb = callback;
+    handle->empty_buffer_cb_userdata = user_data;
+
+    LOGD("set empty_buffer_cb(%p)", callback);
+
+    return MEDIACODEC_ERROR_NONE;
+}
+
+int mediacodec_unset_input_buffer_used_cb(mediacodec_h mediacodec)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+
+    handle->empty_buffer_cb = NULL;
+    handle->empty_buffer_cb_userdata = NULL;
+
+    return MEDIACODEC_ERROR_NONE;
+}
+
+
+int mediacodec_set_output_buffer_available_cb(mediacodec_h mediacodec, mediacodec_output_buffer_available_cb callback, void* user_data)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+    MEDIACODEC_STATE_CHECK(handle, MEDIACODEC_STATE_IDLE);
+
+    handle->fill_buffer_cb = callback;
+    handle->fill_buffer_cb_userdata = user_data;
+
+    LOGD("set fill_buffer_cb(%p)", callback);
+
+    return MEDIACODEC_ERROR_NONE;
+
+}
+
+int mediacodec_unset_output_buffer_available_cb(mediacodec_h mediacodec)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+
+    handle->fill_buffer_cb = NULL;
+    handle->fill_buffer_cb_userdata = NULL;
+
+    return MEDIACODEC_ERROR_NONE;
+}
+
+int mediacodec_set_error_cb(mediacodec_h mediacodec, mediacodec_error_cb callback, void* user_data)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+    MEDIACODEC_STATE_CHECK(handle, MEDIACODEC_STATE_IDLE);
+
+    handle->error_cb = callback;
+    handle->error_cb_userdata = user_data;
+
+    LOGD("set error_cb(%p)", callback);
+
+    return MEDIACODEC_ERROR_NONE;
+
+}
+
+int mediacodec_unset_error_cb(mediacodec_h mediacodec)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+
+    handle->error_cb = NULL;
+    handle->error_cb_userdata = NULL;
+
+    return MEDIACODEC_ERROR_NONE;
+}
+
+int mediacodec_set_eos_cb(mediacodec_h mediacodec, mediacodec_eos_cb callback, void* user_data)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+    MEDIACODEC_STATE_CHECK(handle, MEDIACODEC_STATE_IDLE);
+
+    handle->eos_cb = callback;
+    handle->eos_cb_userdata = user_data;
+
+    LOGD("set eos_cb(%p)", callback);
+
+    return MEDIACODEC_ERROR_NONE;
+
+}
+
+int mediacodec_unset_eos_cb(mediacodec_h mediacodec)
+{
+    MEDIACODEC_INSTANCE_CHECK(mediacodec);
+    mediacodec_s * handle = (mediacodec_s *) mediacodec;
+
+    handle->eos_cb = NULL;
+    handle->eos_cb_userdata = NULL;
+
+    return MEDIACODEC_ERROR_NONE;
+}
+
+static gboolean __mediacodec_empty_buffer_cb(media_packet_h pkt, void *user_data)
+{
+    if(user_data == NULL || pkt == NULL)
+        return 0;
+
+    mediacodec_s * handle = (mediacodec_s *) user_data;
+
+    if ( handle->empty_buffer_cb )
+    {
+        ((mediacodec_input_buffer_used_cb)handle->empty_buffer_cb)(pkt, handle->empty_buffer_cb_userdata);
+    }
+
+    return 1;
+}
+
+static gboolean  __mediacodec_fill_buffer_cb(media_packet_h pkt, void *user_data)
+{
+    if(user_data == NULL || pkt == NULL)
+        return 0;
+
+    mediacodec_s * handle = (mediacodec_s *) user_data;
+
+    if ( handle->fill_buffer_cb )
+    {
+        ((mediacodec_output_buffer_available_cb)handle->fill_buffer_cb)(pkt, handle->fill_buffer_cb_userdata);
+    }
+
+    return 1;
+}
+
+static gboolean __mediacodec_error_cb(mediacodec_error_e error, void *user_data)
+{
+    if(user_data == NULL)
+        return 0;
+
+    mediacodec_s * handle = (mediacodec_s *) user_data;
+
+    if ( handle->error_cb )
+    {
+        ((mediacodec_error_cb)handle->error_cb)(error, handle->error_cb_userdata);
+    }
+
+    return 1;
+}
+
+static gboolean __mediacodec_eos_cb(void *user_data)
+{
+    if(user_data == NULL)
+        return 0;
+
+    mediacodec_s * handle = (mediacodec_s *) user_data;
+
+    if ( handle->eos_cb )
+    {
+        ((mediacodec_eos_cb)handle->eos_cb)(handle->eos_cb_userdata);
+    }
+
+    return 1;
+}
diff --git a/src/media_codec_port.c b/src/media_codec_port.c
new file mode 100644 (file)
index 0000000..37b3c51
--- /dev/null
@@ -0,0 +1,879 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <dlog.h>
+
+#include <media_codec.h>
+#include <media_codec_private.h>
+#include <media_codec_port.h>
+//#include <media_codec_port_gst.h> //to avoid build error until this code is not compatible with gstreamer 1.0
+
+#include <media_codec_spec_emul.h>
+
+static gboolean _mc_check_is_supported(mc_handle_t* mc_handle, mediacodec_codec_type_e codec_id, mediacodec_support_type_e flags);
+
+int mc_create(MMHandleType *mediacodec)
+{
+    mc_handle_t* new_mediacodec = NULL;
+    int ret = MC_ERROR_NONE;
+
+    /* alloc mediacodec structure */
+    new_mediacodec = (mc_handle_t*)g_malloc(sizeof(mc_handle_t));
+    if ( ! new_mediacodec )
+    {
+        LOGE("Cannot allocate memory for player\n");
+        ret = MC_ERROR;
+        goto ERROR;
+    }
+    memset(new_mediacodec, 0, sizeof(mc_handle_t));
+
+    new_mediacodec->is_encoder = false;
+    new_mediacodec->is_video = false;
+    new_mediacodec->is_hw = true;
+    new_mediacodec->is_codec_config = false;
+    new_mediacodec->output_allocated = false;
+    new_mediacodec->is_prepared = false;
+    new_mediacodec->codec_id = MEDIACODEC_NONE;
+
+    new_mediacodec->gst_ports[0] = NULL;
+    new_mediacodec->gst_ports[1] = NULL;
+
+    new_mediacodec->gst_core = NULL;
+    new_mediacodec->dec_info = NULL;
+    new_mediacodec->enc_info = NULL;
+
+    memcpy(new_mediacodec->g_media_codec_spec_emul, spec_emul, sizeof(mc_codec_spec_t)*MC_MAX_NUM_CODEC);
+
+    *mediacodec = (MMHandleType)new_mediacodec;
+
+    return ret;
+
+    // TO DO
+ERROR:
+    if ( new_mediacodec )
+    {
+        // TO DO
+        // If we need destroy and release for others (cmd, mutex..)
+        free(new_mediacodec);
+        new_mediacodec = NULL;
+        return MC_INVALID_ARG;
+    }
+
+    return ret;
+}
+
+int mc_destroy(MMHandleType mediacodec)
+{
+    int ret = MC_ERROR_NONE;
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    if(mc_handle->gst_core != NULL)
+    {
+    #if 0 //to avoid build error until this code is not compatible with gstreamer 1.0
+        if(mc_gst_unprepare(mc_handle->gst_core) != MC_ERROR_NONE)
+        {
+            LOGE("mc_gst_unprepare() failed");
+            return MC_ERROR;
+        }
+       #endif
+       // mc_gst_core_free(mc_handle->gst_core);  //to avoid build error until this code is not compatible with gstreamer 1.0
+        mc_handle->gst_core = NULL;
+    }
+
+    mc_handle->is_prepared = false;
+
+    g_free(mc_handle->dec_info);
+    g_free(mc_handle->enc_info);
+
+
+    /* free mediacodec structure */
+    if(mc_handle) {
+        g_free( (void*)mc_handle );
+        mc_handle = NULL;
+    }
+    return ret;
+}
+
+int mc_set_codec(MMHandleType mediacodec, mediacodec_codec_type_e codec_id, mediacodec_support_type_e flags)
+{
+    int ret = MC_ERROR_NONE;
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    // Mandatory setting
+    if ( !GET_IS_ENCODER(flags) && !GET_IS_DECODER(flags) )
+    {
+        LOGE("should be encoder or decoder\n");
+        return MC_PARAM_ERROR;
+    }
+
+    if(!_mc_check_is_supported(mc_handle, codec_id, flags))
+        return MC_NOT_SUPPORTED;
+
+    mc_handle->is_encoder = GET_IS_ENCODER(flags) ? 1 : 0;
+    mc_handle->is_hw = GET_IS_HW(flags) ? 1 : 0;
+    mc_handle->codec_id = codec_id;
+    mc_handle->is_video = CHECK_BIT(codec_id, 13);
+
+    mc_handle->is_prepared = false;
+
+    LOGD("encoder : %d, hardware : %d, codec_id : %x, video : %d",
+        mc_handle->is_encoder, mc_handle->is_hw, mc_handle->codec_id, mc_handle->is_video);
+#if 0
+    //  mc_handle->is_omx = use_omx;
+    // !!!! make it dynamic
+    mc_handle->port_type = MEDIACODEC_PORT_TYPE_GST;
+
+    // !!!! only gst case is here. expend it to all.
+    if (encoder)
+    {
+        switch(codec_id)
+        {
+            case MEDIACODEC_H264:
+                mc_handle->supported_codec = GST_ENCODE_H264;
+                mc_handle->mimetype = MEDIA_FORMAT_H264_HP;
+                mc_handle->is_video = 1;
+            break;
+            case MEDIACODEC_AAC:
+                mc_handle->supported_codec = GST_ENCODE_AAC;
+                mc_handle->mimetype = MEDIA_FORMAT_AAC;
+                mc_handle->is_video = 0;
+            break;
+            default:
+                LOGE("NOT SUPPORTED!!!!");
+            break;
+        }
+
+        mc_handle->is_encoder = true;
+    }
+    else
+    {
+        switch(codec_id)
+        {
+            case MEDIACODEC_H264:
+                mc_handle->supported_codec = GST_DECODE_H264;
+                mc_handle->mimetype = MEDIA_FORMAT_NV12;
+                mc_handle->is_video = 1;
+                break;
+            case MEDIACODEC_AAC:
+                mc_handle->supported_codec = GST_DECODE_AAC;
+                mc_handle->mimetype = MEDIA_FORMAT_PCM;
+                mc_handle->is_video = 0;
+                break;
+            default:
+                LOGE("NOT SUPPORTED!!!!");
+            break;
+        }
+
+        // !!!! check if need to be dynamic
+        mc_handle->is_encoder = false;
+    }
+#endif
+    return ret;
+}
+
+int mc_set_vdec_info(MMHandleType mediacodec, int width, int height)
+{
+    int ret = MC_ERROR_NONE;
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    if ((width <= 0) || (height <= 0))
+        return MC_PARAM_ERROR;
+
+    MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && mc_handle->is_video && !mc_handle->is_encoder,
+            MC_PARAM_ERROR,"MEDIACODEC_ERROR_INVALID_PARAMETER");
+
+    if (mc_handle->dec_info == NULL)
+    {
+        mc_handle->dec_info = g_new0(mc_decoder_info_t, 1);
+    }
+
+    mc_handle->dec_info->width = width;
+    mc_handle->dec_info->height = height;
+
+    mc_handle->is_prepared = true;
+
+    return ret;
+}
+
+int mc_set_venc_info(MMHandleType mediacodec, int width, int height, int fps, int target_bits)
+{
+    int ret = MC_ERROR_NONE;
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    if ((width <= 0) || (height <= 0))
+        return MC_PARAM_ERROR;
+
+    MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && mc_handle->is_video && mc_handle->is_encoder,
+                        MC_PARAM_ERROR, "MEDIACODEC_ERROR_INVALID_PARAMETER");
+
+    if(mc_handle->enc_info == NULL)
+    {
+        mc_handle->enc_info = g_new0(mc_encoder_info_t, 1);
+    }
+
+    mc_handle->enc_info->frame_width = width;
+    mc_handle->enc_info->frame_height = height;
+    mc_handle->enc_info->fps = fps;
+    mc_handle->enc_info->bitrate = target_bits;
+
+    mc_handle->is_prepared = true;
+
+    return ret;
+}
+
+int mc_set_adec_info(MMHandleType mediacodec, int samplerate, int channel, int bit)
+{
+    int ret = MC_ERROR_NONE;
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    if ((samplerate <= 0) || (channel <= 0) || (bit <= 0))
+        return MC_PARAM_ERROR;
+
+    MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && !mc_handle->is_video && !mc_handle->is_encoder,
+            MC_PARAM_ERROR, "MEDIACODEC_ERROR_INVALID_PARAMETER");
+
+    if (mc_handle->dec_info == NULL)
+    {
+        mc_handle->dec_info = g_new0(mc_decoder_info_t, 1);
+    }
+
+    mc_handle->dec_info->samplerate = samplerate;
+    mc_handle->dec_info->channel = channel;
+    mc_handle->dec_info->bit = bit;
+
+    mc_handle->is_prepared = true;
+
+    return ret;
+}
+
+int mc_set_aenc_info(MMHandleType mediacodec, int samplerate, int channel, int bit,  int bitrate)
+{
+    int ret = MC_ERROR_NONE;
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    if ((samplerate <= 0) || (channel <= 0) || (bit <= 0))
+        return MC_PARAM_ERROR;
+
+    MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && !mc_handle->is_video && mc_handle->is_encoder,
+                        MC_PARAM_ERROR, "MEDIACODEC_ERROR_INVALID_PARAMETER");
+
+    if(mc_handle->enc_info == NULL)
+    {
+        mc_handle->enc_info = g_new0(mc_encoder_info_t, 1);
+    }
+
+    mc_handle->enc_info->samplerate = samplerate;
+    mc_handle->enc_info->channel = channel;
+    mc_handle->enc_info->bit = bit;
+    mc_handle->enc_info->bitrate = bitrate;
+
+    mc_handle->is_prepared = true;
+
+    return ret;
+}
+
+int mc_prepare(MMHandleType mediacodec)
+{
+    int ret = MC_ERROR_NONE;
+#if 0 //to avoid build error until this code is not compatible with gstreamer 1.0      
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+    media_format_mimetype_e mimetype;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    if(!mc_handle->is_prepared)
+        return MC_NOT_INITIALIZED;
+
+    /* setting core details */
+    switch ( mc_handle->port_type )
+    {
+        case MEDIACODEC_PORT_TYPE_GENERAL:
+        {
+            /*
+            //!!!! need to set data to omx/gen core need to seperate
+            mc_handle->gen_core->output_fmt = mc_handle->output_fmt;
+            mc_handle->gen_core->encoder = mc_handle->is_encoder;
+
+            if(mc_handle->is_encoder)
+            {
+            mc_encoder_info_t *info;
+
+            info = mc_handle->enc_info;
+            mc_handle->gen_core->enc_info = mc_handle->enc_info;
+
+            media_format_set_video_info(mc_handle->output_fmt, mc_handle->mimetype, info->frame_width, info->frame_height, info->bitrate, 0);
+            }
+            else
+            {
+            mc_decoder_info_t *info;
+
+            info = mc_handle->dec_info;
+            mc_handle->gen_core->dec_info = mc_handle->dec_info;
+            media_format_set_video_info(mc_handle->output_fmt, mc_handle->mimetype, info->width, info->height, 0, 0);
+            }
+
+            ret = mc_general_init(mc_handle->gen_core);
+            */
+        }
+        break;
+
+        case MEDIACODEC_PORT_TYPE_OMX:
+        {
+            //et = mc_omx_init(mc_handle);
+            //ret = mc_omx_create_handle(mc_handle);
+        }
+        break;
+
+        case MEDIACODEC_PORT_TYPE_GST:
+        {
+
+            int i;
+            int codec_list;
+            static const mc_codec_map_t *codec_map;
+
+            mc_gst_core_t* new_core = mc_gst_core_new();  
+            // !!!! null check
+
+            new_core->encoder = mc_handle->is_encoder;
+            new_core->is_hw = mc_handle->is_hw;
+            new_core->video = mc_handle->is_video;
+            new_core->codec_id = mc_handle->codec_id;
+
+            /* setting internal callbacks */
+            for (i = 0; i < _MEDIACODEC_EVENT_TYPE_INTERNAL_FILLBUFFER ; i++)
+            {
+                LOGD("copy cb function [%d]", i);
+                if (mc_handle->user_cb[i])
+                {
+                    new_core->user_cb[i] = mc_handle->user_cb[i];
+                    new_core->user_data[i] = mc_handle->user_data[i];
+                    LOGD("user_cb[%d] %p, %p", i, new_core->user_cb[i], mc_handle->user_cb[i]);
+                }
+            }
+
+            if(new_core->output_fmt == NULL)
+            {
+                if(media_format_create(&new_core->output_fmt) != MEDIA_FORMAT_ERROR_NONE)
+                {
+                    LOGE("media format create failed");
+                }
+                LOGD("pkt_fmt is allocated");
+            }
+
+            if(new_core->encoder)
+            {
+                codec_list = sizeof(encoder_map) / sizeof(encoder_map[0]);
+                codec_map = encoder_map;
+            }
+            else
+            {
+                codec_list = sizeof(decoder_map) / sizeof(decoder_map[0]);
+                codec_map = decoder_map;
+            }
+
+            for(i = 0; i < codec_list; i++)
+            {
+                if((new_core->codec_id == codec_map[i].id) && (new_core->is_hw == codec_map[i].hardware))
+                    break;
+            }
+
+            new_core->factory_name = codec_map[i].type.factory_name;
+
+            mimetype = codec_map[i].type.out_format;
+
+            new_core->mime = codec_map[i].type.mime;
+
+            LOGD("factory name : %s, output_fmt : %x mime : %s", new_core->factory_name, mimetype, new_core->mime);
+
+            if(new_core->factory_name == NULL || mimetype == MEDIA_FORMAT_MAX)
+            {
+                LOGE("Cannot find output format");
+                return MC_NOT_SUPPORTED;
+            }
+
+            if(mc_handle->is_encoder)
+            {
+                mc_encoder_info_t *info;
+
+                info = mc_handle->enc_info;
+                new_core->enc_info = mc_handle->enc_info;
+
+                if (new_core->video)
+                {
+                    media_format_set_video_mime(new_core->output_fmt, mimetype);
+                    media_format_set_video_width(new_core->output_fmt, info->frame_width);
+                    media_format_set_video_height(new_core->output_fmt, info->frame_height);
+                    media_format_set_video_avg_bps(new_core->output_fmt, info->bitrate);
+                }
+                else
+                {
+                    media_format_set_audio_mime(new_core->output_fmt, mimetype);
+                    media_format_set_audio_channel(new_core->output_fmt, info->channel);
+                    media_format_set_audio_samplerate(new_core->output_fmt, info->samplerate);
+                    media_format_set_audio_bit(new_core->output_fmt, info->bit);
+                    media_format_set_audio_avg_bps(new_core->output_fmt, info->bitrate);
+                }
+
+            }
+            else
+            {
+                mc_decoder_info_t *info;
+
+                info = mc_handle->dec_info;
+                new_core->dec_info = mc_handle->dec_info;
+                if (new_core->video)
+                {
+                    media_format_set_video_mime(new_core->output_fmt, mimetype);
+                    media_format_set_video_width(new_core->output_fmt, info->width);
+                    media_format_set_video_height(new_core->output_fmt, info->height);
+                }
+                else
+                {
+                    media_format_set_audio_mime(new_core->output_fmt, mimetype);
+                    media_format_set_audio_channel(new_core->output_fmt, info->channel);
+                    media_format_set_audio_samplerate(new_core->output_fmt, info->samplerate);
+                    media_format_set_audio_bit(new_core->output_fmt, info->bit);
+                }
+
+            }
+
+            LOGD("is_encoder (%d)  is_video (%d)",  new_core->encoder, new_core->video);
+            mc_handle->gst_core = new_core;
+            //mc_gst_prepare(mc_handle->gst_core); //to avoid build error until this code is not compatible with gstreamer 1.0
+
+
+               }
+
+        break;
+
+        default:
+        break;
+    }
+#endif
+
+    return ret;
+}
+
+int mc_unprepare(MMHandleType mediacodec)
+{
+    int ret = MC_ERROR_NONE;
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    /* deinit core details */
+    switch ( mc_handle->port_type )
+    {
+        case MEDIACODEC_PORT_TYPE_GENERAL:
+        {
+            //ret = mc_general_deinit(mc_handle->gen_core);
+        }
+        break;
+
+        case MEDIACODEC_PORT_TYPE_OMX:
+        {
+            //ret = mc_omx_deinit(mc_handle);
+        }
+        break;
+
+        case MEDIACODEC_PORT_TYPE_GST:
+        {
+         //   ret = mc_gst_unprepare(mc_handle->gst_core);  //to avoid build error until this code is not compatible with gstreamer 1.0
+
+            if(mc_handle->gst_core != NULL)
+            {
+              //  mc_gst_core_free(mc_handle->gst_core);  //to avoid build error until this code is not compatible with gstreamer 1.0
+                mc_handle->gst_core = NULL;
+            }
+        }
+        break;
+
+        default:
+            break;
+    }
+
+    return ret;
+}
+
+int mc_process_input(MMHandleType mediacodec, media_packet_h inbuf, uint64_t timeOutUs )
+{
+    int ret = MC_ERROR_NONE;
+    uint64_t buf_size = 0;
+    void *buf_data = NULL;
+
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    ret = media_packet_get_buffer_size(inbuf, &buf_size);
+    if (ret != MEDIA_PACKET_ERROR_NONE)
+    {
+        LOGE("invaild input buffer");
+        return MC_INVALID_IN_BUF;
+    }
+    ret = media_packet_get_buffer_data_ptr(inbuf, &buf_data);
+    if (ret != MEDIA_PACKET_ERROR_NONE)
+    {
+        LOGE("invaild input buffer");
+        return MC_INVALID_IN_BUF;
+    }
+
+    if((buf_data == NULL) || (buf_size == 0))
+    {
+        LOGE("invaild input buffer");
+        return MC_INVALID_IN_BUF;
+    }
+
+    switch ( mc_handle->port_type )
+    {
+        case MEDIACODEC_PORT_TYPE_GENERAL:
+        {
+             //ret = mc_general_process_input(mc_handle->gen_core, inbuf, timeOutUs);
+        }
+        break;
+
+        case MEDIACODEC_PORT_TYPE_OMX:
+        {
+            //ret = mc_omx_process_input(mc_handle, inbuf, timeOutUs);
+        }
+        break;
+
+        case MEDIACODEC_PORT_TYPE_GST:
+        {
+            //ret = mc_gst_process_input(mc_handle->gst_core, inbuf, timeOutUs); //to avoid build error until this code is not compatible with gstreamer 1.0
+        }
+        break;
+
+        default:
+            break;
+    }
+
+    return ret;
+}
+
+int mc_get_output(MMHandleType mediacodec, media_packet_h *outbuf, uint64_t timeOutUs)
+{
+    int ret = MC_ERROR_NONE;
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    /* setting core details */
+    switch ( mc_handle->port_type )
+    {
+        case MEDIACODEC_PORT_TYPE_GENERAL:
+        {
+            //ret= mc_general_get_output(mc_handle->gen_core, outbuf, timeOutUs);
+        }
+        break;
+
+        case MEDIACODEC_PORT_TYPE_OMX:
+        {
+            //ret = mc_omx_get_output(mc_handle, outbuf, timeOutUs);
+        }
+        break;
+
+        case MEDIACODEC_PORT_TYPE_GST:
+        {
+            //ret = mc_gst_get_output(mc_handle->gst_core, outbuf, timeOutUs); //to avoid build error until this code is not compatible with gstreamer 1.0
+        }
+        break;
+
+        default:
+            break;
+    }
+
+    return ret;
+}
+
+int mc_set_empty_buffer_cb(MMHandleType mediacodec, mediacodec_input_buffer_used_cb callback, void* user_data)
+{
+    int ret = MC_ERROR_NONE;
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    if(mc_handle->user_cb[_MEDIACODEC_EVENT_TYPE_EMPTYBUFFER])
+    {
+        LOGE("Already set mediacodec_empty_buffer_cb\n");
+        return MC_PARAM_ERROR;
+    }
+    else
+    {
+        if (!callback)
+        {
+            return MC_INVALID_ARG;
+        }
+
+        LOGD("Set empty buffer callback(cb = %p, data = %p)\n", callback, user_data);
+
+        mc_handle->user_cb[_MEDIACODEC_EVENT_TYPE_EMPTYBUFFER] = (mc_empty_buffer_cb) callback;
+        mc_handle->user_data[_MEDIACODEC_EVENT_TYPE_EMPTYBUFFER] = user_data;
+        return MC_ERROR_NONE;
+    }
+
+    return ret;
+}
+int mc_unset_empty_buffer_cb(MMHandleType mediacodec)
+{
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    mc_handle->user_cb[_MEDIACODEC_EVENT_TYPE_EMPTYBUFFER] = NULL;
+    mc_handle->user_data[_MEDIACODEC_EVENT_TYPE_EMPTYBUFFER] = NULL;
+
+    return MC_ERROR_NONE;
+}
+
+int mc_set_fill_buffer_cb(MMHandleType mediacodec, mediacodec_output_buffer_available_cb callback, void* user_data)
+{
+    int ret = MC_ERROR_NONE;
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    if(mc_handle->user_cb[_MEDIACODEC_EVENT_TYPE_FILLBUFFER])
+    {
+        LOGE("Already set mediacodec_fill_buffer_cb\n");
+        return MC_PARAM_ERROR;
+    }
+    else
+    {
+        if (!callback) {
+            return MC_INVALID_ARG;
+        }
+
+        LOGD("Set fill buffer callback(cb = %p, data = %p)\n", callback, user_data);
+
+        mc_handle->user_cb[_MEDIACODEC_EVENT_TYPE_FILLBUFFER] = (mc_fill_buffer_cb) callback;
+        mc_handle->user_data[_MEDIACODEC_EVENT_TYPE_FILLBUFFER] = user_data;
+        return MC_ERROR_NONE;
+    }
+
+    return ret;
+}
+int mc_unset_fill_buffer_cb(MMHandleType mediacodec)
+{
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    mc_handle->user_cb[_MEDIACODEC_EVENT_TYPE_FILLBUFFER] = NULL;
+    mc_handle->user_data[_MEDIACODEC_EVENT_TYPE_FILLBUFFER] = NULL;
+
+    return MC_ERROR_NONE;
+}
+
+int mc_set_error_cb(MMHandleType mediacodec, mediacodec_error_cb callback, void* user_data)
+{
+    int ret = MC_ERROR_NONE;
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    if(mc_handle->user_cb[_MEDIACODEC_EVENT_TYPE_ERROR])
+    {
+        LOGE("Already set mediacodec_fill_buffer_cb\n");
+        return MC_PARAM_ERROR;
+    }
+    else
+    {
+        if (!callback) {
+            return MC_INVALID_ARG;
+        }
+
+        LOGD("Set event handler callback(cb = %p, data = %p)\n", callback, user_data);
+
+        mc_handle->user_cb[_MEDIACODEC_EVENT_TYPE_ERROR] = (mc_error_cb) callback;
+        mc_handle->user_data[_MEDIACODEC_EVENT_TYPE_ERROR] = user_data;
+        return MC_ERROR_NONE;
+    }
+
+    return ret;
+}
+
+int mc_unset_error_cb(MMHandleType mediacodec)
+{
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    mc_handle->user_cb[_MEDIACODEC_EVENT_TYPE_ERROR] = NULL;
+    mc_handle->user_data[_MEDIACODEC_EVENT_TYPE_ERROR] = NULL;
+
+    return MC_ERROR_NONE;
+}
+
+int mc_set_eos_cb(MMHandleType mediacodec, mediacodec_eos_cb callback, void* user_data)
+{
+    int ret = MC_ERROR_NONE;
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    if(mc_handle->user_cb[_MEDIACODEC_EVENT_TYPE_EOS])
+    {
+        LOGE("Already set mediacodec_fill_buffer_cb\n");
+        return MC_PARAM_ERROR;
+    }
+    else
+    {
+        if (!callback) {
+            return MC_INVALID_ARG;
+        }
+
+        LOGD("Set event handler callback(cb = %p, data = %p)\n", callback, user_data);
+
+        mc_handle->user_cb[_MEDIACODEC_EVENT_TYPE_EOS] = (mc_eos_cb) callback;
+        mc_handle->user_data[_MEDIACODEC_EVENT_TYPE_EOS] = user_data;
+        return MC_ERROR_NONE;
+    }
+
+    return ret;
+}
+
+int mc_unset_eos_cb(MMHandleType mediacodec)
+{
+    mc_handle_t* mc_handle = (mc_handle_t*) mediacodec;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return MC_INVALID_ARG;
+    }
+
+    mc_handle->user_cb[_MEDIACODEC_EVENT_TYPE_EOS] = NULL;
+    mc_handle->user_data[_MEDIACODEC_EVENT_TYPE_EOS] = NULL;
+
+    return MC_ERROR_NONE;
+}
+
+gboolean _mc_check_is_supported(mc_handle_t* mc_handle, mediacodec_codec_type_e codec_id, mediacodec_support_type_e flags)
+{
+    int i=0;
+
+    if (!mc_handle)
+    {
+        LOGE("fail invaild param\n");
+        return FALSE;
+    }
+
+    for (i = 0; i < MC_MAX_NUM_CODEC; i++)
+    {
+        if (mc_handle->g_media_codec_spec_emul[i].mime == codec_id)
+        {
+            if (mc_handle->g_media_codec_spec_emul[i].codec_type & (flags & 0x3))
+            {
+                if (mc_handle->g_media_codec_spec_emul[i].support_type & (flags & 0xC))
+                {
+                    mc_handle->port_type = mc_handle->g_media_codec_spec_emul[i].port_type;
+                    LOGD("port type : %d", mc_handle->port_type);
+                    return TRUE;
+                }
+            }
+
+        }
+    }
+
+       return FALSE;
+}
+
diff --git a/src/media_codec_queue.c b/src/media_codec_queue.c
new file mode 100644 (file)
index 0000000..a1aac8a
--- /dev/null
@@ -0,0 +1,105 @@
+#include <media_codec_queue.h>
+
+async_queue_t *mc_async_queue_new (void)
+{
+    async_queue_t *async_queue;
+
+    async_queue = g_slice_new0 (async_queue_t);
+#if 0 //to avoid build error until this code is compatible with glib 2.0
+    async_queue->condition = g_cond_new ();
+    async_queue->mutex = g_mutex_new ();
+    async_queue->enabled = TRUE;
+#endif
+    return async_queue;
+}
+
+void mc_async_queue_free (async_queue_t * async_queue)
+{
+#if 0 //to avoid build error until this code is compatible with glib 2.0
+
+    g_cond_free (async_queue->condition);
+    g_mutex_free (async_queue->mutex);
+
+    g_list_free (async_queue->head);
+    g_slice_free (async_queue_t, async_queue);
+#endif
+}
+
+void mc_async_queue_push (async_queue_t * async_queue, gpointer data)
+{
+    g_mutex_lock (async_queue->mutex);
+
+    async_queue->tail = g_list_append(async_queue->tail, data);
+    if(async_queue->tail && async_queue->tail->next)
+        async_queue->tail = async_queue->tail->next;
+    else
+        async_queue->head = async_queue->tail;
+
+    async_queue->length++;
+
+    g_cond_signal (async_queue->condition);
+    //LOGD("queue pushed : %p, %d, %p",queue, async_queue->length, data);
+
+    g_mutex_unlock (async_queue->mutex);
+}
+
+gpointer mc_async_queue_pop (async_queue_t * async_queue)
+{
+    gpointer data = NULL;
+
+    g_mutex_lock (async_queue->mutex);
+
+    if (!async_queue->enabled) {
+        /* g_warning ("not enabled!"); */
+        goto leave;
+    }
+
+    if (!async_queue->head) {
+        g_cond_wait (async_queue->condition, async_queue->mutex);
+    }
+
+    if (async_queue->head) {
+        GList *node = async_queue->head;
+        data = node->data;
+
+        async_queue->head = node->next;
+        if (async_queue->head)
+            async_queue->head->prev = NULL;
+        else
+            async_queue->tail = NULL;
+        async_queue->length--;
+        //LOGD("async queue poped : %p, %d, %p",queue, async_queue->length, data);
+        g_list_free_1 (node);
+    }
+
+leave:
+    g_mutex_unlock (async_queue->mutex);
+
+    return data;
+}
+
+void mc_async_queue_disable (async_queue_t * async_queue)
+{
+    g_mutex_lock (async_queue->mutex);
+    async_queue->enabled = FALSE;
+    g_cond_broadcast (async_queue->condition);
+    g_mutex_unlock (async_queue->mutex);
+}
+
+void mc_async_queue_enable (async_queue_t * async_queue)
+{
+    g_mutex_lock (async_queue->mutex);
+    async_queue->enabled = TRUE;
+    g_mutex_unlock (async_queue->mutex);
+}
+
+void mc_async_queue_flush(async_queue_t *async_queue)
+{
+    g_mutex_lock(async_queue->mutex);
+
+    g_list_free(async_queue->head);
+    async_queue->head = async_queue->tail = NULL;
+    async_queue->length = 0;
+
+    g_mutex_unlock(async_queue->mutex);
+}
diff --git a/src/media_codec_util.c b/src/media_codec_util.c
new file mode 100644 (file)
index 0000000..4c1b8ee
--- /dev/null
@@ -0,0 +1,33 @@
+#include <media_codec_util.h>
+
+void *mc_aligned_malloc(int size, int alignment)
+{
+    unsigned char *pMem;
+    unsigned char *tmp;
+
+    if((tmp = (unsigned char *)malloc(size + alignment)) != NULL)
+    {
+        pMem = (unsigned char*)((unsigned int)(tmp + alignment - 1) & (~(unsigned int)(alignment -1)));
+
+        if(pMem == tmp)
+            pMem += alignment;
+
+        *(pMem - 1) = (unsigned int)(pMem - tmp);
+
+        return ((void*) pMem);
+    }
+    return NULL;
+}
+
+void mc_aligned_free(void *mem)
+{
+    unsigned char *ptr;
+
+    if(mem == NULL)
+        return;
+
+    ptr = mem;
+    ptr -= *(ptr-1);
+
+    free(ptr);
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9b5dc2a
--- /dev/null
@@ -0,0 +1,23 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_test "${fw_name}-test")
+
+INCLUDE_DIRECTORIES(../include)
+INCLUDE_DIRECTORIES(../include/headers)
+link_directories(${CMAKE_SOURCE_DIR}/../)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_test} REQUIRED appcore-efl)
+FOREACH(flag ${${fw_test}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+aux_source_directory(. sources)
+FOREACH(src ${sources})
+    GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+    MESSAGE("${src_name}")
+    ADD_EXECUTABLE(${src_name} ${src})
+    TARGET_LINK_LIBRARIES(${src_name} capi-media-codec ${${fw_test}_LDFLAGS})
+ENDFOREACH()
+
diff --git a/test/media_codec_test.c b/test/media_codec_test.c
new file mode 100644 (file)
index 0000000..cddabcf
--- /dev/null
@@ -0,0 +1,1276 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <glib.h>
+#include <Elementary.h>
+#include <appcore-efl.h>
+
+#include <media_codec.h>
+#include <media_packet.h>
+#include <media_codec_queue.h> // !!!! remove it
+#include <media_codec_port.h> // !!!! remove it
+
+//#include <media_codec_private.h>
+//#include <media_codec_port_general.h>
+//#include <media_codec_port_omx.h>
+//#include <media_codec_port.h>
+//#include <media_codec_util.h>
+
+#define PACKAGE "media_codec_test"
+#define TEST_FILE_SIZE (10 * 1024 * 1024)              //10M - test case
+#define MAX_STRING_LEN 256
+#define MAX_HANDLE                     10
+#define DEFAULT_OUT_BUF_WIDTH   640
+#define DEFAULT_OUT_BUF_HEIGHT  480
+#define OUTBUF_SIZE (DEFAULT_OUT_BUF_WIDTH * DEFAULT_OUT_BUF_HEIGHT * 3 / 2)
+
+#define DEFAULT_SAMPPLERATE   44100
+#define DEFAULT_CHANNEL                    2
+#define DEFAULT_BIT                        16
+#define DEFAULT_BITRATE             128
+#define DEFAULT_SAMPLEBYTE         1024
+#define ADTS_HEADER_SIZE            7
+
+#define DUMP_OUTBUF         1
+#define MAX_INPUT_BUF_NUM   20
+#define USE_INPUT_QUEUE     1
+
+
+//extern int file_handle_args (int argc, char ** argv, int flag);
+
+/*
+ * Test MAIN
+ */
+
+enum
+{
+    CURRENT_STATUS_MAINMENU,
+    CURRENT_STATUS_FILENAME,
+    CURRENT_STATUS_CREATE,
+    CURRENT_STATUS_DESTROY,
+    CURRENT_STATUS_SET_CODEC,
+    CURRENT_STATUS_SET_VDEC_INFO,
+    CURRENT_STATUS_SET_VENC_INFO,
+    CURRENT_STATUS_SET_ADEC_INFO,
+    CURRENT_STATUS_SET_AENC_INFO,
+    CURRENT_STATUS_PREPARE,
+    CURRENT_STATUS_UNPREPARE,
+    CURRENT_STATUS_PROCESS_INPUT,
+    CURRENT_STATUS_GET_OUTPUT,
+    CURRENT_STATUS_RESET_OUTPUT_BUFFER,
+    CURRENT_STATUS_SET_SIZE,
+};
+
+int g_menu_state = CURRENT_STATUS_MAINMENU;
+int g_handle_num = 1;
+static mediacodec_h g_media_codec[MAX_HANDLE] = {0};
+char g_uri[MAX_STRING_LEN];
+FILE *fp_src = NULL;
+media_format_h input_fmt = NULL;
+#if USE_INPUT_QUEUE
+media_packet_h *input_buf = NULL;
+#else
+media_packet_h in_buf = NULL;
+#endif
+media_packet_h output_buf = NULL;
+async_queue_t *input_avaliable = NULL;
+
+GThread *pa_thread;
+gint pa_running = 0;
+uint64_t pts = 0;
+
+static int width = DEFAULT_OUT_BUF_WIDTH;
+static int height = DEFAULT_OUT_BUF_HEIGHT;
+static float fps = 0;
+static int target_bits = 0;
+
+static int samplerate = DEFAULT_SAMPPLERATE;
+static int channel = DEFAULT_CHANNEL;
+static int bit = DEFAULT_BIT;
+static int bitrate = DEFAULT_BITRATE;
+static int samplebyte = DEFAULT_SAMPLEBYTE;
+unsigned char buf_adts[ADTS_HEADER_SIZE];
+
+media_format_mimetype_e mimetype;
+
+int use_video = 0;
+int use_encoder = 0;
+int frame_count = 0;
+
+#if DUMP_OUTBUF
+FILE *fp_out = NULL;
+#endif
+//static gpointer _feed_pa(gpointer data);
+static void display_sub_basic();
+static int _mediacodec_get_output(void);
+static void _mediacodec_empty_buffer_cb(media_packet_h pkt, void *user_data);
+static void _mediacodec_fill_buffer_cb(media_packet_h pkt, void *user_data);
+
+static int _create_app(void *data)
+{
+    printf("My app is going alive!\n");
+    return 0;
+}
+
+static int _terminate_app(void *data)
+{
+    printf("My app is going gone!\n");
+    return 0;
+}
+
+
+struct appcore_ops ops = {
+    .create = _create_app,
+    .terminate = _terminate_app,
+};
+
+unsigned int bytestream2nalunit(FILE *fd, unsigned char* nal)
+{
+    int nal_length = 0;
+    size_t result;
+    int read_size = 1;
+    unsigned char buffer[1000000];
+    unsigned char val, zero_count, i;
+
+    zero_count = 0;
+    if (feof(fd))
+        return 0;
+
+    result = fread(buffer, 1, read_size, fd);
+    if(result != read_size)
+    {
+        exit(1);
+    }
+    val = buffer[0];
+    while (!val)
+    {
+        if ((zero_count == 2 || zero_count == 3) && val == 1)
+        {
+            break;
+        }
+        zero_count++;
+        result = fread(buffer, 1, read_size, fd);
+
+        if(result != read_size)
+        {
+            exit(1);
+        }
+        val = buffer[0];
+    }
+    nal[nal_length++] = 0;
+    nal[nal_length++] = 0;
+    nal[nal_length++] = 0;
+    nal[nal_length++] = 1;
+    zero_count = 0;
+    while(1)
+    {
+        if (feof(fd))
+            return nal_length;
+
+        result = fread(buffer, 1, read_size, fd);
+        if(result != read_size)
+        {
+            exit(1);
+        }
+        val = buffer[0];
+
+        if (!val)
+        {
+            zero_count++;
+        }
+        else
+        {
+            if ((zero_count == 2 || zero_count == 3 || zero_count == 4) && (val == 1))
+            {
+                break;
+            }
+            else
+            {
+                for (i = 0; i<zero_count; i++)
+                {
+                    nal[nal_length++] = 0;
+                }
+                nal[nal_length++] = val;
+                zero_count = 0;
+            }
+        }
+    }
+
+    fseek(fd, -(zero_count + 1), SEEK_CUR);
+
+    return nal_length;
+}
+
+unsigned int bytestream2yuv420(FILE *fd, unsigned char* yuv)
+{
+    size_t result;
+    int read_size;
+    unsigned char buffer[1000000];
+
+    if (feof(fd))
+        return 0;
+
+    read_size = width*height*3/2;
+
+    result = fread(buffer, 1,read_size, fd);
+    if(result != read_size)
+    {
+        exit(1);
+    }
+
+    memcpy(yuv, buffer, width*height*3/2);
+
+    return width*height*3/2;
+}
+
+unsigned int extract_input_aacdec(FILE *fd, unsigned char* aacdata)
+{
+    int readsize;
+    size_t result;
+    unsigned char buffer[1000000];
+
+    if (feof(fd))
+        return 0;
+
+    result = fread(buffer, 1,6, fd);
+    if(result != 6)
+    {
+        exit(1);
+    }
+
+    if ((buffer != NULL) && (buffer[0] == 0xff) && ((buffer[1] & 0xf6) == 0xf0)) {
+        readsize = ((buffer[3] & 0x03) << 11) | (buffer[4] << 3) | ((buffer[5] & 0xe0) >> 5);
+        result = fread(buffer+6, 1,(readsize - 6), fd);
+        memcpy(aacdata, buffer,readsize);
+    } else {
+        readsize = 0;
+        g_print("[FAIL] Not found aac frame sync.....\n");
+    }
+
+    return readsize;
+}
+
+unsigned int extract_input_aacenc(FILE *fd, unsigned char* rawdata)
+{
+    int readsize;
+    size_t result;
+    unsigned char buffer[1000000];
+
+    if (feof(fd))
+        return 0;
+
+    readsize =  ((samplebyte*channel)*(bit/8));
+    result = fread(buffer, 1, readsize, fd);
+    if(result != readsize)
+    {
+        exit(1);
+    }
+
+    memcpy(rawdata, buffer,readsize);
+
+    return readsize;
+}
+
+/**
+ *  Add ADTS header at the beginning of each and every AAC packet.
+ *  This is needed as MediaCodec encoder generates a packet of raw AAC data.
+ *  Note the packetLen must count in the ADTS header itself.
+ **/
+void add_adts_to_packet(unsigned char *buffer, int packetLen) {
+    int profile = 2;    //AAC LC (0x01)
+    int freqIdx = 3;    //48KHz (0x03)
+    int chanCfg = 2;    //CPE (0x02)
+
+    if (samplerate == 96000) freqIdx = 0;
+    else if (samplerate == 88200) freqIdx = 1;
+    else if (samplerate == 64000) freqIdx = 2;
+    else if (samplerate == 48000) freqIdx = 3;
+    else if (samplerate == 44100) freqIdx = 4;
+    else if (samplerate == 32000) freqIdx = 5;
+    else if (samplerate == 24000) freqIdx = 6;
+    else if (samplerate == 22050) freqIdx = 7;
+    else if (samplerate == 16000) freqIdx = 8;
+    else if (samplerate == 12000) freqIdx = 9;
+    else if (samplerate == 11025) freqIdx = 10;
+    else if (samplerate == 8000) freqIdx = 11;
+
+    if ((channel == 1) || (channel == 2))
+        chanCfg = channel;
+
+    // fill in ADTS data
+    buffer[0] = (char)0xFF;
+    buffer[1] = (char)0xF1;
+    buffer[2] = (char)(((profile-1)<<6) + (freqIdx<<2) +(chanCfg>>2));
+    buffer[3] = (char)(((chanCfg&3)<<6) + (packetLen>>11));
+    buffer[4] = (char)((packetLen&0x7FF) >> 3);
+    buffer[5] = (char)(((packetLen&7)<<5) + 0x1F);
+    buffer[6] = (char)0xFC;
+}
+
+static void input_filepath(char *filename)
+{
+    int len = strlen(filename);
+    int i = 0;
+
+    if(len < 0 || len > MAX_STRING_LEN)
+        return;
+
+    for(i = 0; i < g_handle_num; i++)
+    {
+        if(g_media_codec[i] != NULL)
+        {
+            mediacodec_unprepare(g_media_codec[i]);
+            mediacodec_destroy(g_media_codec[i]);
+            g_media_codec[i] = NULL;
+        }
+
+        if (mediacodec_create(&g_media_codec[i]) != MEDIACODEC_ERROR_NONE)
+        {
+            g_print("mediacodec create is failed\n");
+        }
+    }
+    //input_fmt = (media_format_s *) malloc(sizeof(media_format_s));
+    //memset(input_fmt, 0, sizeof(media_format_s));
+    media_format_create(&input_fmt);
+
+#if DUMP_OUTBUF
+    fp_out = fopen("/opt/usr/media/codec_dump.out", "wb");
+#endif
+
+    strncpy (g_uri, filename, len);
+
+    return;
+}
+
+void _allocate_buf(void)
+{
+#if USE_INPUT_QUEUE
+    int i = 0;
+
+    // !!!! remove dependency on internal headers.
+    input_avaliable = mc_async_queue_new();
+    input_buf = (media_packet_h *)malloc(sizeof(media_packet_h)*MAX_INPUT_BUF_NUM);
+
+    for (i = 0; i < MAX_INPUT_BUF_NUM; i++)
+    {
+        media_packet_create_alloc(input_fmt, NULL, NULL, &input_buf[i]);
+        g_print("input queue buf = %p\n", input_buf[i]);
+        mc_async_queue_push(input_avaliable, input_buf[i]);
+    }
+#else
+    media_packet_create_alloc(input_fmt, NULL, NULL, &in_buf);
+    //media_format_unref(input_fmt);
+    g_print("input queue buf = %p\n", in_buf);
+#endif
+    return;
+}
+
+#if USE_INPUT_QUEUE
+void _free_buf(void)
+{
+    int i = 0;
+
+    if (input_avaliable)
+        mc_async_queue_free(input_avaliable);
+
+    if (input_buf)
+    {
+        for (i = 0; i < MAX_INPUT_BUF_NUM; i++)
+        {
+            if(input_buf[i])
+            {
+                media_packet_destroy(input_buf[i]);
+            }
+        }
+        media_format_unref(input_fmt);
+        input_fmt = NULL;
+        free(input_buf);
+        input_buf = NULL;
+    }
+    return;
+}
+#endif
+
+static void _mediacodec_empty_buffer_cb(media_packet_h pkt, void *user_data)
+{
+    if (pkt != NULL)
+    {
+#if USE_INPUT_QUEUE
+        media_packet_unset_flags(pkt, MEDIA_PACKET_CODEC_CONFIG);
+        mc_async_queue_push(input_avaliable, pkt);
+        g_print("availablebuf = %p\n", pkt);
+#else
+        g_print("Used input buffer = %p\n", pkt);
+        media_packet_destroy(pkt);
+#endif
+    }
+    return;
+}
+
+static void _mediacodec_fill_buffer_cb(media_packet_h pkt, void *user_data)
+{
+    if (pkt != NULL)
+    {
+        _mediacodec_get_output();
+    }
+    return;
+}
+
+static void _mediacodec_eos_cb(void *user_data)
+{
+    g_print("event : eos\n");
+}
+
+void _mediacodec_destroy(void)
+{
+    int i = 0;
+    g_print("mediacodec_destroy\n");
+
+    g_atomic_int_set(&pa_running, 0);
+    g_thread_join(pa_thread);
+
+    for (i = 0; i < g_handle_num; i++)
+    {
+        if(g_media_codec[i] != NULL)
+        {
+            //mediacodec_unprepare(g_media_codec[i]);
+            mediacodec_destroy(g_media_codec[i]);
+            g_media_codec[i] = NULL;
+        }
+    }
+#if USE_INPUT_QUEUE
+    _free_buf();
+#endif
+    if (fp_src)
+        fclose(fp_src);
+#if DUMP_OUTBUF
+    if (fp_out)
+        fclose(fp_out);
+#endif
+    return;
+}
+
+void _mediacodec_set_codec(int codecid, int flag)
+{
+    int encoder = 0;
+    g_print("_mediacodec_configure\n");
+    g_print("codecid = %x, flag = %d\n", codecid, flag);
+    if (g_media_codec[0] != NULL)
+    {
+        mediacodec_set_codec(g_media_codec[0], (mediacodec_codec_type_e)codecid, flag);
+        encoder = GET_IS_ENCODER(flag) ? 1 : 0;
+        if (use_video)
+        {
+            if (encoder)
+            {
+                //input_fmt->mimetype |= MEDIA_FORMAT_RAW;
+                //input_fmt->mimetype |= MEDIA_FORMAT_NV12;
+                mimetype |= MEDIA_FORMAT_RAW;
+                mimetype |= MEDIA_FORMAT_I420;
+            }
+            else
+            {
+                //input_fmt->mimetype |= MEDIA_FORMAT_H264_SP;
+                mimetype |= MEDIA_FORMAT_H264_SP;
+            }
+            mimetype |= MEDIA_FORMAT_VIDEO;
+        }
+        else
+        {
+            if (encoder)
+            {
+                mimetype |= MEDIA_FORMAT_RAW;
+                mimetype |= MEDIA_FORMAT_PCM;
+            }
+            else
+            {
+                mimetype |= MEDIA_FORMAT_AAC;
+            }
+            mimetype |= MEDIA_FORMAT_AUDIO;
+            g_print(" [audio test] mimetype (0x%x)\n", mimetype);
+        }
+    }
+    else
+    {
+        g_print("mediacodec handle is not created\n");
+    }
+    return;
+}
+
+void _mediacodec_set_vdec_info(int width, int height)
+{
+    g_print("_mediacodec_set_vdec_info\n");
+    g_print("width = %d, height = %d\n", width, height);
+    if (g_media_codec[0] != NULL)
+    {
+        mediacodec_set_vdec_info(g_media_codec[0], width, height);
+        //input_fmt->detail.video.width = width;
+        //input_fmt->detail.video.height = height;
+    }
+    else
+    {
+        g_print("mediacodec handle is not created\n");
+    }
+    return;
+}
+
+void _mediacodec_set_venc_info(int width, int height, float fps, int target_bits)
+{
+    g_print("_mediacodec_set_venc_info\n");
+    if (g_media_codec[0] != NULL)
+    {
+        mediacodec_set_venc_info(g_media_codec[0], width, height, fps, target_bits);
+        //input_fmt->detail.video.width = width;
+        //input_fmt->detail.video.height = height;
+    }
+    else
+    {
+        g_print("mediacodec handle is not created\n");
+    }
+    return;
+}
+
+void _mediacodec_set_adec_info(int samplerate, int chnnel, int bit)
+{
+    g_print("_mediacodec_set_adec_info\n");
+    g_print("samplerate = %d, channel = %d, bit = %d\n", samplerate, chnnel, bit);
+    if (g_media_codec[0] != NULL)
+    {
+        mediacodec_set_adec_info(g_media_codec[0], samplerate, chnnel, bit);
+    }
+    else
+    {
+        g_print("mediacodec handle is not created\n");
+    }
+    return;
+}
+
+void _mediacodec_set_aenc_info(int samplerate, int chnnel, int bit, int bitrate)
+{
+    g_print("_mediacodec_set_aenc_info\n");
+    g_print("samplerate = %d, channel = %d, bit = %d, bitrate = %d\n", samplerate, chnnel, bit, bitrate);
+    if (g_media_codec[0] != NULL)
+    {
+        mediacodec_set_aenc_info(g_media_codec[0], samplerate, chnnel, bit, bitrate);
+    }
+    else
+    {
+        g_print("mediacodec handle is not created\n");
+    }
+    return;
+}
+
+
+void _mediacodec_prepare(void)
+{
+    int i = 0;
+    int err = 0;
+    if (use_video)
+    {
+        media_format_set_video_mime(input_fmt, mimetype);
+        media_format_set_video_width(input_fmt, width);
+        media_format_set_video_height(input_fmt, height);
+        media_format_set_video_avg_bps(input_fmt, target_bits);
+    }
+    else
+    {
+        g_print(" [audio test] mimetype (0x%x), channel(%d), samplerate (%d), bit (%d)\n", mimetype, channel, samplerate, bit);
+        media_format_set_audio_mime(input_fmt, mimetype);
+        media_format_set_audio_channel(input_fmt, channel);
+        media_format_set_audio_samplerate(input_fmt, samplerate);
+        media_format_set_audio_bit(input_fmt, bit);
+    }
+
+    for (i=0; i < g_handle_num; i++)
+    {
+        if(g_media_codec[i] != NULL)
+        {
+            mediacodec_set_input_buffer_used_cb(g_media_codec[i], _mediacodec_empty_buffer_cb, g_media_codec[i]);
+            mediacodec_set_output_buffer_available_cb(g_media_codec[i], _mediacodec_fill_buffer_cb, g_media_codec[i]);
+            mediacodec_set_eos_cb(g_media_codec[i], _mediacodec_eos_cb, g_media_codec[i]);
+
+            err = mediacodec_prepare(g_media_codec[i]);
+
+            if (err != MEDIACODEC_ERROR_NONE)
+            {
+                g_print("mediacodec_prepare failed error = %d \n", err);
+            }
+#if USE_INPUT_QUEUE
+            _allocate_buf();
+#endif
+        }
+        else
+        {
+            g_print("mediacodec handle is not created\n");
+        }
+    }
+    frame_count = 0;
+
+    return;
+}
+
+
+
+void _mediacodec_unprepare(void)
+{
+    int i = 0;
+    int err = 0;
+    g_print("_mediacodec_unprepare\n");
+
+    for (i=0; i < g_handle_num; i++)
+    {
+        if(g_media_codec[i] != NULL)
+        {
+            mediacodec_unset_input_buffer_used_cb(g_media_codec[i]);
+            mediacodec_unset_output_buffer_available_cb(g_media_codec[i]);
+
+            err = mediacodec_unprepare(g_media_codec[i]);
+            if (err != MEDIACODEC_ERROR_NONE)
+            {
+                g_print("mediacodec_unprepare failed error = %d \n", err);
+            }
+        }
+        else
+        {
+            g_print("mediacodec handle is not created\n");
+        }
+    }
+    frame_count = 0;
+    return;
+}
+
+int _mediacodec_process_input(void)
+{
+    g_print("_mediacodec_process_input\n");
+    unsigned int buf_size = 0;
+#if USE_INPUT_QUEUE
+    media_packet_h in_buf = NULL;
+#endif
+    void *data = NULL;
+    int ret = 0;
+
+    if (g_media_codec[0] == NULL)
+    {
+        g_print("mediacodec handle is not created\n");
+        return MEDIACODEC_ERROR_INVALID_PARAMETER;
+    }
+
+    if (fp_src == NULL)
+    {
+        fp_src = fopen(g_uri, "r");
+        if (fp_src == NULL)
+        {
+            g_print("%s file open failed\n", g_uri);
+            return MEDIACODEC_ERROR_INVALID_PARAMETER;
+        }
+    }
+#if USE_INPUT_QUEUE
+    in_buf = mc_async_queue_pop(input_avaliable);
+#else
+    _allocate_buf();
+#endif
+
+
+    if (in_buf != NULL)
+    {
+        media_packet_get_buffer_data_ptr(in_buf, &data);
+        if(data == NULL)
+            return MEDIACODEC_ERROR_INVALID_PARAMETER;
+
+        if (use_encoder)
+        {
+            if (use_video)
+            {
+                buf_size = bytestream2yuv420(fp_src, data);
+                media_packet_set_pts (in_buf, pts);
+                g_print("input pts = %llu\n", pts);
+                if (fps != 0)
+                {
+                    pts += (GST_SECOND / fps);
+                }
+            }
+            else
+            {
+                buf_size = extract_input_aacenc(fp_src, data);
+                media_packet_set_pts (in_buf, pts);
+                g_print("input pts = %llu\n", pts);
+                if (samplerate != 0)
+                {
+                    pts += ((GST_SECOND / samplerate) * samplebyte);
+                }
+            }
+        }
+        else
+        {
+            if (use_video)
+            {
+                if(frame_count == 0)
+                    ret = media_packet_set_flags(in_buf, MEDIA_PACKET_CODEC_CONFIG);
+                else if(frame_count == 1258)
+                    ret = media_packet_set_flags(in_buf, MEDIA_PACKET_END_OF_STREAM);
+
+                buf_size = bytestream2nalunit(fp_src, data);
+            }
+            else
+                buf_size = extract_input_aacdec(fp_src, data);
+        }
+
+        if (buf_size == 0)
+        {
+          g_print("input file read failed\n");
+          return MEDIACODEC_ERROR_INVALID_PARAMETER;
+        }
+
+        media_packet_set_buffer_size(in_buf, buf_size);
+        g_print("%s - input_buf size = %d  (0x%x), frame_count : %d\n",__func__, buf_size, buf_size, frame_count);
+        ret = mediacodec_process_input (g_media_codec[0], in_buf, 0);
+        frame_count++;
+        return ret;
+    }
+
+    return MEDIACODEC_ERROR_NONE;
+}
+
+int _mediacodec_get_output(void)
+{
+    int err = 0;
+    uint64_t buf_size = 0;
+    void *data = NULL;
+    g_print("_mediacodec_get_output\n");
+    if (g_media_codec[0] == NULL)
+    {
+        g_print("mediacodec handle is not created\n");
+        return MEDIACODEC_ERROR_INVALID_PARAMETER;
+    }
+
+    err = mediacodec_get_output(g_media_codec[0], &output_buf, 0);
+    if( err == MEDIACODEC_ERROR_NONE)
+    {
+        media_packet_get_buffer_size(output_buf, &buf_size);
+        g_print("%s - output_buf size = %lld\n",__func__, buf_size);
+#if DUMP_OUTBUF
+        media_packet_get_buffer_data_ptr(output_buf, &data);
+        if ((!use_video) && (use_encoder))
+        {
+            if (buf_size > 0)
+            {
+                add_adts_to_packet(buf_adts, (buf_size+ADTS_HEADER_SIZE));
+                fwrite(&buf_adts[0], 1, ADTS_HEADER_SIZE, fp_out);
+            }
+        }
+
+        if (data != NULL)
+            fwrite(data, 1, buf_size, fp_out);
+#endif
+//        printf("%s - output_buf : %p\n",__func__, output_buf);
+//        mediacodec_reset_output_buffer(g_media_codec[0], &output_buf);
+        media_packet_destroy(output_buf);
+    }
+    else
+    {
+        g_print("get_output failed err = %d\n", err);
+        return err;
+    }
+
+    return MEDIACODEC_ERROR_NONE;
+}
+
+void _mediacodec_reset_output_buffer(void)
+{
+    g_print("_media_codec_reset_output_buffer\n");
+    if (g_media_codec[0] == NULL)
+    {
+        g_print("mediacodec handle is not created\n");
+        return;
+    }
+/*
+    if(output_buf == NULL)
+    {
+        g_print("output buffer is NULL");
+        return;
+    }
+*/
+    //mediacodec_reset_output_buffer(g_media_codec[0], &output_buf);
+    return;
+}
+
+void _mediacodec_process_input_n(int num)
+{
+    int i = 0;
+    int ret = 0;
+    for (i =0; i < num; i++)
+    {
+        ret = _mediacodec_process_input();
+        if (ret != 0)
+            g_print ("_mediacodec_process_input err = %d\n", ret);
+    }
+    return;
+}
+
+void _mediacodec_get_output_n(int num)
+{
+    int i = 0;
+    int ret = 0;
+    for (i =0; i < num; i++)
+    {
+        ret = _mediacodec_get_output();
+        if (ret != 0)
+            g_print ("_mediacodec_get_output err = %d\n", ret);
+    }
+    return;
+}
+
+int _mediacodec_pa_runcheck(void)
+{
+    return pa_running;
+}
+#if 0 //to avoid build error until this code is not compatible with glib2.0
+static gpointer _feed_pa(gpointer data)
+{
+    int ret = 0;
+
+    while (1) //FIXME crash g_atomic_int_get(&pa_running)
+    {
+        if (!_mediacodec_pa_runcheck())
+            break;
+        ret = _mediacodec_process_input();
+        if (ret == MEDIACODEC_ERROR_INVALID_PARAMETER)
+            break;
+//        ret = _mediacodec_get_output();
+        usleep(100);
+    }
+/*
+    while (1) //FIXME crash g_atomic_int_get(&pa_running)
+    {
+        if (!_mediacodec_pa_runcheck())
+            break;
+        ret = _mediacodec_get_output();
+        usleep(100);
+    }
+*/
+    g_print("_feed_pa task finished\n");
+    return NULL;
+}
+#endif
+void _mediacodec_process_all(void)
+{
+    g_print("_mediacodec_process_all\n");
+    pa_running = 1;
+ //   pa_thread = g_thread_create(_feed_pa, GINT_TO_POINTER(1), TRUE, NULL);  //to avoid build error until this code is not compatible with glib2.0
+    return;
+}
+
+
+void quit_program(void)
+{
+    int i = 0;
+
+    for (i = 0; i < g_handle_num; i++)
+    {
+        if(g_media_codec[i]!=NULL)
+        {
+            mediacodec_unprepare(g_media_codec[i]);
+            mediacodec_destroy(g_media_codec[i]);
+            g_media_codec[i] = NULL;
+        }
+    }
+    elm_exit();
+}
+
+void reset_menu_state()
+{
+    g_menu_state = CURRENT_STATUS_MAINMENU;
+    return;
+}
+
+void _interpret_main_menu(char *cmd)
+{
+    int len =  strlen(cmd);
+    if (len == 1)
+    {
+        if (strncmp(cmd, "a", 1) == 0)
+        {
+            g_menu_state = CURRENT_STATUS_FILENAME;
+        }
+        else if (strncmp(cmd, "o", 1) == 0)
+        {
+            g_menu_state = CURRENT_STATUS_GET_OUTPUT;
+        }
+        else if (strncmp(cmd, "q", 1) == 0)
+        {
+            quit_program();
+        }
+        else
+        {
+            g_print("unknown menu \n");
+        }
+    }
+    else if (len == 2)
+    {
+        if (strncmp(cmd, "pr", 2) == 0)
+        {
+            _mediacodec_prepare();
+        }
+        else if (strncmp(cmd, "sc", 2) == 0)
+        {
+            g_menu_state = CURRENT_STATUS_SET_CODEC;
+        }
+        else if (strncmp(cmd, "vd", 2) == 0)
+        {
+            g_menu_state = CURRENT_STATUS_SET_VDEC_INFO;
+        }
+        else if (strncmp(cmd, "ve", 2) == 0)
+        {
+            g_menu_state = CURRENT_STATUS_SET_VENC_INFO;
+        }
+        else if (strncmp(cmd, "ad", 2) == 0)
+        {
+            g_menu_state = CURRENT_STATUS_SET_ADEC_INFO;
+        }
+        else if (strncmp(cmd, "ae", 2) == 0)
+        {
+            g_menu_state = CURRENT_STATUS_SET_AENC_INFO;
+        }
+        else if (strncmp(cmd, "pi", 2) == 0)
+        {
+            g_menu_state = CURRENT_STATUS_PROCESS_INPUT;
+        }
+        else if (strncmp(cmd, "rb", 2) == 0)
+        {
+            _mediacodec_reset_output_buffer();
+        }
+        else if (strncmp(cmd, "pa", 2) == 0)
+        {
+            _mediacodec_process_all();
+        }
+        else if (strncmp(cmd, "un", 2) == 0)
+        {
+            _mediacodec_unprepare();
+        }
+        else if (strncmp(cmd, "dt", 2) == 0)
+        {
+            _mediacodec_destroy();
+        }
+        else
+        {
+            g_print("unknown menu \n");
+        }
+    }
+    else
+    {
+        g_print("unknown menu \n");
+    }
+    return;
+}
+
+static void displaymenu(void)
+{
+    if (g_menu_state == CURRENT_STATUS_MAINMENU)
+    {
+        display_sub_basic();
+    }
+    else if (g_menu_state == CURRENT_STATUS_FILENAME)
+    {
+        g_print("*** input mediapath.\n");
+    }
+    else if (g_menu_state == CURRENT_STATUS_SET_CODEC)
+    {
+        g_print("*** Codec id : L16  = 1         Flags : MEDIACODEC_ENCODER = 1\n");
+        g_print("               ALAW = 2                 MEDIACODEC_DECODER = 2\n");
+        g_print("               ULAW = 3                 MEDIACODEC_SUPPORT_TYPE_HW = 4,\n");
+        g_print("               AMR  = 4                 MEDIACODEC_SUPPORT_TYPE_SW = 8,\n");
+        g_print("               G729 = 5                 MEDIACODEC_SUPPORT_TYPE_OMX = 16\n");
+        g_print("               AAC  = 6                 MEDIACODEC_SUPPORT_TYPE_GEN = 32,\n");
+        g_print("               MP3  = 7\n");
+        g_print("               H261  = 101\n");
+        g_print("               H263  = 102\n");
+        g_print("               H264  = 103\n");
+        g_print("               MJPEG = 104\n");
+        g_print("               MPEG1 = 105\n");
+        g_print("               MPEG2 = 106\n");
+        g_print("               MPEG4 = 107\n");
+        g_print("*** input codec id, falgs.\n");
+    }
+    else if (g_menu_state == CURRENT_STATUS_SET_VDEC_INFO)
+    {
+        g_print("*** input video decode configure.(width, height)\n");
+    }
+    else if (g_menu_state == CURRENT_STATUS_SET_VENC_INFO)
+    {
+        g_print("*** input video encode configure.(width, height, fps, target_bits)\n");
+    }
+    else if (g_menu_state == CURRENT_STATUS_SET_ADEC_INFO)
+    {
+        g_print("*** input audio decode configure.(samplerate, channel, bit)\n");
+    }
+    else if (g_menu_state == CURRENT_STATUS_SET_AENC_INFO)
+    {
+        g_print("*** input audio encode configure.(samplerate, channel, bit, bitrate)\n");
+    }
+    else if (g_menu_state == CURRENT_STATUS_PROCESS_INPUT)
+    {
+        g_print("*** input dec process number\n");
+    }
+    else if (g_menu_state == CURRENT_STATUS_GET_OUTPUT)
+    {
+        g_print("*** input get output buffer number\n");
+    }
+    else
+    {
+        g_print("*** unknown status.\n");
+        quit_program();
+    }
+    g_print(" >>> ");
+}
+
+gboolean timeout_menu_display(void* data)
+{
+    displaymenu();
+    return FALSE;
+}
+
+
+static void interpret (char *cmd)
+{
+    switch (g_menu_state)
+    {
+        case CURRENT_STATUS_MAINMENU:
+            {
+                _interpret_main_menu(cmd);
+            }
+            break;
+        case CURRENT_STATUS_FILENAME:
+            {
+                input_filepath(cmd);
+                reset_menu_state();
+            }
+            break;
+        case CURRENT_STATUS_SET_CODEC:
+            {
+                static int codecid = 0;
+                static int flag = 0;
+                static int cnt = 0;
+
+                int tmp;
+                char **ptr = NULL;
+                switch (cnt)
+                {
+                    case 0:
+                        tmp = atoi(cmd);
+
+                        if(tmp > 100)
+                        {
+                            tmp = strtol(cmd, ptr, 16);
+                            codecid = 0x2000 + ((tmp & 0xFF) << 4);
+                            use_video = 1;
+                        }
+                        else
+                        {
+                            codecid = 0x1000 + (tmp<<4);
+                        }
+                        cnt++;
+                        break;
+                    case 1:
+                        flag = atoi(cmd);
+                        if (GET_IS_ENCODER(flag))
+                            use_encoder = 1;
+                        else if (GET_IS_DECODER(flag))
+                            use_encoder = 0;
+                        _mediacodec_set_codec(codecid, flag);
+                        reset_menu_state();
+                        codecid = 0;
+                        flag = 0;
+                        cnt = 0;
+                        break;
+                    default:
+                        break;
+                }
+            }
+            break;
+        case CURRENT_STATUS_SET_VDEC_INFO:
+            {
+                static int cnt = 0;
+                switch (cnt)
+                {
+                    case 0:
+                        width = atoi(cmd);
+                        cnt++;
+                        break;
+                    case 1:
+                        height = atoi(cmd);
+                        _mediacodec_set_vdec_info(width, height);
+                        reset_menu_state();
+                        cnt = 0;
+                        break;
+                    default:
+                        break;
+                }
+            }break;
+        case CURRENT_STATUS_SET_VENC_INFO:
+            {
+                static int cnt = 0;
+                switch (cnt) {
+                    case 0:
+                        width = atoi(cmd);
+                        cnt++;
+                        break;
+                    case 1:
+                        height = atoi(cmd);
+                        cnt++;
+                        break;
+                    case 2:
+                        fps = atol(cmd);
+                        cnt++;
+                        break;
+                    case 3:
+                        target_bits = atoi(cmd);
+                        g_print("width = %d, height = %d, fps = %f, target_bits = %d\n", width, height, fps, target_bits);
+                        _mediacodec_set_venc_info(width, height, fps, target_bits);
+                        reset_menu_state();
+                        cnt = 0;
+                        break;
+                    default:
+                        break;
+                }
+            }
+            break;
+        case CURRENT_STATUS_SET_ADEC_INFO:
+            {
+                static int cnt = 0;
+                switch (cnt)
+                {
+                    case 0:
+                        samplerate = atoi(cmd);
+                        cnt++;
+                        break;
+                    case 1:
+                        channel = atoi(cmd);
+                        cnt++;
+                        break;
+                    case 2:
+                        bit = atoi(cmd);
+                        _mediacodec_set_adec_info(samplerate, channel,bit);
+                        reset_menu_state();
+                        cnt = 0;
+                        break;
+                    default:
+                        break;
+                }
+            }break;
+        case CURRENT_STATUS_SET_AENC_INFO:
+            {
+                static int cnt = 0;
+                switch (cnt)
+                {
+                    case 0:
+                        samplerate = atoi(cmd);
+                        cnt++;
+                        break;
+                    case 1:
+                        channel = atoi(cmd);
+                        cnt++;
+                        break;
+                    case 2:
+                        bit = atoi(cmd);
+                        cnt++;
+                        break;
+                    case 3:
+                        bitrate = atoi(cmd);
+                        _mediacodec_set_aenc_info(samplerate, channel,bit,bitrate);
+                        reset_menu_state();
+                        cnt = 0;
+                        break;
+                    default:
+                        break;
+                }
+            }break;
+        case CURRENT_STATUS_PROCESS_INPUT:
+            {
+                static int num = 0;
+                num = atoi(cmd);
+                _mediacodec_process_input_n(num);
+                reset_menu_state();
+            }
+            break;
+        case CURRENT_STATUS_GET_OUTPUT:
+            {
+                static int num = 0;
+                num = atoi(cmd);
+                _mediacodec_get_output_n(num);
+                reset_menu_state();
+            }
+            break;
+         default:
+            break;
+    }
+
+    g_timeout_add(100, timeout_menu_display, 0);
+}
+
+static void display_sub_basic()
+{
+    g_print("\n");
+    g_print("=========================================================================================\n");
+    g_print("                                    media codec test\n");
+    g_print("-----------------------------------------------------------------------------------------\n");
+    g_print("a. Create \t");
+    g_print("sc. Set codec \t\t");
+    g_print("vd. Set vdec info w, h\t");
+    g_print("ve. Set venc info \n");
+    g_print("ad. Set adec info s, c, b\t");
+    g_print("ae. Set aenc info \n");
+    g_print("pr. Prepare \t");
+    g_print("pi. Process input \t");
+    g_print("o. Get output \t\t");
+    g_print("rb. Reset output buffer \n");
+    g_print("pa. Process all frames \n");
+    g_print("un. Unprepare \t");
+    g_print("dt. Destroy \t\t");
+    g_print("q. quite test suite \t");
+    g_print("\n");
+    g_print("=========================================================================================\n");
+}
+
+gboolean input (GIOChannel *channel)
+{
+    gchar buf[MAX_STRING_LEN];
+    gsize read;
+    GError *error = NULL;
+
+    g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
+    buf[read] = '\0';
+    g_strstrip(buf);
+    interpret (buf);
+
+    return TRUE;
+}
+
+int main(int argc, char *argv[])
+{
+    GIOChannel *stdin_channel;
+    stdin_channel = g_io_channel_unix_new(0);
+    g_io_channel_set_flags (stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
+    g_io_add_watch (stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
+
+    displaymenu();
+
+    ops.data = NULL;
+
+    return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+
+}
diff --git a/test/tags b/test/tags
new file mode 100644 (file)
index 0000000..95f511d
--- /dev/null
+++ b/test/tags
@@ -0,0 +1,44 @@
+!_TAG_FILE_FORMAT      2       /extended format; --format=1 will not append ;" to lines/
+!_TAG_FILE_SORTED      1       /0=unsorted, 1=sorted, 2=foldcase/
+!_TAG_PROGRAM_AUTHOR   Darren Hiebert  /dhiebert@users.sourceforge.net/
+!_TAG_PROGRAM_NAME     Exuberant Ctags //
+!_TAG_PROGRAM_URL      http://ctags.sourceforge.net    /official site/
+!_TAG_PROGRAM_VERSION  5.9~svn20110310 //
+CURRENT_STATUS_DESTROY videowall/player_vw_test.c      /^      CURRENT_STATUS_DESTROY,$/;"     e       enum:__anon1    file:
+CURRENT_STATUS_FILENAME        videowall/player_vw_test.c      /^      CURRENT_STATUS_FILENAME,$/;"    e       enum:__anon1    file:
+CURRENT_STATUS_HANDLE_NUM      videowall/player_vw_test.c      /^      CURRENT_STATUS_HANDLE_NUM,$/;"  e       enum:__anon1    file:
+CURRENT_STATUS_LOOP    videowall/player_vw_test.c      /^      CURRENT_STATUS_LOOP,$/;"        e       enum:__anon1    file:
+CURRENT_STATUS_MAINMENU        videowall/player_vw_test.c      /^      CURRENT_STATUS_MAINMENU,$/;"    e       enum:__anon1    file:
+CURRENT_STATUS_PAUSE   videowall/player_vw_test.c      /^      CURRENT_STATUS_PAUSE,$/;"       e       enum:__anon1    file:
+CURRENT_STATUS_PLAY    videowall/player_vw_test.c      /^      CURRENT_STATUS_PLAY,$/;"        e       enum:__anon1    file:
+MAX_STRING_LEN videowall/player_vw_test.c      27;"    d       file:
+TEST_FILE_SIZE media_codec_test.c      26;"    d       file:
+VIDEO_DUMP_PATH_PREFIX videowall/player_vw_test.c      28;"    d       file:
+__interpret_input      videowall/player_vw_test.c      /^static void __interpret_input(char *cmd)$/;"  f       file:   signature:(char *cmd)
+__interpret_main       videowall/player_vw_test.c      /^static void __interpret_main(char *cmd)$/;"   f       file:   signature:(char *cmd)
+__print_menu   videowall/player_vw_test.c      /^static void __print_menu()$/;"        f       file:
+__quit videowall/player_vw_test.c      /^static void __quit()$/;"      f       file:
+__reset_menu_state     videowall/player_vw_test.c      /^static void __reset_menu_state(void)$/;"      f       file:   signature:(void)
+__timeout_get_current  videowall/player_vw_test.c      /^static gboolean __timeout_get_current(void* data)$/;" f       file:   signature:(void* data)
+_completed_cb  videowall/player_vw_test.c      /^static void _completed_cb(void *user_data)$/;"        f       file:   signature:(void *user_data)
+_frame_decoded_cb      videowall/player_vw_test.c      /^static void _frame_decoded_cb(unsigned char *data, int size, void *user_data)$/;"     f       file:   signature:(unsigned char *data, int size, void *user_data)
+_get_status    videowall/player_vw_test.c      /^static void _get_status()$/;" f       file:
+_input videowall/player_vw_test.c      /^static gboolean _input(GIOChannel *channel)$/;"       f       file:   signature:(GIOChannel *channel)
+_setup_dump    videowall/player_vw_test.c      /^static void _setup_dump()$/;" f       file:
+file_handle_args       media_codec_test.c      /^extern int file_handle_args (int argc, char ** argv, int flag);$/;"   p       file:   signature:(int argc, char ** argv, int flag)
+file_handle_args       media_codec_test.c      /^int file_handle_args (int argc, char ** argv, int flag)$/;"   f       signature:(int argc, char ** argv, int flag)
+fnp    media_codec_test.c      /^char *fnp;$/;"        v
+g_dump_fd      videowall/player_vw_test.c      /^FILE *g_dump_fd;$/;"  v
+g_loop videowall/player_vw_test.c      /^GMainLoop *g_loop;$/;"        v
+g_menu_state   videowall/player_vw_test.c      /^int g_menu_state = CURRENT_STATUS_MAINMENU;$/;"       v
+g_player       videowall/player_vw_test.c      /^static vw_player_h g_player;$/;"      v       file:
+g_uri  videowall/player_vw_test.c      /^char g_uri[MAX_STRING_LEN];$/;"       v
+inf    media_codec_test.c      /^      FILE *inf, *outf;$/;"   v
+inf    media_codec_test.c      /^      int inf, outf;$/;"      v
+input_filename videowall/player_vw_test.c      /^static void input_filename(char *filename)$/;"        f       file:   signature:(char *filename)
+main   media_codec_test.c      /^int main (int argc, char ** argv)$/;" f       signature:(int argc, char ** argv)
+main   videowall/player_vw_test.c      /^int main(int argc, char *argv[])$/;"  f       signature:(int argc, char *argv[])
+outf   media_codec_test.c      /^      FILE *inf, *outf;$/;"   v
+outf   media_codec_test.c      /^      int inf, outf;$/;"      v
+szInputName    media_codec_test.c      /^char szInputName[255];$/;"    v
+szOutputName   media_codec_test.c      /^char szOutputName[255];$/;"   v