[sink] Impelement pause/resume/set resolution API.
[src] Fix prevent defects.
Change-Id: Ib094ae32c4112da936f745c65b8515f76fef42dc
Signed-off-by: Sangkyu Park <sk1122.park@samsung.com>
#endif
#define LOG_TAG "CAPI_MEDIA_SCMIRRORING"
+#define FONT_COLOR_RESET "\033[0m"
+#define FONT_COLOR_RED "\033[31m"
+#define FONT_COLOR_GREEN "\033[32m"
+#define FONT_COLOR_YELLOW "\033[33m"
+#define FONT_COLOR_BLUE "\033[34m"
+#define FONT_COLOR_PURPLE "\033[35m"
+#define FONT_COLOR_CYAN "\033[36m"
+#define FONT_COLOR_GRAY "\033[37m"
+
#define scmirroring_debug(fmt, arg...) do { \
- LOGD(""fmt"", ##arg); \
- } while (0)
+ LOGD(FONT_COLOR_RESET""fmt"", ##arg); \
+ } while (0)
#define scmirroring_info(fmt, arg...) do { \
- LOGI(""fmt"", ##arg); \
- } while (0)
+ LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg); \
+ } while (0)
#define scmirroring_error(fmt, arg...) do { \
- LOGE(""fmt"", ##arg); \
- } while (0)
+ LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
+ } while (0)
#define scmirroring_debug_fenter() do { \
- LOGD("<Enter>"); \
- } while (0)
+ LOGD(FONT_COLOR_RESET"<Enter>"); \
+ } while (0)
#define scmirroring_debug_fleave() do { \
- LOGD("<Leave>"); \
- } while (0)
+ LOGD(FONT_COLOR_RESET"<Leave>"); \
+ } while (0)
#define scmirroring_error_fenter() do { \
- LOGE("NO-ERROR : <Enter>"); \
- } while (0)
+ LOGE(FONT_COLOR_RESET"NO-ERROR : <Enter>"); \
+ } while (0)
#define scmirroring_error_fleave() do { \
- LOGE("NO-ERROR : <Leave>"); \
- } while (0)
+ LOGE(FONT_COLOR_RESET"NO-ERROR : <Leave>"); \
+ } while (0)
#define scmirroring_retvm_if(expr, val, fmt, arg...) do { \
if(expr) { \
- LOGE(""fmt"", ##arg); \
+ LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
return (val); \
} \
} while (0)
#define scmirroring_sucure_info(fmt, arg...) do { \
- SECURE_LOGI(""fmt"", ##arg); \
- } while (0)
+ SECURE_LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg); \
+ } while (0)
#define SCMIRRORING_SAFE_FREE(src) { if(src) {free(src); src = NULL;}}
#define STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
#define SCMIRRORING_STATE_CMD_STOP "STOP"
#define SCMIRRORING_STATE_CMD_DESTROY "DESTROY"
-typedef struct
-{
+typedef struct {
int error_code;
int src_state;
void *user_data;
scmirroring_state_cb state_cb;
}scmirroring_state_cb_s;
-typedef struct
-{
+typedef struct {
int error_code;
int sink_state;
void *user_data;
scmirroring_sink_state_cb state_cb;
}scmirroring_sink_state_cb_s;
-typedef struct
-{
+typedef struct {
char *ip;
char *port;
bool use_hdcp;
scmirroring_state_cb_s *scmirroring_state_cb;
} scmirroring_src_s;
-typedef struct
-{
+typedef struct {
MMHandleType mm_handle;
char *ip;
char *port;
int scmirroring_sink_set_ip_and_port(scmirroring_sink_h scmirroring_sink, const char *ip, const char *port);
/**
- * @brief Pass window handle created by application and surface type (x11/evas)
+ * @brief Pass window handle created by application and surface type(x11/evas)
* @details This function will use handle created by the application to set the overlay &
* display on the surface passed by the application
*
* @since_tizen 2.4
*
* @param[in] scmirroring_sink The handle to the screen mirroring sink
- * @param[in] type Surface type (x11/evas)
+ * @param[in] type Surface type(x11/evas)
* @param[in] display_surface The display_surface created by application to force sink to display content over it
* @return @c 0 on success,
* otherwise a negative error value
int scmirroring_sink_set_display(scmirroring_sink_h scmirroring_sink, scmirroring_display_type_e type, void* display_surface);
/**
- * @brief Sets resolution of screen mirroring sink
- * @details This function sets resolution of screen mirroring sink.
+ * @brief Sets resolutions of screen mirroring sink
+ * @details This function sets resolutions of screen mirroring sink using scmirroring_resolution_e as following.
+ * (ex. SCMIRRORING_RESOLUTION_1920x1080_P30 | SCMIRRORING_RESOLUTION_1280x720_P30)
+ * Use it only when you want to set specific resolutions but if sreen mirroring source dose not support the resolutions which you set,
+ * the screen mirroring sink will be disconnected.
*
* @since_tizen 2.4
*
*
* @see scmirroring_sink_create()
*/
-int scmirroring_sink_set_resolution(scmirroring_sink_h scmirroring_sink, scmirroring_resolution_e resolution);
+int scmirroring_sink_set_resolution(scmirroring_sink_h scmirroring_sink, int resolution);
/**
* @brief Prepares the screen mirroring sink handle and allocates specific resources.
int scmirroring_sink_connect(scmirroring_sink_h scmirroring_sink);
/**
- * @brief Start receiving data from the SCMIRRORING source and display it (mirror)
+ * @brief Start receiving data from the SCMIRRORING source and display it(mirror)
*
* @since_tizen 2.4
* @privlevel public
#include <glib.h>
#ifdef __cplusplus
- extern "C" {
+extern "C" {
#endif
#define ERROR_NONE 0
#define SCMIRRORING_SRC_INI_MAX_STRLEN 80
-typedef enum __scmirroring_ini_videosink_element
-{
- SCMIRRORING_INI_VSINK_V4l2SINK = 0,
- SCMIRRORING_INI_VSINK_XIMAGESINK,
- SCMIRRORING_INI_VSINK_XVIMAGESINK,
- SCMIRRORING_INI_VSINK_FAKESINK,
- SCMIRRORING_INI_VSINK_EVASIMAGESINK,
- SCMIRRORING_INI_VSINK_GLIMAGESINK,
- SCMIRRORING_INI_VSINK_NUM
+typedef enum __scmirroring_ini_videosink_element {
+ SCMIRRORING_INI_VSINK_V4l2SINK = 0,
+ SCMIRRORING_INI_VSINK_XIMAGESINK,
+ SCMIRRORING_INI_VSINK_XVIMAGESINK,
+ SCMIRRORING_INI_VSINK_FAKESINK,
+ SCMIRRORING_INI_VSINK_EVASIMAGESINK,
+ SCMIRRORING_INI_VSINK_GLIMAGESINK,
+ SCMIRRORING_INI_VSINK_NUM
}SCMIRRORING_INI_VSINK_ELEMENT;
-typedef enum __scmirroring_ini_videosrc_element
-{
- SCMIRRORING_INI_VSRC_XVIMAGESRC,
- SCMIRRORING_INI_VSRC_FILESRC,
- SCMIRRORING_INI_VSRC_CAMERASRC,
- SCMIRRORING_INI_VSRC_VIDEOTESTSRC,
- SCMIRRORING_INI_VSRC_NUM
+typedef enum __scmirroring_ini_videosrc_element {
+ SCMIRRORING_INI_VSRC_XVIMAGESRC,
+ SCMIRRORING_INI_VSRC_FILESRC,
+ SCMIRRORING_INI_VSRC_CAMERASRC,
+ SCMIRRORING_INI_VSRC_VIDEOTESTSRC,
+ SCMIRRORING_INI_VSRC_NUM
}SCMIRRORING_INI_VSRC_ELEMENT;
-typedef enum __scmirroring_ini_session_mode
-{
- SCMIRRORING_INI_AUDIO_VIDEO_MUXED,
- SCMIRRORING_INI_VIDEO_ONLY,
- SCMIRRORING_INI_AUDIO_ONLY,
- SCMIRRORING_INI_AUDIO_VIDEO_SAPERATE
+typedef enum __scmirroring_ini_session_mode {
+ SCMIRRORING_INI_AUDIO_VIDEO_MUXED,
+ SCMIRRORING_INI_VIDEO_ONLY,
+ SCMIRRORING_INI_AUDIO_ONLY,
+ SCMIRRORING_INI_AUDIO_VIDEO_SAPERATE
}SCMIRRORING_INI_SESSION_MODE;
*/
/* @ mark means the item has tested */
-typedef struct __scmirroring_src_ini
-{
- /* general */
- SCMIRRORING_INI_VSRC_ELEMENT videosrc_element;
- gint session_mode;
- SCMIRRORING_INI_VSINK_ELEMENT videosink_element; // @
- gchar name_of_video_converter[SCMIRRORING_SRC_INI_MAX_STRLEN];
- gboolean skip_rescan; // @
- gboolean generate_dot; // @
- gboolean provide_clock; // @
- gint mtu_size;
-
- gchar name_of_audio_device[SCMIRRORING_SRC_INI_MAX_STRLEN];
- gint audio_latency_time;
- gint audio_buffer_time;
- gint audio_do_timestamp;
- guint64 video_reso_supported;
- guint decide_udp_bitrate[21];
- gint video_native_resolution;
- gint hdcp_enabled;
- guint8 uibc_gen_capability;
-
- gchar gst_param[SCMIRRORING_SRC_INI_GST_START_PARAMS_NUM][256]; // @
- gboolean disable_segtrap;
-
- gint dump_ts;
+typedef struct __scmirroring_src_ini {
+ /* general */
+ SCMIRRORING_INI_VSRC_ELEMENT videosrc_element;
+ gint session_mode;
+ SCMIRRORING_INI_VSINK_ELEMENT videosink_element;
+ gchar name_of_video_converter[SCMIRRORING_SRC_INI_MAX_STRLEN];
+ gboolean skip_rescan;
+ gboolean generate_dot;
+ gboolean provide_clock;
+ gint mtu_size;
+
+ gchar name_of_audio_device[SCMIRRORING_SRC_INI_MAX_STRLEN];
+ gint audio_latency_time;
+ gint audio_buffer_time;
+ gint audio_do_timestamp;
+ guint64 video_reso_supported;
+ guint decide_udp_bitrate[21];
+ gint video_native_resolution;
+ gint hdcp_enabled;
+ guint8 uibc_gen_capability;
+
+ gchar gst_param[SCMIRRORING_SRC_INI_GST_START_PARAMS_NUM][256];
+ gboolean disable_segtrap;
+
+ gint dump_ts;
} scmirroring_src_ini_t;
#ifdef __cplusplus
- }
+}
#endif
#endif
* @brief Enumeration for screen mirroring error.
* @since_tizen 2.4
*/
-typedef enum
-{
+typedef enum {
SCMIRRORING_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
SCMIRRORING_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
SCMIRRORING_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
* @brief Enumeration for screen mirroring source state.
* @since_tizen 2.4
*/
-typedef enum
-{
+typedef enum {
SCMIRRORING_STATE_NULL = 0, /**< Screen mirroring is created, but not realized yet */
SCMIRRORING_STATE_READY, /**< Screen mirroring is ready to play media */
SCMIRRORING_STATE_CONNECTION_WAIT, /**< Screen mirroring is waiting for connection */
* @brief Enumeration for screen mirroring sink state.
* @since_tizen 2.4
*/
-typedef enum
-{
+typedef enum {
SCMIRRORING_SINK_STATE_NONE = 0, /**< Screen mirroring is not created yet */
SCMIRRORING_SINK_STATE_NULL, /**< Screen mirroring is created, but not prepared yet */
SCMIRRORING_SINK_STATE_PREPARED, /**< Screen mirroring is prepared to play media */
* @brief Enumeration for screen mirroring resolution.
* @since_tizen 2.4
*/
-typedef enum
-{
- SCMIRRORING_RESOLUTION_1920x1080_P30 = 0, /**< W-1920, H-1080, 30 fps*/
- SCMIRRORING_RESOLUTION_1280x720_P30, /**< W-1280, H-720, 30 fps*/
- SCMIRRORING_RESOLUTION_960x540_P30, /**< W-960, H-540, 30 fps*/
- SCMIRRORING_RESOLUTION_864x480_P30, /**< W-864, H-480, 30 fps*/
- SCMIRRORING_RESOLUTION_720x480_P60, /**< W-720, H-480, 30 fps*/
- SCMIRRORING_RESOLUTION_640x480_P60, /**< W-640, H-480, 60 fps*/
- SCMIRRORING_RESOLUTION_640x360_P30, /**< W-640, H-360, 30 fps*/
- SCMIRRORING_RESOLUTION_MAX, /* Number of resolution set */
+typedef enum {
+ SCMIRRORING_RESOLUTION_UNKNOWN = 0,
+ SCMIRRORING_RESOLUTION_1920x1080_P30 =(1 << 0), /**< W-1920, H-1080, 30 fps*/
+ SCMIRRORING_RESOLUTION_1280x720_P30 =(1 << 1), /**< W-1280, H-720, 30 fps*/
+ SCMIRRORING_RESOLUTION_960x540_P30 = (1 << 2), /**< W-960, H-540, 30 fps*/
+ SCMIRRORING_RESOLUTION_864x480_P30 = (1 << 3), /**< W-864, H-480, 30 fps*/
+ SCMIRRORING_RESOLUTION_720x480_P60 = (1 << 4), /**< W-720, H-480, 30 fps*/
+ SCMIRRORING_RESOLUTION_640x480_P60 = (1 << 5), /**< W-640, H-480, 60 fps*/
+ SCMIRRORING_RESOLUTION_640x360_P30 = (1 << 6), /**< W-640, H-360, 30 fps*/
+ SCMIRRORING_RESOLUTION_MAX = 128,
} scmirroring_resolution_e;
/**
* @brief Enumeration for screen mirroring connection mode.
* @since_tizen 2.4
*/
-typedef enum
-{
+typedef enum {
SCMIRRORING_CONNECTION_WIFI_DIRECT = 0, /**< Wi-Fi Direct*/
SCMIRRORING_CONNECTION_MAX, /* Number of Connection mode */
} scmirroring_connection_mode_e;
* @brief Enumeration for screen mirroring display surface type
* @since_tizen 2.4
*/
-typedef enum
-{
+typedef enum {
SCMIRRORING_DISPLAY_TYPE_OVERLAY = 0, /**< Use overlay surface to display streaming multimedia data */
SCMIRRORING_DISPLAY_TYPE_EVAS, /**< Use Evas pixmap surface to display streaming multimedia data */
SCMIRRORING_DISPLAY_TYPE_MAX
*
* @see scmirroring_src_create()
*/
-typedef void (*scmirroring_state_cb)(scmirroring_error_e error, scmirroring_state_e state, void *user_data);
+typedef void(*scmirroring_state_cb)(scmirroring_error_e error, scmirroring_state_e state, void *user_data);
/**
* @brief Called when each status is changed
*
* @see scmirroring_sink_create()
*/
-typedef void (*scmirroring_sink_state_cb)(scmirroring_error_e error, scmirroring_sink_state_e state, void *user_data);
+typedef void(*scmirroring_sink_state_cb)(scmirroring_error_e error, scmirroring_sink_state_e state, void *user_data);
#ifdef __cplusplus
}
static gint g_server_status = MIRACAST_WFD_SOURCE_OFF;
static int __miracast_server_emit_status_signal(int status);
-static const GDBusMethodInfo scmirroring_server_method_info_method =
-{
+static const GDBusMethodInfo scmirroring_server_method_info_method = {
-1,
"launch_method",
NULL,
NULL,
NULL
};
-static const GDBusMethodInfo * const scmirroring_server_method_info_pointers[] = {&scmirroring_server_method_info_method, NULL};
+static const GDBusMethodInfo *const scmirroring_server_method_info_pointers[] = {&scmirroring_server_method_info_method, NULL};
-static const GDBusInterfaceInfo scmirroring_server_interface_info =
-{
+static const GDBusInterfaceInfo scmirroring_server_interface_info = {
-1,
PROC_DBUS_INTERFACE,
(GDBusMethodInfo **) &scmirroring_server_method_info_pointers,
/* Introspection data for the service we are exporting */
static const gchar introspection_xml[] =
- "<node>"
- " <interface name='"PROC_DBUS_INTERFACE"'>"
- " <method name='launch_method'>"
- " </method>"
- " <method name='get_miracast_wfd_source_status'>"
- " <arg type='i' name='status' direction='out'/>"
- " </method>"
- " </interface>"
- "</node>";
-
-
-static void
-handle_method_call (GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
+ "<node>"
+ " <interface name='"PROC_DBUS_INTERFACE"'>"
+ " <method name='launch_method'>"
+ " </method>"
+ " <method name='get_miracast_wfd_source_status'>"
+ " <arg type='i' name='status' direction='out'/>"
+ " </method>"
+ " </interface>"
+ "</node>";
+
+
+static void
+handle_method_call(GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
{
scmirroring_debug("handle_method_call is called\n");
- if(method_name != NULL)
+ if (method_name != NULL)
scmirroring_debug("method_name is %s\n", method_name);
- if (g_strcmp0 (method_name, "launch_method") == 0)
- {
- g_dbus_method_invocation_return_value (invocation, NULL);
- }
- else if(g_strcmp0 (method_name, "get_miracast_wfd_source_status") == 0)
- {
+ if (g_strcmp0(method_name, "launch_method") == 0) {
+ g_dbus_method_invocation_return_value(invocation, NULL);
+ } else if (g_strcmp0(method_name, "get_miracast_wfd_source_status") == 0) {
g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", g_server_status));
}
}
/* for now */
-static const GDBusInterfaceVTable interface_vtable =
-{
+static const GDBusInterfaceVTable interface_vtable = {
handle_method_call,
NULL,
- NULL
+ NULL
};
-static void
-on_bus_acquired (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
+static void
+on_bus_acquired(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
{
guint registration_id;
- scmirroring_debug ("on_bus_acquired called\n");
- registration_id = g_dbus_connection_register_object (connection,
- PROC_DBUS_OBJECT,
- introspection_data->interfaces[0],
- &interface_vtable,
- NULL,
- NULL, /* user_data_free_func */
- NULL); /* GError** */
- g_assert (registration_id > 0);
+ scmirroring_debug("on_bus_acquired called\n");
+ registration_id = g_dbus_connection_register_object(connection,
+ PROC_DBUS_OBJECT,
+ introspection_data->interfaces[0],
+ &interface_vtable,
+ NULL,
+ NULL, /* user_data_free_func */
+ NULL); /* GError** */
+ g_assert(registration_id > 0);
}
-static void
-on_name_acquired (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
+static void
+on_name_acquired(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
{
- scmirroring_debug ("on_name_acquired called\n");
+ scmirroring_debug("on_name_acquired called\n");
}
-static void
-on_name_lost (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
+static void
+on_name_lost(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
{
- scmirroring_debug ("on_name_lost called\n");
+ scmirroring_debug("on_name_lost called\n");
}
typedef struct _MiracastServerObject MiracastServerObject;
#define MIRACAST_SERVER_TYPE_OBJECT (miracast_server_object_get_type())
#define MIRACAST_SERVER_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST \
- ((object), MIRACAST_SERVER_TYPE_OBJECT, MiracastServerObject))
+ ((object), MIRACAST_SERVER_TYPE_OBJECT, MiracastServerObject))
-G_DEFINE_TYPE(MiracastServerObject, miracast_server_object, G_TYPE_OBJECT)
+G_DEFINE_TYPE(MiracastServerObject, miracast_server_object, G_TYPE_OBJECT);
-static void miracast_server_object_init(MiracastServerObject * obj)
+static void miracast_server_object_init(MiracastServerObject *obj)
{
scmirroring_debug("miracast_server_object_init\n");
obj->resolution = -1;
}
-static void miracast_server_object_class_init(MiracastServerObjectClass * klass)
+static void miracast_server_object_class_init(MiracastServerObjectClass *klass)
{
scmirroring_debug("miracast_server_object_class_init\n");
}
return ret;
}
-static void __miracast_server_quit_program(MiracastServerObject * server)
+static void __miracast_server_quit_program(MiracastServerObject *server)
{
scmirroring_error("Quit program is called");
int ret = 0;
if (server->server == NULL) {
- scmirroring_error ("server is already NULL");
+ scmirroring_error("server is already NULL");
goto done;
}
ret = __miracast_server_emit_status_signal(MIRACAST_WFD_SOURCE_OFF);
- if(ret != SCMIRRORING_ERROR_NONE )
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
scmirroring_error("Failed to emit miracast server off signal");
}
- pool = (void*)gst_rtsp_server_get_session_pool (server->server);
- gst_rtsp_session_pool_cleanup (pool);
- g_object_unref (pool);
+ pool = (void *)gst_rtsp_server_get_session_pool(server->server);
+ gst_rtsp_session_pool_cleanup(pool);
+ g_object_unref(pool);
int serv_ref_cnt = GST_OBJECT_REFCOUNT_VALUE(server->server);
- scmirroring_debug ("serv ref cnt:%d", serv_ref_cnt);
+ scmirroring_debug("serv ref cnt:%d", serv_ref_cnt);
- for(i=0; i < serv_ref_cnt; i++)
- g_object_unref (server->server);
+ for (i = 0; i < serv_ref_cnt; i++)
+ g_object_unref(server->server);
done:
__miracast_server_send_resp(server, "OK:DESTROY");
scmirroring_error("__miracast_server_signal_handler call quit_program() %d", signo);
int ret = 0;
- switch(signo)
- {
+ switch (signo) {
case SIGINT:
case SIGQUIT:
case SIGTERM:
ret = __miracast_server_emit_status_signal(MIRACAST_WFD_SOURCE_OFF);
- if(ret != SCMIRRORING_ERROR_NONE )
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
scmirroring_error("Failed to emit miracast server off signal");
}
break;
static void __miracast_server_set_signal()
{
- /*SIGABRT A Process abort signal.
- SIGALRM T Alarm clock.
- SIGBUS A Access to an undefined portion of a memory object.
- SIGCHLD I Child process terminated, stopped,
- SIGCONT C Continue executing, if stopped.
- SIGFPE A Erroneous arithmetic operation.
- SIGHUP T Hangup.
- SIGILL A Illegal instruction.
- SIGINT T Terminal interrupt signal.
- SIGKILL T Kill (cannot be caught or ignored).
- SIGPIPE T Write on a pipe with no one to read it.
- SIGQUIT A Terminal quit signal.
- SIGSEGV A Invalid memory reference.
- SIGSTOP S Stop executing (cannot be caught or ignored).
- SIGTERM T Termination signal.
- SIGTSTP S Terminal stop signal.
- SIGTTIN S Background process attempting read.
- SIGTTOU S Background process attempting write.
- SIGUSR1 T User-defined signal 1.
- SIGUSR2 T User-defined signal 2.
- SIGPOLL T Pollable event.
- SIGPROF T Profiling timer expired.
- SIGSYS A Bad system call.
- SIGTRAP A Trace/breakpoint trap.
- SIGURG I High bandwidth data is available at a socket.
- SIGVTALRM T Virtual timer expired.
- SIGXCPU A CPU time limit exceeded.
- SIGXFSZ A File size limit exceeded.
-
-The default actions are as follows:
-T : Abnormal termination of the process. The process is terminated with all the consequences of _exit()
-A : Abnormal termination of the process.
-I : Ignore the signal.
-S : Stop the process
-*/
+ /*SIGABRT A Process abort signal.
+ SIGALRM T Alarm clock.
+ SIGBUS A Access to an undefined portion of a memory object.
+ SIGCHLD I Child process terminated, stopped,
+ SIGCONT C Continue executing, if stopped.
+ SIGFPE A Erroneous arithmetic operation.
+ SIGHUP T Hangup.
+ SIGILL A Illegal instruction.
+ SIGINT T Terminal interrupt signal.
+ SIGKILL T Kill(cannot be caught or ignored).
+ SIGPIPE T Write on a pipe with no one to read it.
+ SIGQUIT A Terminal quit signal.
+ SIGSEGV A Invalid memory reference.
+ SIGSTOP S Stop executing(cannot be caught or ignored).
+ SIGTERM T Termination signal.
+ SIGTSTP S Terminal stop signal.
+ SIGTTIN S Background process attempting read.
+ SIGTTOU S Background process attempting write.
+ SIGUSR1 T User-defined signal 1.
+ SIGUSR2 T User-defined signal 2.
+ SIGPOLL T Pollable event.
+ SIGPROF T Profiling timer expired.
+ SIGSYS A Bad system call.
+ SIGTRAP A Trace/breakpoint trap.
+ SIGURG I High bandwidth data is available at a socket.
+ SIGVTALRM T Virtual timer expired.
+ SIGXCPU A CPU time limit exceeded.
+ SIGXFSZ A File size limit exceeded.
+
+ The default actions are as follows:
+ T : Abnormal termination of the process. The process is terminated with all the consequences of _exit()
+ A : Abnormal termination of the process.
+ I : Ignore the signal.
+ S : Stop the process
+ */
struct sigaction act_new;
- memset (&act_new, 0, sizeof (struct sigaction));
+ memset(&act_new, 0, sizeof(struct sigaction));
act_new.sa_handler = __miracast_server_signal_handler;
static bool __miracast_server_setup()
{
- GObject *object = NULL;
+ GObject *object = NULL;
scmirroring_debug("__miracast_server_setup start\n");
- introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
+ introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
if (introspection_data == NULL) {
scmirroring_error("Introspection data is NULL");
return false;
}
- object = g_object_new (MIRACAST_SERVER_TYPE_OBJECT, NULL);
+ object = g_object_new(MIRACAST_SERVER_TYPE_OBJECT, NULL);
- g_bus_own_name (G_BUS_TYPE_SYSTEM,
- PROC_DBUS_INTERFACE,
- G_BUS_NAME_OWNER_FLAGS_NONE,
- on_bus_acquired,
- on_name_acquired,
- on_name_lost,
- object,
- NULL);
+ g_bus_own_name(G_BUS_TYPE_SYSTEM,
+ PROC_DBUS_INTERFACE,
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ on_bus_acquired,
+ on_name_acquired,
+ on_name_lost,
+ object,
+ NULL);
g_server_object = object;
serv_addr.sun_family = AF_UNIX;
unlink(MEDIA_IPC_PATH);
- strncpy(serv_addr.sun_path, MEDIA_IPC_PATH, sizeof(serv_addr.sun_path));
+ strncpy(serv_addr.sun_path, MEDIA_IPC_PATH, sizeof(serv_addr.sun_path));
/* Bind to the local address */
- for (i = 0; i < 20; i ++) {
+ for (i = 0; i < 20; i++) {
if (bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == 0) {
bind_success = true;
break;
/*change permission of sock file*/
if (chmod(MEDIA_IPC_PATH, 0770) < 0)
- scmirroring_error ("chmod failed [%s]", strerror(errno));
+ scmirroring_error("chmod failed [%s]", strerror(errno));
if (chown(MEDIA_IPC_PATH, 200, 5000) < 0)
- scmirroring_error ("chown failed [%s]", strerror(errno));
+ scmirroring_error("chown failed [%s]", strerror(errno));
scmirroring_debug("Listening...");
*sockfd = sock;
void __miracast_server_msg_cb(gboolean is_error, void *userdata)
{
- //MiracastServerObject *server = (MiracastServerObject *)userdata;
+ /*MiracastServerObject *server = (MiracastServerObject *)userdata; */
- if(is_error) {
+ if (is_error) {
scmirroring_error("Error occured");
}
}
int __miracast_server_gst_init()
{
- gint* argc = NULL;
- gchar** argv = NULL;
+ gint *argc = NULL;
+ gchar **argv = NULL;
static const int max_argc = 50;
GError *err = NULL;
- int i = 0;
+ int i = 0;
/* alloc */
- argc = calloc(1, sizeof(int) );
- argv = calloc(max_argc, sizeof(gchar*));
+ argc = calloc(1, sizeof(int));
+ argv = calloc(max_argc, sizeof(gchar *));
if (!argc || !argv) {
scmirroring_error("Cannot allocate memory for scmirroringsink\n");
goto ERROR;
(*argc)++;
/* check disable registry scan */
- if (scmirroring_src_ini_get_structure()->skip_rescan ) {
+ if (scmirroring_src_ini_get_structure()->skip_rescan) {
argv[*argc] = g_strdup("--gst-disable-registry-update");
(*argc)++;
}
/* check disable segtrap */
- if (scmirroring_src_ini_get_structure()->disable_segtrap ) {
+ if (scmirroring_src_ini_get_structure()->disable_segtrap) {
argv[*argc] = g_strdup("--gst-disable-segtrap");
(*argc)++;
}
scmirroring_debug("initializing gstreamer with following parameter\n");
scmirroring_debug("argc : %d\n", *argc);
- for (i = 0; i < SCMIRRORING_SRC_INI_GST_START_PARAMS_NUM; i++ ) {
- if (g_strcmp0(scmirroring_src_ini_get_structure()->gst_param[i],"") != 0) {
+ for (i = 0; i < SCMIRRORING_SRC_INI_GST_START_PARAMS_NUM; i++) {
+ if (g_strcmp0(scmirroring_src_ini_get_structure()->gst_param[i], "") != 0) {
argv[*argc] = g_strdup(scmirroring_src_ini_get_structure()->gst_param[i]);
(*argc)++;
}
}
- for ( i = 0; i < *argc; i++ ) {
+ for (i = 0; i < *argc; i++) {
scmirroring_debug("argv[%d] : %s\n", i, argv[i]);
}
/* initializing gstreamer */
- if ( ! gst_init_check (argc, &argv, &err)) {
+ if (!gst_init_check(argc, &argv, &err)) {
scmirroring_error("Could not initialize GStreamer: %s\n", err ? err->message : "unknown error occurred");
if (err) {
- g_error_free (err);
- }
+ g_error_free(err);
+ }
goto ERROR;
}
/* release */
- for ( i = 0; i < *argc; i++ ) {
- SCMIRRORING_SAFE_FREE( argv[i] );
+ for (i = 0; i < *argc; i++) {
+ SCMIRRORING_SAFE_FREE(argv[i]);
}
+ SCMIRRORING_SAFE_FREE(argc);
return SCMIRRORING_ERROR_NONE;
ERROR:
- SCMIRRORING_SAFE_FREE(argv);
+ for (i = 0; i < *argc; i++) {
+ SCMIRRORING_SAFE_FREE(argv[i]);
+ }
SCMIRRORING_SAFE_FREE(argc);
return SCMIRRORING_ERROR_INVALID_OPERATION;
}
#define VIDEO_PIPELINE "ximagesrc ! videorate ! videoscale ! videoconvert ! " \
- "video/x-raw,width=1280,height=720,framerate=30/1 ! " \
- "x264enc aud=false byte-stream=true bitrate=512 ! video/x-h264,profile=baseline ! mpegtsmux wfd-mode=TRUE ! " \
- "rtpmp2tpay name=pay0 pt=33"
+ "video/x-raw, width=1280, height=720, framerate=30/1 ! " \
+ "x264enc aud=false byte-stream=true bitrate=512 ! video/x-h264, profile=baseline ! mpegtsmux wfd-mode=TRUE ! " \
+ "rtpmp2tpay name=pay0 pt=33"
#define AUDIO_PIPELINE "pulsesrc device=alsa_output.0.analog-stereo.monitor ! audioconvert ! " \
- "faac ! mpegtsmux wfd-mode=TRUE ! " \
- "rtpmp2tpay name=pay0 pt=33"
+ "faac ! mpegtsmux wfd-mode=TRUE ! " \
+ "rtpmp2tpay name=pay0 pt=33"
#define SCMIRRORING_PIPELINE "ximagesrc ! videoscale ! videoconvert ! " \
- "video/x-raw,width=1280,height=720,framerate=60/1 ! " \
- "x264enc aud=false byte-stream=true bitrate=512 ! video/x-h264,profile=baseline ! mpegtsmux name=mux " \
- "pulsesrc device=alsa_output.0.analog-stereo.monitor ! audioconvert ! " \
- "faac ! mux. mux. ! " \
- "rtpmp2tpay name=pay0 pt=33"
+ "video/x-raw, width=1280, height=720, framerate=60/1 ! " \
+ "x264enc aud=false byte-stream=true bitrate=512 ! video/x-h264, profile=baseline ! mpegtsmux name=mux " \
+ "pulsesrc device=alsa_output.0.analog-stereo.monitor ! audioconvert ! " \
+ "faac ! mux. mux. ! " \
+ "rtpmp2tpay name=pay0 pt=33"
#define TEST_MOUNT_POINT "/wfd1.0/streamid=0"
static void
-__client_closed (GstRTSPClient * client)
+__client_closed(GstRTSPClient *client)
{
if (client == NULL) return;
- scmirroring_debug ("client %p: connection closed", client);
+ scmirroring_debug("client %p: connection closed", client);
return;
}
static void
-__new_session (GstRTSPClient * client, GstRTSPSession *session)
+__new_session(GstRTSPClient *client, GstRTSPSession *session)
{
if (client == NULL) return;
- scmirroring_debug ("New session(%p) is made for client %p", session, client);
+ scmirroring_debug("New session(%p) is made for client %p", session, client);
return;
}
static void
-__teardown_req (GstRTSPClient * client, GstRTSPContext *ctx)
+__teardown_req(GstRTSPClient *client, GstRTSPContext *ctx)
{
if (client == NULL) return;
- scmirroring_debug ("Got TEARDOWN request for client %p", client);
+ scmirroring_debug("Got TEARDOWN request for client %p", client);
return;
}
-static void
-__miracast_server_client_connected_cb (GstRTSPServer * server,
- GstRTSPClient * client, gpointer user_data)
+static void
+__miracast_server_client_connected_cb(GstRTSPServer *server,
+ GstRTSPClient *client, gpointer user_data)
{
MiracastServerObject *server_obj = (MiracastServerObject *)user_data;
int ret = SCMIRRORING_ERROR_NONE;
server_obj->client = (void *)client;
ret = __miracast_server_emit_status_signal(MIRACAST_WFD_SOURCE_ON);
- if(ret != SCMIRRORING_ERROR_NONE )
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
scmirroring_error("Failed to emit miracast server on signal");
}
__miracast_server_send_resp(server_obj, "OK:CONNECTED");
}
-int __miracast_server_start(MiracastServerObject * server_obj)
+int __miracast_server_start(MiracastServerObject *server_obj)
{
int ret = SCMIRRORING_ERROR_NONE;
- if (scmirroring_src_ini_load() != ERROR_NONE) {
+ if (scmirroring_src_ini_load() != ERROR_NONE) {
scmirroring_error("Error occurred during parsing config file");
return SCMIRRORING_ERROR_INVALID_OPERATION;
- }
+ }
ret = __miracast_server_gst_init();
if (ret < SCMIRRORING_ERROR_NONE) {
GstRTSPMediaFactoryWFD *factory = NULL;
GstRTSPMountPoints *mounts = NULL;
- server = (void*)gst_rtsp_wfd_server_new();
+ server = (void *)gst_rtsp_wfd_server_new();
if (NULL == server) {
scmirroring_error("Failed to create server...");
return SCMIRRORING_ERROR_OUT_OF_MEMORY;
}
- gst_rtsp_server_set_address(GST_RTSP_SERVER(server), server_obj->ip);
+ gst_rtsp_server_set_address(GST_RTSP_SERVER(server), server_obj->ip);
gst_rtsp_server_set_service(GST_RTSP_SERVER(server), server_obj->port);
- mounts = gst_rtsp_server_get_mount_points (GST_RTSP_SERVER(server));
+ mounts = gst_rtsp_server_get_mount_points(GST_RTSP_SERVER(server));
- factory = gst_rtsp_media_factory_wfd_new ();
+ factory = gst_rtsp_media_factory_wfd_new();
- gst_rtsp_media_factory_wfd_set (factory,
- scmirroring_src_ini_get_structure()->videosrc_element,
- scmirroring_src_ini_get_structure()->name_of_audio_device,
- scmirroring_src_ini_get_structure()->audio_latency_time,
- scmirroring_src_ini_get_structure()->audio_buffer_time,
- scmirroring_src_ini_get_structure()->audio_do_timestamp,
- scmirroring_src_ini_get_structure()->mtu_size
- );
+ gst_rtsp_media_factory_wfd_set(factory,
+ scmirroring_src_ini_get_structure()->videosrc_element,
+ scmirroring_src_ini_get_structure()->name_of_audio_device,
+ scmirroring_src_ini_get_structure()->audio_latency_time,
+ scmirroring_src_ini_get_structure()->audio_buffer_time,
+ scmirroring_src_ini_get_structure()->audio_do_timestamp,
+ scmirroring_src_ini_get_structure()->mtu_size
+ );
if (server_obj->resolution == SCMIRRORING_RESOLUTION_1920x1080_P30) {
} else {
gst_rtsp_wfd_server_set_video_native_reso(server, GST_WFD_VIDEO_CEA_RESOLUTION);
gst_rtsp_wfd_server_set_supported_reso(server,
- scmirroring_src_ini_get_structure()->video_reso_supported);
+ scmirroring_src_ini_get_structure()->video_reso_supported);
}
- gst_rtsp_media_factory_wfd_set_dump_ts (factory,
- scmirroring_src_ini_get_structure()->dump_ts);
+ gst_rtsp_media_factory_wfd_set_dump_ts(factory,
+ scmirroring_src_ini_get_structure()->dump_ts);
- g_object_ref (factory);
- gst_rtsp_mount_points_add_factory (mounts, TEST_MOUNT_POINT, GST_RTSP_MEDIA_FACTORY(factory));
- g_object_unref (mounts);
+ g_object_ref(factory);
+ gst_rtsp_mount_points_add_factory(mounts, TEST_MOUNT_POINT, GST_RTSP_MEDIA_FACTORY(factory));
+ g_object_unref(mounts);
/* attach the server to the default maincontext */
- if ((id = gst_rtsp_server_attach (GST_RTSP_SERVER_CAST(server), NULL)) == 0)
+ if ((id = gst_rtsp_server_attach(GST_RTSP_SERVER_CAST(server), NULL)) == 0)
goto failed;
- g_signal_connect (server, "client-connected",
- G_CALLBACK (__miracast_server_client_connected_cb), server_obj);
+ g_signal_connect(server, "client-connected",
+ G_CALLBACK(__miracast_server_client_connected_cb), server_obj);
- server_obj->server = (void*) server;
- server_obj->factory = (void*) factory;
+ server_obj->server = (void *) server;
+ server_obj->factory = (void *) factory;
return SCMIRRORING_ERROR_NONE;
return SCMIRRORING_ERROR_INVALID_OPERATION;
}
-void __miracast_server_interpret(MiracastServerObject * server, char *buf)
+void __miracast_server_interpret(MiracastServerObject *server, char *buf)
{
int ret = SCMIRRORING_ERROR_NONE;
__miracast_server_send_resp(server, "OK:SET");
} else if (g_strrstr(buf, SCMIRRORING_STATE_CMD_PAUSE)) {
- gst_rtsp_wfd_server_trigger_request (GST_RTSP_SERVER(server->server), WFD_TRIGGER_PAUSE);
+ gst_rtsp_wfd_server_trigger_request(GST_RTSP_SERVER(server->server), WFD_TRIGGER_PAUSE);
__miracast_server_send_resp(server, "OK:PAUSE");
} else if (g_strrstr(buf, SCMIRRORING_STATE_CMD_RESUME)) {
- gst_rtsp_wfd_server_trigger_request (GST_RTSP_SERVER(server->server), WFD_TRIGGER_PLAY);
+ gst_rtsp_wfd_server_trigger_request(GST_RTSP_SERVER(server->server), WFD_TRIGGER_PLAY);
__miracast_server_send_resp(server, "OK:RESUME");
} else if (g_strrstr(buf, SCMIRRORING_STATE_CMD_STOP)) {
- gst_rtsp_wfd_server_trigger_request (GST_RTSP_SERVER(server->server), WFD_TRIGGER_TEARDOWN);
+ gst_rtsp_wfd_server_trigger_request(GST_RTSP_SERVER(server->server), WFD_TRIGGER_TEARDOWN);
__miracast_server_send_resp(server, "OK:STOP");
} else if (g_strrstr(buf, SCMIRRORING_STATE_CMD_DESTROY)) {
__miracast_server_quit_program(server);
}
}
-int __miracast_server_accept(int serv_sock, int* client_sock)
+int __miracast_server_accept(int serv_sock, int *client_sock)
{
int sockfd = -1;
struct sockaddr_un client_addr;
return SCMIRRORING_ERROR_INVALID_PARAMETER;
client_addr_len = sizeof(client_addr);
- if ((sockfd = accept(serv_sock, (struct sockaddr*)&client_addr, &client_addr_len)) < 0) {
+ if ((sockfd = accept(serv_sock, (struct sockaddr *)&client_addr, &client_addr_len)) < 0) {
scmirroring_error("accept failed : %s", strerror(errno));
*client_sock = -1;
return SCMIRRORING_ERROR_INVALID_OPERATION;
}
gboolean __miracast_server_client_read_cb(GIOChannel *src,
- GIOCondition condition,
- gpointer data)
+ GIOCondition condition,
+ gpointer data)
{
char buf[MAX_MSG_LEN + 1];
gsize read;
continue;
}
scmirroring_debug("Handling %s", str);
- __miracast_server_interpret (server, str);
+ __miracast_server_interpret(server, str);
if (idx >= read) break;
}
gboolean __miracast_server_read_cb(GIOChannel *src,
- GIOCondition condition,
- gpointer data)
+ GIOCondition condition,
+ gpointer data)
{
MiracastServerObject *server = (MiracastServerObject *)data;
/* Create new channel to watch udp socket */
GSource *source = NULL;
source = g_io_create_watch(channel, G_IO_IN | G_IO_HUP | G_IO_ERR);
- //int source_id = -1;
+ /*int source_id = -1; */
/* To avoid blocking in g_io_channel_read_chars */
g_io_channel_set_encoding(channel, NULL, NULL);
g_io_channel_set_buffered(channel, FALSE);
- g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL);
+ g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL);
server->client_channel = channel;
gboolean ret;
if (status != MIRACAST_WFD_SOURCE_ON && status != MIRACAST_WFD_SOURCE_OFF) {
- scmirroring_error ("invalid arguments [%d]", status);
+ scmirroring_error("invalid arguments [%d]", status);
return -1;
}
if (g_server_status == status) {
- scmirroring_debug ("The server status is not changed, status [%d] ", status);
+ scmirroring_debug("The server status is not changed, status [%d] ", status);
return 0;
}
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
if (!conn && err) {
- scmirroring_error("g_bus_get_sync() error (%s) ", err->message);
- g_error_free (err);
+ scmirroring_error("g_bus_get_sync() error(%s) ", err->message);
+ g_error_free(err);
return -1;
}
- ret = g_dbus_connection_emit_signal (conn,
- NULL, PROC_DBUS_OBJECT, PROC_DBUS_INTERFACE, PROC_DBUS_STATUS_CHANGE_SIGNAL,
- g_variant_new ("(i)", status), &err);
+ ret = g_dbus_connection_emit_signal(conn,
+ NULL, PROC_DBUS_OBJECT, PROC_DBUS_INTERFACE, PROC_DBUS_STATUS_CHANGE_SIGNAL,
+ g_variant_new("(i)", status), &err);
if (!ret && err) {
- scmirroring_error("g_dbus_connection_emit_signal() error (%s) ", err->message);
+ scmirroring_error("g_dbus_connection_emit_signal() error(%s) ", err->message);
goto error;
}
ret = g_dbus_connection_flush_sync(conn, NULL, &err);
if (!ret && err) {
- scmirroring_error("g_dbus_connection_flush_sync() error (%s) ", err->message);
+ scmirroring_error("g_dbus_connection_flush_sync() error(%s) ", err->message);
goto error;
}
g_object_unref(conn);
- scmirroring_debug ("sending miracast server status [%s] success",
- (status == MIRACAST_WFD_SOURCE_ON) ? "On" : "Off");
+ scmirroring_debug("sending miracast server status [%s] success",
+ (status == MIRACAST_WFD_SOURCE_ON) ? "On" : "Off");
g_server_status = status;
return 0;
error:
- g_error_free (err);
- g_object_unref(conn);
+ g_error_free(err);
+ if (conn) g_object_unref(conn);
return -1;
}
GIOChannel *channel = NULL;
GMainContext *context = NULL;
-#if !GLIB_CHECK_VERSION(2,35,0)
+#if !GLIB_CHECK_VERSION(2, 35, 0)
g_type_init();
#endif
g_mainloop = g_main_loop_new(NULL, FALSE);
- if(NULL == g_mainloop) {
+ if (NULL == g_mainloop) {
scmirroring_error("Unable to create gmain loop! Aborting rtsp server\n");
exit(-1);
}
Name: capi-media-screen-mirroring
Summary: A screen mirroring library in Tizen C API
-Version: 0.1.30
+Version: 0.1.34
Release: 0
Group: Multimedia/API
License: Apache License, Version 2.0
#include <scmirroring_sink.h>
#include <scmirroring_private.h>
-static scmirroring_error_e __scmirroring_sink_error_convert(const char* func, int error)
+static scmirroring_error_e __scmirroring_sink_error_convert(const char *func, int error)
{
int ret = SCMIRRORING_ERROR_NONE;
const char *errorstr = NULL;
- switch(error)
- {
+ switch (error) {
case MM_ERROR_NONE:
ret = SCMIRRORING_ERROR_NONE;
errorstr = "ERROR_NONE";
break;
- case MM_ERROR_WFD_NOT_INITIALIZED :
- case MM_ERROR_COMMON_INVALID_ATTRTYPE :
- case MM_ERROR_COMMON_INVALID_PERMISSION :
- case MM_ERROR_COMMON_OUT_OF_ARRAY :
- case MM_ERROR_COMMON_OUT_OF_RANGE :
- case MM_ERROR_COMMON_ATTR_NOT_EXIST :
+ case MM_ERROR_WFD_NOT_INITIALIZED:
+ case MM_ERROR_COMMON_INVALID_ATTRTYPE:
+ case MM_ERROR_COMMON_INVALID_PERMISSION:
+ case MM_ERROR_COMMON_OUT_OF_ARRAY:
+ case MM_ERROR_COMMON_OUT_OF_RANGE:
+ case MM_ERROR_COMMON_ATTR_NOT_EXIST:
ret = SCMIRRORING_ERROR_INVALID_PARAMETER;
errorstr = "INVALID_PARAMETER";
break;
errorstr = "INVALID_OPERATION";
}
- if(ret != SCMIRRORING_ERROR_NONE)
+ if (ret != SCMIRRORING_ERROR_NONE)
scmirroring_error("[%s] %s (0x%08x) : core frameworks error code(0x%08x)", func, errorstr, ret, error);
else
scmirroring_debug("[%s] %s", func, errorstr);
{
scmirroring_sink_state_e state = SCMIRRORING_SINK_STATE_NONE;
- switch( mm_state )
- {
+ switch (mm_state) {
case MM_WFD_SINK_STATE_NONE:
state = SCMIRRORING_SINK_STATE_NONE;
break;
{
scmirroring_error_e error = __scmirroring_sink_error_convert(__func__, error_type);
scmirroring_sink_state_e state = __scmirroring_sink_state_convert(state_type);
- scmirroring_sink_s *handle = (scmirroring_sink_s*)uData;
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)uData;
/* call application callback */
if (handle->scmirroring_sink_state_cb->state_cb)
scmirroring_retvm_if(scmirroring_sink == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
- scmirroring_sink_s *handle = (scmirroring_sink_s*)calloc(1, sizeof(scmirroring_sink_s));
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)calloc(1, sizeof(scmirroring_sink_s));
scmirroring_retvm_if(handle == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
handle->mm_handle = 0;
- handle->ip= NULL;
+ handle->ip = NULL;
handle->port = NULL;
handle->use_hdcp = TRUE;
handle->scmirroring_sink_state_cb = NULL;
ret = mm_wfd_sink_create(&handle->mm_handle);
- if(ret != MM_ERROR_NONE)
- {
+ if (ret != MM_ERROR_NONE) {
SCMIRRORING_SAFE_FREE(handle);
scmirroring_error("Fail to Create");
- return __scmirroring_sink_error_convert(__func__,ret);
+ return __scmirroring_sink_error_convert(__func__, ret);
}
*scmirroring_sink = (scmirroring_sink_h)handle;
int scmirroring_sink_set_ip_and_port(scmirroring_sink_h scmirroring_sink, const char *ip, const char *port)
{
- scmirroring_sink_s *handle = (scmirroring_sink_s*)scmirroring_sink;
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink;
scmirroring_error_fenter();
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_sink_s *handle = (scmirroring_sink_s*)scmirroring_sink;
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink;
scmirroring_error_fenter();
int scmirroring_sink_connect(scmirroring_sink_h scmirroring_sink)
{
int ret = SCMIRRORING_ERROR_NONE;
- char server_uri[255] = {0,};
+ char server_uri[255] = {0, };
- scmirroring_sink_s *handle = (scmirroring_sink_s*)scmirroring_sink;
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink;
scmirroring_error_fenter();
scmirroring_retvm_if(handle == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
- if(handle->ip == NULL)
- {
- scmirroring_error("INVALID_IP(NULL) (0x%08x)",SCMIRRORING_ERROR_INVALID_PARAMETER);
+ if (handle->ip == NULL) {
+ scmirroring_error("INVALID_IP(NULL) (0x%08x)", SCMIRRORING_ERROR_INVALID_PARAMETER);
return SCMIRRORING_ERROR_INVALID_PARAMETER;
}
- if(handle->port == NULL)
- {
- scmirroring_error("INVALID_PORT(NULL) (0x%08x)",SCMIRRORING_ERROR_INVALID_PARAMETER);
+ if (handle->port == NULL) {
+ scmirroring_error("INVALID_PORT(NULL) (0x%08x)", SCMIRRORING_ERROR_INVALID_PARAMETER);
return SCMIRRORING_ERROR_INVALID_PARAMETER;
}
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_sink_s *handle = (scmirroring_sink_s*)scmirroring_sink;
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink;
scmirroring_error_fenter();
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_sink_s *handle = (scmirroring_sink_s*)scmirroring_sink;
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink;
scmirroring_error_fenter();
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_sink_s *handle = (scmirroring_sink_s*)scmirroring_sink;
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink;
scmirroring_error_fenter();
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_sink_s *handle = (scmirroring_sink_s*)scmirroring_sink;
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink;
scmirroring_error_fenter();
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_sink_s *handle = (scmirroring_sink_s*)scmirroring_sink;
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink;
scmirroring_error_fenter();
scmirroring_retvm_if(handle == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
scmirroring_retvm_if(callback == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "callback is NULL");
- if(handle->scmirroring_sink_state_cb == NULL)
- {
- handle->scmirroring_sink_state_cb = (scmirroring_sink_state_cb_s*)calloc(1, sizeof(scmirroring_sink_state_cb_s));
- if(handle->scmirroring_sink_state_cb == NULL)
- {
+ if (handle->scmirroring_sink_state_cb == NULL) {
+ handle->scmirroring_sink_state_cb = (scmirroring_sink_state_cb_s *)calloc(1, sizeof(scmirroring_sink_state_cb_s));
+ if (handle->scmirroring_sink_state_cb == NULL) {
scmirroring_error("Error Set CB");
return SCMIRRORING_ERROR_OUT_OF_MEMORY;
}
- }
- else
- {
+ } else {
memset(handle->scmirroring_sink_state_cb, 0, sizeof(scmirroring_sink_state_cb_s));
}
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_sink_s *handle = (scmirroring_sink_s*)scmirroring_sink;
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink;
scmirroring_error_fenter();
return ret;
}
-int scmirroring_sink_set_display(scmirroring_sink_h scmirroring_sink, scmirroring_display_type_e type, void * display_surface)
+int scmirroring_sink_set_display(scmirroring_sink_h scmirroring_sink, scmirroring_display_type_e type, void *display_surface)
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_sink_s *handle = (scmirroring_sink_s*)scmirroring_sink;
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink;
scmirroring_error_fenter();
scmirroring_retvm_if(handle == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
scmirroring_retvm_if(display_surface == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "display_surface is NULL");
- if((type != SCMIRRORING_DISPLAY_TYPE_OVERLAY) && (type != SCMIRRORING_DISPLAY_TYPE_EVAS))
- {
+ if ((type != SCMIRRORING_DISPLAY_TYPE_OVERLAY) && (type != SCMIRRORING_DISPLAY_TYPE_EVAS)) {
scmirroring_error("Invalid display type [%d]", type);
return SCMIRRORING_ERROR_INVALID_PARAMETER;
}
- scmirroring_debug("display type (%d)", type);
+ scmirroring_debug("display type(%d)", type);
ret = mm_wfd_sink_set_attribute(handle->mm_handle, NULL, "display_surface_type", type, NULL);
- if(ret != MM_ERROR_NONE)
- {
+ if (ret != MM_ERROR_NONE) {
scmirroring_error("Fail to Set Display Type");
- return __scmirroring_sink_error_convert(__func__,ret);
+ return __scmirroring_sink_error_convert(__func__, ret);
}
- ret = mm_wfd_sink_set_attribute(handle->mm_handle, NULL, "display_overlay", display_surface, sizeof(display_surface), NULL);
- if(ret != MM_ERROR_NONE)
- {
+ ret = mm_wfd_sink_set_attribute(handle->mm_handle, NULL, "display_overlay", display_surface, sizeof(void *), NULL);
+ if (ret != MM_ERROR_NONE) {
scmirroring_error("Fail to Set Display Overlay");
- return __scmirroring_sink_error_convert(__func__,ret);
+ return __scmirroring_sink_error_convert(__func__, ret);
}
ret = __scmirroring_sink_error_convert(__func__, ret);
return ret;
}
-int scmirroring_sink_set_resolution(scmirroring_sink_h scmirroring_sink, scmirroring_resolution_e resolution)
+int scmirroring_sink_set_resolution(scmirroring_sink_h scmirroring_sink, int resolution)
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_sink_s *handle = (scmirroring_sink_s*)scmirroring_sink;
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink;
scmirroring_error_fenter();
scmirroring_retvm_if(handle == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
- if((resolution < SCMIRRORING_RESOLUTION_1920x1080_P30) ||(resolution >= SCMIRRORING_RESOLUTION_MAX))
- {
+ if ((resolution < SCMIRRORING_RESOLUTION_1920x1080_P30) || (resolution >= SCMIRRORING_RESOLUTION_MAX)) {
scmirroring_error("INVALID resolution : %d", resolution);
return SCMIRRORING_ERROR_INVALID_PARAMETER;
}
+ scmirroring_debug("resolution(%d)", resolution);
+ ret = mm_wfd_sink_set_resolution(handle->mm_handle, resolution);
+ if (ret != MM_ERROR_NONE) {
+ scmirroring_error("Fail to Set resolution");
+ return __scmirroring_sink_error_convert(__func__, ret);
+ }
+
+ ret = __scmirroring_sink_error_convert(__func__, ret);
+
scmirroring_error_fleave();
return ret;
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_sink_s *handle = (scmirroring_sink_s*)scmirroring_sink;
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink;
scmirroring_error_fenter();
scmirroring_retvm_if(handle == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
+ ret = mm_wfd_sink_pause(handle->mm_handle);
+
+ ret = __scmirroring_sink_error_convert(__func__, ret);
+
scmirroring_error_fleave();
return ret;
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_sink_s *handle = (scmirroring_sink_s*)scmirroring_sink;
+ scmirroring_sink_s *handle = (scmirroring_sink_s *)scmirroring_sink;
scmirroring_error_fenter();
scmirroring_retvm_if(handle == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
+ ret = mm_wfd_sink_resume(handle->mm_handle);
+
+ ret = __scmirroring_sink_error_convert(__func__, ret);
+
scmirroring_error_fleave();
return ret;
scmirroring_src_s *scmirroring = (scmirroring_src_s *) data;
if (scmirroring == NULL) {
- scmirroring_error ("SCMIRRORING is NULL");
+ scmirroring_error("SCMIRRORING is NULL");
return FALSE;
}
scmirroring_state_cb_s *cb_info = scmirroring->scmirroring_state_cb;
- if((cb_info != NULL) && (cb_info->state_cb != NULL)) {
- scmirroring_debug("Calling user callback (error: %d, status: %d)", cb_info->error_code, cb_info->src_state);
+ if ((cb_info != NULL) && (cb_info->state_cb != NULL)) {
+ scmirroring_debug("Calling user callback(error: %d, status: %d)", cb_info->error_code, cb_info->src_state);
cb_info->state_cb(cb_info->error_code, cb_info->src_state, cb_info->user_data);
}
- if (cb_info->src_state == SCMIRRORING_STATE_NULL) {
+ if (cb_info != NULL && cb_info->src_state == SCMIRRORING_STATE_NULL) {
SCMIRRORING_SAFE_FREE(scmirroring->ip);
SCMIRRORING_SAFE_FREE(scmirroring->port);
SCMIRRORING_SAFE_FREE(scmirroring->scmirroring_state_cb);
GDBusConnection *conn = NULL;
GError *error = NULL;
-#if !GLIB_CHECK_VERSION(2,35,0)
+#if !GLIB_CHECK_VERSION(2, 35, 0)
g_type_init();
#endif
- scmirroring_debug("----------- socket connect failed it means server is not yet started ------------");
+ scmirroring_debug("-----------socket connect failed it means server is not yet started------------");
scmirroring_debug("going to start miracast server");
conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
}
proxy = g_dbus_proxy_new_sync(conn,
- G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
- NULL,
- "org.tizen.scmirroring.server",
- "/org/tizen/scmirroring/server",
- "org.tizen.scmirroring.server",
- NULL,
- &error);
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
+ NULL,
+ "org.tizen.scmirroring.server",
+ "/org/tizen/scmirroring/server",
+ "org.tizen.scmirroring.server",
+ NULL,
+ &error);
if (error) {
scmirroring_error("g_dbus_proxy_new_sync failed : %s", error->message);
g_error_free(error);
return SCMIRRORING_ERROR_INVALID_OPERATION;
}
- g_dbus_proxy_call_sync (proxy, "launch_method", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ g_dbus_proxy_call_sync(proxy, "launch_method", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (error) {
scmirroring_error("g_dbus_proxy_call_sync failed : %s", error->message);
g_error_free(error);
return SCMIRRORING_STATE_NONE;
}
-static void __scmirroring_src_set_callback_info (scmirroring_src_s *scmirroring, int error_code, int state)
+static void __scmirroring_src_set_callback_info(scmirroring_src_s *scmirroring, int error_code, int state)
{
scmirroring_state_cb_s *cb_info = scmirroring->scmirroring_state_cb;
if (cb_info) {
cb_info->src_state = state;
GSource *src_user_cb = NULL;
- src_user_cb = g_idle_source_new ();
+ src_user_cb = g_idle_source_new();
g_source_set_callback(src_user_cb, (GSourceFunc)__scmirroring_src_callback_call, scmirroring, NULL);
g_source_attach(src_user_cb, g_main_context_get_thread_default());
} else {
int error_code = SCMIRRORING_ERROR_INVALID_OPERATION;
int src_state = SCMIRRORING_STATE_NONE;
gchar **response;
- response = g_strsplit(buf, ":", 0);
+ response = g_strsplit(buf, ":", 0);
scmirroring_debug("error: %s, status: %s", response[0], response[1]);
if (scmirroring->current_state != src_state) {
scmirroring->current_state = src_state;
- __scmirroring_src_set_callback_info (scmirroring, error_code, src_state);
+ __scmirroring_src_set_callback_info(scmirroring, error_code, src_state);
} else {
scmirroring_debug("Current state is already %d", src_state);
}
{
char buf[MAX_MSG_LEN + 1];
gsize read;
-
+
scmirroring_src_s *_scmirroring = (scmirroring_src_s *)data;
if (condition & G_IO_IN) {
continue;
}
scmirroring_debug("Handling %s", str);
- __scmirroring_src_interpret (_scmirroring, str);
+ __scmirroring_src_interpret(_scmirroring, str);
if (idx >= read) break;
}
} else if (condition & G_IO_ERR) {
return TRUE;
}
-static int __scmirroring_src_send_set_cm (scmirroring_src_h scmirroring)
+static int __scmirroring_src_send_set_cm(scmirroring_src_h scmirroring)
{
/* Set connection mode to miracast server */
char *cmd = NULL;
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
cmd = g_strdup_printf("SET CM %d", _scmirroring->connect_mode);
ret = __scmirroring_src_send_cmd_to_server(_scmirroring, cmd);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
SCMIRRORING_SAFE_FREE(cmd);
scmirroring_error("Failed to be ready [%d]", ret);
return SCMIRRORING_ERROR_INVALID_OPERATION;
/* Set IP and Port to server */
char *cmd = NULL;
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
cmd = g_strdup_printf("SET IP %s:%s", _scmirroring->ip, _scmirroring->port);
ret = __scmirroring_src_send_cmd_to_server(_scmirroring, cmd);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
SCMIRRORING_SAFE_FREE(cmd);
scmirroring_error("Failed to be ready [%d]", ret);
return SCMIRRORING_ERROR_INVALID_OPERATION;
return ret;
}
-static int __scmirroring_src_send_set_reso (scmirroring_src_h scmirroring)
+static int __scmirroring_src_send_set_reso(scmirroring_src_h scmirroring)
{
/* Set resolution to miracast server */
char *cmd = NULL;
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
cmd = g_strdup_printf("SET RESO %d", _scmirroring->resolution);
ret = __scmirroring_src_send_cmd_to_server(_scmirroring, cmd);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
SCMIRRORING_SAFE_FREE(cmd);
scmirroring_error("Failed to be ready [%d]", ret);
return SCMIRRORING_ERROR_INVALID_OPERATION;
scmirroring_retvm_if(scmirroring == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
- _scmirroring = (scmirroring_src_s*)calloc(1,sizeof(scmirroring_src_s));
+ _scmirroring = (scmirroring_src_s *)calloc(1, sizeof(scmirroring_src_s));
scmirroring_retvm_if(_scmirroring == NULL, SCMIRRORING_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- _scmirroring->ip= NULL;
+ _scmirroring->ip = NULL;
_scmirroring->port = NULL;
_scmirroring->connected = NOT_CONNECTED_TO_SERVER;
_scmirroring->use_hdcp = TRUE;
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
scmirroring_debug_fenter();
scmirroring_retvm_if(_scmirroring == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
- if((connect_mode < SCMIRRORING_CONNECTION_WIFI_DIRECT) ||(connect_mode >= SCMIRRORING_CONNECTION_MAX))
- {
+ if ((connect_mode < SCMIRRORING_CONNECTION_WIFI_DIRECT) || (connect_mode >= SCMIRRORING_CONNECTION_MAX)) {
scmirroring_error("INVALID Connection mode : %d", connect_mode);
return SCMIRRORING_ERROR_INVALID_PARAMETER;
}
_scmirroring->connect_mode = connect_mode;
- if(_scmirroring->connected)
- {
- ret = __scmirroring_src_send_set_cm (_scmirroring);
+ if (_scmirroring->connected) {
+ ret = __scmirroring_src_send_set_cm(_scmirroring);
}
scmirroring_debug_fleave();
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
scmirroring_debug_fenter();
scmirroring_retvm_if(_scmirroring == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
scmirroring_retvm_if(callback == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "callback is NULL");
- if(_scmirroring->scmirroring_state_cb == NULL)
- {
- _scmirroring->scmirroring_state_cb = (scmirroring_state_cb_s*)calloc(1, sizeof(scmirroring_state_cb_s));
+ if (_scmirroring->scmirroring_state_cb == NULL) {
+ _scmirroring->scmirroring_state_cb = (scmirroring_state_cb_s *)calloc(1, sizeof(scmirroring_state_cb_s));
scmirroring_retvm_if(_scmirroring->scmirroring_state_cb == NULL, SCMIRRORING_ERROR_OUT_OF_MEMORY, "Error Set CB");
- }
- else
- {
+ } else {
memset(_scmirroring->scmirroring_state_cb, 0, sizeof(scmirroring_state_cb_s));
}
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
scmirroring_debug_fenter();
scmirroring_retvm_if(_scmirroring == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
- if(_scmirroring->scmirroring_state_cb != NULL)
- {
+ if (_scmirroring->scmirroring_state_cb != NULL) {
_scmirroring->scmirroring_state_cb->user_data = NULL;
_scmirroring->scmirroring_state_cb->state_cb = NULL;
}
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
scmirroring_debug_fenter();
_scmirroring->ip = strdup(ip);
_scmirroring->port = strdup(port);
- if((_scmirroring->ip == NULL) || (_scmirroring->port == NULL))
- {
+ if ((_scmirroring->ip == NULL) || (_scmirroring->port == NULL)) {
scmirroring_error("OUT_OF_MEMORY");
return SCMIRRORING_ERROR_OUT_OF_MEMORY;
}
- if(_scmirroring->connected)
- {
- ret = __scmirroring_src_send_set_ip (_scmirroring);
+ if (_scmirroring->connected) {
+ ret = __scmirroring_src_send_set_ip(_scmirroring);
}
scmirroring_debug_fleave();
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
scmirroring_debug_fenter();
scmirroring_retvm_if(_scmirroring == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
- if((resolution < SCMIRRORING_RESOLUTION_1920x1080_P30) ||(resolution >= SCMIRRORING_RESOLUTION_MAX))
- {
+ if ((resolution < SCMIRRORING_RESOLUTION_1920x1080_P30) || (resolution >= SCMIRRORING_RESOLUTION_MAX)) {
scmirroring_error("INVALID resolution : %d", resolution);
return SCMIRRORING_ERROR_INVALID_PARAMETER;
}
_scmirroring->resolution = resolution;
- if(_scmirroring->connected)
- {
- ret = __scmirroring_src_send_set_reso (_scmirroring);
+ if (_scmirroring->connected) {
+ ret = __scmirroring_src_send_set_reso(_scmirroring);
}
scmirroring_debug_fleave();
GIOChannel *channel = NULL;
struct timeval tv_timeout = { TIMEOUT_SEC, 0 };
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
scmirroring_debug_fenter();
scmirroring_retvm_if(_scmirroring == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
scmirroring_retvm_if(_scmirroring->connected == CONNECTED_TO_SERVER, SCMIRRORING_ERROR_INVALID_OPERATION,
- "INVALID OPERATION, already connected to server.");
+ "INVALID OPERATION, already connected to server.");
/*Create TCP Socket*/
if ((sock = socket(PF_FILE, SOCK_STREAM, 0)) < 0) {
scmirroring_error("g_io_channel_unix_new failed: %s", strerror(errno));
}
- g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL);
+ g_io_channel_set_flags(channel, G_IO_FLAG_NONBLOCK, NULL);
_scmirroring->sock = sock;
_scmirroring->channel = channel;
/* Connecting to the miracast server */
memset(&serv_addr, 0, sizeof(struct sockaddr_un));
serv_addr.sun_family = AF_UNIX;
- strcpy(serv_addr.sun_path, _scmirroring->sock_path);
+ strncpy(serv_addr.sun_path, _scmirroring->sock_path, sizeof(serv_addr.sun_path));
try:
scmirroring_debug("Trying to connect to the miracast server");
- if (connect(_scmirroring->sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
+ if (connect(_scmirroring->sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) {
/* Once failed to connect, try to launch miracast server */
if (retry == 0) {
ret = __miracast_server_launch(_scmirroring);
_scmirroring->connected = CONNECTED_TO_SERVER;
_scmirroring->current_state = SCMIRRORING_STATE_READY;
- __scmirroring_src_set_callback_info (_scmirroring, SCMIRRORING_ERROR_NONE, SCMIRRORING_STATE_READY);
+ __scmirroring_src_set_callback_info(_scmirroring, SCMIRRORING_ERROR_NONE, SCMIRRORING_STATE_READY);
- if((_scmirroring->ip != NULL) ||(_scmirroring->port != NULL))
- {
- ret = __scmirroring_src_send_set_ip (_scmirroring);
- ret = __scmirroring_src_send_set_cm (_scmirroring);
- ret = __scmirroring_src_send_set_reso (_scmirroring);
+ if ((_scmirroring->ip != NULL) || (_scmirroring->port != NULL)) {
+ ret = __scmirroring_src_send_set_ip(_scmirroring);
+ ret = __scmirroring_src_send_set_cm(_scmirroring);
+ ret = __scmirroring_src_send_set_reso(_scmirroring);
}
scmirroring_debug_fleave();
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
scmirroring_debug_fenter();
scmirroring_retvm_if(_scmirroring == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
- if(_scmirroring->channel != NULL)
- {
- g_io_channel_shutdown (_scmirroring->channel, FALSE, NULL);
+ if (_scmirroring->channel != NULL) {
+ g_io_channel_shutdown(_scmirroring->channel, FALSE, NULL);
g_io_channel_unref(_scmirroring->channel);
_scmirroring->channel = NULL;
}
- if(_scmirroring->sock != -1)
- {
- close (_scmirroring->sock);
+ if (_scmirroring->sock != -1) {
+ close(_scmirroring->sock);
_scmirroring->sock = -1;
}
int scmirroring_src_start(scmirroring_src_h scmirroring)
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
scmirroring_debug_fenter();
scmirroring_retvm_if(_scmirroring == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
ret = __scmirroring_src_send_cmd_to_server(_scmirroring, SCMIRRORING_STATE_CMD_START);
- if(ret != SCMIRRORING_ERROR_NONE)
+ if (ret != SCMIRRORING_ERROR_NONE)
scmirroring_error("Failed to start [%d]", ret);
scmirroring_debug_fleave();
int scmirroring_src_pause(scmirroring_src_h scmirroring)
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
scmirroring_debug_fenter();
scmirroring_retvm_if(_scmirroring == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
ret = __scmirroring_src_send_cmd_to_server(_scmirroring, SCMIRRORING_STATE_CMD_PAUSE);
- if(ret != SCMIRRORING_ERROR_NONE)
+ if (ret != SCMIRRORING_ERROR_NONE)
scmirroring_error("Failed to pause [%d]", ret);
scmirroring_debug_fleave();
int scmirroring_src_resume(scmirroring_src_h scmirroring)
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
scmirroring_debug_fenter();
scmirroring_retvm_if(_scmirroring == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
ret = __scmirroring_src_send_cmd_to_server(_scmirroring, SCMIRRORING_STATE_CMD_RESUME);
- if(ret != SCMIRRORING_ERROR_NONE)
+ if (ret != SCMIRRORING_ERROR_NONE)
scmirroring_error("Failed to resume [%d]", ret);
scmirroring_debug_fleave();
int scmirroring_src_stop(scmirroring_src_h scmirroring)
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
scmirroring_debug_fenter();
scmirroring_retvm_if(_scmirroring == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
ret = __scmirroring_src_send_cmd_to_server(_scmirroring, SCMIRRORING_STATE_CMD_STOP);
- if(ret != SCMIRRORING_ERROR_NONE)
+ if (ret != SCMIRRORING_ERROR_NONE)
scmirroring_error("Failed to be stop [%d]", ret);
scmirroring_debug_fleave();
int scmirroring_src_destroy(scmirroring_src_h scmirroring)
{
int ret = SCMIRRORING_ERROR_NONE;
- scmirroring_src_s *_scmirroring = (scmirroring_src_s*)scmirroring;
+ scmirroring_src_s *_scmirroring = (scmirroring_src_s *)scmirroring;
scmirroring_debug_fenter();
scmirroring_retvm_if(_scmirroring == NULL, SCMIRRORING_ERROR_INVALID_PARAMETER, "Handle is NULL");
- if(_scmirroring->connected == CONNECTED_TO_SERVER)
- {
+ if (_scmirroring->connected == CONNECTED_TO_SERVER) {
ret = __scmirroring_src_send_cmd_to_server(_scmirroring, SCMIRRORING_STATE_CMD_DESTROY);
- if(ret != SCMIRRORING_ERROR_NONE)
+ if (ret != SCMIRRORING_ERROR_NONE)
scmirroring_error("Failed to destroy [%d]", ret);
- }
- else
- {
+ } else {
SCMIRRORING_SAFE_FREE(_scmirroring->ip);
SCMIRRORING_SAFE_FREE(_scmirroring->port);
SCMIRRORING_SAFE_FREE(_scmirroring->scmirroring_state_cb);
/* static void __get_string_list(gchar** out_list, gchar* str); */
/* macro */
-#define SCMIRRORING_INI_GET_STRING( x_item, x_ini, x_default ) \
-do \
-{ \
- gchar* str = iniparser_getstring(dict, x_ini, x_default); \
- \
- if ( str && \
- ( strlen( str ) > 1 ) && \
- ( strlen( str ) < SCMIRRORING_SRC_INI_MAX_STRLEN ) ) \
- { \
- strcpy ( x_item, str ); \
- } \
- else \
- { \
- strcpy ( x_item, x_default ); \
- } \
-}while(0)
+#define SCMIRRORING_INI_GET_STRING(x_item, x_ini, x_default) \
+ do { \
+ gchar *str = iniparser_getstring(dict, x_ini, x_default); \
+ \
+ if (str && \
+ (strlen(str) > 1) && \
+ (strlen(str) < SCMIRRORING_SRC_INI_MAX_STRLEN)) { \
+ strcpy(x_item, str); \
+ } \
+ else { \
+ strcpy(x_item, x_default); \
+ } \
+ } while (0);
+
int
scmirroring_src_ini_load(void)
{
- static gboolean loaded = FALSE;
- dictionary * dict = NULL;
- gint idx = 0;
+ static gboolean loaded = FALSE;
+ dictionary *dict = NULL;
+ gint idx = 0;
- if ( loaded )
- return ERROR_NONE;
+ if (loaded)
+ return ERROR_NONE;
- dict = NULL;
+ dict = NULL;
- /* disabling ini parsing for launching */
- #if 1 //debianize
- /* get scmirroring ini status because system will be crashed
- * if ini file is corrupted.
- */
- /* FIXIT : the api actually deleting illregular ini. but the function name said it's just checking. */
- __scmirroring_ini_check_ini_status();
+ /* disabling ini parsing for launching */
+#if 1 /*debianize */
+ /* get scmirroring ini status because system will be crashed
+ * if ini file is corrupted.
+ */
+ /* FIXIT : the api actually deleting illregular ini. but the function name said it's just checking. */
+ __scmirroring_ini_check_ini_status();
- /* first, try to load existing ini file */
- dict = iniparser_load(SCMIRRORING_SRC_INI_DEFAULT_PATH);
+ /* first, try to load existing ini file */
+ dict = iniparser_load(SCMIRRORING_SRC_INI_DEFAULT_PATH);
- /* if no file exists. create one with set of default values */
- if ( !dict )
- {
+ /* if no file exists. create one with set of default values */
+ if (!dict) {
#if 0
- scmirroring_debug("No inifile found. scmirroring will create default inifile.\n");
- if ( FALSE == __generate_default_ini() )
- {
- scmirroring_debug("Creating default inifile failed. Player will use default values.\n");
- }
- else
- {
- /* load default ini */
- dict = iniparser_load(SCMIRRORING_SRC_INI_DEFAULT_PATH);
- }
+ scmirroring_debug("No inifile found. scmirroring will create default inifile.\n");
+ if (FALSE == __generate_default_ini()) {
+ scmirroring_debug("Creating default inifile failed. Player will use default values.\n");
+ } else {
+ /* load default ini */
+ dict = iniparser_load(SCMIRRORING_SRC_INI_DEFAULT_PATH);
+ }
#else
- scmirroring_debug("No inifile found. \n");
+ scmirroring_debug("No inifile found. \n");
- return ERROR_FILE_NOT_FOUND;
+ return ERROR_FILE_NOT_FOUND;
#endif
- }
+ }
#endif
- /* get ini values */
- memset( &g_scmirroring_src_ini, 0, sizeof(scmirroring_src_ini_t) );
-
- if ( dict ) /* if dict is available */
- {
- /* general */
- gchar temp[SCMIRRORING_SRC_INI_MAX_STRLEN];
- g_scmirroring_src_ini.videosrc_element = iniparser_getint(dict, "general:videosrc element", DEFAULT_VIDEOSRC);
- g_scmirroring_src_ini.session_mode = iniparser_getint(dict, "general:session_mode", DEFAULT_SESSION_MODE);
- g_scmirroring_src_ini.videosink_element = iniparser_getint(dict, "general:videosink element", DEFAULT_VIDEOSINK);
- g_scmirroring_src_ini.disable_segtrap = iniparser_getboolean(dict, "general:disable segtrap", DEFAULT_DISABLE_SEGTRAP);
- g_scmirroring_src_ini.skip_rescan = iniparser_getboolean(dict, "general:skip rescan", DEFAULT_SKIP_RESCAN);
- g_scmirroring_src_ini.videosink_element = iniparser_getint(dict, "general:videosink element", DEFAULT_VIDEOSINK);
- g_scmirroring_src_ini.mtu_size = iniparser_getint(dict, "general:mtu_size value", DEFAULT_MTU_SIZE);
- g_scmirroring_src_ini.generate_dot = iniparser_getboolean(dict, "general:generate dot", DEFAULT_GENERATE_DOT);
- g_scmirroring_src_ini.provide_clock= iniparser_getboolean(dict, "general:provide clock", DEFAULT_PROVIDE_CLOCK);
+ /* get ini values */
+ memset(&g_scmirroring_src_ini, 0, sizeof(scmirroring_src_ini_t));
+
+ if (dict) { /* if dict is available */
+ /* general */
+ gchar temp[SCMIRRORING_SRC_INI_MAX_STRLEN];
+ g_scmirroring_src_ini.videosrc_element = iniparser_getint(dict, "general:videosrc element", DEFAULT_VIDEOSRC);
+ g_scmirroring_src_ini.session_mode = iniparser_getint(dict, "general:session_mode", DEFAULT_SESSION_MODE);
+ g_scmirroring_src_ini.videosink_element = iniparser_getint(dict, "general:videosink element", DEFAULT_VIDEOSINK);
+ g_scmirroring_src_ini.disable_segtrap = iniparser_getboolean(dict, "general:disable segtrap", DEFAULT_DISABLE_SEGTRAP);
+ g_scmirroring_src_ini.skip_rescan = iniparser_getboolean(dict, "general:skip rescan", DEFAULT_SKIP_RESCAN);
+ g_scmirroring_src_ini.videosink_element = iniparser_getint(dict, "general:videosink element", DEFAULT_VIDEOSINK);
+ g_scmirroring_src_ini.mtu_size = iniparser_getint(dict, "general:mtu_size value", DEFAULT_MTU_SIZE);
+ g_scmirroring_src_ini.generate_dot = iniparser_getboolean(dict, "general:generate dot", DEFAULT_GENERATE_DOT);
+ g_scmirroring_src_ini.provide_clock = iniparser_getboolean(dict, "general:provide clock", DEFAULT_PROVIDE_CLOCK);
#ifndef ENABLE_QC_SPECIFIC
- SCMIRRORING_INI_GET_STRING( g_scmirroring_src_ini.name_of_audio_device, "general:exynosaudio device name", DEFAULT_AUDIO_DEVICE_NAME );
- g_scmirroring_src_ini.audio_buffer_time = iniparser_getint(dict, "general:exynosaudio buffer_time",DEFAULT_AUDIO_BUFFER_TIME);
+ SCMIRRORING_INI_GET_STRING(g_scmirroring_src_ini.name_of_audio_device, "general:exynosaudio device name", DEFAULT_AUDIO_DEVICE_NAME);
+ g_scmirroring_src_ini.audio_buffer_time = iniparser_getint(dict, "general:exynosaudio buffer_time", DEFAULT_AUDIO_BUFFER_TIME);
#else
- SCMIRRORING_INI_GET_STRING( g_scmirroring_src_ini.name_of_audio_device, "general:qcmsmaudio device name", DEFAULT_AUDIO_DEVICE_NAME );
- g_scmirroring_src_ini.audio_buffer_time = iniparser_getint(dict, "general:qcmsmaudio buffer_time",DEFAULT_AUDIO_BUFFER_TIME);
+ SCMIRRORING_INI_GET_STRING(g_scmirroring_src_ini.name_of_audio_device, "general:qcmsmaudio device name", DEFAULT_AUDIO_DEVICE_NAME);
+ g_scmirroring_src_ini.audio_buffer_time = iniparser_getint(dict, "general:qcmsmaudio buffer_time", DEFAULT_AUDIO_BUFFER_TIME);
#endif
- g_scmirroring_src_ini.audio_latency_time = iniparser_getint(dict, "general:audio latency_time",DEFAULT_AUDIO_LATENCY_TIME);
- g_scmirroring_src_ini.audio_do_timestamp = iniparser_getint(dict, "general:audio do_timestamp",DEFAULT_AUDIO_DO_TIMESTAMP);
- SCMIRRORING_INI_GET_STRING(temp, "general:video resolution_supported", "");
- if (strlen(temp) > 0) g_scmirroring_src_ini.video_reso_supported = strtoull(temp, NULL, 16);
- else g_scmirroring_src_ini.video_reso_supported = DEFAULT_VIDEO_RESOLUTION_SUPPORTED;
- g_scmirroring_src_ini.decide_udp_bitrate[0] = iniparser_getint(dict, "general:INIT_UDP_resolution_set_1",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[1] = iniparser_getint(dict, "general:MIN_UDP_resolution_set_1",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[2] = iniparser_getint(dict, "general:MAX_UDP_resolution_set_1",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[3] = iniparser_getint(dict, "general:INIT_UDP_resolution_set_2",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[4] = iniparser_getint(dict, "general:MIN_UDP_resolution_set_2",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[5] = iniparser_getint(dict, "general:MAX_UDP_resolution_set_2",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[6] = iniparser_getint(dict, "general:INIT_UDP_resolution_set_3",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[7] = iniparser_getint(dict, "general:MIN_UDP_resolution_set_3",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[8] = iniparser_getint(dict, "general:MAX_UDP_resolution_set_3",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[9] = iniparser_getint(dict, "general:INIT_UDP_resolution_set_4",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[10] = iniparser_getint(dict, "general:MIN_UDP_resolution_set_4",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[11] = iniparser_getint(dict, "general:MAX_UDP_resolution_set_4",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[12] = iniparser_getint(dict, "general:INIT_UDP_resolution_set_5",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[13] = iniparser_getint(dict, "general:MIN_UDP_resolution_set_5",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[14] = iniparser_getint(dict, "general:MAX_UDP_resolution_set_5",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[15] = iniparser_getint(dict, "general:INIT_UDP_resolution_set_6",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[16] = iniparser_getint(dict, "general:MIN_UDP_resolution_set_6",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[17] = iniparser_getint(dict, "general:MAX_UDP_resolution_set_6",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[18] = iniparser_getint(dict, "general:INIT_UDP_resolution_set_7",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[19] = iniparser_getint(dict, "general:MIN_UDP_resolution_set_7",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.decide_udp_bitrate[20] = iniparser_getint(dict, "general:MAX_UDP_resolution_set_7",DEFAULT_VIDEO_BITRATE);
- g_scmirroring_src_ini.video_native_resolution = iniparser_getint(dict, "general:video native_resolution",DEFAULT_NATIVE_VIDEO_RESOLUTION);
- g_scmirroring_src_ini.hdcp_enabled = iniparser_getint(dict, "general:encryption HDCP_enabled",DEFAULT_HDCP_ENABLED);
- g_scmirroring_src_ini.uibc_gen_capability = iniparser_getint(dict, "general:uibc UIBC_GEN_capability",DEFAULT_UIBC_GEN_CAPABILITY);
- SCMIRRORING_INI_GET_STRING( g_scmirroring_src_ini.name_of_video_converter, "general:video converter element", DEFAULT_VIDEO_CONVERTER );
-
- SCMIRRORING_INI_GET_STRING( g_scmirroring_src_ini.gst_param[0], "general:gstparam1", DEFAULT_GST_PARAM );
- SCMIRRORING_INI_GET_STRING( g_scmirroring_src_ini.gst_param[1], "general:gstparam2", DEFAULT_GST_PARAM );
- SCMIRRORING_INI_GET_STRING( g_scmirroring_src_ini.gst_param[2], "general:gstparam3", DEFAULT_GST_PARAM );
- SCMIRRORING_INI_GET_STRING( g_scmirroring_src_ini.gst_param[3], "general:gstparam4", DEFAULT_GST_PARAM );
- SCMIRRORING_INI_GET_STRING( g_scmirroring_src_ini.gst_param[4], "general:gstparam5", DEFAULT_GST_PARAM );
-
- g_scmirroring_src_ini.dump_ts = iniparser_getint(dict, "general:dump ts", DEFAULT_DUMP_TS);
-
- }
- else /* if dict is not available just fill the structure with default value */
- {
- scmirroring_debug("failed to load ini. using hardcoded default\n");
-
- /* general */
- g_scmirroring_src_ini.videosrc_element = DEFAULT_VIDEOSRC;
- g_scmirroring_src_ini.session_mode = DEFAULT_SESSION_MODE;
- g_scmirroring_src_ini.disable_segtrap = DEFAULT_DISABLE_SEGTRAP;
- g_scmirroring_src_ini.skip_rescan = DEFAULT_SKIP_RESCAN;
- g_scmirroring_src_ini.videosink_element = DEFAULT_VIDEOSINK;
- g_scmirroring_src_ini.mtu_size = DEFAULT_MTU_SIZE;
- g_scmirroring_src_ini.generate_dot = DEFAULT_GENERATE_DOT;
- g_scmirroring_src_ini.provide_clock= DEFAULT_PROVIDE_CLOCK;
-
- strcpy( g_scmirroring_src_ini.name_of_audio_device, DEFAULT_AUDIO_DEVICE_NAME);
- g_scmirroring_src_ini.audio_latency_time = DEFAULT_AUDIO_LATENCY_TIME;
- g_scmirroring_src_ini.audio_buffer_time = DEFAULT_AUDIO_BUFFER_TIME;
- g_scmirroring_src_ini.audio_do_timestamp = DEFAULT_AUDIO_DO_TIMESTAMP;
- g_scmirroring_src_ini.video_reso_supported = DEFAULT_VIDEO_RESOLUTION_SUPPORTED;
- for (idx=0; idx<21; ++idx) {
- g_scmirroring_src_ini.decide_udp_bitrate[idx] = DEFAULT_VIDEO_BITRATE;
- }
- g_scmirroring_src_ini.video_native_resolution = DEFAULT_NATIVE_VIDEO_RESOLUTION;
- g_scmirroring_src_ini.hdcp_enabled = DEFAULT_HDCP_ENABLED;
- g_scmirroring_src_ini.uibc_gen_capability = DEFAULT_UIBC_GEN_CAPABILITY;
-
- strcpy( g_scmirroring_src_ini.name_of_video_converter, DEFAULT_VIDEO_CONVERTER);
-
-
- strcpy( g_scmirroring_src_ini.gst_param[0], DEFAULT_GST_PARAM );
- strcpy( g_scmirroring_src_ini.gst_param[1], DEFAULT_GST_PARAM );
- strcpy( g_scmirroring_src_ini.gst_param[2], DEFAULT_GST_PARAM );
- strcpy( g_scmirroring_src_ini.gst_param[3], DEFAULT_GST_PARAM );
- strcpy( g_scmirroring_src_ini.gst_param[4], DEFAULT_GST_PARAM );
-
- g_scmirroring_src_ini.dump_ts = DEFAULT_DUMP_TS;
-
- }
-
- /* free dict as we got our own structure */
- iniparser_freedict (dict);
-
- loaded = TRUE;
-
- /* The simulator uses a separate ini file. */
- //__scmirroring_ini_force_setting();
-
-
- /* dump structure */
- scmirroring_debug("scmirroring settings -----------------------------------\n");
-
- /* general */
- scmirroring_debug("videosrc element : %d\n", g_scmirroring_src_ini.videosrc_element);
- scmirroring_debug("session mode in mirroring : %d\n", g_scmirroring_src_ini.session_mode);
- scmirroring_debug("disable_segtrap : %d\n", g_scmirroring_src_ini.disable_segtrap);
- scmirroring_debug("skip rescan : %d\n", g_scmirroring_src_ini.skip_rescan);
- scmirroring_debug("videosink element(0:v4l2sink, 1:ximagesink, 2:xvimagesink, 3:fakesink) : %d\n", g_scmirroring_src_ini.videosink_element);
- scmirroring_debug("mtu_size : %d\n", g_scmirroring_src_ini.mtu_size);
- scmirroring_debug("generate_dot : %d\n", g_scmirroring_src_ini.generate_dot);
- scmirroring_debug("provide_clock : %d\n", g_scmirroring_src_ini.provide_clock);
- scmirroring_debug("name_of_video_converter : %s\n", g_scmirroring_src_ini.name_of_video_converter);
-
- scmirroring_debug("audio device name : %s\n", g_scmirroring_src_ini.name_of_audio_device);
- scmirroring_debug("audio latency_time : %d\n", g_scmirroring_src_ini.audio_latency_time);
- scmirroring_debug("audio buffer_time : %d\n", g_scmirroring_src_ini.audio_buffer_time);
- scmirroring_debug("audio do_timestamp : %d\n", g_scmirroring_src_ini.audio_do_timestamp);
- scmirroring_debug("video resolution_supported : %d\n", g_scmirroring_src_ini.video_reso_supported);
- scmirroring_debug("video native_resolution : %d\n", g_scmirroring_src_ini.video_native_resolution);
- scmirroring_debug("encryption HDCP_enabled : %d\n", g_scmirroring_src_ini.hdcp_enabled);
- scmirroring_debug("uibc UIBC_GEN_capability : %d\n", g_scmirroring_src_ini.uibc_gen_capability);
-
- scmirroring_debug("gst_param1 : %s\n", g_scmirroring_src_ini.gst_param[0]);
- scmirroring_debug("gst_param2 : %s\n", g_scmirroring_src_ini.gst_param[1]);
- scmirroring_debug("gst_param3 : %s\n", g_scmirroring_src_ini.gst_param[2]);
- scmirroring_debug("gst_param4 : %s\n", g_scmirroring_src_ini.gst_param[3]);
- scmirroring_debug("gst_param5 : %s\n", g_scmirroring_src_ini.gst_param[4]);
-
- scmirroring_debug("dump ts : %d\n", g_scmirroring_src_ini.dump_ts);
-
- scmirroring_debug("---------------------------------------------------\n");
-
- return ERROR_NONE;
+ g_scmirroring_src_ini.audio_latency_time = iniparser_getint(dict, "general:audio latency_time", DEFAULT_AUDIO_LATENCY_TIME);
+ g_scmirroring_src_ini.audio_do_timestamp = iniparser_getint(dict, "general:audio do_timestamp", DEFAULT_AUDIO_DO_TIMESTAMP);
+ SCMIRRORING_INI_GET_STRING(temp, "general:video resolution_supported", "");
+ if (strlen(temp) > 0) g_scmirroring_src_ini.video_reso_supported = strtoull(temp, NULL, 16);
+ else g_scmirroring_src_ini.video_reso_supported = DEFAULT_VIDEO_RESOLUTION_SUPPORTED;
+ g_scmirroring_src_ini.decide_udp_bitrate[0] = iniparser_getint(dict, "general:INIT_UDP_resolution_set_1", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[1] = iniparser_getint(dict, "general:MIN_UDP_resolution_set_1", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[2] = iniparser_getint(dict, "general:MAX_UDP_resolution_set_1", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[3] = iniparser_getint(dict, "general:INIT_UDP_resolution_set_2", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[4] = iniparser_getint(dict, "general:MIN_UDP_resolution_set_2", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[5] = iniparser_getint(dict, "general:MAX_UDP_resolution_set_2", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[6] = iniparser_getint(dict, "general:INIT_UDP_resolution_set_3", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[7] = iniparser_getint(dict, "general:MIN_UDP_resolution_set_3", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[8] = iniparser_getint(dict, "general:MAX_UDP_resolution_set_3", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[9] = iniparser_getint(dict, "general:INIT_UDP_resolution_set_4", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[10] = iniparser_getint(dict, "general:MIN_UDP_resolution_set_4", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[11] = iniparser_getint(dict, "general:MAX_UDP_resolution_set_4", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[12] = iniparser_getint(dict, "general:INIT_UDP_resolution_set_5", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[13] = iniparser_getint(dict, "general:MIN_UDP_resolution_set_5", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[14] = iniparser_getint(dict, "general:MAX_UDP_resolution_set_5", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[15] = iniparser_getint(dict, "general:INIT_UDP_resolution_set_6", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[16] = iniparser_getint(dict, "general:MIN_UDP_resolution_set_6", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[17] = iniparser_getint(dict, "general:MAX_UDP_resolution_set_6", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[18] = iniparser_getint(dict, "general:INIT_UDP_resolution_set_7", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[19] = iniparser_getint(dict, "general:MIN_UDP_resolution_set_7", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.decide_udp_bitrate[20] = iniparser_getint(dict, "general:MAX_UDP_resolution_set_7", DEFAULT_VIDEO_BITRATE);
+ g_scmirroring_src_ini.video_native_resolution = iniparser_getint(dict, "general:video native_resolution", DEFAULT_NATIVE_VIDEO_RESOLUTION);
+ g_scmirroring_src_ini.hdcp_enabled = iniparser_getint(dict, "general:encryption HDCP_enabled", DEFAULT_HDCP_ENABLED);
+ g_scmirroring_src_ini.uibc_gen_capability = iniparser_getint(dict, "general:uibc UIBC_GEN_capability", DEFAULT_UIBC_GEN_CAPABILITY);
+ SCMIRRORING_INI_GET_STRING(g_scmirroring_src_ini.name_of_video_converter, "general:video converter element", DEFAULT_VIDEO_CONVERTER);
+
+ SCMIRRORING_INI_GET_STRING(g_scmirroring_src_ini.gst_param[0], "general:gstparam1", DEFAULT_GST_PARAM);
+ SCMIRRORING_INI_GET_STRING(g_scmirroring_src_ini.gst_param[1], "general:gstparam2", DEFAULT_GST_PARAM);
+ SCMIRRORING_INI_GET_STRING(g_scmirroring_src_ini.gst_param[2], "general:gstparam3", DEFAULT_GST_PARAM);
+ SCMIRRORING_INI_GET_STRING(g_scmirroring_src_ini.gst_param[3], "general:gstparam4", DEFAULT_GST_PARAM);
+ SCMIRRORING_INI_GET_STRING(g_scmirroring_src_ini.gst_param[4], "general:gstparam5", DEFAULT_GST_PARAM);
+
+ g_scmirroring_src_ini.dump_ts = iniparser_getint(dict, "general:dump ts", DEFAULT_DUMP_TS);
+
+ } else { /* if dict is not available just fill the structure with default value */
+ scmirroring_debug("failed to load ini. using hardcoded default\n");
+
+ /* general */
+ g_scmirroring_src_ini.videosrc_element = DEFAULT_VIDEOSRC;
+ g_scmirroring_src_ini.session_mode = DEFAULT_SESSION_MODE;
+ g_scmirroring_src_ini.disable_segtrap = DEFAULT_DISABLE_SEGTRAP;
+ g_scmirroring_src_ini.skip_rescan = DEFAULT_SKIP_RESCAN;
+ g_scmirroring_src_ini.videosink_element = DEFAULT_VIDEOSINK;
+ g_scmirroring_src_ini.mtu_size = DEFAULT_MTU_SIZE;
+ g_scmirroring_src_ini.generate_dot = DEFAULT_GENERATE_DOT;
+ g_scmirroring_src_ini.provide_clock = DEFAULT_PROVIDE_CLOCK;
+
+ strcpy(g_scmirroring_src_ini.name_of_audio_device, DEFAULT_AUDIO_DEVICE_NAME);
+ g_scmirroring_src_ini.audio_latency_time = DEFAULT_AUDIO_LATENCY_TIME;
+ g_scmirroring_src_ini.audio_buffer_time = DEFAULT_AUDIO_BUFFER_TIME;
+ g_scmirroring_src_ini.audio_do_timestamp = DEFAULT_AUDIO_DO_TIMESTAMP;
+ g_scmirroring_src_ini.video_reso_supported = DEFAULT_VIDEO_RESOLUTION_SUPPORTED;
+ for (idx = 0; idx < 21; ++idx) {
+ g_scmirroring_src_ini.decide_udp_bitrate[idx] = DEFAULT_VIDEO_BITRATE;
+ }
+ g_scmirroring_src_ini.video_native_resolution = DEFAULT_NATIVE_VIDEO_RESOLUTION;
+ g_scmirroring_src_ini.hdcp_enabled = DEFAULT_HDCP_ENABLED;
+ g_scmirroring_src_ini.uibc_gen_capability = DEFAULT_UIBC_GEN_CAPABILITY;
+
+ strcpy(g_scmirroring_src_ini.name_of_video_converter, DEFAULT_VIDEO_CONVERTER);
+
+
+ strcpy(g_scmirroring_src_ini.gst_param[0], DEFAULT_GST_PARAM);
+ strcpy(g_scmirroring_src_ini.gst_param[1], DEFAULT_GST_PARAM);
+ strcpy(g_scmirroring_src_ini.gst_param[2], DEFAULT_GST_PARAM);
+ strcpy(g_scmirroring_src_ini.gst_param[3], DEFAULT_GST_PARAM);
+ strcpy(g_scmirroring_src_ini.gst_param[4], DEFAULT_GST_PARAM);
+
+ g_scmirroring_src_ini.dump_ts = DEFAULT_DUMP_TS;
+
+ }
+
+ /* free dict as we got our own structure */
+ iniparser_freedict(dict);
+
+ loaded = TRUE;
+
+ /* The simulator uses a separate ini file. */
+ /*__scmirroring_ini_force_setting(); */
+
+
+ /* dump structure */
+ scmirroring_debug("scmirroring settings-----------------------------------\n");
+
+ /* general */
+ scmirroring_debug("videosrc element : %d\n", g_scmirroring_src_ini.videosrc_element);
+ scmirroring_debug("session mode in mirroring : %d\n", g_scmirroring_src_ini.session_mode);
+ scmirroring_debug("disable_segtrap : %d\n", g_scmirroring_src_ini.disable_segtrap);
+ scmirroring_debug("skip rescan : %d\n", g_scmirroring_src_ini.skip_rescan);
+ scmirroring_debug("videosink element(0:v4l2sink, 1:ximagesink, 2:xvimagesink, 3:fakesink) : %d\n", g_scmirroring_src_ini.videosink_element);
+ scmirroring_debug("mtu_size : %d\n", g_scmirroring_src_ini.mtu_size);
+ scmirroring_debug("generate_dot : %d\n", g_scmirroring_src_ini.generate_dot);
+ scmirroring_debug("provide_clock : %d\n", g_scmirroring_src_ini.provide_clock);
+ scmirroring_debug("name_of_video_converter : %s\n", g_scmirroring_src_ini.name_of_video_converter);
+
+ scmirroring_debug("audio device name : %s\n", g_scmirroring_src_ini.name_of_audio_device);
+ scmirroring_debug("audio latency_time : %d\n", g_scmirroring_src_ini.audio_latency_time);
+ scmirroring_debug("audio buffer_time : %d\n", g_scmirroring_src_ini.audio_buffer_time);
+ scmirroring_debug("audio do_timestamp : %d\n", g_scmirroring_src_ini.audio_do_timestamp);
+ scmirroring_debug("video resolution_supported : %d\n", g_scmirroring_src_ini.video_reso_supported);
+ scmirroring_debug("video native_resolution : %d\n", g_scmirroring_src_ini.video_native_resolution);
+ scmirroring_debug("encryption HDCP_enabled : %d\n", g_scmirroring_src_ini.hdcp_enabled);
+ scmirroring_debug("uibc UIBC_GEN_capability : %d\n", g_scmirroring_src_ini.uibc_gen_capability);
+
+ scmirroring_debug("gst_param1 : %s\n", g_scmirroring_src_ini.gst_param[0]);
+ scmirroring_debug("gst_param2 : %s\n", g_scmirroring_src_ini.gst_param[1]);
+ scmirroring_debug("gst_param3 : %s\n", g_scmirroring_src_ini.gst_param[2]);
+ scmirroring_debug("gst_param4 : %s\n", g_scmirroring_src_ini.gst_param[3]);
+ scmirroring_debug("gst_param5 : %s\n", g_scmirroring_src_ini.gst_param[4]);
+
+ scmirroring_debug("dump ts : %d\n", g_scmirroring_src_ini.dump_ts);
+
+ scmirroring_debug("---------------------------------------------------\n");
+
+ return ERROR_NONE;
}
static
void __scmirroring_ini_check_ini_status(void)
{
- struct stat ini_buff;
-
- if ( g_stat(SCMIRRORING_SRC_INI_DEFAULT_PATH, &ini_buff) < 0 )
- {
- scmirroring_debug("failed to get scmirroring ini status\n");
- }
- else
- {
- if ( ini_buff.st_size < 5 )
- {
- scmirroring_debug("scmirroring.ini file size=%d, Corrupted! So, Removed\n", (int)ini_buff.st_size);
- g_remove( SCMIRRORING_SRC_INI_DEFAULT_PATH );
- }
- }
+ struct stat ini_buff;
+
+ if (g_stat(SCMIRRORING_SRC_INI_DEFAULT_PATH, &ini_buff) < 0) {
+ scmirroring_debug("failed to get scmirroring ini status\n");
+ } else {
+ if (ini_buff.st_size < 5) {
+ scmirroring_debug("scmirroring.ini file size=%d, Corrupted! So, Removed\n", (int)ini_buff.st_size);
+ g_remove(SCMIRRORING_SRC_INI_DEFAULT_PATH);
+ }
+ }
}
-scmirroring_src_ini_t*
+scmirroring_src_ini_t *
scmirroring_src_ini_get_structure(void)
{
- return &g_scmirroring_src_ini;
+ return &g_scmirroring_src_ini;
}
#if 0
static
-void __get_string_list(gchar** out_list, gchar* str)
+void __get_string_list(gchar **out_list, gchar *str)
{
- gchar** list = NULL;
- gchar** walk = NULL;
- gint i = 0;
- gchar* strtmp = NULL;
+ gchar **list = NULL;
+ gchar **walk = NULL;
+ gint i = 0;
+ gchar *strtmp = NULL;
- if ( ! str )
- return;
+ if (!str)
+ return;
- if ( strlen( str ) < 1 )
- return;
+ if (strlen(str) < 1)
+ return;
- strtmp = g_strdup (str);
+ strtmp = g_strdup(str);
- /* trimming. it works inplace */
- g_strstrip( strtmp );
+ /* trimming. it works inplace */
+ g_strstrip(strtmp);
- /* split */
- list = g_strsplit( strtmp, ",", 10 );
+ /* split */
+ list = g_strsplit(strtmp, ", ", 10);
- g_return_if_fail ( list != NULL );
+ g_return_if_fail(list != NULL);
- g_strfreev( list );
- if (strtmp)
- g_free (strtmp);
+ g_strfreev(list);
+ if (strtmp)
+ g_free(strtmp);
}
#endif
static void __quit_program(void)
{
- g_print ("Quit Program\n");
+ g_print("Quit Program\n");
g_scmirroring = 0;
g_main_loop_quit(g_loop);
{
g_print("\n");
g_print("=====================================================================\n");
- g_print(" SCMIRRORING Testsuite (press q to quit) \n");
+ g_print(" SCMIRRORING Testsuite(press q to quit) \n");
g_print("=====================================================================\n");
- g_print("a : a ip port (ex. a 192.168.49.1 2022)\n");
- g_print("c : set resolution (ex. c 0 (0 : 1920x1080_P30, 1 : 1280x720_P30, 2 : 960x540_P30, 3: 640x360_P30)\n");
- g_print("f : set connection mode (ex. f 0 (0 : wifi_direct, 1 : Other)\n");
+ g_print("a : a ip port(ex. a 192.168.49.1 2022)\n");
+ g_print("c : set resolution(ex. c 0 (0 : 1920x1080_P30, 1 : 1280x720_P30, 2 : 960x540_P30, 3: 640x360_P30)\n");
+ g_print("f : set connection mode(ex. f 0 (0 : wifi_direct, 1 : Other)\n");
g_print("C : Connect\n");
g_print("I : dIsconnect\n");
g_print("S : Start \n");
g_print("-----------------------------------------------------------------------------------------\n");
}
-gboolean __timeout_menu_display(void* data)
+gboolean __timeout_menu_display(void *data)
{
__displaymenu();
return FALSE;
}
-static void __interpret (char *cmd)
+static void __interpret(char *cmd)
{
int ret = SCMIRRORING_ERROR_NONE;
gchar **value;
- value = g_strsplit(cmd," ",0);
+ value = g_strsplit(cmd, " ", 0);
- if (strncmp(cmd, "a", 1) == 0)
- {
+ if (strncmp(cmd, "a", 1) == 0) {
ret = scmirroring_src_set_ip_and_port(g_scmirroring, value[1], value[2]);
- g_print ("Input server IP and port number IP[%s] Port[%s]\n", value[1], value[2]);
- }
- else if (strncmp(cmd, "c", 1) == 0)
- {
+ g_print("Input server IP and port number IP[%s] Port[%s]\n", value[1], value[2]);
+ } else if (strncmp(cmd, "c", 1) == 0) {
ret = scmirroring_src_set_resolution(g_scmirroring, atoi(value[1]));
- g_print ("Set Resolution[%d]\n", atoi(value[1]));
- }
- else if (strncmp(cmd, "f", 1) == 0)
- {
+ g_print("Set Resolution[%d]\n", atoi(value[1]));
+ } else if (strncmp(cmd, "f", 1) == 0) {
ret = scmirroring_src_set_connection_mode(g_scmirroring, atoi(value[1]));
- g_print ("Connection mode [%d]\n", atoi(value[1]));
- }
- else if (strncmp(cmd, "C", 1) == 0)
- {
- g_print ("Connect\n");
+ g_print("Connection mode [%d]\n", atoi(value[1]));
+ } else if (strncmp(cmd, "C", 1) == 0) {
+ g_print("Connect\n");
ret = scmirroring_src_connect(g_scmirroring);
- }
- else if (strncmp(cmd, "I", 1) == 0)
- {
- g_print ("dIsconnect\n");
+ } else if (strncmp(cmd, "I", 1) == 0) {
+ g_print("dIsconnect\n");
ret = scmirroring_src_disconnect(g_scmirroring);
- }
- else if (strncmp(cmd, "S", 1) == 0)
- {
- g_print ("Start\n");
+ } else if (strncmp(cmd, "S", 1) == 0) {
+ g_print("Start\n");
ret = scmirroring_src_start(g_scmirroring);
- }
- else if (strncmp(cmd, "P", 1) == 0)
- {
- g_print ("Pause\n");
+ } else if (strncmp(cmd, "P", 1) == 0) {
+ g_print("Pause\n");
ret = scmirroring_src_pause(g_scmirroring);
- }
- else if (strncmp(cmd, "R", 1) == 0)
- {
- g_print ("Resume\n");
+ } else if (strncmp(cmd, "R", 1) == 0) {
+ g_print("Resume\n");
ret = scmirroring_src_resume(g_scmirroring);
- }
- else if (strncmp(cmd, "T", 1) == 0)
- {
- g_print ("Stop\n");
+ } else if (strncmp(cmd, "T", 1) == 0) {
+ g_print("Stop\n");
ret = scmirroring_src_stop(g_scmirroring);
- }
- else if (strncmp(cmd, "D", 1) == 0)
- {
- g_print ("Destroy\n");
+ } else if (strncmp(cmd, "D", 1) == 0) {
+ g_print("Destroy\n");
ret = scmirroring_src_destroy(g_scmirroring);
- }
- else if (strncmp(cmd, "q", 1) == 0)
- {
+ } else if (strncmp(cmd, "q", 1) == 0) {
__quit_program();
- }
- else
- {
+ } else {
g_print("unknown menu \n");
}
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("Error Occured [%d]\n", ret);
}
g_timeout_add(100, __timeout_menu_display, 0);
-return;
+ return;
}
-gboolean __input (GIOChannel *channel)
+gboolean __input(GIOChannel *channel)
{
char buf[MAX_STRING_LEN + 3];
gsize read;
g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
buf[read] = '\0';
g_strstrip(buf);
- __interpret (buf);
+ __interpret(buf);
return TRUE;
}
int ret = 0;
GIOChannel *stdin_channel;
stdin_channel = g_io_channel_unix_new(0);
- g_io_channel_set_flags (stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
+ g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)__input, NULL);
ret = scmirroring_src_create(&g_scmirroring);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("scmirroring_src_create fail [%d]", ret);
return 0;
}
ret = scmirroring_src_set_state_changed_cb(g_scmirroring, scmirroring_state_callback, NULL);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("scmirroring_src_create fail [%d]", ret);
return 0;
}
#include <wifi-direct.h>
#define MAX_STRING_LEN 2048
+/*#define ENABLE_WIFI_DIRECT */
scmirroring_src_h g_scmirroring = NULL;
GMainLoop *g_loop;
static int g_peer_cnt = 0;
static char g_peer_ip[32];
static char g_peer_port[32];
-static char g_sink_mac_addr[18] = {0,};
+static char g_sink_mac_addr[18] = {0, };
static void scmirroring_state_callback(scmirroring_error_e error_code, scmirroring_state_e state, void *user_data)
{
static void __quit_program(void)
{
- g_print ("Quit Program\n");
+ g_print("Quit Program\n");
__disconnect_p2p_connection();
{
g_print("\n");
g_print("=====================================================================\n");
- g_print(" SCMIRRORING Testsuite (press q to quit) \n");
+ g_print(" SCMIRRORING Testsuite(press q to quit) \n");
g_print("=====================================================================\n");
- g_print("a : a ip port (ex. a 192.168.49.1 2022)\n");
- g_print("b : set sink device mac address (ex. b f8:d0:bd:7f:e9:7c)\n");
- g_print("c : set resolution (ex. c 0 (0 : 1920x1080_P30, 1 : 1280x720_P30, 2 : 960x540_P30, 3: 640x360_P30)\n");
- g_print("f : set connection mode (ex. f 0 (0 : wifi_direct, 1 : Other)\n");
+ g_print("a : a ip port(ex. a 192.168.49.1 2022)\n");
+ g_print("b : set sink device mac address(ex. b f8:d0:bd:7f:e9:7c)\n");
+ g_print("c : set resolution(ex. c 0 (0 : 1920x1080_P30, 1 : 1280x720_P30, 2 : 960x540_P30, 3: 640x360_P30)\n");
+ g_print("f : set connection mode(ex. f 0 (0 : wifi_direct, 1 : Other)\n");
g_print("C : Connect\n");
g_print("I : dIsconnect\n");
g_print("S : Start \n");
g_print("-----------------------------------------------------------------------------------------\n");
}
-gboolean __timeout_menu_display(void* data)
+gboolean __timeout_menu_display(void *data)
{
__displaymenu();
return FALSE;
return SCMIRRORING_ERROR_INVALID_OPERATION;
}
- int err= wifi_direct_connect(g_sink_mac_addr);
+ int err = wifi_direct_connect(g_sink_mac_addr);
if (err != WIFI_DIRECT_ERROR_NONE) {
g_print("Failed to connect [%d]\n", err);
return SCMIRRORING_ERROR_INVALID_OPERATION;
return SCMIRRORING_ERROR_NONE;
}
-static void __interpret (char *cmd)
+static void __interpret(char *cmd)
{
int ret = SCMIRRORING_ERROR_NONE;
gchar **value;
- value = g_strsplit(cmd," ",0);
+ value = g_strsplit(cmd, " ", 0);
- if (strncmp(cmd, "a", 1) == 0)
- {
+ if (strncmp(cmd, "a", 1) == 0) {
ret = scmirroring_src_set_ip_and_port(g_scmirroring, value[1], value[2]);
- g_print ("Input server IP and port number IP[%s] Port[%s]\n", value[1], value[2]);
+ g_print("Input server IP and port number IP[%s] Port[%s]\n", value[1], value[2]);
}
- if (strncmp(cmd, "b", 1) == 0)
- {
- strncpy (g_sink_mac_addr, value[1], sizeof (g_sink_mac_addr));
+ if (strncmp(cmd, "b", 1) == 0) {
+ strncpy(g_sink_mac_addr, value[1], sizeof(g_sink_mac_addr));
g_sink_mac_addr[17] = '\0';
- g_print ("Sink mac address : %s\n", g_sink_mac_addr);
+ g_print("Sink mac address : %s\n", g_sink_mac_addr);
ret = __wifi_direct_device_connect();
- }
- else if (strncmp(cmd, "c", 1) == 0)
- {
+ } else if (strncmp(cmd, "c", 1) == 0) {
ret = scmirroring_src_set_resolution(g_scmirroring, atoi(value[1]));
- g_print ("Set Resolution[%d]\n", atoi(value[1]));
- }
- else if (strncmp(cmd, "f", 1) == 0)
- {
+ g_print("Set Resolution[%d]\n", atoi(value[1]));
+ } else if (strncmp(cmd, "f", 1) == 0) {
ret = scmirroring_src_set_connection_mode(g_scmirroring, atoi(value[1]));
- g_print ("Connection mode [%d]\n", atoi(value[1]));
- }
- else if (strncmp(cmd, "C", 1) == 0)
- {
- g_print ("Connect\n");
+ g_print("Connection mode [%d]\n", atoi(value[1]));
+ } else if (strncmp(cmd, "C", 1) == 0) {
+ g_print("Connect\n");
ret = scmirroring_src_connect(g_scmirroring);
- }
- else if (strncmp(cmd, "I", 1) == 0)
- {
- g_print ("dIsconnect\n");
+ } else if (strncmp(cmd, "I", 1) == 0) {
+ g_print("dIsconnect\n");
ret = scmirroring_src_disconnect(g_scmirroring);
- }
- else if (strncmp(cmd, "S", 1) == 0)
- {
- g_print ("Start\n");
+ } else if (strncmp(cmd, "S", 1) == 0) {
+ g_print("Start\n");
ret = scmirroring_src_start(g_scmirroring);
- }
- else if (strncmp(cmd, "P", 1) == 0)
- {
- g_print ("Pause\n");
+ } else if (strncmp(cmd, "P", 1) == 0) {
+ g_print("Pause\n");
ret = scmirroring_src_pause(g_scmirroring);
- }
- else if (strncmp(cmd, "R", 1) == 0)
- {
- g_print ("Resume\n");
+ } else if (strncmp(cmd, "R", 1) == 0) {
+ g_print("Resume\n");
ret = scmirroring_src_resume(g_scmirroring);
- }
- else if (strncmp(cmd, "T", 1) == 0)
- {
- g_print ("Stop\n");
+ } else if (strncmp(cmd, "T", 1) == 0) {
+ g_print("Stop\n");
ret = scmirroring_src_stop(g_scmirroring);
- g_print ("Stop end\n");
- }
- else if (strncmp(cmd, "D", 1) == 0)
- {
- g_print ("Destroy\n");
+ g_print("Stop end\n");
+ } else if (strncmp(cmd, "D", 1) == 0) {
+ g_print("Destroy\n");
ret = scmirroring_src_destroy(g_scmirroring);
- }
- else if (strncmp(cmd, "q", 1) == 0)
- {
+ } else if (strncmp(cmd, "q", 1) == 0) {
__quit_program();
- }
- else
- {
+ } else {
g_print("unknown menu \n");
}
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("Error Occured [%d]\n", ret);
}
g_timeout_add(100, __timeout_menu_display, 0);
- g_print ("Return interpret\n");
+ g_print("Return interpret\n");
return;
}
-gboolean __input (GIOChannel *channel)
+gboolean __input(GIOChannel *channel)
{
char buf[MAX_STRING_LEN + 3];
gsize read;
g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
buf[read] = '\0';
- g_print ("Read %"G_GSSIZE_FORMAT" bytes: %s\n", read, buf);
+ g_print("Read %"G_GSSIZE_FORMAT" bytes: %s\n", read, buf);
g_strstrip(buf);
- __interpret (buf);
+ __interpret(buf);
return TRUE;
}
int ret = WIFI_DIRECT_ERROR_NONE;
ret = wifi_direct_disconnect_all();
- if(!ret)
- {
+ if (!ret) {
g_print("wifi_direct_disconnect_all success\n");
- }
- else
- {
+ } else {
g_print("wifi_direct_disconnect_all fail\n");
}
- g_print("------ p2p connection disconnected ------\n");
+ g_print("------p2p connection disconnected------\n");
return TRUE;
}
bool _connected_peer_cb(wifi_direct_connected_peer_info_s *peer, void *user_data)
{
g_print("[_connected_peer_cb] Connected to IP [%s]\n", peer->ip_address);
- //g_print("[_connected_peer_cb] Connected to Port [%d]\n", peer->scmirroring_ctrl_port);
+ /*g_print("[_connected_peer_cb] Connected to Port [%d]\n", peer->scmirroring_ctrl_port); */
g_print("[_connected_peer_cb] Connected device_name [%s]\n", peer->device_name);
g_print("[_connected_peer_cb] Connected to mac_address [%s]\n", peer->mac_address);
g_print("[_connected_peer_cb] Connected to interface_address [%s]\n", peer->interface_address);
memset(g_peer_port, 0x00, sizeof(g_peer_port));
snprintf(g_peer_ip, sizeof(g_peer_ip), "%s", peer->ip_address);
- //snprintf(g_peer_port, sizeof(g_peer_port), "%d", peer->scmirroring_ctrl_port);
+ /*snprintf(g_peer_port, sizeof(g_peer_port), "%d", peer->scmirroring_ctrl_port); */
- //g_timeout_add(SINKTEST_EXECUTE_DELAY, __scmirroring_sink_start, NULL);
+ /*g_timeout_add(SINKTEST_EXECUTE_DELAY, __scmirroring_sink_start, NULL); */
return TRUE;
}
void _activation_cb(int error_code, wifi_direct_device_state_e device_state, void *user_data)
{
- switch (device_state)
- {
+ switch (device_state) {
case WIFI_DIRECT_DEVICE_STATE_ACTIVATED:
g_print("device_state : WIFI_DIRECT_DEVICE_STATE_ACTIVATED\n");
break;
void _discover_cb(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data)
{
int ret = WIFI_DIRECT_ERROR_NONE;
- //g_print("Discovered [ error : %d discovery state : %d ]\n", error_code, discovery_state);
+ /*g_print("Discovered [ error : %d discovery state : %d ]\n", error_code, discovery_state); */
- switch (discovery_state)
- {
+ switch (discovery_state) {
case WIFI_DIRECT_ONLY_LISTEN_STARTED:
g_print("discovery_state : WIFI_DIRECT_ONLY_LISTEN_STARTED \n");
break;
case WIFI_DIRECT_DISCOVERY_FOUND:
g_print("discovery_state : WIFI_DIRECT_DISCOVERY_FOUND \n");
ret = wifi_direct_foreach_discovered_peers(_discovered_peer_cb, (void *)NULL);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_foreach_discovered_peers failed : %d\n", ret);
}
break;
{
char *local_ip = NULL;
- wifi_direct_get_ip_address (&local_ip);
+ wifi_direct_get_ip_address(&local_ip);
if (!local_ip) {
- g_print ("Failed to get local ip\n");
+ g_print("Failed to get local ip\n");
return;
}
g_print("[_ip_assigned_cb] IP assigned [ ip addr : %s if addr : %s mac_addr:%s ]\n", ip_address, interface_address, mac_address);
scmirroring_src_set_ip_and_port(g_scmirroring, local_ip, "2022");
- g_print ("Input server IP and port number IP[%s] Port[%s]\n", local_ip, "2022");
+ g_print("Input server IP and port number IP[%s] Port[%s]\n", local_ip, "2022");
+ g_free(local_ip);
}
void _connection_cb(int error_code, wifi_direct_connection_state_e connection_state, const char *mac_address, void *user_data)
{
g_print("Connected [ error : %d connection state : %d mac_addr:%s ]\n", error_code, connection_state, mac_address);
- switch (connection_state)
- {
- case WIFI_DIRECT_CONNECTION_IN_PROGRESS:
- {
- g_print(" WIFI_DIRECT_CONNECTION_IN_PROGRESS\n");
- break;
- }
- case WIFI_DIRECT_CONNECTION_RSP:
- {
- g_print(" WIFI_DIRECT_CONNECTION_RSP\n");
- bool is_go = FALSE;
- wifi_direct_is_group_owner(&is_go);
- if(!is_go) {
- wifi_direct_foreach_connected_peers(_connected_peer_cb, (void *)NULL);
- g_print("WIFI_DIRECT_CONNECTION_RSP : Source is not group owner\n");
- } else {
- g_print("WIFI_DIRECT_CONNECTION_RSP : Source is group owner\n ");
+ switch (connection_state) {
+ case WIFI_DIRECT_CONNECTION_IN_PROGRESS: {
+ g_print(" WIFI_DIRECT_CONNECTION_IN_PROGRESS\n");
+ break;
+ }
+ case WIFI_DIRECT_CONNECTION_RSP: {
+ g_print(" WIFI_DIRECT_CONNECTION_RSP\n");
+ bool is_go = FALSE;
+ wifi_direct_is_group_owner(&is_go);
+ if (!is_go) {
+ wifi_direct_foreach_connected_peers(_connected_peer_cb, (void *)NULL);
+ g_print("WIFI_DIRECT_CONNECTION_RSP : Source is not group owner\n");
+ } else {
+ g_print("WIFI_DIRECT_CONNECTION_RSP : Source is group owner\n ");
+ }
+ break;
}
- break;
- }
case WIFI_DIRECT_CONNECTION_REQ:
case WIFI_DIRECT_CONNECTION_WPS_REQ:
case WIFI_DIRECT_DISCONNECTION_RSP:
return;
}
+#ifdef ENABLE_WIFI_DIRECT
static gboolean __start_p2p_connection(gpointer data)
{
- int ret = WIFI_DIRECT_ERROR_NONE;
- int go_intent = 0;
- wifi_direct_state_e direct_state = WIFI_DIRECT_STATE_DEACTIVATED;
- struct ug_data *ugd = (struct ug_data *)data;
-
- g_print("====== Start p2p connection ======\n");
-
- ret = wifi_direct_initialize();
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
- g_print("Error : wifi_direct_initialize failed : %d\n", ret);
- return FALSE;
- }
-
- /* Activation / Deactivation state Callback */
- ret = wifi_direct_set_device_state_changed_cb(_activation_cb, (void *)ugd);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
- g_print("Error : wifi_direct_set_device_state_changed_cb failed : %d\n", ret);
- goto error;
- }
-
- /* Discovery state Callback */
- ret = wifi_direct_set_discovery_state_changed_cb(_discover_cb, (void *)ugd);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
- g_print("Error : wifi_direct_set_discovery_state_changed_cb failed : %d\n", ret);
- goto error;
- }
-
- /* Connection state Callback */
- ret = wifi_direct_set_connection_state_changed_cb(_connection_cb, (void *)ugd);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
- g_print("Error : wifi_direct_set_connection_state_changed_cb failed : %d\n", ret);
- goto error;
- }
-
- /* IP address assigning state callback */
- ret = wifi_direct_set_client_ip_address_assigned_cb(_ip_assigned_cb, (void *)ugd);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
- g_print("Error : wifi_direct_set_client_ip_address_assigned_cb failed : %d\n", ret);
- goto error;
- }
-
- ret = wifi_direct_get_state(&direct_state);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
- g_print("Error : wifi_direct_get_state failed : %d\n", ret);
- goto error;
- }
-
- if (direct_state < WIFI_DIRECT_STATE_ACTIVATED)
- {
- g_print("wifi direct status < WIFI_DIRECT_STATE_ACTIVATED\n");
- g_print("\n ------ Starting to activate scmirroring ------\n");
- ret = wifi_direct_activate();
- if (ret < WIFI_DIRECT_ERROR_NONE)
- {
- g_print("Error : wifi_direct_activate failed : %d\n", ret);
- return FALSE;
- }
- }
- else
- {
- g_print("wifi direct status >= WIFI_DIRECT_STATE_ACTIVATED.. Disconnect all first\n");
- ret = wifi_direct_disconnect_all();
- if(!ret)
- {
- g_print("wifi_direct_disconnect_all success\n");
- }
- else
- {
- g_print("wifi_direct_disconnect_all fail\n");
- }
- }
-
-#if 0
- /*Enable Screen Mirroring*/
+ int ret = WIFI_DIRECT_ERROR_NONE;
+ int go_intent = 0;
+ wifi_direct_state_e direct_state = WIFI_DIRECT_STATE_DEACTIVATED;
+ struct ug_data *ugd = (struct ug_data *)data;
+
+ g_print("====== Start p2p connection ======\n");
+
+ ret = wifi_direct_initialize();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ g_print("Error : wifi_direct_initialize failed : %d\n", ret);
+ return FALSE;
+ }
+
+ /* Activation / Deactivation state Callback */
+ ret = wifi_direct_set_device_state_changed_cb(_activation_cb, (void *)ugd);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ g_print("Error : wifi_direct_set_device_state_changed_cb failed : %d\n", ret);
+ goto error;
+ }
+
+ /* Discovery state Callback */
+ ret = wifi_direct_set_discovery_state_changed_cb(_discover_cb, (void *)ugd);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ g_print("Error : wifi_direct_set_discovery_state_changed_cb failed : %d\n", ret);
+ goto error;
+ }
+
+ /* Connection state Callback */
+ ret = wifi_direct_set_connection_state_changed_cb(_connection_cb, (void *)ugd);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ g_print("Error : wifi_direct_set_connection_state_changed_cb failed : %d\n", ret);
+ goto error;
+ }
+
+ /* IP address assigning state callback */
+ ret = wifi_direct_set_client_ip_address_assigned_cb(_ip_assigned_cb, (void *)ugd);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ g_print("Error : wifi_direct_set_client_ip_address_assigned_cb failed : %d\n", ret);
+ goto error;
+ }
+
+ ret = wifi_direct_get_state(&direct_state);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ g_print("Error : wifi_direct_get_state failed : %d\n", ret);
+ goto error;
+ }
+
+ if (direct_state < WIFI_DIRECT_STATE_ACTIVATED) {
+ g_print("wifi direct status < WIFI_DIRECT_STATE_ACTIVATED\n");
+ g_print("\n------Starting to activate scmirroring------\n");
+ ret = wifi_direct_activate();
+ if (ret < WIFI_DIRECT_ERROR_NONE) {
+ g_print("Error : wifi_direct_activate failed : %d\n", ret);
+ return FALSE;
+ }
+ } else {
+ g_print("wifi direct status >= WIFI_DIRECT_STATE_ACTIVATED.. Disconnect all first\n");
+ ret = wifi_direct_disconnect_all();
+ if (!ret) {
+ g_print("wifi_direct_disconnect_all success\n");
+ } else {
+ g_print("wifi_direct_disconnect_all fail\n");
+ }
+ }
+
+ /*Enable Screen Mirroring*/
ret = wifi_direct_init_display();
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
- g_print("Error : wifi_direct_init_display failed : %d\n", ret);
- goto error;
- }
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ g_print("Error : wifi_direct_init_display failed : %d\n", ret);
+ goto error;
+ }
ret = wifi_direct_set_display_availability(TRUE);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
- g_print("Error : wifi_direct_set_display_availability failed : %d\n", ret);
- goto error;
- }
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ g_print("Error : wifi_direct_set_display_availability failed : %d\n", ret);
+ goto error;
+ }
ret = wifi_direct_set_display(WIFI_DISPLAY_TYPE_SRC, 2022, 0);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
- g_print("Error : wifi_direct_display_set_device failed : %d\n", ret);
- goto error;
- }
-#endif
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ g_print("Error : wifi_direct_display_set_device failed : %d\n", ret);
+ goto error;
+ }
+
+ ret = wifi_direct_get_group_owner_intent(&go_intent);
+ g_print("go_intent = [%d]\n", go_intent);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ g_print("Error : wifi_direct_get_group_owner_intent failed : %d\n", ret);
+ goto error;
+ }
+
+ go_intent = 14;
+ ret = wifi_direct_set_group_owner_intent(go_intent);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ g_print("Error : wifi_direct_get_group_owner_intent failed : %d\n", ret);
+ goto error;
+ }
+ g_print("wifi_direct_set_group_owner_intent() result=[%d] go_intent[%d]\n", ret, go_intent);
+
+ /* 10 sec discovery in cycle mode */
+ int err = wifi_direct_start_discovery(0, 10);
+ if (err < WIFI_DIRECT_ERROR_NONE) {
+ g_print("wifi_direct_discovery fail\n");
+ return false;
+ } else {
+ g_print("wifi_direct_discovery start\n");
+ }
+
- ret = wifi_direct_get_group_owner_intent(&go_intent);
- g_print("go_intent = [%d]\n", go_intent);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
- g_print("Error : wifi_direct_get_group_owner_intent failed : %d\n", ret);
- goto error;
- }
-
- go_intent = 14;
- ret = wifi_direct_set_group_owner_intent(go_intent);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
- g_print("Error : wifi_direct_get_group_owner_intent failed : %d\n", ret);
- goto error;
- }
- g_print("wifi_direct_set_group_owner_intent() result=[%d] go_intent[%d]\n", ret, go_intent);
-
-/* 10 sec discovery in cycle mode */
- int err = wifi_direct_start_discovery(0,10);
- if (err < WIFI_DIRECT_ERROR_NONE) {
- g_print("wifi_direct_discovery fail\n");
- return false;
- } else {
- g_print("wifi_direct_discovery start\n");
- }
-
-
- g_print("====== p2p connection established ======\n");
-
- return TRUE;
+ g_print("====== p2p connection established ======\n");
+
+ return TRUE;
error:
- ret = wifi_direct_deinitialize();
+ ret = wifi_direct_deinitialize();
- return FALSE;
+ return FALSE;
}
+#endif
gboolean _scmirroring_start_jobs(gpointer data)
{
+#ifdef ENABLE_WIFI_DIRECT
__start_p2p_connection(data);
-
+#endif
return FALSE;
}
GIOChannel *stdin_channel;
GMainContext *context = NULL;
stdin_channel = g_io_channel_unix_new(0);
- g_io_channel_set_flags (stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
+ g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)__input, NULL);
ret = scmirroring_src_create(&g_scmirroring);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("scmirroring_src_create fail [%d]", ret);
return 0;
}
ret = scmirroring_src_set_state_changed_cb(g_scmirroring, scmirroring_state_callback, NULL);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("scmirroring_src_create fail [%d]", ret);
return 0;
}
GSource *start_job_src = NULL;
start_job_src = g_idle_source_new();
- g_source_set_callback (start_job_src, _scmirroring_start_jobs, NULL, NULL);
- g_source_attach (start_job_src, context);
+ g_source_set_callback(start_job_src, _scmirroring_start_jobs, NULL, NULL);
+ g_source_attach(start_job_src, context);
g_main_loop_run(g_loop);
#define MAX_STRING_LEN 2048
#define SINKTEST_EXECUTE_DELAY 5000
+#define MAIN_MENU 0
+#define SUBMENU_RESOLUTION 1
-//#define TEST_WITH_WIFI_DIRECT
+/*#define TEST_WITH_WIFI_DIRECT */
scmirroring_sink_h g_scmirroring = NULL;
+gint g_resolution = 0;
+gint g_menu = MAIN_MENU;
+
GMainLoop *g_loop;
#ifdef TEST_WITH_WIFI_DIRECT
static int g_peer_cnt = 0;
static gboolean __start_p2p_connection(gpointer data);
static gboolean __disconnect_p2p_connection(void);
#endif
+static void __quit_program(void);
+gboolean __timeout_menu_display(void *data);
+static void __display_resolution_submenu(void);
+gboolean __timeout_resolution_submenu_display(void *data);
+static void __interpret_resolution_submenu(char *cmd);
+
+
+gboolean __timeout_resolution_submenu_display(void *data)
+{
+ __display_resolution_submenu();
+ return FALSE;
+}
+
+static void __display_resolution_submenu(void)
+{
+ g_print("\n");
+ g_print("**********************************************************************\n");
+ g_print(" Setting resolution \n");
+ g_print("**********************************************************************\n");
+ g_print("1 : SCMIRRORING_RESOLUTION_1920x1080_P30 [%d]\n", SCMIRRORING_RESOLUTION_1920x1080_P30);
+ g_print("2 : SCMIRRORING_RESOLUTION_1280x720_P30 [%d]\n", SCMIRRORING_RESOLUTION_1280x720_P30);
+ g_print("3 : SCMIRRORING_RESOLUTION_960x540_P30 [%d]\n", SCMIRRORING_RESOLUTION_960x540_P30);
+ g_print("4 : SCMIRRORING_RESOLUTION_864x480_P30 [%d]\n", SCMIRRORING_RESOLUTION_864x480_P30);
+ g_print("5 : SCMIRRORING_RESOLUTION_720x480_P60 [%d]\n", SCMIRRORING_RESOLUTION_720x480_P60);
+ g_print("6 : SCMIRRORING_RESOLUTION_640x480_P60 [%d]\n", SCMIRRORING_RESOLUTION_640x480_P60);
+ g_print("7 : SCMIRRORING_RESOLUTION_640x360_P30 [%d]\n", SCMIRRORING_RESOLUTION_640x360_P30);
+ g_print("r : Reset resolution \n");
+ g_print("g : Go back to main menu \n");
+ g_print("**********************************************************************\n");
+
+}
+
+static void __interpret_resolution_submenu(char *cmd)
+{
+ if (strncmp(cmd, "1", 1) == 0) {
+ g_print("resolution |= SCMIRRORING_RESOLUTION_1920x1080_P30[%d]\n", SCMIRRORING_RESOLUTION_1920x1080_P30);
+ g_resolution |= SCMIRRORING_RESOLUTION_1920x1080_P30;
+ } else if (strncmp(cmd, "2", 1) == 0) {
+ g_print("resolution |= SCMIRRORING_RESOLUTION_1280x720_P30[%d]\n", SCMIRRORING_RESOLUTION_1280x720_P30);
+ g_resolution |= SCMIRRORING_RESOLUTION_1280x720_P30;
+ } else if (strncmp(cmd, "3", 1) == 0) {
+ g_print("resolution |= SCMIRRORING_RESOLUTION_960x540_P30[%d]\n", SCMIRRORING_RESOLUTION_960x540_P30);
+ g_resolution |= SCMIRRORING_RESOLUTION_960x540_P30;
+ } else if (strncmp(cmd, "4", 1) == 0) {
+ g_print("resolution |= SCMIRRORING_RESOLUTION_864x480_P30[%d]\n", SCMIRRORING_RESOLUTION_864x480_P30);
+ g_resolution |= SCMIRRORING_RESOLUTION_864x480_P30;
+ } else if (strncmp(cmd, "5", 1) == 0) {
+ g_print("resolution |= SCMIRRORING_RESOLUTION_720x480_P60[%d]\n", SCMIRRORING_RESOLUTION_720x480_P60);
+ g_resolution |= SCMIRRORING_RESOLUTION_720x480_P60;
+ } else if (strncmp(cmd, "6", 1) == 0) {
+ g_print("resolution |= SCMIRRORING_RESOLUTION_640x480_P60[%d]\n", SCMIRRORING_RESOLUTION_640x480_P60);
+ g_resolution |= SCMIRRORING_RESOLUTION_640x480_P60;
+ } else if (strncmp(cmd, "7", 1) == 0) {
+ g_print("resolution |= SCMIRRORING_RESOLUTION_640x360_P30[%d]\n", SCMIRRORING_RESOLUTION_640x360_P30);
+ g_resolution |= SCMIRRORING_RESOLUTION_640x360_P30;
+ } else if (strncmp(cmd, "r", 1) == 0) {
+ g_resolution = 0;
+ } else if (strncmp(cmd, "g", 1) == 0) {
+ g_print("go back to main menu\n");
+ g_menu = MAIN_MENU;
+ g_timeout_add(100, __timeout_menu_display, 0);
+ return;
+ }
+
+ g_print("resolution : %d\n", g_resolution);
+
+ g_timeout_add(100, __timeout_resolution_submenu_display, 0);
+
+ return;
+}
static void scmirroring_sink_state_callback(scmirroring_error_e error_code, scmirroring_sink_state_e state, void *user_data)
{
- g_print("Received Callback error code[%d]", error_code);
+ g_print("Received Callback error code[%d] state[%d]", error_code, state);
- if(state == SCMIRRORING_SINK_STATE_NONE)
+ if (state == SCMIRRORING_SINK_STATE_NONE)
g_print(" state[%d] SCMIRRORING_SINK_STATE_NONE", state);
- else if(state == SCMIRRORING_SINK_STATE_NULL)
+ else if (state == SCMIRRORING_SINK_STATE_NULL)
g_print(" st ate[%d] (state == SCMIRRORING_SINK_STATE_NULL)", state);
- else if(state ==SCMIRRORING_SINK_STATE_PREPARED)
+ else if (state == SCMIRRORING_SINK_STATE_PREPARED)
g_print(" state[%d] SCMIRRORING_SINK_STATE_PREPARED", state);
- else if(state == SCMIRRORING_SINK_STATE_CONNECTED)
+ else if (state == SCMIRRORING_SINK_STATE_CONNECTED) {
g_print(" state[%d] SCMIRRORING_SINK_STATE_CONNECTED", state);
- if(scmirroring_sink_start(g_scmirroring)!= SCMIRRORING_ERROR_NONE)
+ if (scmirroring_sink_start(g_scmirroring) != SCMIRRORING_ERROR_NONE)
g_print("scmirroring_sink_start fail");
- else if(state == SCMIRRORING_SINK_STATE_PLAYING)
+ } else if (state == SCMIRRORING_SINK_STATE_PLAYING)
g_print(" state[%d] SCMIRRORING_SINK_STATE_PLAYING", state);
- else if(state == SCMIRRORING_SINK_STATE_PAUSED)
+ else if (state == SCMIRRORING_SINK_STATE_PAUSED)
g_print(" state[%d] SCMIRRORING_SINK_STATE_PAUSED", state);
- else if(state == SCMIRRORING_SINK_STATE_DISCONNECTED)
+ else if (state == SCMIRRORING_SINK_STATE_DISCONNECTED) {
g_print(" state[%d] SCMIRRORING_SINK_STATE_DISCONNECTED", state);
- else
+ if (scmirroring_sink_unprepare(g_scmirroring) != SCMIRRORING_ERROR_NONE) {
+ g_print("scmirroring_sink_unprepare fail");
+ }
+ if (scmirroring_sink_destroy(g_scmirroring) != SCMIRRORING_ERROR_NONE) {
+ g_print("scmirroring_sink_destroy fail");
+ }
+ __quit_program();
+ } else
g_print(" state[%d] Invalid State", state);
return;
static void __quit_program(void)
{
- g_print ("Quit Program\n");
+ g_print("Quit Program\n");
#ifdef TEST_WITH_WIFI_DIRECT
__disconnect_p2p_connection();
{
g_print("\n");
g_print("=====================================================================\n");
- g_print(" SCMIRRORING Sink Testsuite (press q to quit) \n");
+ g_print(" SCMIRRORING Sink Testsuite(press q to quit) \n");
g_print("=====================================================================\n");
#ifndef TEST_WITH_WIFI_DIRECT
- g_print("a : a ip port (ex. a 192.168.49.1 2022)\n");
+ g_print("a : a ip port(ex. a 192.168.49.1 2022)\n");
g_print("s : start \n");
#endif
+ g_print("P : Pause\n");
+ g_print("R : Resume\n");
g_print("D : Disconnect\n");
g_print("T : desTroy\n");
+ g_print("L : Setting resolution\n");
g_print("q : quit\n");
g_print("-----------------------------------------------------------------------------------------\n");
}
-gboolean __timeout_menu_display(void* data)
+gboolean __timeout_menu_display(void *data)
{
__displaymenu();
bool _connected_peer_cb(wifi_direct_connected_peer_info_s *peer, void *user_data)
{
int peer_port = 0;
- if (wifi_direct_get_peer_display_port(peer->mac_address, &peer_port) != WIFI_DIRECT_ERROR_NONE)
- {
- g_print ("Can not get port info\n Use default (2022)\n");
+ if (wifi_direct_get_peer_display_port(peer->mac_address, &peer_port) != WIFI_DIRECT_ERROR_NONE) {
+ g_print("Can not get port info\n Use default(2022)\n");
peer_port = DEFAULT_SCREEN_MIRRORING_PORT;
}
- if (peer_port == 0)
- {
- g_print ("Can not get port info\n Use default (2022)\n");
+ if (peer_port == 0) {
+ g_print("Can not get port info\n Use default(2022)\n");
peer_port = DEFAULT_SCREEN_MIRRORING_PORT;
}
void _activation_cb(int error_code, wifi_direct_device_state_e device_state, void *user_data)
{
- switch (device_state)
- {
+ switch (device_state) {
case WIFI_DIRECT_DEVICE_STATE_ACTIVATED:
g_print("device_state : WIFI_DIRECT_DEVICE_STATE_ACTIVATED\n");
break;
void _discover_cb(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data)
{
int ret = WIFI_DIRECT_ERROR_NONE;
- //g_print("Discovered [ error : %d discovery state : %d ]\n", error_code, discovery_state);
+ /*g_print("Discovered [ error : %d discovery state : %d ]\n", error_code, discovery_state); */
- switch (discovery_state)
- {
+ switch (discovery_state) {
case WIFI_DIRECT_ONLY_LISTEN_STARTED:
g_print("discovery_state : WIFI_DIRECT_ONLY_LISTEN_STARTED \n");
break;
case WIFI_DIRECT_DISCOVERY_FOUND:
g_print("discovery_state : WIFI_DIRECT_DISCOVERY_FOUND \n");
ret = wifi_direct_foreach_discovered_peers(_discovered_peer_cb, (void *)NULL);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_foreach_discovered_peers failed : %d\n", ret);
}
break;
g_print("Connected [ error : %d connection state : %d mac_addr:%s ]\n", error_code, connection_state, mac_address);
- if (connection_state == WIFI_DIRECT_CONNECTION_REQ)
- {
+ if (connection_state == WIFI_DIRECT_CONNECTION_REQ) {
ret = wifi_direct_accept_connection(mac_address);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_accept_connection failed : %d\n", ret);
}
- }
- else if (connection_state == WIFI_DIRECT_CONNECTION_RSP)
- {
+ } else if (connection_state == WIFI_DIRECT_CONNECTION_RSP) {
bool is_go = FALSE;
ret = wifi_direct_is_group_owner(&is_go);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_is_group_owner failed : %d\n", ret);
}
- if (is_go)
- {
+ if (is_go) {
g_print("Connected as Group Owner\n");
- }
- else
- {
+ } else {
ret = wifi_direct_foreach_connected_peers(_connected_peer_cb, (void *)NULL);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_foreach_connected_peers failed : %d\n", ret);
return;
}
}
#endif
-static void __interpret (char *cmd)
+static void __interpret(char *cmd)
{
int ret = SCMIRRORING_ERROR_NONE;
- gchar **value;
- value = g_strsplit(cmd," ",0);
- if(strncmp(cmd, "D", 1) == 0)
- {
- g_print ("Disconnect\n");
+ gchar **value;
+ value = g_strsplit(cmd, " ", 0);
+ if (strncmp(cmd, "D", 1) == 0) {
+ g_print("Disconnect\n");
ret = scmirroring_sink_disconnect(g_scmirroring);
- }
- else if(strncmp(cmd, "T", 1) == 0)
- {
- g_print ("Destroy\n");
+ } else if (strncmp(cmd, "P", 1) == 0) {
+ g_print("Pause\n");
+ ret = scmirroring_sink_pause(g_scmirroring);
+ } else if (strncmp(cmd, "R", 1) == 0) {
+ g_print("Resume\n");
+ ret = scmirroring_sink_resume(g_scmirroring);
+ } else if (strncmp(cmd, "T", 1) == 0) {
+ g_print("Destroy\n");
ret = scmirroring_sink_unprepare(g_scmirroring);
ret = scmirroring_sink_destroy(g_scmirroring);
- }
- else if(strncmp(cmd, "q", 1) == 0)
- {
+ } else if (strncmp(cmd, "q", 1) == 0) {
__quit_program();
+ } else if (strncmp(cmd, "L", 1) == 0) {
+ g_menu = SUBMENU_RESOLUTION;
+ g_timeout_add(100, __timeout_resolution_submenu_display, 0);
+ return;
}
#ifndef TEST_WITH_WIFI_DIRECT
- else if (strncmp(cmd, "a", 1) == 0)
- {
+ else if (strncmp(cmd, "a", 1) == 0) {
ret = __scmirroring_sink_create(NULL);
- if(ret == SCMIRRORING_ERROR_NONE)
- {
- ret = scmirroring_sink_set_ip_and_port(g_scmirroring, value[1], value[2]);
- g_print ("Input server IP and port number IP[%s] Port[%s]\n", value[1], value[2]);
- }
- }
- else if (strncmp(cmd, "s", 1) == 0)
- {
- g_print ("Start\n");
+ if (ret == SCMIRRORING_ERROR_NONE) {
+ ret = scmirroring_sink_set_ip_and_port(g_scmirroring, value[1], value[2]);
+ g_print("Input server IP and port number IP[%s] Port[%s]\n", value[1], value[2]);
+ }
+ } else if (strncmp(cmd, "s", 1) == 0) {
+ g_print("Start\n");
ret = __scmirroring_sink_start(NULL);
}
#endif
- else
- {
+ else {
g_print("unknown menu \n");
}
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("Error Occured [%d]", ret);
}
g_timeout_add(100, __timeout_menu_display, 0);
-return;
+ return;
}
-gboolean __input (GIOChannel *channel)
+gboolean __input(GIOChannel *channel)
{
char buf[MAX_STRING_LEN + 3];
gsize read;
g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
buf[read] = '\0';
g_strstrip(buf);
- __interpret (buf);
+
+ if (g_menu == MAIN_MENU)
+ __interpret(buf);
+ else if (g_menu == SUBMENU_RESOLUTION)
+ __interpret_resolution_submenu(buf);
+
return TRUE;
}
g_print("====== Start p2p connection ======\n");
ret = wifi_direct_initialize();
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_initialize failed : %d\n", ret);
return FALSE;
}
/* Activation / Deactivation state Callback */
ret = wifi_direct_set_device_state_changed_cb(_activation_cb, (void *)ugd);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_set_device_state_changed_cb failed : %d\n", ret);
goto error;
}
/* Discovery state Callback */
ret = wifi_direct_set_discovery_state_changed_cb(_discover_cb, (void *)ugd);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_set_discovery_state_changed_cb failed : %d\n", ret);
goto error;
}
/* Connection state Callback */
ret = wifi_direct_set_connection_state_changed_cb(_connection_cb, (void *)ugd);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_set_connection_state_changed_cb failed : %d\n", ret);
goto error;
}
/* IP address assigning state callback */
ret = wifi_direct_set_client_ip_address_assigned_cb(_ip_assigned_cb, (void *)ugd);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_set_client_ip_address_assigned_cb failed : %d\n", ret);
goto error;
}
ret = wifi_direct_get_state(&direct_state);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_get_state failed : %d\n", ret);
goto error;
}
- if (direct_state < WIFI_DIRECT_STATE_ACTIVATED)
- {
+ if (direct_state < WIFI_DIRECT_STATE_ACTIVATED) {
g_print("wifi direct status < WIFI_DIRECT_STATE_ACTIVATED\n");
- g_print("\n ------ Starting to activate scmirroring ------\n");
+ g_print("\n------Starting to activate scmirroring------\n");
ret = wifi_direct_activate();
- if (ret < WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret < WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_activate failed : %d\n", ret);
return FALSE;
}
- }
- else
- {
+ } else {
g_print("wifi direct status >= WIFI_DIRECT_STATE_ACTIVATED.. Disconnect all first\n");
ret = wifi_direct_disconnect_all();
- if(!ret)
- {
+ if (!ret) {
g_print("wifi_direct_disconnect_all success\n");
- }
- else
- {
+ } else {
g_print("wifi_direct_disconnect_all fail\n");
}
}
/*Enable Screen Mirroring*/
ret = wifi_direct_init_display();
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_display_init failed : %d\n", ret);
goto error;
}
/*Enable Wifi Direct - You can set this as true if you want to see it from wifi-direct list*/
ret = wifi_direct_set_display_availability(TRUE);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_display_init failed : %d\n", ret);
goto error;
}
ret = wifi_direct_set_display(WIFI_DISPLAY_TYPE_SINK, 2022, 0);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_display_set_device failed : %d\n", ret);
goto error;
}
ret = wifi_direct_get_group_owner_intent(&go_intent);
g_print("go_intent = [%d]\n", go_intent);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_get_group_owner_intent failed : %d\n", ret);
goto error;
}
go_intent = 1;
ret = wifi_direct_set_group_owner_intent(go_intent);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_get_group_owner_intent failed : %d\n", ret);
goto error;
}
g_print("wifi_direct_set_group_owner_intent() result=[%d] go_intent[%d]\n", ret, go_intent);
ret = wifi_direct_set_max_clients(1);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_set_max_clients failed : %d\n", ret);
goto error;
}
ret = wifi_direct_get_state(&direct_state);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_get_state failed : %d\n", ret);
goto error;
}
- if(direct_state > WIFI_DIRECT_STATE_ACTIVATING)
- {
- char * device_name = NULL;
+ if (direct_state > WIFI_DIRECT_STATE_ACTIVATING) {
+ char *device_name = NULL;
ret = wifi_direct_start_discovery(1, 0);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_start_discovery failed : %d\n", ret);
goto error;
}
ret = wifi_direct_get_device_name(&device_name);
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_get_device_name failed : %d\n", ret);
goto error;
}
g_print("Device Name : [%s]\n", device_name);
- if(device_name)
+ if (device_name)
free(device_name);
- }
- else
- {
+ } else {
g_print("Error : Direct not activated yet\n");
}
int ret = WIFI_DIRECT_ERROR_NONE;
ret = wifi_direct_deactivate();
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_deactivate failed : %d\n", ret);
return FALSE;
}
ret = wifi_direct_deinitialize();
- if(ret != WIFI_DIRECT_ERROR_NONE)
- {
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
g_print("Error : wifi_direct_deinitialize failed : %d\n", ret);
return FALSE;
}
- g_print("------ p2p connection disconnected ------\n");
+ g_print("------p2p connection disconnected------\n");
return TRUE;
}
int ret = SCMIRRORING_ERROR_NONE;
ret = scmirroring_sink_create(&g_scmirroring);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("scmirroring_sink_create fail [%d]", ret);
return SCMIRRORING_ERROR_OUT_OF_MEMORY;
}
ret = scmirroring_sink_prepare(g_scmirroring);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("scmirroring_sink_prepare fail [%d]", ret);
return SCMIRRORING_ERROR_OUT_OF_MEMORY;
}
#ifdef TEST_WITH_WIFI_DIRECT
ret = scmirroring_sink_create(&g_scmirroring);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("scmirroring_sink_create fail [%d]", ret);
return FALSE;
}
+ if (g_resolution != 0) {
+ ret = scmirroring_sink_set_resolution(g_scmirroring, g_resolution);
+ if (ret != SCMIRRORING_ERROR_NONE) {
+ g_print("Failed to set resolution, error[%d]\n", ret);
+ }
+ }
+
ret = scmirroring_sink_prepare(g_scmirroring);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("scmirroring_sink_prepare fail [%d]", ret);
return SCMIRRORING_ERROR_OUT_OF_MEMORY;
}
ret = scmirroring_sink_set_ip_and_port(g_scmirroring, g_peer_ip, g_peer_port);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("scmirroring_sink_set_ip_and_port fail [%d]", ret);
return FALSE;
}
#endif
ret = scmirroring_sink_set_state_changed_cb(g_scmirroring, scmirroring_sink_state_callback, NULL);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("scmirroring_sink_set_state_changed_cb fail [%d]", ret);
return FALSE;
}
-
-
-
ret = scmirroring_sink_connect(g_scmirroring);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("scmirroring_sink_connect fail [%d]", ret);
return FALSE;
}
#if 0
ret = scmirroring_sink_set_display(g_scmirroring, SCMIRRORING_DISPLAY_TYPE_X11, NULL);
- if(ret != SCMIRRORING_ERROR_NONE)
- {
+ if (ret != SCMIRRORING_ERROR_NONE) {
g_print("scmirroring_sink_set_display fail [%d]", ret);
return FALSE;
}
int ret = WIFI_DIRECT_ERROR_NONE;
ret = __start_p2p_connection(data);
- if(ret == FALSE)
+ if (ret == FALSE)
return FALSE;
#endif
- return FALSE;
+ return FALSE;
}
int main(int argc, char *argv[])
GSource *start_job_src = NULL;
stdin_channel = g_io_channel_unix_new(0);
- g_io_channel_set_flags (stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
+ g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)__input, NULL);
__displaymenu();
context = g_main_loop_get_context(g_loop);
start_job_src = g_idle_source_new();
- g_source_set_callback (start_job_src, _scmirroring_start_jobs, NULL, NULL);
- g_source_attach (start_job_src, context);
+ g_source_set_callback(start_job_src, _scmirroring_start_jobs, NULL, NULL);
+ g_source_attach(start_job_src, context);
g_main_loop_run(g_loop);