* while(EOS) {
* if(track1 is set) {
* mediademuxer_read_sample();
- * if(seek_request)
+ * if(seek_request)
* mediademuxer_seek();
- * }
+ * }
* else if(track2 is set) {
* mediademuxer_read_sample();
- * }
- * if(track2_not_needed)
- * mediademuxer_unselect_track(track2);
+ * }
+ * if(track2_not_needed)
+ * mediademuxer_unselect_track(track2);
* }
* </pre>
* mediademuxer_stop()<br>
#ifdef __cplusplus
extern "C" {
-#endif /* __cplusplus */
+#endif /* __cplusplus */
#ifndef TIZEN_ERROR_MEDIA_DEMUXER
#define TIZEN_ERROR_MEDIA_DEMUXER -0x04000000
MEDIADEMUXER_NONE, /**< The mediademuxer is not created */
MEDIADEMUXER_IDLE, /**< The mediademuxer is created, but not prepared */
MEDIADEMUXER_READY, /**< The mediademuxer is ready to demux media */
- MEDIADEMUXER_DEMUXING /**< The mediademuxer is demuxing media */
+ MEDIADEMUXER_DEMUXING /**< The mediademuxer is demuxing media */
} mediademuxer_state;
/**
* @since_tizen 3.0
*/
typedef enum {
- MEDIADEMUXER_ERROR_NONE = TIZEN_ERROR_NONE, /*< Successful */
- MEDIADEMUXER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- MEDIADEMUXER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- MEDIADEMUXER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
- MEDIADEMUXER_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
- MEDIADEMUXER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
- MEDIADEMUXER_ERROR_INVALID_STATE = TIZEN_ERROR_MEDIA_DEMUXER | 0x01, /**< Invalid state */
- MEDIADEMUXER_ERROR_INVALID_PATH = TIZEN_ERROR_MEDIA_DEMUXER | 0x02, /**< Invalid path */
- MEDIADEMUXER_ERROR_RESOURCE_LIMIT = TIZEN_ERROR_MEDIA_DEMUXER | 0x03, /**< Resource limit */
- MEDIADEMUXER_ERROR_SEEK_FAILED = TIZEN_ERROR_MEDIA_DEMUXER | 0x04, /**< Seek operation failure */
- MEDIADEMUXER_ERROR_DRM_NOT_PERMITTED = TIZEN_ERROR_MEDIA_DEMUXER | 0x05 /**< Not permitted format */
+ MEDIADEMUXER_ERROR_NONE = TIZEN_ERROR_NONE, /*< Successful */
+ MEDIADEMUXER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ MEDIADEMUXER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ MEDIADEMUXER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */
+ MEDIADEMUXER_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
+ MEDIADEMUXER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ MEDIADEMUXER_ERROR_INVALID_STATE = TIZEN_ERROR_MEDIA_DEMUXER | 0x01, /**< Invalid state */
+ MEDIADEMUXER_ERROR_INVALID_PATH = TIZEN_ERROR_MEDIA_DEMUXER | 0x02, /**< Invalid path */
+ MEDIADEMUXER_ERROR_RESOURCE_LIMIT = TIZEN_ERROR_MEDIA_DEMUXER | 0x03, /**< Resource limit */
+ MEDIADEMUXER_ERROR_SEEK_FAILED = TIZEN_ERROR_MEDIA_DEMUXER | 0x04, /**< Seek operation failure */
+ MEDIADEMUXER_ERROR_DRM_NOT_PERMITTED = TIZEN_ERROR_MEDIA_DEMUXER | 0x05 /**< Not permitted format */
} mediademuxer_error_e;
/**
* @see mediademuxer_set_error_cb()
* @see mediademuxer_unset_error_cb()
*/
-typedef void (*mediademuxer_error_cb)(mediademuxer_error_e error, void *user_data);
+typedef void (*mediademuxer_error_cb) (mediademuxer_error_e error, void *user_data);
/**
* @brief Creates a media demuxer handle for demuxing.
* @see media_format_unref()
* @see #media_format_h
* */
-int mediademuxer_get_track_info(mediademuxer_h demuxer, int track_index,
- media_format_h *format);
+int mediademuxer_get_track_info(mediademuxer_h demuxer, int track_index, media_format_h *format);
/**
* @brief Reads a frame(sample) of one single track.
* @see media_packet_destroy()
* @see #media_packet_h
* */
-int mediademuxer_read_sample(mediademuxer_h demuxer, int track_index,
- media_packet_h *outbuf);
+int mediademuxer_read_sample(mediademuxer_h demuxer, int track_index, media_packet_h *outbuf);
/**
* @brief Seeks to a particular instance of time (in micro seconds).
* @see mediademuxer_unset_error_cb()
* @see mediademuxer_error_cb()
* */
-int mediademuxer_set_error_cb(mediademuxer_h demuxer,
- mediademuxer_error_cb callback, void *user_data);
+int mediademuxer_set_error_cb(mediademuxer_h demuxer, mediademuxer_error_cb callback, void *user_data);
/**
* @brief Unregisters the error callback function.
#ifdef __cplusplus
}
#endif
-#endif /* __TIZEN_MEDIADEMUXER_H__ */
+#endif /* __TIZEN_MEDIADEMUXER_H__ */
#ifdef __cplusplus
extern "C" {
#endif
-
typedef enum {
MD_ERROR_NONE = 0,
- MD_ERROR = -1, /**< codec happens error */
- MD_MEMORY_ERROR = -2, /**< codec memory is not enough */
- MD_PARAM_ERROR = -3, /**< codec parameter is error */
- MD_INVALID_ARG = -4, /** < codec has invalid arguments */
+ MD_ERROR = -1, /**< codec happens error */
+ MD_MEMORY_ERROR = -2, /**< codec memory is not enough */
+ MD_PARAM_ERROR = -3, /**< codec parameter is error */
+ MD_INVALID_ARG = -4, /** < codec has invalid arguments */
MD_PERMISSION_DENIED = -5,
- MD_INVALID_STATUS = -6, /**< codec works at invalid status */
- MD_NOT_SUPPORTED = -7, /**< codec can't support this specific video format */
+ MD_INVALID_STATUS = -6, /**< codec works at invalid status */
+ MD_NOT_SUPPORTED = -7, /**< codec can't support this specific video format */
MD_INVALID_IN_BUF = -8,
MD_INVALID_OUT_BUF = -9,
MD_INTERNAL_ERROR = -10,
- MD_HW_ERROR = -11, /**< codec happens hardware error */
+ MD_HW_ERROR = -11, /**< codec happens hardware error */
MD_NOT_INITIALIZED = -12,
MD_INVALID_STREAM = -13,
MD_OUTPUT_BUFFER_EMPTY = -14,
- MD_OUTPUT_BUFFER_OVERFLOW = -15, /**< codec output buffer is overflow */
- MD_MEMORY_ALLOCED = -16, /**< codec has got memory and can decode one frame */
- MD_COURRPTED_INI = -17, /**< value in the ini file is not valid */
+ MD_OUTPUT_BUFFER_OVERFLOW = -15, /**< codec output buffer is overflow */
+ MD_MEMORY_ALLOCED = -16, /**< codec has got memory and can decode one frame */
+ MD_COURRPTED_INI = -17, /**< value in the ini file is not valid */
MD_ERROR_FILE_NOT_FOUND = -18,
- MD_EOS, /** read sample reached end of stream */
+ MD_EOS, /** read sample reached end of stream */
} md_ret_e;
-#define MD_ERROR_CLASS 0x80000000 /**< Definition of number describing error group */
-#define MD_ERROR_COMMON_CLASS 0x80000100 /**< Category for describing common error group */
-#define MD_ERROR_GST_PORT_CLASS 0x80000200 /**< Category for describing gst_port error group */
-#define MD_ERROR_FFMPEG_PORT_CLASS 0x80000300 /**< Category for describing ffmpeg port error group */
+#define MD_ERROR_CLASS 0x80000000 /**< Definition of number describing error group */
+#define MD_ERROR_COMMON_CLASS 0x80000100 /**< Category for describing common error group */
+#define MD_ERROR_GST_PORT_CLASS 0x80000200 /**< Category for describing gst_port error group */
+#define MD_ERROR_FFMPEG_PORT_CLASS 0x80000300 /**< Category for describing ffmpeg port error group */
#define MD_ERROR_CUSTOM_PORT_CLASS 0x80000400 /**< Category for describing custom error group */
/*
MD_ERROR_CLASS
*/
#define MD_ERROR_UNKNOWN (MD_ERROR_CLASS | 0x00) /**< Unclassified error */
-#define MD_ERROR_INVALID_ARGUMENT (MD_ERROR_CLASS | 0x01) /**< Invalid argument */
-#define MD_ERROR_OUT_OF_MEMORY (MD_ERROR_CLASS | 0x02) /**< Out of memory */
-#define MD_ERROR_OUT_OF_STORAGE (MD_ERROR_CLASS | 0x03) /**< Out of storage */
-#define MD_ERROR_INVALID_HANDLE (MD_ERROR_CLASS | 0x04) /**< Invalid handle */
-#define MD_ERROR_FILE_NOT_FOUND (MD_ERROR_CLASS | 0x05) /**< Cannot find file */
+#define MD_ERROR_INVALID_ARGUMENT (MD_ERROR_CLASS | 0x01) /**< Invalid argument */
+#define MD_ERROR_OUT_OF_MEMORY (MD_ERROR_CLASS | 0x02) /**< Out of memory */
+#define MD_ERROR_OUT_OF_STORAGE (MD_ERROR_CLASS | 0x03) /**< Out of storage */
+#define MD_ERROR_INVALID_HANDLE (MD_ERROR_CLASS | 0x04) /**< Invalid handle */
+#define MD_ERROR_FILE_NOT_FOUND (MD_ERROR_CLASS | 0x05) /**< Cannot find file */
#define MD_ERROR_FILE_READ (MD_ERROR_CLASS | 0x06) /**< Fail to read data from file */
#define MD_ERROR_FILE_WRITE (MD_ERROR_CLASS | 0x07) /**< Fail to write data to file */
#define MD_ERROR_END_OF_FILE (MD_ERROR_CLASS | 0x08) /**< End of file */
-#define MD_ERROR_NOT_SUPPORT_API (MD_ERROR_CLASS | 0x09) /**< Not supported API*/
-#define MD_ERROR_PORT_REG_FAILED (MD_ERROR_CLASS | 0x0a) /**< port regitstration failed error */
+#define MD_ERROR_NOT_SUPPORT_API (MD_ERROR_CLASS | 0x09) /**< Not supported API */
+#define MD_ERROR_PORT_REG_FAILED (MD_ERROR_CLASS | 0x0a) /**< port regitstration failed error */
/*
MD_ERROR_COMMON_CLASS
*/
-#define MD_ERROR_COMMON_INVALID_ARGUMENT (MD_ERROR_COMMON_CLASS | 1) /**< Invalid argument */
-#define MD_ERROR_COMMON_NO_FREE_SPACE (MD_ERROR_COMMON_CLASS | 2) /**< Out of storage */
-#define MD_ERROR_COMMON_OUT_OF_MEMORY (MD_ERROR_COMMON_CLASS | 3) /**< Out of memory */
-#define MD_ERROR_COMMON_UNKNOWN (MD_ERROR_COMMON_CLASS | 4) /**< Unknown error */
-#define MD_ERROR_COMMON_INVALID_ATTRTYPE (MD_ERROR_COMMON_CLASS | 5) /**< Invalid argument */
-#define MD_ERROR_COMMON_INVALID_PERMISSION (MD_ERROR_COMMON_CLASS | 6) /**< Invalid permission */
-#define MD_ERROR_COMMON_OUT_OF_ARRAY (MD_ERROR_COMMON_CLASS | 7) /**< Out of array */
-#define MD_ERROR_COMMON_OUT_OF_RANGE (MD_ERROR_COMMON_CLASS | 8) /**< Out of value range*/
-#define MD_ERROR_COMMON_ATTR_NOT_EXIST (MD_ERROR_COMMON_CLASS | 9) /**< Attribute doesn't exist. */
+#define MD_ERROR_COMMON_INVALID_ARGUMENT (MD_ERROR_COMMON_CLASS | 1) /**< Invalid argument */
+#define MD_ERROR_COMMON_NO_FREE_SPACE (MD_ERROR_COMMON_CLASS | 2) /**< Out of storage */
+#define MD_ERROR_COMMON_OUT_OF_MEMORY (MD_ERROR_COMMON_CLASS | 3) /**< Out of memory */
+#define MD_ERROR_COMMON_UNKNOWN (MD_ERROR_COMMON_CLASS | 4) /**< Unknown error */
+#define MD_ERROR_COMMON_INVALID_ATTRTYPE (MD_ERROR_COMMON_CLASS | 5) /**< Invalid argument */
+#define MD_ERROR_COMMON_INVALID_PERMISSION (MD_ERROR_COMMON_CLASS | 6) /**< Invalid permission */
+#define MD_ERROR_COMMON_OUT_OF_ARRAY (MD_ERROR_COMMON_CLASS | 7) /**< Out of array */
+#define MD_ERROR_COMMON_OUT_OF_RANGE (MD_ERROR_COMMON_CLASS | 8) /**< Out of value range*/
+#define MD_ERROR_COMMON_ATTR_NOT_EXIST (MD_ERROR_COMMON_CLASS | 9) /**< Attribute doesn't exist. */
/*
* MD_ERROR_GST_PORT_CLASS
*/
-#define MD_ERROR_GST_PORT_NOT_INITIALIZED (MD_ERROR_GST_PORT_CLASS | 0x01) /**< GST Port instance is not initialized */
+#define MD_ERROR_GST_PORT_NOT_INITIALIZED (MD_ERROR_GST_PORT_CLASS | 0x01) /**< GST Port instance is not initialized */
/*
MD_ERROR_FFMPEG_PORT_CLASS
#ifdef __cplusplus
}
#endif
-#endif /* __TIZEN_MEDIADEMUXER_ERROR_H__ */
+#endif /* __TIZEN_MEDIADEMUXER_ERROR_H__ */
#ifdef __cplusplus
}
#endif
-#endif /*__TIZEN_MEDIADEMUXER_INI_H__*/
+#endif /* __TIZEN_MEDIADEMUXER_INI_H__ */
*/
int md_stop(MMHandleType demuxer);
-
/**
* This function destroy the pipeline
*
#ifdef __cplusplus
}
#endif
-#endif /* __TIZEN_MEDIADEMUXER_PORT_H__ */
+#endif /* __TIZEN_MEDIADEMUXER_PORT_H__ */
#endif
#define LOG_TAG "TIZEN_N_MEDIADEMUXER"
-#define DEMUXER_CHECK_CONDITION(condition,error,msg) \
- if(condition) {} else \
- { LOGE("[%s] %s(0x%08x)",__FUNCTION__, msg,error); return error;}; \
+#define DEMUXER_CHECK_CONDITION(condition, error, msg) \
+ if (condition) {} else \
+ { LOGE("[%s] %s(0x%08x)", __FUNCTION__, msg, error); return error; }; \
#define DEMUXER_INSTANCE_CHECK(demuxer) \
- DEMUXER_CHECK_CONDITION(demuxer != NULL, MEDIADEMUXER_ERROR_INVALID_PARAMETER,"DEMUXER_ERROR_INVALID_PARAMETER")
+ DEMUXER_CHECK_CONDITION(demuxer != NULL, MEDIADEMUXER_ERROR_INVALID_PARAMETER, "DEMUXER_ERROR_INVALID_PARAMETER")
-#define DEMUXER_STATE_CHECK(demuxer,expected_state) \
- DEMUXER_CHECK_CONDITION(demuxer->state == expected_state,MEDIADEMUXER_ERROR_INVALID_STATE,"DEMUXER_ERROR_INVALID_STATE")
+#define DEMUXER_STATE_CHECK(demuxer, expected_state) \
+ DEMUXER_CHECK_CONDITION(demuxer->state == expected_state, MEDIADEMUXER_ERROR_INVALID_STATE, "DEMUXER_ERROR_INVALID_STATE")
#define DEMUXER_NULL_ARG_CHECK(arg) \
- DEMUXER_CHECK_CONDITION(arg != NULL,MEDIADEMUXER_ERROR_INVALID_PARAMETER,"DEMUXER_ERROR_INVALID_PARAMETER")
+ DEMUXER_CHECK_CONDITION(arg != NULL, MEDIADEMUXER_ERROR_INVALID_PARAMETER, "DEMUXER_ERROR_INVALID_PARAMETER")
/**
* @brief Enumeration for media demuxer source type
*/
typedef enum {
MEDIADEMUXER_SRC_NONE = 0, /**< Not defined src type */
- MEDIADEMUXER_SRC_FILE, /**< Local file src type */
- MEDIADEMUXER_SRC_RTP, /**< Rtp src type */
- MEDIADEMUXER_SRC_WFD, /**< Wfd src type */
- MEDIADEMUXER_SRC_HTTP, /**< Http src type */
- MEDIADEMUXER_SRC_SS, /**< Smooth streaming src type */
- MEDIADEMUXER_SRC_RTSP, /**< Rtsp src type */
- MEDIADEMUXER_SRC_UNKNOWN, /**< Unknown src type */
- MEDIADEMUXER_SRC_INVALID /**< Invalid src type */
+ MEDIADEMUXER_SRC_FILE, /**< Local file src type */
+ MEDIADEMUXER_SRC_RTP, /**< Rtp src type */
+ MEDIADEMUXER_SRC_WFD, /**< Wfd src type */
+ MEDIADEMUXER_SRC_HTTP, /**< Http src type */
+ MEDIADEMUXER_SRC_SS, /**< Smooth streaming src type */
+ MEDIADEMUXER_SRC_RTSP, /**< Rtsp src type */
+ MEDIADEMUXER_SRC_UNKNOWN, /**< Unknown src type */
+ MEDIADEMUXER_SRC_INVALID /**< Invalid src type */
} mediademuxer_src_type;
typedef struct _mediademuxer_s {
/* initialize values */
md_ini_t ini;
/* port specific handle */
- /*Source information */
+ /* Source information */
char *uri_src;
mediademuxer_src_type uri_src_media_type;
MMHandleType mdport_handle;
#ifdef __cplusplus
}
#endif
-#endif /* __TIZEN_MEDIADEMUXER_PRIVATE_H__ */
+#endif /* __TIZEN_MEDIADEMUXER_PRIVATE_H__ */
extern "C" {
#endif
-//#define PRINT_ON_CONSOLE
+/* #define PRINT_ON_CONSOLE */
#ifdef PRINT_ON_CONSOLE
#include <stdlib.h>
#include <stdio.h>
#define PRINT_F g_print
-#define MD_FENTER(); PRINT_F("function:[%s] ENTER\n",__func__);
-#define MD_FLEAVE(); PRINT_F("function [%s] LEAVE\n",__func__);
+#define MD_FENTER(); PRINT_F("function:[%s] ENTER\n", __func__);
+#define MD_FLEAVE(); PRINT_F("function [%s] LEAVE\n", __func__);
#define MD_C PRINT_F
#define MD_E PRINT_F
#define MD_W PRINT_F
#else
#include <stdlib.h>
#include <stdio.h>
-#define MD_FENTER(); LOGI("function:[%s] ENTER\n",__func__);
-#define MD_FLEAVE(); LOGI("function [%s] LEAVE\n",__func__);
-#define MD_C LOGE /*MMF_DEBUG_LEVEL_0 */
-#define MD_E LOGE /*MMF_DEBUG_LEVEL_1 */
-#define MD_W LOGW /*MMF_DEBUG_LEVEL_2 */
-#define MD_I LOGI /*MMF_DEBUG_LEVEL_3 */
-#define MD_L LOGI /*MMF_DEBUG_LEVEL_4 */
-#define MD_V LOGV /*MMF_DEBUG_LEVEL_5 */
-#define MD_F LOGF /*MMF_DEBUG_LEVEL_6 - indicate that something in the executed code path is not fully implemented or handled yet */
+#define MD_FENTER(); LOGI("function:[%s] ENTER\n", __func__);
+#define MD_FLEAVE(); LOGI("function [%s] LEAVE\n", __func__);
+#define MD_C LOGE /* MMF_DEBUG_LEVEL_0 */
+#define MD_E LOGE /* MMF_DEBUG_LEVEL_1 */
+#define MD_W LOGW /* MMF_DEBUG_LEVEL_2 */
+#define MD_I LOGI /* MMF_DEBUG_LEVEL_3 */
+#define MD_L LOGI /* MMF_DEBUG_LEVEL_4 */
+#define MD_V LOGV /* MMF_DEBUG_LEVEL_5 */
+#define MD_F LOGF /* MMF_DEBUG_LEVEL_6 - indicate that something in the executed code path is not fully implemented or handled yet */
#endif
/* general */
#define MEDIADEMUXER_FREEIF(x) \
- if ( x ) \
- g_free( x ); \
+ if (x) \
+ g_free(x); \
x = NULL;
#if 1
#define MEDIADEMUXER_FLEAVE();
#endif
-#define MEDIADEMUXER_CHECK_NULL( x_var ) \
- if ( ! x_var ) \
- { \
- MD_E("[%s] is NULL\n", #x_var ); \
+#define MEDIADEMUXER_CHECK_NULL(x_var) \
+ if (!x_var) { \
+ MD_E("[%s] is NULL\n", #x_var); \
goto ERROR; \
}
-#define MEDIADEMUXER_CHECK_SET_AND_PRINT( x_var, x_cond, ret, ret_val, err_text ) \
- if ( x_var != x_cond ) \
- { \
+#define MEDIADEMUXER_CHECK_SET_AND_PRINT(x_var, x_cond, ret, ret_val, err_text) \
+ if (x_var != x_cond) { \
ret = ret_val; \
- MD_E("%s\n", #err_text ); \
+ MD_E("%s\n", #err_text); \
goto ERROR; \
}
extern "C" {
#endif
-/*Place holder*/
+/* Place holder */
#ifdef __cplusplus
}
#endif
-#endif /* __TIZEN_MEDIADEMUXER_PORT_CUSTOM_H__ */
+#endif /* __TIZEN_MEDIADEMUXER_PORT_CUSTOM_H__ */
extern "C" {
#endif
-/*Place holder*/
+/* Place holder */
#ifdef __cplusplus
}
#endif
-#endif /* __TIZEN_MEDIADEMUXER_PORT_FFMPEG_H__ */
+#endif /* __TIZEN_MEDIADEMUXER_PORT_FFMPEG_H__ */
#define POLLING_INTERVAL 1000
#define MAX_APP_BUFFER 100
-#define MEDIADEMUXER_SET_STATE( x_element, x_state, error ) \
- do \
- { \
- MD_I("setting state [%s:%d] to [%s]\n", #x_state, x_state, GST_ELEMENT_NAME( x_element ) ); \
- if ( GST_STATE_CHANGE_FAILURE == gst_element_set_state ( x_element, x_state) ) \
- { \
- MD_E("failed to set state %s to %s\n", #x_state, GST_ELEMENT_NAME( x_element )); \
+#define MEDIADEMUXER_SET_STATE(x_element, x_state, error) \
+ do { \
+ MD_I("setting state [%s:%d] to [%s]\n", #x_state, x_state, GST_ELEMENT_NAME(x_element)); \
+ if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(x_element, x_state)) { \
+ MD_E("failed to set state %s to %s\n", #x_state, GST_ELEMENT_NAME(x_element)); \
goto error; \
} \
- }while(0)
+ } while (0)
-#define MEDIADEMUXER_LINK_PAD( srcpad, sinkpad, error ) \
- do \
- { \
- if ( GST_PAD_LINK_OK != gst_pad_link(srcpad, sinkpad) ) \
- { \
+#define MEDIADEMUXER_LINK_PAD(srcpad, sinkpad, error) \
+ do { \
+ if (GST_PAD_LINK_OK != gst_pad_link(srcpad, sinkpad)) { \
MD_E("failed to linkpad\n"); \
goto error; \
} \
- }while(0)
+ } while (0)
typedef enum {
_GST_EVENT_TYPE_COMPLETE,
int total_tracks;
GMutex *mutex;
/* for user cb */
- void* user_cb[_GST_EVENT_TYPE_NUM];
- void* user_data[_GST_EVENT_TYPE_NUM];
+ void *user_cb[_GST_EVENT_TYPE_NUM];
+ void *user_data[_GST_EVENT_TYPE_NUM];
} mdgst_handle_t;
#ifdef __cplusplus
}
#endif
-#endif /* __TIZEN_MEDIADEMUXER_PORT_GST_H__ */
+#endif /* __TIZEN_MEDIADEMUXER_PORT_GST_H__ */
handle->demux_state = MEDIADEMUXER_NONE;
} else {
MD_E("[CoreAPI][%s] DEMUXER_ERROR_OUT_OF_MEMORY(0x%08x)",
- __FUNCTION__, MEDIADEMUXER_ERROR_OUT_OF_MEMORY);
+ __FUNCTION__, MEDIADEMUXER_ERROR_OUT_OF_MEMORY);
return MEDIADEMUXER_ERROR_OUT_OF_MEMORY;
}
} else {
} else {
if (!path) {
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
- __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_PATH);
+ __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_PATH);
return MEDIADEMUXER_ERROR_INVALID_PATH;
} else {
- if(handle->demux_state != MEDIADEMUXER_IDLE)
+ if (handle->demux_state != MEDIADEMUXER_IDLE)
return MEDIADEMUXER_ERROR_INVALID_STATE;
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
- __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
+ __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
return MEDIADEMUXER_ERROR_INVALID_OPERATION;
}
}
if (ret == MEDIADEMUXER_ERROR_NONE)
handle->demux_state = MEDIADEMUXER_READY;
} else {
- if(handle->demux_state != MEDIADEMUXER_IDLE)
+ if (handle->demux_state != MEDIADEMUXER_IDLE)
return MEDIADEMUXER_ERROR_INVALID_STATE;
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
- __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
+ __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
return MEDIADEMUXER_ERROR_INVALID_OPERATION;
}
return ret;
if (handle && handle->demux_state == MEDIADEMUXER_READY) {
ret = md_get_track_count((MMHandleType) (handle->md_handle), count);
} else {
- if(handle->demux_state != MEDIADEMUXER_READY)
+ if (handle->demux_state != MEDIADEMUXER_READY)
return MEDIADEMUXER_ERROR_INVALID_STATE;
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
- __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
+ __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
return MEDIADEMUXER_ERROR_INVALID_OPERATION;
}
return ret;
if (handle && handle->demux_state == MEDIADEMUXER_READY) {
ret = md_select_track((MMHandleType) (handle->md_handle), track_index);
} else {
- if(handle->demux_state != MEDIADEMUXER_READY)
+ if (handle->demux_state != MEDIADEMUXER_READY)
return MEDIADEMUXER_ERROR_INVALID_STATE;
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
- __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
+ __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
return MEDIADEMUXER_ERROR_INVALID_OPERATION;
}
return ret;
if (ret == MEDIADEMUXER_ERROR_NONE)
handle->demux_state = MEDIADEMUXER_DEMUXING;
} else {
- if(handle->demux_state != MEDIADEMUXER_READY)
+ if (handle->demux_state != MEDIADEMUXER_READY)
return MEDIADEMUXER_ERROR_INVALID_STATE;
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
- __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
+ __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
return MEDIADEMUXER_ERROR_INVALID_OPERATION;
}
return ret;
}
int mediademuxer_get_track_info(mediademuxer_h demuxer, int track_index,
- media_format_h *format)
+ media_format_h *format)
{
MD_I("mediademuxer_get_track_info\n");
mediademuxer_error_e ret;
|| handle->demux_state == MEDIADEMUXER_DEMUXING)) {
ret = md_get_track_info((MMHandleType) (handle->md_handle), track_index, format);
} else {
- if(handle->demux_state != MEDIADEMUXER_READY)
+ if (handle->demux_state != MEDIADEMUXER_READY)
return MEDIADEMUXER_ERROR_INVALID_STATE;
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
- __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
+ __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
return MEDIADEMUXER_ERROR_INVALID_OPERATION;
}
return ret;
}
int mediademuxer_read_sample(mediademuxer_h demuxer, int track_index,
- media_packet_h *outbuf)
+ media_packet_h *outbuf)
{
MD_I("mediademuxer_read_sample\n");
mediademuxer_error_e ret;
DEMUXER_INSTANCE_CHECK(demuxer);
mediademuxer_s *handle;
handle = (mediademuxer_s *)(demuxer);
- if (outbuf == NULL || track_index < 0) {
+ if (outbuf == NULL || track_index < 0)
return MEDIADEMUXER_ERROR_INVALID_PARAMETER;
- }
if (handle && handle->demux_state == MEDIADEMUXER_DEMUXING) {
ret = md_read_sample((MMHandleType) (handle->md_handle), track_index, outbuf);
} else {
- if(handle->demux_state != MEDIADEMUXER_DEMUXING)
+ if (handle->demux_state != MEDIADEMUXER_DEMUXING)
return MEDIADEMUXER_ERROR_INVALID_STATE;
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
- __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
+ __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
return MEDIADEMUXER_ERROR_INVALID_OPERATION;
}
return ret;
if (handle && handle->demux_state == MEDIADEMUXER_DEMUXING) {
ret = md_seek((MMHandleType) (handle->md_handle), pos);
} else {
- if(handle->demux_state != MEDIADEMUXER_DEMUXING)
+ if (handle->demux_state != MEDIADEMUXER_DEMUXING)
return MEDIADEMUXER_ERROR_INVALID_STATE;
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
- __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
+ __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
return MEDIADEMUXER_ERROR_INVALID_OPERATION;
}
return ret;
|| handle->demux_state == MEDIADEMUXER_DEMUXING)) {
ret = md_unselect_track((MMHandleType) (handle->md_handle), track_index);
} else {
- if(handle->demux_state != MEDIADEMUXER_READY)
+ if (handle->demux_state != MEDIADEMUXER_READY)
return MEDIADEMUXER_ERROR_INVALID_STATE;
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
- __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
+ __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
return MEDIADEMUXER_ERROR_INVALID_OPERATION;
}
return ret;
if (ret == MEDIADEMUXER_ERROR_NONE)
handle->demux_state = MEDIADEMUXER_READY;
} else {
- if(handle->demux_state != MEDIADEMUXER_DEMUXING)
+ if (handle->demux_state != MEDIADEMUXER_DEMUXING)
return MEDIADEMUXER_ERROR_INVALID_STATE;
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
- __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
+ __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
return MEDIADEMUXER_ERROR_INVALID_OPERATION;
}
return ret;
if (ret == MEDIADEMUXER_ERROR_NONE)
handle->demux_state = MEDIADEMUXER_IDLE;
} else {
- if(handle->demux_state != MEDIADEMUXER_READY)
+ if (handle->demux_state != MEDIADEMUXER_READY)
return MEDIADEMUXER_ERROR_INVALID_STATE;
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
__FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
ret = md_destroy(handle->md_handle);
if (ret != MEDIADEMUXER_ERROR_NONE) {
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
- __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
+ __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
return MEDIADEMUXER_ERROR_INVALID_OPERATION;
} else {
MD_E("[CoreAPI][%s] destroy handle : %p", __FUNCTION__,
}
} else {
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
- __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
+ __FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
return MEDIADEMUXER_ERROR_INVALID_OPERATION;
}
handle->demux_state = MEDIADEMUXER_NONE;
static gboolean _mediademuxer_error_cb(mediademuxer_error_e error, void *user_data)
{
- if(user_data == NULL){
- MD_I("_mediademuxer_error_cb: ERROR %d to report. But call back is not set\n",error);
+ if (user_data == NULL) {
+ MD_I("_mediademuxer_error_cb: ERROR %d to report. But call back is not set\n", error);
return 0;
}
mediademuxer_s * handle = (mediademuxer_s *) user_data;
- if(handle->demux_state != MEDIADEMUXER_IDLE)
+ if (handle->demux_state != MEDIADEMUXER_IDLE)
return MEDIADEMUXER_ERROR_INVALID_STATE;
- if ( handle->error_cb ) {
+ if (handle->error_cb)
((mediademuxer_error_cb)handle->error_cb)(error, handle->error_cb_userdata);
- }
- else {
- MD_I("_mediademuxer_error_cb: ERROR %d to report. But call back is not set\n",error);
- }
+ else
+ MD_I("_mediademuxer_error_cb: ERROR %d to report. But call back is not set\n", error);
return 0;
}
static void _md_ini_check_ini_status(void);
/* macro */
-#define MEDIADEMUXER_INI_GET_STRING( x_dict, x_item, x_ini, x_default ) \
- do \
- { \
+#define MEDIADEMUXER_INI_GET_STRING(x_dict, x_item, x_ini, x_default) \
+ do { \
gchar* str = iniparser_getstring(x_dict, x_ini, x_default); \
\
- if ( str && \
- ( strlen( str ) > 0 ) && \
- ( strlen( str ) < MEDIADEMUXER_INI_MAX_STRLEN ) ) \
- { \
- strcpy ( x_item, str ); \
+ if (str && \
+ (strlen(str) > 0) && \
+ (strlen(str) < MEDIADEMUXER_INI_MAX_STRLEN)) { \
+ strcpy(x_item, str); \
+ } else { \
+ strcpy(x_item, x_default); \
} \
- else \
- { \
- strcpy ( x_item, x_default ); \
- } \
- }while(0)
+ } while (0)
-#define MEDIADEMUXER_INI_GET_COLOR( x_dict, x_item, x_ini, x_default ) \
- do \
- { \
+#define MEDIADEMUXER_INI_GET_COLOR(x_dict, x_item, x_ini, x_default) \
+ do { \
gchar* str = iniparser_getstring(x_dict, x_ini, x_default); \
\
- if ( str && \
- ( strlen( str ) > 0 ) && \
- ( strlen( str ) < MEDIADEMUXER_INI_MAX_STRLEN ) ) \
- { \
+ if (str && \
+ (strlen(str) > 0) && \
+ (strlen(str) < MEDIADEMUXER_INI_MAX_STRLEN)) { \
x_item = (guint) strtoul(str, NULL, 16); \
- } \
- else \
- { \
+ } else { \
x_item = (guint) strtoul(x_default, NULL, 16); \
} \
- }while(0)
+ } while (0)
/* x_ini is the list of index to set TRUE at x_list[index] */
-#define MEDIADEMUXER_INI_GET_BOOLEAN_FROM_LIST( x_dict, x_list, x_list_max, x_ini, x_default ) \
- do \
- { \
+#define MEDIADEMUXER_INI_GET_BOOLEAN_FROM_LIST(x_dict, x_list, x_list_max, x_ini, x_default) \
+ do { \
int index = 0; \
const char *delimiters = " ,"; \
char *usr_ptr = NULL; \
char *token = NULL; \
gchar temp_arr[MEDIADEMUXER_INI_MAX_STRLEN] = {0}; \
- MMMEDIADEMUXER_INI_GET_STRING( x_dict, temp_arr, x_ini, x_default); \
- token = strtok_r( temp_arr, delimiters, &usr_ptr ); \
- while (token) \
- { \
+ MMMEDIADEMUXER_INI_GET_STRING(x_dict, temp_arr, x_ini, x_default); \
+ token = strtok_r(temp_arr, delimiters, &usr_ptr); \
+ while (token) { \
index = atoi(token); \
- if (index < 0 || index > x_list_max -1) \
- { \
+ if (index < 0 || index > x_list_max -1) { \
MD_W("%d is not valid index\n", index); \
- } \
- else \
- { \
+ } else { \
x_list[index] = TRUE; \
} \
- token = strtok_r( NULL, delimiters, &usr_ptr ); \
+ token = strtok_r(NULL, delimiters, &usr_ptr); \
} \
- }while(0)
+ } while (0)
/* x_ini is the list of value to be set at x_list[index] */
-#define MEDIADEMUXER_INI_GET_INT_FROM_LIST( x_dict, x_list, x_list_max, x_ini, x_default ) \
- do \
- { \
+#define MEDIADEMUXER_INI_GET_INT_FROM_LIST(x_dict, x_list, x_list_max, x_ini, x_default) \
+ do { \
int index = 0; \
int value = 0; \
const char *delimiters = " ,"; \
char *token = NULL; \
gchar temp_arr[MEDIADEMUXER_INI_MAX_STRLEN] = {0}; \
MMMEDIADEMUXER_INI_GET_STRING(x_dict, temp_arr, x_ini, x_default); \
- token = strtok_r( temp_arr, delimiters, &usr_ptr ); \
- while (token) \
- { \
- if ( index > x_list_max -1) \
- { \
+ token = strtok_r(temp_arr, delimiters, &usr_ptr); \
+ while (token) { \
+ if (index > x_list_max -1) { \
MD_E("%d is not valid index\n", index); \
break; \
- } \
- else \
- { \
+ } else { \
value = atoi(token); \
x_list[index] = value; \
index++; \
} \
- token = strtok_r( NULL, delimiters, &usr_ptr ); \
+ token = strtok_r(NULL, delimiters, &usr_ptr); \
} \
- }while(0)
+ } while (0)
int md_ini_load(md_ini_t *ini)
{
if (dict) { /* if dict is available */
/* general */
- MEDIADEMUXER_INI_GET_STRING(dict, ini->port_name,
- "port_in_use:mediademuxer_port",
- DEFAULT_PORT);
+ MEDIADEMUXER_INI_GET_STRING(dict, ini->port_name, "port_in_use:mediademuxer_port", DEFAULT_PORT);
} else { /* if dict is not available just fill the structure with default value */
MD_W("failed to load ini. using hardcoded default\n");
- strncpy(ini->port_name, DEFAULT_PORT,
- MEDIADEMUXER_INI_MAX_STRLEN - 1);
+ strncpy(ini->port_name, DEFAULT_PORT, MEDIADEMUXER_INI_MAX_STRLEN - 1);
}
if (0 == strcmp(ini->port_name, "GST_PORT"))
if (ini_buff.st_size < 5) {
MD_W("demuxer.ini file size=%d, Corrupted! So, Removed\n", (int)ini_buff.st_size);
- if (g_remove(MEDIADEMUXER_INI_DEFAULT_PATH) == -1) {
+ if (g_remove(MEDIADEMUXER_INI_DEFAULT_PATH) == -1)
MD_E("failed to delete corrupted ini");
- }
}
}
}
/* create new file */
fp = fopen(MEDIADEMUXER_INI_DEFAULT_PATH, "wt");
- if (!fp) {
+ if (!fp)
return FALSE;
- }
/* writing default ini file */
if (strlen(default_ini) !=
- fwrite(default_ini, 1, strlen(default_ini), fp)) {
+ fwrite(default_ini, 1, strlen(default_ini), fp)) {
fclose(fp);
return FALSE;
}
}
#endif
-#endif /* #ifdef _MEDIADEMUXER_INI_C_ */
+#endif /* #ifdef _MEDIADEMUXER_INI_C_ */
/* load ini files */
result = md_ini_load(&new_demuxer->ini);
MEDIADEMUXER_CHECK_SET_AND_PRINT(result, MD_ERROR_NONE, result,
- MD_COURRPTED_INI, "can't load ini");
+ MD_COURRPTED_INI, "can't load ini");
register_port_func[new_demuxer->ini.port_type](pOps);
result = pOps->init(&new_demuxer->mdport_handle);
MEDIADEMUXER_CHECK_SET_AND_PRINT(result, MD_ERROR_NONE, result,
- MD_NOT_INITIALIZED,
- "md_create failed");
+ MD_NOT_INITIALIZED, "md_create failed");
*demuxer = (MMHandleType) new_demuxer;
MEDIADEMUXER_FLEAVE();
return result;
MEDIADEMUXER_FENTER();
return_val_if_fail(path, FALSE);
uri = g_ascii_strdown(path, -1);
- if (uri == NULL) {
+ if (uri == NULL)
return FALSE;
- }
/* trimming */
g_strstrip(uri);
/* strlen(".sdp") == 4 */
/* first, check extension name */
ret = g_str_has_suffix(uri, "sdp");
/* second, if no suffix is there, check it's contents */
- if (!ret) {
+ if (!ret)
/* FIXIT : do it soon */
- }
g_free(uri);
uri = NULL;
MEDIADEMUXER_FLEAVE();
}
} else if ((path = strstr(*uri, "rtsp://"))) {
if (strlen(path)) {
- if ((path = strstr(*uri, "/wfd1.0/"))) {
+ if ((path = strstr(*uri, "/wfd1.0/")))
return (MEDIADEMUXER_SRC_WFD);
- } else {
+ else
return (MEDIADEMUXER_SRC_RTSP);
- }
}
} else if ((path = strstr(*uri, "http://"))) {
if (strlen(path)) {
MEDIADEMUXER_CHECK_NULL(demuxer);
result = _md_util_parse(demuxer, (const char *)uri);
MEDIADEMUXER_CHECK_SET_AND_PRINT(result, MD_ERROR_NONE, result,
- MD_ERROR_INVALID_ARGUMENT,
- "error while parsing the file");
+ MD_ERROR_INVALID_ARGUMENT,
+ "error while parsing the file");
MEDIADEMUXER_FLEAVE();
return result;
ERROR:
MEDIADEMUXER_CHECK_NULL(pOps);
result = pOps->prepare(md_handle->mdport_handle, md_handle->uri_src);
MEDIADEMUXER_CHECK_SET_AND_PRINT(result, MD_ERROR_NONE, result,
- MD_ERROR, "error while doing prepare");
+ MD_ERROR, "error while doing prepare");
MEDIADEMUXER_FLEAVE();
return result;
ERROR:
MEDIADEMUXER_CHECK_NULL(pOps);
result = pOps->get_track_count(md_handle->mdport_handle, count);
MEDIADEMUXER_CHECK_SET_AND_PRINT(result, MD_ERROR_NONE,
- result, MD_ERROR,
- "error while getting track count");
+ result, MD_ERROR,
+ "error while getting track count");
MEDIADEMUXER_FLEAVE();
return result;
ERROR:
MEDIADEMUXER_CHECK_NULL(pOps);
result = pOps->set_track(md_handle->mdport_handle, track);
MEDIADEMUXER_CHECK_SET_AND_PRINT(result, MD_ERROR_NONE, result,
- MD_ERROR, "error select track");
+ MD_ERROR, "error select track");
MEDIADEMUXER_FLEAVE();
return result;
ERROR:
MEDIADEMUXER_CHECK_NULL(pOps);
result = pOps->start(md_handle->mdport_handle);
MEDIADEMUXER_CHECK_SET_AND_PRINT(result, MD_ERROR_NONE, result,
- MD_ERROR, "error while doing start");
+ MD_ERROR, "error while doing start");
MEDIADEMUXER_FLEAVE();
return result;
ERROR:
MEDIADEMUXER_CHECK_NULL(pOps);
result = pOps->get_track_info(md_handle->mdport_handle, format, track);
MEDIADEMUXER_CHECK_SET_AND_PRINT(result, MD_ERROR_NONE,
- result, MD_ERROR,
- "error while getting track count");
+ result, MD_ERROR,
+ "error while getting track count");
MEDIADEMUXER_FLEAVE();
return result;
ERROR:
MEDIADEMUXER_CHECK_NULL(pOps);
result = pOps->seek(md_handle->mdport_handle, pos);
MEDIADEMUXER_CHECK_SET_AND_PRINT(result, MD_ERROR_NONE, result,
- MD_ERROR, "error while doing seek");
+ MD_ERROR, "error while doing seek");
MEDIADEMUXER_FLEAVE();
return result;
ERROR:
MEDIADEMUXER_CHECK_NULL(pOps);
result = pOps->unset_track(md_handle->mdport_handle, track);
MEDIADEMUXER_CHECK_SET_AND_PRINT(result, MD_ERROR_NONE, result,
- MD_ERROR, "error unselect track");
+ MD_ERROR, "error unselect track");
MEDIADEMUXER_FLEAVE();
return result;
ERROR:
MEDIADEMUXER_CHECK_NULL(pOps);
result = pOps->stop(md_handle->mdport_handle);
MEDIADEMUXER_CHECK_SET_AND_PRINT(result, MD_ERROR_NONE, result,
- MD_ERROR, "error while doing stop");
+ MD_ERROR, "error while doing stop");
MEDIADEMUXER_FLEAVE();
return result;
ERROR:
MEDIADEMUXER_CHECK_NULL(pOps);
result = pOps->unprepare(md_handle->mdport_handle);
MEDIADEMUXER_CHECK_SET_AND_PRINT(result, MD_ERROR_NONE, result,
- MD_ERROR, "error while doing stop");
+ MD_ERROR, "error while doing stop");
MEDIADEMUXER_FLEAVE();
return result;
ERROR:
MEDIADEMUXER_CHECK_NULL(pOps);
result = pOps->destroy(md_handle->mdport_handle);
MEDIADEMUXER_CHECK_SET_AND_PRINT(result, MD_ERROR_NONE, result,
- MD_ERROR, "error while doing destroy");
+ MD_ERROR, "error while doing destroy");
/* free mediademuxer structure */
if (md_handle) {
}
if (md_handle->uri_src) {
MD_I("md_destroy deallocating md_handle->uri_src %p:\n",
- md_handle->uri_src);
+ md_handle->uri_src);
g_free((void *)(md_handle->uri_src));
}
MD_I("md_destroy deallocating md_handle %p:\n", md_handle);
MEDIADEMUXER_CHECK_NULL(md_handle);
media_port_demuxer_ops *pOps = md_handle->demuxer_ops;
MEDIADEMUXER_CHECK_NULL(pOps);
- result = pOps->set_error_cb(md_handle->mdport_handle, callback,user_data);
+ result = pOps->set_error_cb(md_handle->mdport_handle, callback, user_data);
MEDIADEMUXER_CHECK_SET_AND_PRINT(result, MD_ERROR_NONE, result,
MD_ERROR, "error while setting error call back");
MEDIADEMUXER_FLEAVE();
static int custom_demuxer_init(MMHandleType *pHandle);
static int custom_demuxer_prepare(MMHandleType pHandle, char *uri);
static int custom_demuxer_get_data_count(MMHandleType pHandle, int *count);
-static int custom_demuxer_get_track_info(MMHandleType pHandle,
- media_format_h *format, int track);
+static int custom_demuxer_get_track_info(MMHandleType pHandle, media_format_h *format, int track);
static int custom_demuxer_set_track(MMHandleType pHandle, int track);
static int custom_demuxer_get_data(MMHandleType pHandle, char *buffer);
-/*Media Demuxer API common*/
+/* Media Demuxer API common */
static media_port_demuxer_ops def_demux_ops = {
.n_size = 0,
.init = custom_demuxer_init,
def_demux_ops.n_size = sizeof(def_demux_ops);
- memcpy((char *)pOps + sizeof(pOps->n_size),
- (char *)&def_demux_ops + sizeof(def_demux_ops.n_size),
- pOps->n_size - sizeof(pOps->n_size));
+ memcpy((char *)pOps + sizeof(pOps->n_size), (char *)&def_demux_ops + sizeof(def_demux_ops.n_size), pOps->n_size - sizeof(pOps->n_size));
MEDIADEMUXER_FLEAVE();
return ret;
return 0;
}
-
static int custom_demuxer_get_data_count(MMHandleType pHandle, int *count)
{
MEDIADEMUXER_FENTER();
return 0;
}
-static int custom_demuxer_get_track_info(MMHandleType pHandle,
- media_format_h *format, int track)
+static int custom_demuxer_get_track_info(MMHandleType pHandle, media_format_h *format, int track)
{
MEDIADEMUXER_FENTER();
MD_E("%s:exit: Not implemented\n", __func__);
static int ffmpeg_demuxer_init(MMHandleType *pHandle);
static int ffmpeg_demuxer_prepare(MMHandleType pHandle, char *uri);
static int ffmpeg_demuxer_get_data_count(MMHandleType pHandle, int *count);
-static int ffmpeg_demuxer_get_track_info(MMHandleType pHandle,
- media_format_h *format, int track);
+static int ffmpeg_demuxer_get_track_info(MMHandleType pHandle, media_format_h *format, int track);
static int ffmpeg_demuxer_set_track(MMHandleType pHandle, int track);
static int ffmpeg_demuxer_get_data(MMHandleType pHandle, char *buffer);
-/*Media Demuxer API common*/
+/* Media Demuxer API common */
static media_port_demuxer_ops def_demux_ops = {
.n_size = 0,
.init = ffmpeg_demuxer_init,
def_demux_ops.n_size = sizeof(def_demux_ops);
- memcpy((char *)pOps + sizeof(pOps->n_size),
- (char *)&def_demux_ops + sizeof(def_demux_ops.n_size),
- pOps->n_size - sizeof(pOps->n_size));
+ memcpy((char *)pOps + sizeof(pOps->n_size), (char *)&def_demux_ops + sizeof(def_demux_ops.n_size), pOps->n_size - sizeof(pOps->n_size));
MEDIADEMUXER_FLEAVE();
return ret;
return ret;
}
-static int ffmpeg_demuxer_get_track_info(MMHandleType pHandle,
- media_format_h *format, int track)
+static int ffmpeg_demuxer_get_track_info(MMHandleType pHandle, media_format_h *format, int track)
{
int ret = MD_ERROR_NONE;
MEDIADEMUXER_FENTER();
static int gst_set_error_cb(MMHandleType pHandle,
gst_error_cb callback, void* user_data);
-/*Media Demuxer API common*/
+/* Media Demuxer API common */
static media_port_demuxer_ops def_demux_ops = {
.n_size = 0,
.init = gst_demuxer_init,
MEDIADEMUXER_FENTER();
int ret = MD_ERROR_NONE;
switch (GST_MESSAGE_TYPE(msg)) {
- case GST_MESSAGE_EOS: {
- MD_I("EOS Reached");
- }
- break;
- case GST_MESSAGE_ERROR: {
- GError *error = NULL;
- gst_message_parse_error(msg, &error, NULL);
- if (!error) {
- MD_I("GST error message parsing failed");
- break;
- }
- MD_E("Error: %s\n", error->message);
- g_error_free(error);
+ case GST_MESSAGE_EOS: {
+ MD_I("EOS Reached");
+ }
+ break;
+ case GST_MESSAGE_ERROR: {
+ GError *error = NULL;
+ gst_message_parse_error(msg, &error, NULL);
+ if (!error) {
+ MD_I("GST error message parsing failed");
+ break;
}
- break;
- default:
- break;
+ MD_E("Error: %s\n", error->message);
+ g_error_free(error);
+ }
+ break;
+ default:
+ break;
}
MEDIADEMUXER_FLEAVE();
return ret;
while (temp) {
/*
if (temp->pad) {
- MD_I("deallocate GST_PAD %p\n", temp->pad);
- gst_object_unref(temp->pad);
+ MD_I("deallocate GST_PAD %p\n", temp->pad);
+ gst_object_unref(temp->pad);
} */
if (temp->name) {
MD_I("deallocate GST_PAD name %p\n", temp->name);
}
int __gst_add_track_info(GstPad *pad, gchar *name, track **head,
- GstElement *pipeline)
+ GstElement *pipeline)
{
MEDIADEMUXER_FENTER();
GstPad *apppad = NULL;
gst_object_unref(apppad);
return MD_ERROR;
}
- gst_bin_add_many(GST_BIN(pipeline),parse_element, NULL);
+ gst_bin_add_many(GST_BIN(pipeline), parse_element, NULL);
MEDIADEMUXER_SET_STATE(parse_element, GST_STATE_PAUSED, ERROR);
parse_sink_pad = gst_element_get_static_pad(parse_element, "sink");
return MD_ERROR;
}
- /* Link demuxer pad with sink pad of parse element*/
+ /* Link demuxer pad with sink pad of parse element */
MEDIADEMUXER_LINK_PAD(pad, parse_sink_pad, ERROR);
- outcaps = gst_caps_new_simple("video/x-h264", "stream-format",G_TYPE_STRING, "byte-stream", NULL);
+ outcaps = gst_caps_new_simple("video/x-h264", "stream-format", G_TYPE_STRING, "byte-stream", NULL);
gst_element_link_filtered(parse_element, temp->appsink, outcaps);
} else {
MEDIADEMUXER_LINK_PAD(pad, apppad, ERROR);
}
- /*gst_pad_link(pad, fpad) */
+ /* gst_pad_link(pad, fpad) */
if (*head == NULL) {
*head = temp;
} else {
track *prev = *head;
- while (prev->next) {
+ while (prev->next)
prev = prev->next;
- }
prev->next = temp;
}
gst_object_unref(apppad);
MD_E("fail to get typefind src pad.\n");
goto ERROR;
}
- if (!id3tag) {
+ if (!id3tag)
aud_pad = gst_element_get_static_pad(gst_handle->demux, "sink");
- } else {
+ else
aud_pad = gst_element_get_static_pad(id3tag, "sink");
- }
if (!aud_pad) {
MD_E("fail to get audio parse sink pad.\n");
goto ERROR;
gst_object_unref(fake_pad);
}
- /* calling "on_pad_added" function to set the caps*/
+ /* calling "on_pad_added" function to set the caps */
aud_srcpad = gst_element_get_static_pad(gst_handle->demux, "src");
if (!aud_srcpad) {
MD_E("fail to get audioparse source pad.\n");
gst_object_unref(aud_srcpad);
trck = head_track->head;
- while (aud_srcpad != trck->pad && trck != NULL) {
+ while (aud_srcpad != trck->pad && trck != NULL)
trck = trck->next;
- }
if (trck != NULL) {
trck->caps = caps;
trck->caps_string = gst_caps_to_string(trck->caps);
- MD_I("caps set to %s\n",trck->caps_string);
- g_strlcpy(name,"audio",strlen(name));
+ MD_I("caps set to %s\n", trck->caps_string);
+ g_strlcpy(name, "audio", strlen(name));
trck->name = name;
}
(head_track->num_audio_track)++;
}
static void __gst_cb_typefind(GstElement *tf, guint probability,
- GstCaps *caps, gpointer data)
+ GstCaps *caps, gpointer data)
{
MEDIADEMUXER_FENTER();
mdgst_handle_t *gst_handle = (mdgst_handle_t *) data;
goto ERROR;
} else {
g_signal_connect(gst_handle->demux, "pad-added",
- G_CALLBACK(__gst_on_pad_added), gst_handle);
+ G_CALLBACK(__gst_on_pad_added), gst_handle);
g_signal_connect(gst_handle->demux, "no-more-pads",
- G_CALLBACK(__gst_no_more_pad), gst_handle);
+ G_CALLBACK(__gst_no_more_pad), gst_handle);
gst_bin_add_many(GST_BIN(gst_handle->pipeline),
- gst_handle->demux, NULL);
+ gst_handle->demux, NULL);
pad = gst_element_get_static_pad(gst_handle->typefind, "src");
if (!pad) {
MD_E("fail to get typefind src pad.\n");
gst_pad_unlink(pad, fake_pad);
MEDIADEMUXER_LINK_PAD(pad, qt_pad, ERROR);
MEDIADEMUXER_SET_STATE(gst_handle->demux,
- GST_STATE_PAUSED, ERROR);
+ GST_STATE_PAUSED, ERROR);
if (pad)
gst_object_unref(pad);
if (qt_pad)
goto ERROR;
}
g_signal_connect(gst_handle->typefind, "have-type",
- G_CALLBACK(__gst_cb_typefind), gst_handle);
+ G_CALLBACK(__gst_cb_typefind), gst_handle);
gst_handle->fakesink = gst_element_factory_make("fakesink", NULL);
if (!gst_handle->fakesink) {
MD_E("fakesink creation failed");
/* Build the pipeline */
gst_bin_add_many(GST_BIN(gst_handle->pipeline),
- gst_handle->filesrc,
- gst_handle->typefind,
- gst_handle->fakesink,
- NULL);
+ gst_handle->filesrc,
+ gst_handle->typefind,
+ gst_handle->fakesink,
+ NULL);
gst_element_link_many(gst_handle->filesrc,
- gst_handle->typefind,
- gst_handle->fakesink,
- NULL);
+ gst_handle->typefind,
+ gst_handle->fakesink,
+ NULL);
/* connect signals, bus watcher */
bus = gst_pipeline_get_bus(GST_PIPELINE(gst_handle->pipeline));
mdgst_handle_t *new_mediademuxer = (mdgst_handle_t *) pHandle;
*count = (new_mediademuxer->info).num_video_track +
- (new_mediademuxer->info).num_audio_track +
- (new_mediademuxer->info).num_subtitle_track +
- (new_mediademuxer->info).num_other_track;
+ (new_mediademuxer->info).num_audio_track +
+ (new_mediademuxer->info).num_subtitle_track +
+ (new_mediademuxer->info).num_other_track;
MEDIADEMUXER_FLEAVE();
return ret;
ERROR:
}
new_mediademuxer->selected_tracks[track] = true;
_gst_set_appsink((((mdgst_handle_t *) pHandle)->info).head, track,
- new_mediademuxer->total_tracks);
+ new_mediademuxer->total_tracks);
MEDIADEMUXER_FLEAVE();
return MD_ERROR_NONE;
ERROR:
int indx;
for (indx = 0; indx < gst_handle->total_tracks; indx++) {
MD_I("track indx[%d] is marked as [%d]. (0- not selected, 1= selected)\n",
- indx, gst_handle->selected_tracks[indx]);
+ indx, gst_handle->selected_tracks[indx]);
/*
if (gst_handle->selected_tracks[indx] == false)
_gst_demuxer_unset(pHandle, indx);
track_info *head_track = &(gst_handle->info);
MD_I("Total Audio track=%d, Video track=%d, text track=%d\n",
- head_track->num_audio_track, head_track->num_video_track,
- head_track->num_subtitle_track);
+ head_track->num_audio_track, head_track->num_video_track,
+ head_track->num_subtitle_track);
track *temp = head_track->head;
indx = 0;
while (temp) {
MD_I("Got one element %p\n", temp->appsink);
if (gst_element_set_state(temp->appsink, GST_STATE_PLAYING) ==
- GST_STATE_CHANGE_FAILURE) {
+ GST_STATE_CHANGE_FAILURE) {
MD_E("Failed to set into PLAYING state");
ret = MD_ERROR_UNKNOWN;
}
goto ERROR;
}
- if (gst_structure_has_name(struc, "application/x-id3")) {
+ if (gst_structure_has_name(struc, "application/x-id3"))
id3_flag = 1;
- }
if (gst_structure_has_name(struc, "audio/mpeg") || id3_flag) {
gint mpegversion;
int layer;
gst_structure_get_int(struc, "mpegversion", &mpegversion);
- if (mpegversion == 4 || mpegversion == 2 ) {
+ if (mpegversion == 4 || mpegversion == 2) {
gst_structure_get_int(struc, "channels", &channels);
gst_structure_get_int(struc, "rate", &rate);
gst_structure_get_int(struc, "bit", &bit);
stream_format = gst_structure_get_string(struc, "stream-format");
if (media_format_set_audio_mime(format, MEDIA_FORMAT_AAC_LC))
goto ERROR;
- if(channels == 0)
- channels = 2; /* default */
+ if (channels == 0)
+ channels = 2; /* default */
if (media_format_set_audio_channel(format, channels))
goto ERROR;
- if(rate == 0)
- rate = 44100; /* default */
+ if (rate == 0)
+ rate = 44100; /* default */
if (media_format_set_audio_samplerate(format, rate))
goto ERROR;
- if(bit == 0) {
- bit = 16; /* default */
- }
- if (media_format_set_audio_bit(format, bit)) {
+ if (bit == 0)
+ bit = 16; /* default */
+ if (media_format_set_audio_bit(format, bit))
goto ERROR;
- }
if (strncmp(stream_format, "adts", 4) == 0)
media_format_set_audio_aac_type(format, 1);
else
media_format_set_audio_aac_type(format, 0);
}
- if (mpegversion == 1 || id3_flag ) {
+ if (mpegversion == 1 || id3_flag) {
gst_structure_get_int(struc, "layer", &layer);
- if((layer == 3) || (id3_flag == 1)) {
+ if ((layer == 3) || (id3_flag == 1)) {
gst_structure_get_int(struc, "channels", &channels);
gst_structure_get_int(struc, "rate", &rate);
gst_structure_get_int(struc, "bit", &bit);
if (media_format_set_audio_mime(format, MEDIA_FORMAT_MP3))
goto ERROR;
- if(channels == 0)
- channels = 2; /* default */
+ if (channels == 0)
+ channels = 2; /* default */
if (media_format_set_audio_channel(format, channels))
goto ERROR;
- if(rate == 0)
- rate = 44100; /* default */
- if(bit == 0)
- bit = 16; /* default */
+ if (rate == 0)
+ rate = 44100; /* default */
+ if (bit == 0)
+ bit = 16; /* default */
if (media_format_set_audio_samplerate(format, rate))
goto ERROR;
if (media_format_set_audio_bit(format, bit))
goto ERROR;
- }
- else {
- MD_I("No Support for MPEG%d Layer %d media\n",mpegversion,layer);
+ } else {
+ MD_I("No Support for MPEG%d Layer %d media\n", mpegversion, layer);
goto ERROR;
}
}
- }else if (gst_structure_has_name(struc, "audio/x-amr-nb-sh") ||
+ } else if (gst_structure_has_name(struc, "audio/x-amr-nb-sh") ||
gst_structure_has_name(struc, "audio/x-amr-wb-sh")) {
media_format_mimetype_e mime_type;
gst_structure_get_int(struc, "channels", &channels);
gst_structure_get_int(struc, "rate", &rate);
if (gst_structure_has_name(struc, "audio/x-amr-nb-sh")) {
- mime_type= MEDIA_FORMAT_AMR_NB;
+ mime_type = MEDIA_FORMAT_AMR_NB;
rate = 8000;
- }
- else {
+ } else {
mime_type = MEDIA_FORMAT_AMR_WB;
rate = 16000;
}
- if (media_format_set_audio_mime(format,mime_type))
+ if (media_format_set_audio_mime(format, mime_type))
goto ERROR;
- if(channels == 0)
- channels = 1; /* default */
- if(bit == 0)
- bit = 16; /* default */
+ if (channels == 0)
+ channels = 1; /* default */
+ if (bit == 0)
+ bit = 16; /* default */
if (media_format_set_audio_channel(format, channels))
goto ERROR;
if (media_format_set_audio_samplerate(format, rate))
gst_structure_get_int(struc, "bit", &bit);
if (media_format_set_audio_mime(format, MEDIA_FORMAT_AMR_NB))
goto ERROR;
- if(channels == 0)
- channels = 1; /* default */
+ if (channels == 0)
+ channels = 1; /* default */
if (media_format_set_audio_channel(format, channels))
goto ERROR;
if (media_format_set_audio_samplerate(format, rate))
goto ERROR;
if (bit == 0)
- bit = 16; /* default */
+ bit = 16; /* default */
if (media_format_set_audio_bit(format, bit))
goto ERROR;
} else if (gst_structure_has_name(struc, "audio/AMR-WB")) {
gst_structure_get_int(struc, "bit", &bit);
if (media_format_set_audio_mime(format, MEDIA_FORMAT_AMR_WB))
goto ERROR;
- if(channels == 0)
- channels = 1; /* default */
+ if (channels == 0)
+ channels = 1; /* default */
if (media_format_set_audio_channel(format, channels))
goto ERROR;
if (media_format_set_audio_samplerate(format, rate))
goto ERROR;
if (bit == 0)
- bit = 16; /* default */
+ bit = 16; /* default */
if (media_format_set_audio_bit(format, bit))
goto ERROR;
} else {
}
static int gst_demuxer_get_track_info(MMHandleType pHandle,
- media_format_h *format, int index)
+ media_format_h *format, int index)
{
MEDIADEMUXER_FENTER();
int ret = MD_ERROR_NONE;
int count = 0;
temp = (new_mediademuxer->info).head;
loop = (new_mediademuxer->info).num_video_track +
- (new_mediademuxer->info).num_audio_track +
- (new_mediademuxer->info).num_subtitle_track +
- (new_mediademuxer->info).num_other_track;
+ (new_mediademuxer->info).num_audio_track +
+ (new_mediademuxer->info).num_subtitle_track +
+ (new_mediademuxer->info).num_other_track;
if (index >= loop || index < 0) {
MD_E("total tracks(loop) is less then selected track(index), So not support this track");
goto ERROR;
}
ret = media_format_create(format);
- if(ret != MEDIA_FORMAT_ERROR_NONE){
- MD_E("Mediaformat creation failed. returned %d\n",ret);
+ if (ret != MEDIA_FORMAT_ERROR_NONE) {
+ MD_E("Mediaformat creation failed. returned %d\n", ret);
ret = MD_INTERNAL_ERROR;
goto ERROR;
}
} else if (temp->name[0] == 'v') {
MD_I("Setting for Video \n");
_set_mime_video(*format, temp);
- } else {
+ } else
MD_I("Not supported so far (except audio and video)\n");
- }
MEDIADEMUXER_FLEAVE();
return ret;
ERROR:
}
static int _gst_copy_buf_to_media_packet(media_packet_h out_pkt,
- GstBuffer *buffer, char *codec_data)
+ GstBuffer *buffer, char *codec_data)
{
MEDIADEMUXER_FENTER();
int ret = MD_ERROR_NONE;
ret = MD_ERROR_UNKNOWN;
goto ERROR;
}
- /* copy data*/
+ /* copy data */
media_packet_get_buffer_size(out_pkt, &size);
MD_I("Media packet Buffer capacity: %llu GST Buffer size = %d\n", size, map.size);
if (size < (uint64_t)map.size) {
ret = MD_ERROR_UNKNOWN;
goto ERROR;
}
- if (media_packet_set_buffer_size(out_pkt, gst_buffer_get_size(buffer))) {
+ if (media_packet_set_buffer_size(out_pkt, gst_buffer_get_size(buffer))) {
MD_E("unable to set the buffer size\n");
ret = MD_ERROR_UNKNOWN;
goto ERROR;
}
- if (media_packet_set_flags(out_pkt, GST_BUFFER_FLAGS(buffer))) {
+ if (media_packet_set_flags(out_pkt, GST_BUFFER_FLAGS(buffer))) {
MD_E("unable to set the buffer size\n");
ret = MD_ERROR_UNKNOWN;
goto ERROR;
}
static int gst_demuxer_read_sample(MMHandleType pHandle,
- media_packet_h *outbuf, int track_indx)
+ media_packet_h *outbuf, int track_indx)
{
MEDIADEMUXER_FENTER();
int ret = MD_ERROR_NONE;
goto ERROR;
}
while (atrack) {
- if (indx == track_indx) /*Got the requird track details*/
+ if (indx == track_indx) /* Got the requird track details */
break;
if (atrack->next) {
track *next = atrack->next;
ret = MD_ERROR;
goto ERROR;
}
- }
- else if (atrack->name[0] == 'v'){
+ } else if (atrack->name[0] == 'v') {
if (media_format_create(&mediafmt)) {
MD_E("media_format_create failed\n");
ret = MD_ERROR;
ret = MD_ERROR;
goto ERROR;
}
- }
- else {
+ } else {
MD_E("Invalid track format\n");
goto ERROR;
}
/* Create the codec data and pass to _gst_copy_buf_to_media_packet() to add into the media packet */
temp_codec_data = strstr(atrack->caps_string, "codec_data");
if (temp_codec_data != NULL) {
- while (*temp_codec_data != ')') {
+ while (*temp_codec_data != ')')
temp_codec_data++;
- }
temp_codec_data++; /* to esacpe ')' */
codec_data = (char*) malloc(sizeof(char)*strlen(temp_codec_data));
if (codec_data != NULL) {
}
new_mediademuxer->selected_tracks[track] = false;
_gst_unset_appsink((((mdgst_handle_t *) pHandle)->info).head, track,
- new_mediademuxer->total_tracks);
+ new_mediademuxer->total_tracks);
MEDIADEMUXER_FLEAVE();
return MD_ERROR_NONE;
ERROR:
g_free(gst_handle->selected_tracks);
gst_handle->selected_tracks = NULL;
}
- if ((gst_handle->info).head) {
+ if ((gst_handle->info).head)
__gst_free_stuct(&(gst_handle->info).head);
- }
MEDIADEMUXER_FLEAVE();
}
goto ERROR;
}
- if(gst_handle->user_cb[_GST_EVENT_TYPE_ERROR]) {
+ if (gst_handle->user_cb[_GST_EVENT_TYPE_ERROR]) {
MD_E("Already set mediademuxer_error_cb\n");
ret = MD_ERROR_INVALID_ARGUMENT;
goto ERROR;
- }
- else {
+ } else {
if (!callback) {
MD_E("fail invaild argument (callback)\n");
ret = MD_ERROR_INVALID_ARGUMENT;
media_format_mimetype_e a_mime;
int g_menu_state = CURRENT_STATUS_MAINMENU;
int num_tracks = 0;
-int aud_track =-1;
-int vid_track =-1;
+int aud_track = -1;
+int vid_track = -1;
int w;
int h;
int channel = 0;
if (ret != MD_ERROR_NONE) {\
printf("[%s:%d] error code : %x \n", __func__, __LINE__, ret); \
return; \
- }\
- } while(0)
+ } \
+ } while (0)
-#define debug_msg_t(fmt,arg...)\
+#define debug_msg_t(fmt, arg...)\
do { \
- fprintf(stderr, MMF_DEBUG"[%s:%05d] " fmt "\n",__func__, __LINE__, ##arg); \
- } while(0)
+ fprintf(stderr, MMF_DEBUG"[%s:%05d] " fmt "\n", __func__, __LINE__, ##arg); \
+ } while (0)
-#define err_msg_t(fmt,arg...)\
+#define err_msg_t(fmt, arg...)\
do { \
- fprintf(stderr, MMF_ERR"[%s:%05d] " fmt "\n",__func__, __LINE__, ##arg); \
- } while(0)
+ fprintf(stderr, MMF_ERR"[%s:%05d] " fmt "\n", __func__, __LINE__, ##arg); \
+ } while (0)
-#define info_msg_t(fmt,arg...)\
+#define info_msg_t(fmt, arg...)\
do { \
- fprintf(stderr, MMF_INFO"[%s:%05d] " fmt "\n",__func__, __LINE__, ##arg); \
- } while(0)
+ fprintf(stderr, MMF_INFO"[%s:%05d] " fmt "\n", __func__, __LINE__, ##arg); \
+ } while (0)
-#define warn_msg_t(fmt,arg...)\
+#define warn_msg_t(fmt, arg...)\
do { \
- fprintf(stderr, MMF_WARN"[%s:%05d] " fmt "\n",__func__, __LINE__, ##arg); \
- } while(0)
+ fprintf(stderr, MMF_WARN"[%s:%05d] " fmt "\n", __func__, __LINE__, ##arg); \
+ } while (0)
/*-----------------------------------------------------------------------
#define AMR_NB_MIME_HDR_SIZE 6
#define AMR_WB_MIME_HDR_SIZE 9
-static const char AMRNB_HDR [] = "#!AMR\n";
-static const char AMRWB_HDR [] = "#!AMR-WB\n";
-int write_amrnb_header = 0; /* write magic number for AMR-NB Header at one time */
-int write_amrwb_header = 0; /* write magic number for AMR-WB Header at one time */
+static const char AMRNB_HDR[] = "#!AMR\n";
+static const char AMRWB_HDR[] = "#!AMR-WB\n";
+int write_amrnb_header = 0; /* write magic number for AMR-NB Header at one time */
+int write_amrwb_header = 0; /* write magic number for AMR-WB Header at one time */
#endif
bool validate_with_codec = false;
**/
void generate_header_aac_adts(unsigned char *buffer, int packetLen)
{
- int profile = 2; //AAC LC (0x01)
- int freqIdx = 4; //44KHz (0x04)
- int chanCfg = 1; //CPE (0x01)
+ int profile = 2; /* AAC LC (0x01) */
+ int freqIdx = 4; /* 44KHz (0x04) */
+ int chanCfg = 1; /* CPE (0x01) */
if (samplerate == 96000) freqIdx = 0;
else if (samplerate == 88200) freqIdx = 1;
if (fp_audio_out != NULL) {
validate_dump = true;
fp_video_out = fopen("/opt/usr/dump_video.out", "wb");
- } else {
+ } else
g_print("Error - Cannot open file for file dump, Please chek root\n");
- }
#endif
ret = mediademuxer_set_data_source(demuxer, path);
int test_mediademuxer_select_track()
{
- int track = 0;
+ int track = 0;
g_print("test_mediademuxer_select_track\n");
for (track = 0; track < num_tracks; track++) {
if (mediademuxer_select_track(demuxer, track)) {
for (; track < num_tracks; track++) {
if (ret == 0) {
g_print("g_media_format[%d] is created successfully! \n", track);
- ret = mediademuxer_get_track_info(demuxer, track,
- &g_media_format[track]);
+ ret = mediademuxer_get_track_info(demuxer, track, &g_media_format[track]);
if (ret == 0) {
if (media_format_get_video_info(g_media_format[track], &v_mime,
- &w, &h, NULL, NULL) == MEDIA_FORMAT_ERROR_NONE) {
+ &w, &h, NULL, NULL) == MEDIA_FORMAT_ERROR_NONE) {
g_print("media_format_get_video_info is sucess!\n");
g_print("\t\t[media_format_get_video]mime:%x, width :%d, height :%d\n",
- v_mime, w, h);
+ v_mime, w, h);
vid_track = track;
} else if (media_format_get_audio_info(g_media_format[track], &a_mime,
- &channel, &samplerate, &bit, NULL) == MEDIA_FORMAT_ERROR_NONE) {
+ &channel, &samplerate, &bit, NULL) == MEDIA_FORMAT_ERROR_NONE) {
g_print("media_format_get_audio_info is sucess!\n");
g_print("\t\t[media_format_get_audio]mime:%x, channel :%d, samplerate :%d, bit :%d\n",
- a_mime, channel, samplerate, bit);
+ a_mime, channel, samplerate, bit);
media_format_get_audio_aac_type(g_media_format[track], &is_adts);
aud_track = track;
} else {
return;
}
err = mediacodec_destroy(handle);
- if (err != MEDIACODEC_ERROR_NONE) {
+ if (err != MEDIACODEC_ERROR_NONE)
g_print("mediacodec_destory failed error = %d \n", err);
- }
return;
}
if (err == MEDIACODEC_ERROR_NONE) {
media_packet_get_buffer_size(output_buf, &buf_size);
media_packet_get_buffer_data_ptr(output_buf, &data);
- if (data != NULL) {
+ if (data != NULL)
fwrite(data, 1, buf_size, fp_out_codec_audio);
- } else {
+ else
g_print("Data is null inside _mediacodec_fill_audio_buffer_cb\n");
- }
media_packet_destroy(output_buf);
} else {
return;
}
/* set the audio dec info */
- if ((mediacodec_set_adec_info(g_media_codec, samplerate, channel, bit))!= MEDIACODEC_ERROR_NONE) {
+ if ((mediacodec_set_adec_info(g_media_codec, samplerate, channel, bit)) != MEDIACODEC_ERROR_NONE) {
g_print("mediacodec_set_adec is failed\n");
return;
}
{
if (g_media_codec != NULL) {
/* process the media packet */
- if (MEDIACODEC_ERROR_NONE != mediacodec_process_input (g_media_codec, in_buf, 0)) {
+ if (MEDIACODEC_ERROR_NONE != mediacodec_process_input(g_media_codec, in_buf, 0)) {
g_print("mediacodec_process_input is failed inside mediacodec_process_audio_pkt\n");
return;
}
fwrite(&buf_adts[0], 1, ADTS_HEADER_SIZE, fp_audio_out);
} else if ((a_mime == MEDIA_FORMAT_AMR_NB) && (write_amrnb_header == 1)) {
/* This is used only AMR-NB case for adding magic header in only first frame */
- g_print("%s - AMRNB_HDR write in first frame\n",__func__);
+ g_print("%s - AMRNB_HDR write in first frame\n", __func__);
fwrite(&AMRNB_HDR[0], 1, sizeof(AMRNB_HDR) - 1, fp_audio_out);
write_amrnb_header = 0;
} else if ((a_mime == MEDIA_FORMAT_AMR_WB) && (write_amrwb_header == 1)) {
/* This is used only AMR-WB case for adding magic header in only first frame */
- g_print("%s - AMRWB_HDR write in first frame\n",__func__);
+ g_print("%s - AMRWB_HDR write in first frame\n", __func__);
fwrite(&AMRWB_HDR[0], 1, sizeof(AMRWB_HDR) - 1, fp_audio_out);
write_amrwb_header = 0;
}
err = mediacodec_get_output(g_media_codec_1, &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);
+ /* g_print("%s - output_buf size = %lld\n", __func__, buf_size); */
media_packet_get_buffer_data_ptr(output_buf, &data);
- if (data != NULL) {
+ if (data != NULL)
fwrite(data, 1, buf_size, fp_out_codec_video);
- } else {
+ else
g_print("Data is null inside _mediacodec_fill_video_buffer_cb\n");
- }
media_packet_destroy(output_buf);
} else {
g_print("mediacodec_get_output failed inside _mediacodec_fill_video_buffer_cb lerr = %d\n", err);
{
if (g_media_codec_1 != NULL) {
/* process the media packet */
- if (MEDIACODEC_ERROR_NONE != mediacodec_process_input (g_media_codec_1, in_buf, 0)) {
+ if (MEDIACODEC_ERROR_NONE != mediacodec_process_input(g_media_codec_1, in_buf, 0)) {
g_print("mediacodec process input is failed inside mediacodec_process_video_pkt\n");
return;
}
unsigned char* get_codec_data;
unsigned int get_codec_data_size;
- if (media_packet_get_codec_data(pkt,(void**) &get_codec_data, &get_codec_data_size) == MEDIA_PACKET_ERROR_NONE) {
+ if (media_packet_get_codec_data(pkt, (void**) &get_codec_data, &get_codec_data_size) == MEDIA_PACKET_ERROR_NONE) {
g_print("media_packet_get_codec_data is sucess ... !\n");
g_print("codec_data_size = %u\n", get_codec_data_size);
get_codec_data[get_codec_data_size] = '\0';
/* Initialize and set thread detached attribute */
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- if(vid_track != -1){
+ if (vid_track != -1) {
g_print("In main: creating thread for video\n");
pthread_create(&thread[0], &attr, _fetch_video_data, NULL);
}
- if(aud_track != -1){
+ if (aud_track != -1) {
g_print("In main: creating thread for audio\n");
pthread_create(&thread[1], &attr, _fetch_audio_data, NULL);
}
{
g_print("test_mediademuxer_get_state\n");
mediademuxer_state state;
- if(mediademuxer_get_state(demuxer, &state) == MEDIADEMUXER_ERROR_NONE) {
+ if (mediademuxer_get_state(demuxer, &state) == MEDIADEMUXER_ERROR_NONE) {
if (state == MEDIADEMUXER_NONE)
g_print("Mediademuxer_state = NONE\n");
else if (state == MEDIADEMUXER_IDLE)
g_print("Mediademuxer_state = DEMUXING\n");
else
g_print("Mediademuxer_state = NOT SUPPORT STATE\n");
- }
- else {
+ } else
g_print("Mediademuxer_state call failed\n");
- }
return 0;
}
void app_err_cb(mediademuxer_error_e error, void *user_data)
{
- printf("Got Error %d from Mediademuxer\n",error);
+ printf("Got Error %d from Mediademuxer\n", error);
}
int test_mediademuxer_set_error_cb()
{
int ret = 0;
g_print("test_mediademuxer_set_error_cb\n");
- ret = mediademuxer_set_error_cb(demuxer,app_err_cb,demuxer);
+ ret = mediademuxer_set_error_cb(demuxer, app_err_cb, demuxer);
return ret;
}
static void interpret(char *cmd)
{
switch (g_menu_state) {
- case CURRENT_STATUS_MAINMENU: {
- _interpret_main_menu(cmd);
- break;
- }
- case CURRENT_STATUS_FILENAME: {
- int ret = 0;
- ret = test_mediademuxer_set_data_source(demuxer, cmd);
+ case CURRENT_STATUS_MAINMENU: {
+ _interpret_main_menu(cmd);
+ break;
+ }
+ case CURRENT_STATUS_FILENAME: {
+ int ret = 0;
+ ret = test_mediademuxer_set_data_source(demuxer, cmd);
+ if (ret != MD_ERROR_INVALID_ARGUMENT) {
+ ret = test_mediademuxer_prepare();
if (ret != MD_ERROR_INVALID_ARGUMENT) {
- ret = test_mediademuxer_prepare();
- if (ret != MD_ERROR_INVALID_ARGUMENT) {
- g_menu_state = CURRENT_STATUS_SET_DATA;
- } else {
- g_print("test_mediademuxer_prepare failed \n");
- g_menu_state = CURRENT_STATUS_FILENAME;
- }
+ g_menu_state = CURRENT_STATUS_SET_DATA;
} else {
+ g_print("test_mediademuxer_prepare failed \n");
g_menu_state = CURRENT_STATUS_FILENAME;
}
- break;
+ } else {
+ g_menu_state = CURRENT_STATUS_FILENAME;
}
- case CURRENT_STATUS_SET_DATA: {
- int len = strlen(cmd);
-
- if (len == 1) {
- if (strncmp(cmd, "1", len) == 0) {
- test_mediademuxer_get_track_count();
- } else if (strncmp(cmd, "2", len) == 0) {
- test_mediademuxer_select_track();
- } else if (strncmp(cmd, "3", len) == 0) {
- test_mediademuxer_start();
- } else if (strncmp(cmd, "4", len) == 0) {
- test_mediademuxer_get_track_info();
- } else if (strncmp(cmd, "5", len) == 0) {
- test_mediademuxer_read_sample();
- } else if (strncmp(cmd, "6", len) == 0) {
- test_mediademuxer_stop();
- } else if (strncmp(cmd, "7", len) == 0) {
- test_mediademuxer_unprepare();
- } else if (strncmp(cmd, "8", len) == 0) {
- test_mediademuxer_get_state();
- } else if (strncmp(cmd, "9", len) == 0) {
- reset_menu_state();
- } else if (strncmp(cmd, "a", len) == 0) {
- test_mediademuxer_seek_to();
- } else if (strncmp(cmd, "b", len) == 0) {
- test_mediademuxer_unselect_track();
- } else if (strncmp(cmd, "c", len) == 0) {
- test_mediademuxer_get_sample_track_index();
- } else if (strncmp(cmd, "d", len) == 0) {
- test_mediademuxer_get_sample_track_time();
- } else if (strncmp(cmd, "e", len) == 0) {
- test_mediademuxer_advance();
- } else if (strncmp(cmd, "f", len) == 0) {
- test_mediademuxer_is_key_frame();
- } else if (strncmp(cmd, "g", len) == 0) {
- test_mediademuxer_is_encrypted();
- } else {
- g_print("UNKNOW COMMAND\n");
- }
- } else if (len == 2) {
- if (strncmp(cmd, "10", len) == 0) {
- g_print("UNKNOW COMMAND\n");
- } else {
- g_print("UNKNOW COMMAND\n");
- }
- } else {
+ break;
+ }
+ case CURRENT_STATUS_SET_DATA: {
+ int len = strlen(cmd);
+ if (len == 1) {
+ if (strncmp(cmd, "1", len) == 0)
+ test_mediademuxer_get_track_count();
+ else if (strncmp(cmd, "2", len) == 0)
+ test_mediademuxer_select_track();
+ else if (strncmp(cmd, "3", len) == 0)
+ test_mediademuxer_start();
+ else if (strncmp(cmd, "4", len) == 0)
+ test_mediademuxer_get_track_info();
+ else if (strncmp(cmd, "5", len) == 0)
+ test_mediademuxer_read_sample();
+ else if (strncmp(cmd, "6", len) == 0)
+ test_mediademuxer_stop();
+ else if (strncmp(cmd, "7", len) == 0)
+ test_mediademuxer_unprepare();
+ else if (strncmp(cmd, "8", len) == 0)
+ test_mediademuxer_get_state();
+ else if (strncmp(cmd, "9", len) == 0)
+ reset_menu_state();
+ else if (strncmp(cmd, "a", len) == 0)
+ test_mediademuxer_seek_to();
+ else if (strncmp(cmd, "b", len) == 0)
+ test_mediademuxer_unselect_track();
+ else if (strncmp(cmd, "c", len) == 0)
+ test_mediademuxer_get_sample_track_index();
+ else if (strncmp(cmd, "d", len) == 0)
+ test_mediademuxer_get_sample_track_time();
+ else if (strncmp(cmd, "e", len) == 0)
+ test_mediademuxer_advance();
+ else if (strncmp(cmd, "f", len) == 0)
+ test_mediademuxer_is_key_frame();
+ else if (strncmp(cmd, "g", len) == 0)
+ test_mediademuxer_is_encrypted();
+ else
g_print("UNKNOW COMMAND\n");
- }
- break;
- }
- default:
+ } else if (len == 2) {
+ if (strncmp(cmd, "10", len) == 0)
+ g_print("UNKNOW COMMAND\n");
+ else
+ g_print("UNKNOW COMMAND\n");
+ } else
+ g_print("UNKNOW COMMAND\n");
+ break;
+ }
+ default:
break;
}
g_timeout_add(100, timeout_menu_display, 0);