return ESPP_CLIENT_ERROR_NONE;
}
+int espp_client_stop(espp_h espp)
+{
+ espp_s *_espp = (espp_s *)espp;
+ g_autoptr(GMutexLocker) locker = NULL;
+
+ RET_VAL_IF(!espp, ESPP_CLIENT_ERROR_INVALID_PARAMETER, "espp is NULL");
+
+ locker = g_mutex_locker_new(&_espp->mutex);
+
+ if (espp_service_client_socket_request_stop(_espp) != 0)
+ return ESPP_CLIENT_ERROR_INVALID_OPERATION;
+
+ LOG_INFO("espp[%p] is stopped", espp);
+
+ return ESPP_CLIENT_ERROR_NONE;
+}
+
int espp_client_set_audio_stream_info(espp_h espp, espp_audio_stream_info_s *info)
{
espp_s *_espp = (espp_s *)espp;
* @retval #ESPP_CLIENT_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #ESPP_CLIENT_ERROR_INVALID_OPERATION Invalid operation
* @see espp_client_create()
+ * @see espp_client_stop()
*/
int espp_client_start(espp_h espp);
+/**
+ * @brief Stops the espp.
+ * @remarks espp_client_close() must be called after this handle is stopped.
+ * @param[in] espp ESPP service client handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ESPP_CLIENT_ERROR_NONE Successful
+ * @retval #ESPP_CLIENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ESPP_CLIENT_ERROR_INVALID_OPERATION Invalid operation
+ * @see espp_client_start()
+ * @see espp_client_close()
+ */
+int espp_client_stop(espp_h espp);
+
/**
* @brief Sets the audio stream information.
- * @remarks This API has to be called before calling the espp_client_prepare_async().
+ * @remarks This function must be called before calling the espp_client_prepare_async().
* @param[in] espp ESPP service client handle
* @param[in] info Audio stream information structure pointer
* @return @c 0 on success,
/**
* @brief Sets the video stream information.
- * @remarks This API has to be called before calling the espp_client_prepare_async().
+ * @remarks This function must be called before calling the espp_client_prepare_async().
* @param[in] espp ESPP service client handle
* @param[in] info Video stream information structure pointer
* @return @c 0 on success,
int espp_service_client_socket_request_create(espp_s *espp);
int espp_service_client_socket_request_destroy(espp_s *espp);
int espp_service_client_socket_request_start(espp_s *espp);
+int espp_service_client_socket_request_stop(espp_s *espp);
int espp_service_client_socket_request_set_audio_stream_info(espp_s *espp, espp_audio_stream_info_s *info);
int espp_service_client_socket_request_set_video_stream_info(espp_s *espp, espp_video_stream_info_s *info);
return 0;
}
+int espp_service_client_socket_request_stop(espp_s *espp)
+{
+ espp_service_data_from_client_s data;
+ espp_service_data_from_server_s result;
+
+ ASSERT(espp);
+ RET_VAL_IF(espp->fd == -1, -1, "fd is -1");
+
+ FILL_SOCKET_MSG_REQUEST(data, ESPP_SERVICE_REQUEST_STOP);
+ if (send_data(espp->fd, &data, &result) != 0)
+ return -1;
+
+ RET_VAL_IF_SERVER_RESULT_ERROR(result, -1);
+
+ LOG_DEBUG("espp[%p], fd[%d]", espp, espp->fd);
+
+ return 0;
+}
+
int espp_service_client_socket_request_set_audio_stream_info(espp_s *espp, espp_audio_stream_info_s *info)
{
espp_service_data_from_client_s data;
[ESPP_SERVICE_REQUEST_CREATE] = { "Create", NULL },
[ESPP_SERVICE_REQUEST_DESTROY] = {"Destroy", NULL },
[ESPP_SERVICE_REQUEST_START] = { "Start", NULL },
+ [ESPP_SERVICE_REQUEST_STOP] = { "Stop", NULL },
[ESPP_SERVICE_REQUEST_SET_AUDIO_STREAM_INFO] = { "SetAudioStreamInfo", "suiuuu" },
[ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO] = { "SetVideoStreamInfo", "suiuuuuuu" },
};
ESPP_SERVICE_REQUEST_CREATE,
ESPP_SERVICE_REQUEST_DESTROY,
ESPP_SERVICE_REQUEST_START,
+ ESPP_SERVICE_REQUEST_STOP,
ESPP_SERVICE_REQUEST_SET_AUDIO_STREAM_INFO,
ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO,
} espp_service_request_e;
result->ret = 0;
}
+static void __handle_stop(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+{
+ int ret;
+ esplusplayer_handle espp;
+
+ ASSERT(svc);
+ ASSERT(fd >= 0);
+ ASSERT(data);
+ ASSERT(result);
+
+ result->ret = -1;
+
+ RET_IF(!(espp = g_hash_table_lookup(svc->espp_handles, GINT_TO_POINTER(fd))), "failed to g_hash_table_lookup(), fd[%d]", fd);
+
+ ret = esplusplayer_stop(espp);
+ RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_stop(), ESPP[%p]", espp);
+
+ LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_stop() success", fd, espp);
+
+ result->ret = 0;
+}
+
static void __handle_set_audio_stream_info(espp_service_s *svc, int fd, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
{
int ret;
[ESPP_SERVICE_REQUEST_CREATE] = __handle_create,
[ESPP_SERVICE_REQUEST_DESTROY] = __handle_destroy,
[ESPP_SERVICE_REQUEST_START] = __handle_start,
+ [ESPP_SERVICE_REQUEST_STOP] = __handle_stop,
[ESPP_SERVICE_REQUEST_SET_AUDIO_STREAM_INFO] = __handle_set_audio_stream_info,
[ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO] = __handle_set_video_stream_info,
};