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) \
37 g_free( (gpointer)(x) ); \
41 /* lock for commnad */
42 #define MMWFDSINK_CMD_LOCK(x_wfd) \
44 g_mutex_lock(&(((mm_wfd_sink_t*)x_wfd)->cmd_lock));
46 #define MMWFDSINK_CMD_UNLOCK(x_wfd) \
48 g_mutex_unlock(&(((mm_wfd_sink_t*)x_wfd)->cmd_lock));
51 #define MMWFDSINK_CREATE_ELEMENT(x_bin, x_id, x_factory, x_name, x_add_bucket) \
55 ( strlen( x_factory ) > 1 )) \
57 x_bin[x_id].id = x_id;\
58 x_bin[x_id].gst = gst_element_factory_make(x_factory, x_name);\
59 if ( ! x_bin[x_id].gst )\
61 wfd_sink_error("failed to create %s \n", x_factory);\
64 wfd_sink_debug("%s is created \n", x_factory);\
66 element_bucket = g_list_append(element_bucket, &x_bin[x_id]);\
71 #define MMWFDSINK_GENERATE_DOT_IF_ENABLED( x_wfd_sink, x_name ) \
72 if ( x_wfd_sink->ini.generate_dot ) \
74 wfd_sink_debug ("create dot file : %s.dot", x_name);\
75 GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN (x_wfd_sink->pipeline->mainbin[WFD_SINK_M_PIPE].gst), \
76 GST_DEBUG_GRAPH_SHOW_ALL, x_name); \
80 #define MMWFDSINK_POST_MESSAGE( x_wfd_sink, x_error_type, x_state_type ) \
81 if (x_wfd_sink->msg_cb) \
83 wfd_sink_debug("Message (error : %d, state : %d) will be posted using user callback\n", x_error_type, x_state_type); \
84 x_wfd_sink->msg_cb(x_error_type, x_state_type, x_wfd_sink->msg_user_data); \
89 #define MMWFDSINK_CURRENT_STATE( x_wfd_sink) ((mm_wfd_sink_t *)x_wfd_sink)->state.state
90 #define MMWFDSINK_PREVIOUS_STATE( x_wfd_sink) ((mm_wfd_sink_t *)x_wfd_sink)->state.prev_state
91 #define MMWFDSINK_PENDING_STATE( x_wfd_sink) ((mm_wfd_sink_t *)x_wfd_sink)->state.pending_state
92 #define MMWFDSINK_STATE_GET_NAME(x_state) __mm_wfds_sink_get_state_name(x_state)
94 #define MMWFDSINK_PRINT_STATE(x_wfd_sink) \
95 wfd_sink_debug("-- prev %s, current %s, pending %s --\n", \
96 MMWFDSINK_STATE_GET_NAME(MMWFDSINK_PREVIOUS_STATE(x_wfd_sink)), \
97 MMWFDSINK_STATE_GET_NAME(MMWFDSINK_CURRENT_STATE(x_wfd_sink)), \
98 MMWFDSINK_STATE_GET_NAME(MMWFDSINK_PENDING_STATE(x_wfd_sink)));
100 #define MMWFDSINK_CHECK_STATE( x_wfd_sink, x_cmd) \
101 switch ( __mm_wfd_sink_check_state((mm_wfd_sink_t *)x_wfd_sink, x_cmd) ) \
103 case MM_ERROR_NONE: \
105 case MM_ERROR_WFD_NO_OP: \
106 return MM_ERROR_NONE; \
109 return MM_ERROR_WFD_INVALID_STATE; \
116 mm_wfd_sink_util_add_pad_probe(GstPad *pad, GstElement *element, const gchar *pad_name);
118 mm_wfd_sink_util_add_pad_probe_for_checking_first_buffer(GstPad *pad, GstElement *element, const gchar *pad_name);
120 #define MMWFDSINK_PAD_PROBE( x_wfd_sink, x_pad, x_element, x_pad_name ) \
123 if (x_wfd_sink->ini.enable_pad_probe ) \
125 mm_wfd_sink_util_add_pad_probe (x_pad, x_element, (const gchar*)x_pad_name); \
129 mm_wfd_sink_util_add_pad_probe_for_checking_first_buffer (x_pad, x_element, (const gchar*)x_pad_name); \
134 mm_wfd_sink_util_add_pad_probe_for_data_dump(GstElement *element, const gchar *pad_name);
136 #define MMWFDSINK_TS_DATA_DUMP( x_wfd_sink, x_element, x_pad_name ) \
137 if ( x_wfd_sink && x_wfd_sink->ini.enable_ts_data_dump ) \
139 mm_wfd_sink_util_add_pad_probe_for_data_dump (x_element, (const gchar*)x_pad_name); \