mm_wfd_sink_t *new_wfd_sink = NULL;
/* create handle */
- new_wfd_sink = g_malloc0(sizeof(mm_wfd_sink_t));
- if (!new_wfd_sink) {
- wfd_sink_error("failed to allocate memory for wi-fi display sink");
- return MM_ERROR_WFD_NO_FREE_SPACE;
- }
+ new_wfd_sink = g_new0(mm_wfd_sink_t, 1);
/* initialize resource manager */
result = mm_wfd_sink_rm_create(new_wfd_sink);
goto fail_to_attrs;
}
- /* Initialize gstreamer related */
- new_wfd_sink->attrs = 0;
-
- new_wfd_sink->pipeline = NULL;
- new_wfd_sink->audio_decodebin_is_linked = FALSE;
- new_wfd_sink->video_decodebin_is_linked = FALSE;
-
- /* Initialize timestamp compensation related */
- new_wfd_sink->need_to_reset_basetime = FALSE;
- new_wfd_sink->clock = NULL;
- new_wfd_sink->video_buffer_count = 0LL;
- new_wfd_sink->video_average_gap = 0LL;
- new_wfd_sink->video_accumulated_gap = 0LL;
- new_wfd_sink->audio_buffer_count = 0LL;
- new_wfd_sink->audio_average_gap = 0LL;
- new_wfd_sink->audio_accumulated_gap = 0LL;
new_wfd_sink->last_buffer_timestamp = GST_CLOCK_TIME_NONE;
-
- /* Initialize all states */
- MMWFDSINK_CURRENT_STATE(new_wfd_sink) = MM_WFD_SINK_STATE_NONE;
- MMWFDSINK_PREVIOUS_STATE(new_wfd_sink) = MM_WFD_SINK_STATE_NONE;
- MMWFDSINK_PENDING_STATE(new_wfd_sink) = MM_WFD_SINK_STATE_NONE;
-
- /* initialize audio/video information */
- new_wfd_sink->stream_info.audio_stream_info.codec = MM_WFD_SINK_AUDIO_CODEC_NONE;
- new_wfd_sink->stream_info.audio_stream_info.channels = 0;
- new_wfd_sink->stream_info.audio_stream_info.sample_rate = 0;
- new_wfd_sink->stream_info.audio_stream_info.bitwidth = 0;
- new_wfd_sink->stream_info.video_stream_info.codec = MM_WFD_SINK_VIDEO_CODEC_NONE;
- new_wfd_sink->stream_info.video_stream_info.width = 0;
- new_wfd_sink->stream_info.video_stream_info.height = 0;
- new_wfd_sink->stream_info.video_stream_info.frame_rate = 0;
-
- /* Initialize command */
new_wfd_sink->cmd = MM_WFD_SINK_COMMAND_CREATE;
- new_wfd_sink->waiting_cmd = FALSE;
-
- /* Initialize manager related */
- new_wfd_sink->manager_thread = NULL;
- new_wfd_sink->manager_thread_cmd = NULL;
- new_wfd_sink->manager_thread_exit = FALSE;
-
- /* Initialize video resolution */
- new_wfd_sink->supportive_resolution = MM_WFD_SINK_RESOLUTION_UNKNOWN;
-
- /* Initialize coulped sink information */
- new_wfd_sink->coupled_sink_address = NULL;
- new_wfd_sink->coupled_sink_status = MM_WFD_COUPLED_SINK_STATUS_NOT_COUPLED;
-
- /* In case of R2 sink, it would be TRUE */
- new_wfd_sink->is_coupled_sink_supported = FALSE;
/* construct attributes */
new_wfd_sink->attrs = _mmwfd_construct_attribute((MMHandleType)new_wfd_sink);
/* release pipeline */
result = __mm_wfd_sink_destroy_pipeline(wfd_sink);
if (result != MM_ERROR_NONE) {
- wfd_sink_error("failed to destory pipeline");
+ wfd_sink_error("failed to destroy pipeline");
return MM_ERROR_WFD_INTERNAL;
} else {
- wfd_sink_debug("success to destory pipeline");
+ wfd_sink_debug("success to destroy pipeline");
}
/* set state */
srcpad = gst_element_get_static_pad(v_decodebin, "src");
if (!srcpad) {
- wfd_sink_error("faied to get srcpad from %s", GST_ELEMENT_NAME(v_decodebin));
+ wfd_sink_error("failed to get srcpad from %s", GST_ELEMENT_NAME(v_decodebin));
goto ERROR;
}
if (!gst_pad_is_linked(srcpad)) {
sinkpad = gst_element_get_static_pad(v_sinkbin, "sink");
if (!sinkpad) {
- wfd_sink_error("faied to get sinkpad from %s", GST_ELEMENT_NAME(v_sinkbin));
+ wfd_sink_error("failed to get sinkpad from %s", GST_ELEMENT_NAME(v_sinkbin));
goto ERROR;
}
srcpad = gst_element_get_static_pad(a_decodebin, "src");
if (!srcpad) {
- wfd_sink_error("faied to get srcpad from %s", GST_ELEMENT_NAME(a_decodebin));
+ wfd_sink_error("failed to get srcpad from %s", GST_ELEMENT_NAME(a_decodebin));
goto ERROR;
}
if (!gst_pad_is_linked(srcpad)) {
sinkpad = gst_element_get_static_pad(a_sinkbin, "sink");
if (!sinkpad) {
- wfd_sink_error("faied to get sinkpad from %s", GST_ELEMENT_NAME(a_sinkbin));
+ wfd_sink_error("failed to get sinkpad from %s", GST_ELEMENT_NAME(a_sinkbin));
goto ERROR;
}
render_time = GST_BUFFER_TIMESTAMP(buffer);
render_time += ts_offset;
- /* chekc this buffer could be rendered or not */
+ /* check this buffer could be rendered or not */
if (GST_CLOCK_TIME_IS_VALID(running_time) && GST_CLOCK_TIME_IS_VALID(render_time)) {
diff = GST_CLOCK_DIFF(running_time, render_time);
if (diff < 0) {
}
if (GST_CLOCK_TIME_IS_VALID(wfd_sink->last_buffer_timestamp)) {
- /* fisrt 60sec, just calculate the gap between source device and sink device */
+ /* first 60sec, just calculate the gap between source device and sink device */
if (GST_BUFFER_TIMESTAMP(buffer) < 60 * GST_SECOND)
return GST_PAD_PROBE_OK;
GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)));
}
- /* selecet average_gap_diff between video and audio */
+ /* select average_gap_diff between video and audio */
/* which makes no buffer drop in the sink elements */
if (video_avgrage_gap_diff && audio_avgrage_gap_diff) {
if (!video_minus_compensation && !audio_minus_compensation) {
avgrage_gap_diff = audio_avgrage_gap_diff;
}
- wfd_sink_debug("average diff gap difference beween audio:%s%"G_GINT64_FORMAT"d and video:%s%"G_GINT64_FORMAT"d ",
+ wfd_sink_debug("average diff gap difference between audio:%s%"G_GINT64_FORMAT"d and video:%s%"G_GINT64_FORMAT"d ",
audio_minus_compensation ? "-" : "", audio_avgrage_gap_diff,
video_minus_compensation ? "-" : "", video_avgrage_gap_diff);
wfd_sink->stream_info.audio_stream_info.codec,
name[0]);
- //In case of none vieo codec, we don't add video pad
+ //In case of none video codec, we don't add video pad
if (wfd_sink->stream_info.video_stream_info.codec == MM_WFD_SINK_VIDEO_CODEC_NONE && name[0] == 'v') {
wfd_sink_error("Skip video pad add for none video codec");
// Do nothing
wfd_sink_return_val_if_fail(wfd_sink->attrs, MM_ERROR_WFD_NOT_INITIALIZED);
/* Create pipeline */
- wfd_sink->pipeline = (MMWFDSinkGstPipelineInfo *) g_malloc0(sizeof(MMWFDSinkGstPipelineInfo));
- if (wfd_sink->pipeline == NULL)
- goto CREATE_ERROR;
-
- memset(wfd_sink->pipeline, 0, sizeof(MMWFDSinkGstPipelineInfo));
+ wfd_sink->pipeline = g_new0(MMWFDSinkGstPipelineInfo, 1);
/* create mainbin */
- mainbin = (MMWFDSinkGstElement *) g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_M_NUM);
- if (mainbin == NULL)
- goto CREATE_ERROR;
-
- memset(mainbin, 0, sizeof(MMWFDSinkGstElement) * WFD_SINK_M_NUM);
+ mainbin = g_new0(MMWFDSinkGstElement, WFD_SINK_M_NUM);
/* create pipeline */
mainbin[WFD_SINK_M_PIPE].id = WFD_SINK_M_PIPE;
break;
default:
- wfd_sink_error("audio codec is not decied yet. cannot link audio decodebin...");
+ wfd_sink_error("audio codec is not decide yet. cannot link audio decodebin...");
goto fail_to_link;
break;
}
parent = gst_element_get_parent(a_decodebin[WFD_SINK_A_D_BIN].gst);
if (!parent) {
- wfd_sink_debug("audio decodebin has no parent.. need to relase by itself");
+ wfd_sink_debug("audio decodebin has no parent.. need to release by itself");
if (GST_STATE(a_decodebin[WFD_SINK_A_D_BIN].gst) >= GST_STATE_READY) {
wfd_sink_error("try to change state of audio decodebin to NULL");
}
/* alloc handles */
- a_decodebin = (MMWFDSinkGstElement *)g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_A_D_NUM);
- if (!a_decodebin) {
- wfd_sink_error("failed to allocate memory for audio decodebin");
- return MM_ERROR_WFD_NO_FREE_SPACE;
- }
-
- memset(a_decodebin, 0, sizeof(MMWFDSinkGstElement) * WFD_SINK_A_D_NUM);
+ a_decodebin = g_new0(MMWFDSinkGstElement, WFD_SINK_A_D_NUM);
/* create audio decodebin */
a_decodebin[WFD_SINK_A_D_BIN].id = WFD_SINK_A_D_BIN;
}
/* alloc handles */
- a_sinkbin = (MMWFDSinkGstElement *)g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_A_S_NUM);
- if (!a_sinkbin) {
- wfd_sink_error("failed to allocate memory for audio sinkbin");
- return MM_ERROR_WFD_NO_FREE_SPACE;
- }
-
- memset(a_sinkbin, 0, sizeof(MMWFDSinkGstElement) * WFD_SINK_A_S_NUM);
+ a_sinkbin = g_new0(MMWFDSinkGstElement, WFD_SINK_A_S_NUM);
/* create audio sinkbin */
a_sinkbin[WFD_SINK_A_S_BIN].id = WFD_SINK_A_S_BIN;
/* linking elements in the bucket by added order. */
if (__mm_wfd_sink_gst_element_link_bucket(element_bucket) == -1) {
- wfd_sink_error("failed to link elements fo the audio sinkbin");
+ wfd_sink_error("failed to link elements for the audio sinkbin");
goto CREATE_ERROR;
}
break;
default:
- wfd_sink_error("video codec is not decied yet. cannot link video decpdebin...");
+ wfd_sink_error("video codec is not decied yet. cannot link video decodebin...");
goto fail_to_link;
break;
}
}
/* alloc handles */
- v_decodebin = (MMWFDSinkGstElement *)g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_V_D_NUM);
- if (!v_decodebin) {
- wfd_sink_error("failed to allocate memory for video decodebin");
- return MM_ERROR_WFD_NO_FREE_SPACE;
- }
-
- memset(v_decodebin, 0, sizeof(MMWFDSinkGstElement) * WFD_SINK_V_D_NUM);
+ v_decodebin = g_new0(MMWFDSinkGstElement, WFD_SINK_V_D_NUM);
/* create video decodebin */
v_decodebin[WFD_SINK_V_D_BIN].id = WFD_SINK_V_D_BIN;
}
/* alloc handles */
- v_sinkbin = (MMWFDSinkGstElement *)g_malloc0(sizeof(MMWFDSinkGstElement) * WFD_SINK_V_S_NUM);
- if (!v_sinkbin) {
- wfd_sink_error("failed to allocate memory for video sinkbin");
- return MM_ERROR_WFD_NO_FREE_SPACE;
- }
-
- memset(v_sinkbin, 0, sizeof(MMWFDSinkGstElement) * WFD_SINK_V_S_NUM);
+ v_sinkbin = g_new0(MMWFDSinkGstElement, WFD_SINK_V_S_NUM);
/* create video sinkbin */
v_sinkbin[WFD_SINK_V_S_BIN].id = WFD_SINK_V_S_BIN;
wfd_sink_error("failed to change state of pipeline to NULL. ret[%d]", ret);
return MM_ERROR_WFD_INTERNAL;
} else {
- wfd_sink_debug("Successed to change state of pipeline to NULL");
+ wfd_sink_debug("Succeed to change state of pipeline to NULL");
}
bus = gst_pipeline_get_bus(GST_PIPELINE(mainbin[WFD_SINK_M_PIPE].gst));
case MM_WFD_SINK_STATE_DISCONNECTED:
return "DISCONNECTED";
default:
- return "INVAID";
+ return "INVAILD";
}
}
wfd_sink_debug("surface = %p, wl_display = %p", wl_surface, wl_display);
display_overlay = object;
- ret = mm_wfd_sink_wlclient_create(&wlclient);
- if (ret != MM_ERROR_NONE) {
- wfd_sink_error("Wayland client create failure");
- return MM_ERROR_WFD_INTERNAL;
- }
- wfd_sink_debug("Try to get surface id");
+ wlclient = g_new0(wl_client, 1);
+ wfd_sink_debug("Success create wlclient(%p) Try to get surface id", wlclient);
wl_surface_id = mm_wfd_sink_wlclient_get_wl_window_wl_surface_id(wlclient, wl_surface, wl_display);
GST_TIME_ARGS(segment->start), GST_TIME_ARGS(segment->stop),
GST_TIME_ARGS(segment->time));
- wfd_sink_debug("NEWSEGMENT : flags[%d] rate[%lf] applied_rate[%lf] foramt[%d] base[%"G_GUINT64_FORMAT"d] offset[%"G_GUINT64_FORMAT"d] position[%"G_GUINT64_FORMAT"d] duration[%"G_GUINT64_FORMAT"d]",
+ wfd_sink_debug("NEWSEGMENT : flags[%d] rate[%lf] applied_rate[%lf] format[%d] base[%"G_GUINT64_FORMAT"d] offset[%"G_GUINT64_FORMAT"d] position[%"G_GUINT64_FORMAT"d] duration[%"G_GUINT64_FORMAT"d]",
segment->flags, segment->rate, segment->applied_rate, segment->format, segment->base, segment->offset, segment->position, segment->duration);
}
{
GstElement *parent = NULL;
GstBuffer *buffer = NULL;
- guint *probe_id = (guint *)user_data;
wfd_sink_return_val_if_fail(pad, GST_PAD_PROBE_DROP);
wfd_sink_return_val_if_fail(info, GST_PAD_PROBE_DROP);
GST_STR_NULL(GST_ELEMENT_NAME(parent)), GST_STR_NULL(GST_PAD_NAME(pad)),
GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(buffer)), gst_buffer_get_size(buffer));
- if (probe_id && *probe_id > 0) {
- wfd_sink_debug("remove buffer probe[%d]\n", *probe_id);
- gst_pad_remove_probe(pad, *probe_id);
-
- MMWFDSINK_FREEIF(probe_id);
- }
-
if (parent)
gst_object_unref(parent);
mm_wfd_sink_util_add_pad_probe_for_checking_first_buffer(GstPad *pad, GstElement *element, const gchar *pad_name)
{
GstPad *probe_pad = NULL;
- guint *probe_id = NULL;
if (!pad) {
if (element && pad_name)
probe_pad = gst_element_get_static_pad(element, pad_name);
} else {
- probe_pad = pad;
- gst_object_ref(probe_pad);
+ probe_pad = gst_object_ref(pad);
}
- if (probe_pad) {
- probe_id = g_malloc0(sizeof(guint));
- if (!probe_id) {
- wfd_sink_error("failed to allocate memory for probe id\n");
- gst_object_unref(probe_pad);
- return;
- }
+ if (!probe_pad)
+ return;
- *probe_id = gst_pad_add_probe(probe_pad, GST_PAD_PROBE_TYPE_BUFFER, _mm_wfd_sink_util_check_first_buffer_cb, (gpointer)probe_id, NULL);
- wfd_sink_debug("add pad(%s) probe, %d",
- GST_STR_NULL(GST_PAD_NAME(probe_pad)), *probe_id);
+ gst_pad_add_probe(probe_pad, GST_PAD_PROBE_TYPE_BUFFER, _mm_wfd_sink_util_check_first_buffer_cb, NULL, NULL);
+ wfd_sink_debug("add pad(%s) probe",
+ GST_STR_NULL(GST_PAD_NAME(probe_pad)));
- gst_object_unref(probe_pad);
- }
-
- return;
+ gst_object_unref(probe_pad);
}
-