Name: capi-mediademuxer
Summary: A Media Demuxer library in Tizen Native API
-Version: 0.1.34
+Version: 0.1.35
Release: 1
Group: Multimedia/API
License: Apache-2.0
mediademuxer_error_e ret;
DEMUXER_INSTANCE_CHECK(demuxer);
- mediademuxer_s *handle;
+ mediademuxer_s *handle = NULL;
if (*demuxer == NULL) {
- handle = (mediademuxer_s *) g_malloc(sizeof(mediademuxer_s));
- if (handle != NULL) {
- memset(handle, 0, sizeof(mediademuxer_s));
- handle->demux_state = MEDIADEMUXER_STATE_NONE;
- } else {
+ handle = (mediademuxer_s *) g_try_malloc0(sizeof(mediademuxer_s));
+ if (!handle) {
MD_E("[CoreAPI][%s] DEMUXER_ERROR_OUT_OF_MEMORY(0x%08x)",
__FUNCTION__, MEDIADEMUXER_ERROR_OUT_OF_MEMORY);
return MEDIADEMUXER_ERROR_OUT_OF_MEMORY;
}
+ handle->demux_state = MEDIADEMUXER_STATE_NONE;
} else {
MD_E("Already created the instance\n");
return MEDIADEMUXER_ERROR_INVALID_OPERATION;
}
ret = md_create(&handle->md_handle);
-
if (ret != MEDIADEMUXER_ERROR_NONE) {
MD_E("[CoreAPI][%s] DEMUXER_ERROR_INVALID_OPERATION(0x%08x)",
__FUNCTION__, MEDIADEMUXER_ERROR_INVALID_OPERATION);
- free(handle);
+ g_free(handle);
handle = NULL;
return MEDIADEMUXER_ERROR_INVALID_OPERATION;
} else {
media_port_demuxer_ops *pOps = NULL;
md_handle_t *new_demuxer = NULL;
MEDIADEMUXER_FENTER();
- new_demuxer = (md_handle_t *)g_malloc(sizeof(md_handle_t));
+ new_demuxer = (md_handle_t *)g_malloc0(sizeof(md_handle_t));
MD_I("md_create allocatiing new_demuxer %p:\n", new_demuxer);
- MEDIADEMUXER_CHECK_NULL(new_demuxer);
- memset(new_demuxer, 0, sizeof(md_handle_t));
/* alloc ops structure */
- pOps = (media_port_demuxer_ops *)g_malloc(sizeof(media_port_demuxer_ops));
- MEDIADEMUXER_CHECK_NULL(pOps);
+ pOps = (media_port_demuxer_ops *)g_malloc0(sizeof(media_port_demuxer_ops));
new_demuxer->demuxer_ops = pOps;
MD_I("md_create allocating new_demuxer->demuxer_ops %p:\n",
return result;
ERROR:
*demuxer = (MMHandleType)0;
- if (pOps)
- g_free(pOps);
- if (new_demuxer)
- g_free(new_demuxer);
+ g_free(pOps);
+ g_free(new_demuxer);
MEDIADEMUXER_FLEAVE();
return result;
}
file_stat = __md_util_exist_file_path(*uri);
if (file_stat == MD_ERROR_NONE) {
int len_uri = strlen(*uri);
- old_uristr = (char *)g_malloc(sizeof(char) * (len_uri + 1));
+ old_uristr = (char *)g_strdup(*uri);
MEDIADEMUXER_CHECK_NULL(old_uristr);
- MD_L("allocating temp old_uristr[%p] \n", old_uristr);
- strncpy(old_uristr, *uri, len_uri + 1);
/* need to added 7 char for file:// + 1 for '\0'+ uri len */
+ MD_L("allocating temp old_uristr[%p] \n", old_uristr);
new_uristr = (char *)realloc(*uri, (7 + len_uri + 1) * sizeof(char));
if (!new_uristr) {
- free(old_uristr);
+ g_free(old_uristr);
old_uristr = NULL;
return MD_ERROR_INVALID_ARGUMENT;
}
*uri = new_uristr;
g_snprintf(*uri, 7 + len_uri + 1, "file://%s", old_uristr);
MD_L("deallocating old_uristr[%p] \n", old_uristr);
- free(old_uristr);
+ g_free(old_uristr);
old_uristr = NULL;
if (__md_util_is_sdp_file((char *)(*uri))) {
#ifdef TIZEN_FEATURE_STREAMING
int _md_util_parse(MMHandleType demuxer, const char *type)
{
char *media_type_string = NULL;
- int lenght_string = 0;
int result = MD_ERROR_NONE;
md_handle_t *new_demuxer = NULL;
MEDIADEMUXER_FENTER();
MEDIADEMUXER_CHECK_NULL(demuxer);
new_demuxer = (md_handle_t *)demuxer;
- lenght_string = strlen(type);
- media_type_string = (char *)g_malloc(sizeof(char) * (lenght_string + 1));
+ media_type_string = (char *)g_strdup(type);
MEDIADEMUXER_CHECK_NULL(media_type_string);
MD_L("media_type_string allocating %p\n", media_type_string);
- strncpy(media_type_string, type, lenght_string + 1);
/*Set media_type depending upon the header of string else consider using file protocol */
if (new_demuxer->uri_src) {
MD_L("new_demuxer->uri_src deallocating %p\n", new_demuxer->uri_src);
}
new_demuxer->uri_src_media_type = __md_util_media_type(&media_type_string);
if (new_demuxer->uri_src_media_type != MEDIADEMUXER_SRC_INVALID) {
- if (new_demuxer->uri_src)
- g_free(new_demuxer->uri_src);
+ g_free(new_demuxer->uri_src);
new_demuxer->uri_src = media_type_string;
MD_L("uri:%s\n uri_type:%d\n", new_demuxer->uri_src,
new_demuxer->uri_src_media_type);
MEDIADEMUXER_FENTER();
int ret = MD_ERROR_NONE;
mdgst_handle_t *new_mediademuxer = NULL;
- new_mediademuxer = (mdgst_handle_t *)g_malloc(sizeof(mdgst_handle_t));
- MD_I("gst_demuxer_init allocating new_mediademuxer:%p\n", new_mediademuxer);
+ new_mediademuxer = (mdgst_handle_t *)g_try_malloc0(sizeof(mdgst_handle_t));
if (!new_mediademuxer) {
MD_E("Cannot allocate memory for demuxer\n");
ret = MD_ERROR;
goto ERROR;
}
- memset(new_mediademuxer, 0, sizeof(mdgst_handle_t));
+ MD_I("gst_demuxer_init allocating new_mediademuxer:%p\n", new_mediademuxer);
new_mediademuxer->is_prepared = false;
(new_mediademuxer->info).num_audio_track = 0;
(new_mediademuxer->info).num_video_track = 0;
{
MEDIADEMUXER_FENTER();
mdgst_handle_t *gst_handle = (mdgst_handle_t *)data;
- int loop_track;
track_info *head_track = &(gst_handle->info);
track *head = head_track->head;
MEDIADEMUXER_CHECK_NULL_VOID(gst_handle);
gst_handle->selected_tracks =
- (bool *) g_malloc(sizeof(bool) * (gst_handle->total_tracks));
+ (bool *) g_malloc0_n(sizeof(bool), gst_handle->total_tracks);
MD_I("Allocating %p to core->selected_tracks \n", gst_handle->selected_tracks);
- if (!gst_handle->selected_tracks) {
- MD_E("[%s]Memory allocation failed\n", __FUNCTION__);
- return;
- } else {
- for (loop_track = 0; loop_track < gst_handle->total_tracks;
- loop_track++)
- gst_handle->selected_tracks[loop_track] = false;
- }
MD_I("Number of video tracks are %d\n", head_track->num_video_track);
MD_I("Number of audio tracks are %d\n", head_track->num_audio_track);
MD_I("Number of subtitle tracks are %d\n",
if (temp->next) {
track *next = temp->next;
MD_I("deallocate memory %p\n", temp);
- free(temp);
+ g_free(temp);
temp = next;
} else {
MD_I("deallocate memory %p\n", temp);
- free(temp);
+ g_free(temp);
temp = NULL;
*head = NULL;
}
GstPad *id3_srcpad = NULL;
track *temp = NULL;
- temp = (track *)(g_malloc(sizeof(track)));
- if (!temp) {
- MD_E("Not able to allocate memory");
- return MD_ERROR;
- } else {
- MD_I("allocate memory %p", temp);
- }
- memset(temp, 0x00, sizeof(track));
+ temp = (track *)(g_malloc0(sizeof(track)));
+ MD_I("allocate memory %p", temp);
temp->pad = gst_object_ref(pad);
temp->caps = gst_caps_ref(caps);
void *_fetch_audio_data(void *ptr)
{
int ret = MEDIADEMUXER_ERROR_NONE;
- int *status = (int *)g_malloc(sizeof(int) * 1);
- if (!status) {
- g_print("Fail malloc fetch audio data retur status value\n");
- return NULL;
- }
+ int *status = (int *)g_malloc(sizeof(int));
media_packet_h audbuf;
int count = 0;
uint64_t buf_size = 0;
void *_fetch_video_data(void *ptr)
{
int ret = MEDIADEMUXER_ERROR_NONE;
- int *status = (int *)g_malloc(sizeof(int) * 1);
- if (!status) {
- g_print("Fail malloc fetch video data retur status value\n");
- return NULL;
- }
+ int *status = (int *)g_malloc(sizeof(int));
media_packet_h vidbuf;
int count = 0;
uint64_t buf_size = 0;
void *_fetch_text_data(void *ptr)
{
int ret = MEDIADEMUXER_ERROR_NONE;
- int *status = (int *)g_malloc(sizeof(int) * 1);
- if (!status) {
- g_print("Fail malloc fetch video data retur status value\n");
- return NULL;
- }
+ int *status = (int *)g_malloc(sizeof(int));
media_packet_h txtbuf;
int count = 0;
uint64_t buf_size = 0;