4 * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, ByungWook Jang <bw.jang@samsung.com>,
7 * Maksym Ukhanov <m.ukhanov@samsung.com>, Hyunjun Ko <zzoon.ko@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 #ifndef _MM_WFD_SINK_UTIL_H_
24 #define _MM_WFD_SINK_UTIL_H_
28 #include <mm_message.h>
31 #include "mm_wfd_sink_dlog.h"
33 #define MMWFDSINK_FREEIF(x) \
36 g_free((gpointer)(x)); \
40 /* lock for commnad */
41 #define MMWFDSINK_CMD_LOCK(x_wfd) \
43 g_mutex_lock(&(((mm_wfd_sink_t *)x_wfd)->cmd_lock));
45 #define MMWFDSINK_CMD_UNLOCK(x_wfd) \
47 g_mutex_unlock(&(((mm_wfd_sink_t *)x_wfd)->cmd_lock));
50 #define MMWFDSINK_CREATE_ELEMENT(x_bin, x_id, x_factory, x_name, x_add_bucket) \
52 if (x_name && (strlen(x_factory) > 1)) {\
53 x_bin[x_id].id = x_id;\
54 x_bin[x_id].gst = gst_element_factory_make(x_factory, x_name);\
55 if (! x_bin[x_id].gst) {\
56 wfd_sink_error("failed to create %s \n", x_factory);\
59 wfd_sink_debug("%s is created \n", x_factory);\
61 element_bucket = g_list_append(element_bucket, &x_bin[x_id]);\
66 #define MMWFDSINK_GENERATE_DOT_IF_ENABLED(x_wfd_sink, x_name) \
67 if (x_wfd_sink->ini.generate_dot) { \
68 wfd_sink_debug("create dot file : %s.dot", x_name);\
69 GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(x_wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst), \
70 GST_DEBUG_GRAPH_SHOW_ALL, x_name); \
74 #define MMWFDSINK_POST_MESSAGE(x_wfd_sink, x_error_type, x_state_type) \
75 if (x_wfd_sink->msg_cb) { \
76 wfd_sink_debug("Message(error : %d, state : %d) will be posted using user callback\n", x_error_type, x_state_type); \
77 x_wfd_sink->msg_cb(x_error_type, x_state_type, x_wfd_sink->msg_user_data); \
82 #define MMWFDSINK_CURRENT_STATE(x_wfd_sink) ((mm_wfd_sink_t *)x_wfd_sink)->state.state
83 #define MMWFDSINK_PREVIOUS_STATE(x_wfd_sink) ((mm_wfd_sink_t *)x_wfd_sink)->state.prev_state
84 #define MMWFDSINK_PENDING_STATE(x_wfd_sink) ((mm_wfd_sink_t *)x_wfd_sink)->state.pending_state
85 #define MMWFDSINK_STATE_GET_NAME(x_state) __mm_wfds_sink_get_state_name(x_state)
87 #define MMWFDSINK_PRINT_STATE(x_wfd_sink) \
88 wfd_sink_debug("--prev %s, current %s, pending %s--\n", \
89 MMWFDSINK_STATE_GET_NAME(MMWFDSINK_PREVIOUS_STATE(x_wfd_sink)), \
90 MMWFDSINK_STATE_GET_NAME(MMWFDSINK_CURRENT_STATE(x_wfd_sink)), \
91 MMWFDSINK_STATE_GET_NAME(MMWFDSINK_PENDING_STATE(x_wfd_sink)));
93 #define MMWFDSINK_CHECK_STATE(x_wfd_sink, x_cmd) \
94 switch (__mm_wfd_sink_check_state((mm_wfd_sink_t *)x_wfd_sink, x_cmd)) \
98 case MM_ERROR_WFD_NO_OP: \
99 return MM_ERROR_NONE; \
102 return MM_ERROR_WFD_INVALID_STATE; \
109 mm_wfd_sink_util_add_pad_probe(GstPad *pad, GstElement *element, const gchar *pad_name);
111 mm_wfd_sink_util_add_pad_probe_for_checking_first_buffer(GstPad *pad, GstElement *element, const gchar *pad_name);
113 #define MMWFDSINK_PAD_PROBE(x_wfd_sink, x_pad, x_element, x_pad_name) \
115 if (x_wfd_sink->ini.enable_pad_probe) { \
116 mm_wfd_sink_util_add_pad_probe(x_pad, x_element, (const gchar*)x_pad_name); \
118 mm_wfd_sink_util_add_pad_probe_for_checking_first_buffer (x_pad, x_element, (const gchar*)x_pad_name); \
123 mm_wfd_sink_util_add_pad_probe_for_data_dump(GstElement *element, const gchar *pad_name);
125 #define MMWFDSINK_TS_DATA_DUMP(x_wfd_sink, x_element, x_pad_name) \
126 if (x_wfd_sink && x_wfd_sink->ini.enable_ts_data_dump) { \
127 mm_wfd_sink_util_add_pad_probe_for_data_dump (x_element, (const gchar*)x_pad_name); \