return ESPP_CLIENT_ERROR_NONE;
}
+int espp_client_get_playing_time(espp_h espp, uint64_t *time_ms)
+{
+ espp_s *_espp = (espp_s *)espp;
+ g_autoptr(GMutexLocker) locker = NULL;
+
+ RET_VAL_IF(!espp, ESPP_CLIENT_ERROR_INVALID_PARAMETER, "espp is NULL");
+ RET_VAL_IF(!time_ms, ESPP_CLIENT_ERROR_INVALID_PARAMETER, "time_ms is NULL");
+
+ locker = g_mutex_locker_new(&_espp->mutex);
+
+ if (espp_service_client_socket_request_get_playing_time(_espp, time_ms) != 0)
+ return ESPP_CLIENT_ERROR_INVALID_OPERATION;
+
+ LOG_INFO("espp[%p] time_ms[%" PRIu64 "]", espp, *time_ms);
+
+ 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;
int espp_client_seek(espp_h espp, uint64_t time_ms);
/**
- * @brief Gets current stats of the ESPP service client handle.
+ * @brief Gets the current stats of the ESPP service client handle.
* @param[in] espp ESPP service client handle
* @param[out] state The state of the handle
* @return @c 0 on success,
*/
int espp_client_get_state(espp_h espp, espp_state_e *state);
+/**
+ * @brief Gets the current playing time of the ESPP service client handle.
+ * @param[in] espp ESPP service client handle
+ * @param[out] time_ms The playing time in milliseconds
+ * @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 The state must be #ESPP_STATE_PAUSED or #ESPP_STATE_PLAYING.
+ * @see espp_client_prepare_async()
+ */
+int espp_client_get_playing_time(espp_h espp, uint64_t *time_ms);
+
/**
* @brief Sets the audio stream information to the ESPP service client handle.
* @remarks This function must be called before calling the espp_client_prepare_async().
int espp_service_client_socket_request_prepare_async(espp_s *espp);
int espp_service_client_socket_request_seek(espp_s *espp, uint64_t time_ms);
int espp_service_client_socket_request_get_state(espp_s *espp, espp_state_e *state);
+int espp_service_client_socket_request_get_playing_time(espp_s *espp, uint64_t *time_ms);
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);
int espp_service_client_socket_request_set_display_surface_id(espp_s *espp, espp_display_type_e type, unsigned int surface_id, int x, int y, int w, int h);
return 0;
}
+int espp_service_client_socket_request_get_playing_time(espp_s *espp, uint64_t *time_ms)
+{
+ espp_service_data_from_client_s data;
+ espp_service_data_from_server_s result;
+
+ ASSERT(espp);
+ ASSERT(time_ms);
+
+ RET_VAL_IF(espp->fd == -1, -1, "fd is -1");
+
+ FILL_SOCKET_MSG_REQUEST(data, ESPP_SERVICE_REQUEST_GET_PLAYING_TIME);
+ 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);
+
+ *time_ms = result.ret_time;
+
+ 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_PREPARE_ASYNC] = { "PrepareAsync", NULL },
[ESPP_SERVICE_REQUEST_SEEK] = { "Seek", "k" },
[ESPP_SERVICE_REQUEST_GET_STATE] = { "GetState", NULL },
+ [ESPP_SERVICE_REQUEST_GET_PLAYING_TIME] = { "GetPlayingTime", NULL },
[ESPP_SERVICE_REQUEST_SET_AUDIO_STREAM_INFO] = { "SetAudioStreamInfo", "suiuuu" },
[ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO] = { "SetVideoStreamInfo", "suiuuuuuu" },
[ESPP_SERVICE_REQUEST_SET_DISPLAY_SURFACE_ID] = { "SetDisplaySurfaceId", "iuiiii" },
ESPP_SERVICE_REQUEST_PREPARE_ASYNC,
ESPP_SERVICE_REQUEST_SEEK,
ESPP_SERVICE_REQUEST_GET_STATE,
+ ESPP_SERVICE_REQUEST_GET_PLAYING_TIME,
ESPP_SERVICE_REQUEST_SET_AUDIO_STREAM_INFO,
ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO,
ESPP_SERVICE_REQUEST_SET_DISPLAY_SURFACE_ID,
union {
int ret;
espp_service_event_e event;
+ uint64_t ret_time;
};
char params[MAX_PARAMS_LEN];
} espp_service_data_from_server_s;
result->ret = ret;
}
+static void __handle_get_playing_time(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
+{
+ int ret;
+ uint64_t time_ms;
+
+ ASSERT(hdata);
+ ASSERT(data);
+ ASSERT(result);
+ ASSERT(hdata->svc);
+ ASSERT(hdata->fd >= 0);
+
+ result->ret = -1;
+
+ RET_IF(!g_hash_table_lookup(hdata->svc->fd_table, hdata->key), "failed to g_hash_table_lookup(), key[%s]", hdata->key);
+
+ ret = esplusplayer_get_playing_time((esplusplayer_handle)hdata->espp, &time_ms);
+ RET_IF(ret != ESPLUSPLAYER_ERROR_TYPE_NONE, "failed to esplusplayer_get_playing_time(), ESPP[%p]", hdata->espp);
+
+ LOG_INFO("fd[%d], ESPP[%p]: esplusplayer_get_playing_time() success, time_ms[%" PRIu64 "]", hdata->fd, hdata->espp, time_ms);
+
+ result->ret_time = time_ms;
+}
+
static void __handle_set_audio_stream_info(handler_userdata_s *hdata, espp_service_data_from_client_s *data, espp_service_data_from_server_s *result)
{
int ret;
[ESPP_SERVICE_REQUEST_PREPARE_ASYNC] = __handle_prepare_async,
[ESPP_SERVICE_REQUEST_SEEK] = __handle_seek,
[ESPP_SERVICE_REQUEST_GET_STATE] = __handle_get_state,
+ [ESPP_SERVICE_REQUEST_GET_PLAYING_TIME] = __handle_get_playing_time,
[ESPP_SERVICE_REQUEST_SET_AUDIO_STREAM_INFO] = __handle_set_audio_stream_info,
[ESPP_SERVICE_REQUEST_SET_VIDEO_STREAM_INFO] = __handle_set_video_stream_info,
[ESPP_SERVICE_REQUEST_SET_DISPLAY_SURFACE_ID] = __handle_set_display_surface_id,