return ESPP_CLIENT_ERROR_NONE;
}
+int espp_client_set_buffer_size(espp_h espp, espp_buffer_size_type_e size_type, uint64_t size)
+{
+ 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_set_buffer_size(_espp, size_type, size) != 0)
+ return ESPP_CLIENT_ERROR_INVALID_OPERATION;
+
+ LOG_INFO("espp[%p] size_type[%d] size[%" PRIu64 "]", espp, size_type, size);
+
+ return ESPP_CLIENT_ERROR_NONE;
+}
ESPP_BUFFER_STATUS_OVERRUN, /**< Overrun */
} espp_buffer_status_e;
+/**
+ * @brief Enumerations for buffer size type
+ */
+typedef enum {
+ ESPP_BUFFER_SIZE_TYPE_AUDIO_MAX_TIME, /**< The maximum amount of data for audio (in ms) */
+ ESPP_BUFFER_SIZE_TYPE_VIDEO_MAX_TIME, /**< The maximum amount of data for video (in ms) */
+ ESPP_BUFFER_SIZE_TYPE_AUDIO_MIN_TIME_THRESHOLD, /**< Emit underrun when queued bytes drops below the percent of the audio max time (in %) */
+ ESPP_BUFFER_SIZE_TYPE_VIDEO_MIN_TIME_THRESHOLD, /**< Emit underrun when queued bytes drops below the percent of the video max time (in %) */
+ ESPP_BUFFER_SIZE_TYPE_AUDIO_MAX_BYTE, /**< The maximum amount of data for audio (in bytes) */
+ ESPP_BUFFER_SIZE_TYPE_VIDEO_MAX_BYTE, /**< The maximum amount of data for video (in bytes) */
+ ESPP_BUFFER_SIZE_TYPE_AUDIO_MIN_BYTE_THRESHOLD, /**< Emit underrun when queued bytes drops below the percent of the audio max bytes size (in %) */
+ ESPP_BUFFER_SIZE_TYPE_VIDEO_MIN_BYTE_THRESHOLD, /**< Emit underrun when queued bytes drops below the percent of the video max bytes size (in %) */
+} espp_buffer_size_type_e;
+
/**
* @brief Enumerations for the submit error
*/
/**
* @brief Generates EoS(End of Stream) packet and submits it.
* @param[in] espp ESPP service client handle
- * @param[in] stream_type The stream type that reaches EoS.
+ * @param[in] stream_type The stream type that reaches EoS
* @param[out] error ESPP packet submit error (optional, this can be NULL)
* @return @c 0 on success,
* otherwise a negative error value
*/
int espp_client_submit_eos_packet(espp_h espp, espp_stream_type_e stream_type, espp_submit_error_e *error);
+/**
+ * @brief Sets buffer size.
+ * @param[in] espp ESPP service client handle
+ * @param[in] type The buffer size type to be set
+ * @param[in] size The size of the selected buffer type
+ * @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
+ * @pre espp_client_open() must be called before calling this function.
+ * @see espp_open()
+ */
+int espp_client_set_buffer_size(espp_h espp, espp_buffer_size_type_e size_type, uint64_t size);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
int espp_service_client_socket_request_set_callback(espp_s *espp, espp_service_event_e type, void *callback, void *user_data);
int espp_service_client_socket_request_submit_packet(espp_s *espp, espp_packet_s *packet, espp_submit_error_e *error);
int espp_service_client_socket_request_submit_eos_packet(espp_s *espp, espp_stream_type_e stream_type, espp_submit_error_e *error);
+int espp_service_client_socket_request_set_buffer_size(espp_s *espp, espp_buffer_size_type_e size_type, uint64_t size);
/* event handler */
gpointer espp_service_client_event_handler_thread_func(gpointer user_data);
return 0;
}
+
+int espp_service_client_socket_request_set_buffer_size(espp_s *espp, espp_buffer_size_type_e size_type, uint64_t size)
+{
+ 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_SET_BUFFER_SIZE);
+ FILL_SOCKET_MSG_PARAMS(data, ESPP_SERVICE_REQUEST_SET_BUFFER_SIZE,
+ "size_type", size_type, "size", size);
+ 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;
+}
[ESPP_SERVICE_REQUEST_SET_AUDIO_MUTE] = { "SetAudioMute", "b" },
[ESPP_SERVICE_REQUEST_SUBMIT_PACKET] = { "SubmitPacket", "iukku" },
[ESPP_SERVICE_REQUEST_SUBMIT_EOS_PACKET] = { "SubmitEosPacket", "i" },
+ [ESPP_SERVICE_REQUEST_SET_BUFFER_SIZE] = { "SetBufferSize", "ik" },
[ESPP_SERVICE_REQUEST_SET_CALLBACK] = { "SetCallback", "i" },
};
ESPP_SERVICE_REQUEST_SET_AUDIO_MUTE,
ESPP_SERVICE_REQUEST_SUBMIT_PACKET,
ESPP_SERVICE_REQUEST_SUBMIT_EOS_PACKET,
+ ESPP_SERVICE_REQUEST_SET_BUFFER_SIZE,
ESPP_SERVICE_REQUEST_SET_CALLBACK,
} espp_service_request_e;
result->ret = 0;
}
+static void __handle_set_buffer_size(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+{
+ int ret;
+ esplusplayer_buffer_option option;
+ uint64_t size;
+
+ ret = espp_service_msg_parse_params(data->params, data->request,
+ &option, &size);
+ if (ret != 0)
+ return;
+
+ ret = esplusplayer_set_buffer_size((esplusplayer_handle)hdata->espp, option, size);
+ RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_set_buffer_size(), ESPP[%p], option[%d], size[%" PRIu64 "]",
+ hdata->espp, option, size);
+
+ LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_set_buffer_size() success, option[%d], size[%" PRIu64 "]",
+ hdata->fd, hdata->espp, option, size);
+
+ result->ret = 0;
+}
+
static void __ready_to_prepare_cb(const int type, void *user_data)
{
handler_userdata_s *hdata = (handler_userdata_s *)user_data;
[ESPP_SERVICE_REQUEST_SET_AUDIO_MUTE] = __handle_set_audio_mute,
[ESPP_SERVICE_REQUEST_SUBMIT_PACKET] = __handle_submit_packet,
[ESPP_SERVICE_REQUEST_SUBMIT_EOS_PACKET] = __handle_submit_eos_packet,
+ [ESPP_SERVICE_REQUEST_SET_BUFFER_SIZE] = __handle_set_buffer_size,
[ESPP_SERVICE_REQUEST_SET_CALLBACK] = __handle_set_callback,
};