#define MMPLAYER_MAX_INT (2147483647)
#define MMPLAYER_FREEIF(x) \
-if (x) \
- g_free(x); \
-x = NULL;
+do { \
+ if (x) \
+ g_free(x); \
+ x = NULL; \
+} while (0)
#define MMPLAYER_GET_ATTRS(x_player) ((mm_player_t*)x_player)->attrs
gchar* caps_type = NULL; \
caps_type = gst_caps_to_string(x_caps); \
LOGD("caps: %s\n", caps_type); \
- MMPLAYER_FREEIF(caps_type) \
+ MMPLAYER_FREEIF(caps_type); \
} while (0)
/* message posting */
} while (0)
#define MMPLAYER_CHECK_STATE(x_player, x_command) \
-LOGD("checking player state before doing %s\n", #x_command); \
-switch (__mmplayer_check_state(x_player, x_command)) { \
-case MM_ERROR_PLAYER_INVALID_STATE: \
- return MM_ERROR_PLAYER_INVALID_STATE; \
- break; \
- /* NOTE : for robustness of player. we won't treat it as an error */ \
-case MM_ERROR_PLAYER_NO_OP: \
- return MM_ERROR_NONE; \
- break; \
-case MM_ERROR_PLAYER_DOING_SEEK: \
- return MM_ERROR_PLAYER_DOING_SEEK; \
-default: \
- break; \
-}
+do { \
+ LOGD("checking player state before doing %s\n", #x_command); \
+ switch (__mmplayer_check_state(x_player, x_command)) { \
+ case MM_ERROR_PLAYER_INVALID_STATE: \
+ return MM_ERROR_PLAYER_INVALID_STATE; \
+ break; \
+ /* NOTE : for robustness of player. we won't treat it as an error */ \
+ case MM_ERROR_PLAYER_NO_OP: \
+ return MM_ERROR_NONE; \
+ break; \
+ case MM_ERROR_PLAYER_DOING_SEEK: \
+ return MM_ERROR_PLAYER_DOING_SEEK; \
+ default: \
+ break; \
+ } \
+} while (0)
/* setting element state */
#define MMPLAYER_ELEMENT_SET_STATE(x_element, x_state) \
-LOGD("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)) { \
- LOGE("failed to set state %s to %s\n", #x_state, GST_ELEMENT_NAME(x_element)); \
- goto STATE_CHANGE_FAILED; \
-}
+do { \
+ LOGD("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)) { \
+ LOGE("failed to set state %s to %s\n", #x_state, GST_ELEMENT_NAME(x_element)); \
+ goto STATE_CHANGE_FAILED; \
+ } \
+} while (0)
#define MMPLAYER_CHECK_NULL(x_var) \
if (!x_var) { \
else \
LOGE("wrong signal type [%d]\n", x_type); \
} \
-} while (0);
+} while (0)
/* release element resource */
#define MMPLAYER_RELEASE_ELEMENT(x_player, x_bin, x_id) \
}
#define MMPLAYER_UPDATE_TAG_IMAGE(gsttag, attribute, playertag) \
-GstSample *sample = NULL;\
-if (gst_tag_list_get_sample_index(tag_list, gsttag, index, &sample)) {\
- GstMapInfo info = GST_MAP_INFO_INIT;\
- buffer = gst_sample_get_buffer(sample);\
- if (!gst_buffer_map(buffer, &info, GST_MAP_READ)) {\
- LOGD("failed to get image data from tag");\
- return FALSE;\
- } \
- SECURE_LOGD("update album cover data : %p, size : %d\n", info.data, info.size);\
- MMPLAYER_FREEIF(player->album_art);\
- player->album_art = (gchar *)g_malloc(info.size);\
- if (player->album_art) {\
- memcpy(player->album_art, info.data, info.size);\
- mm_attrs_set_data_by_name(attribute, playertag, (void *)player->album_art, info.size);\
- if (MMPLAYER_IS_HTTP_LIVE_STREAMING(player)) {\
- msg_param.data = (void *)player->album_art;\
- msg_param.size = info.size;\
- MMPLAYER_POST_MSG(player, MM_MESSAGE_IMAGE_BUFFER, &msg_param);\
- SECURE_LOGD("post message image buffer data : %p, size : %d\n", info.data, info.size);\
+do { \
+ GstSample *sample = NULL;\
+ if (gst_tag_list_get_sample_index(tag_list, gsttag, index, &sample)) {\
+ GstMapInfo info = GST_MAP_INFO_INIT;\
+ buffer = gst_sample_get_buffer(sample);\
+ if (!gst_buffer_map(buffer, &info, GST_MAP_READ)) {\
+ LOGD("failed to get image data from tag");\
+ return FALSE;\
} \
- } \
- gst_buffer_unmap(buffer, &info);\
-}
+ SECURE_LOGD("update album cover data : %p, size : %d\n", info.data, info.size);\
+ MMPLAYER_FREEIF(player->album_art);\
+ player->album_art = (gchar *)g_malloc(info.size);\
+ if (player->album_art) {\
+ memcpy(player->album_art, info.data, info.size);\
+ mm_attrs_set_data_by_name(attribute, playertag, (void *)player->album_art, info.size);\
+ if (MMPLAYER_IS_HTTP_LIVE_STREAMING(player)) {\
+ msg_param.data = (void *)player->album_art;\
+ msg_param.size = info.size;\
+ MMPLAYER_POST_MSG(player, MM_MESSAGE_IMAGE_BUFFER, &msg_param);\
+ SECURE_LOGD("post message image buffer data : %p, size : %d\n", info.data, info.size);\
+ } \
+ } \
+ gst_buffer_unmap(buffer, &info);\
+ } \
+} while (0)
#define MMPLAYER_UPDATE_TAG_UINT(gsttag, attribute, playertag) \
if (gst_tag_list_get_uint(tag_list, gsttag, &v_uint)) {\
__mmplayer_del_sink(player, player->pipeline->audiobin[MMPLAYER_A_SINK].gst);
MMPLAYER_RELEASE_ELEMENT(player, player->pipeline->audiobin, MMPLAYER_A_BIN);
- MMPLAYER_FREEIF(player->pipeline->audiobin)
+ MMPLAYER_FREEIF(player->pipeline->audiobin);
}
if (player->num_dynamic_pad == 0)
* @remark
* @see __mmplayer_gst_create_midi_pipeline, __mmplayer_gst_create_video_pipeline
*/
-#define MMPLAYER_CREATEONLY_ELEMENT(x_bin, x_id, x_factory, x_name) \
-x_bin[x_id].id = x_id;\
-x_bin[x_id].gst = gst_element_factory_make(x_factory, x_name);\
-if (!x_bin[x_id].gst) {\
- LOGE("failed to create %s \n", x_factory);\
- goto ERROR;\
-} \
-
-#define MMPLAYER_CREATE_ELEMENT_ADD_BIN(x_bin, x_id, x_factory, x_name, y_bin, x_player) \
-x_bin[x_id].id = x_id;\
-x_bin[x_id].gst = gst_element_factory_make(x_factory, x_name);\
-if (!x_bin[x_id].gst) {\
- LOGE("failed to create %s \n", x_factory);\
- goto ERROR;\
-} else {\
- if (x_player->ini.set_dump_element_flag)\
- __mmplayer_add_dump_buffer_probe(x_player, x_bin[x_id].gst);\
-} \
-if (!gst_bin_add(GST_BIN(y_bin), GST_ELEMENT(x_bin[x_id].gst))) { \
- LOGD("__mmplayer_gst_element_link_bucket : Adding element [%s] to bin [%s] failed\n",\
- GST_ELEMENT_NAME(GST_ELEMENT(x_bin[x_id].gst)),\
- GST_ELEMENT_NAME(GST_ELEMENT(y_bin)));\
- goto ERROR;\
-} \
-
/* macro for code readability. just for sinkbin-creation functions */
#define MMPLAYER_CREATE_ELEMENT(x_bin, x_id, x_factory, x_name, x_add_bucket, x_player) \
do {\
LOGD("argv[%d] : %s\n", i, argv2[i]);
}
-
/* initializing gstreamer */
if (!gst_init_check(argc, &argv, &err)) {
LOGE("Could not initialize GStreamer: %s\n", err ? err->message : "unknown error occurred");