STOP
}
- void message(bundle msg, array<file_desc> fd) delegate;
+ void message_fd(bundle msg, array<file_desc> fd) delegate;
+ void message(bundle msg) delegate;
void async_return(async_return_type type, int ret) delegate;
- int init(int type, message msg_cb, async_return ret_cb);
+ int init(int type, message_fd msg_fd_cb, message msg_cb, async_return ret_cb);
int deinit();
int configure(int width, int height, int in_format, int out_format, bool is_secure);
### main package #########
Name: %{name}
Summary: %{name} interface
-Version: 1.4.0
+Version: 1.5.0
Release: 0
Group: Development/Libraries
License: Apache-2.0
typedef struct _hal_codec_ipc_message_s {
- rpc_port_proxy_codec_message_h handle;
+ rpc_port_proxy_codec_message_fd_h msg_fd_handle;
+ rpc_port_proxy_codec_message_h msg_handle;
hal_codec_message_cb user_cb;
void *user_cb_data;
GMutex lock;
}
-static void __hal_codec_ipc_message_cb(void *user_data, bundle *b_msg, rpc_port_proxy_array_file_desc_h fd_handle)
+static void __hal_codec_ipc_message_fd_cb(void *user_data, bundle *b_msg, rpc_port_proxy_array_file_desc_h fd_handle)
{
int ret = 0;
int ipc_ret = 0;
return;
}
+ if (handle->type != HAL_CODEC_TYPE_DECODER ||
+ hal_message->type != HAL_CODEC_MESSAGE_TYPE_OUTPUT_BUFFER) {
+ SLOGE("Not DECODER OUTPUT: type[%d], message[%d]", handle->type, hal_message->type);
+ return;
+ }
+
+ ipc_buffer = &handle->ipc_buffer;
+ ipc_message = &handle->ipc_message;
+
+ /* get buffer */
+ ipc_ret = bundle_get_byte(b_msg, HAL_CODEC_IPC_PARAM_KEY_BUFFER, (void **)&b_data, &hal_buffer_size);
+ if (ipc_ret != BUNDLE_ERROR_NONE ||
+ hal_buffer_size != sizeof(hal_codec_buffer_s)) {
+ SLOGE("[OUTPUT] get buffer from bundle failed[0x%x], size[%zu:%zu]",
+ ipc_ret, hal_buffer_size, sizeof(hal_codec_buffer_s));
+ return;
+ }
+
+ hal_buffer = g_memdup2(b_data, hal_buffer_size);
+
+ ret = __hal_codec_ipc_hal_buffer_set_decoder_output(hal_buffer, fd_handle);
+ if (ret != HAL_CODEC_ERROR_NONE) {
+ g_free(hal_buffer);
+ return;
+ }
+
+ g_mutex_lock(&ipc_buffer->lock);
+
+ if (ipc_buffer->output_buffers[hal_buffer->index]) {
+ SLOGE("[OUTPUT] duplicated buffer index[%d]", hal_buffer->index);
+ g_free(hal_buffer);
+ g_mutex_unlock(&ipc_buffer->lock);
+ return;
+ }
+
+ hal_message->buffer = hal_buffer;
+ ipc_buffer->output_buffers[hal_buffer->index] = hal_buffer;
+
+ ipc_buffer->output_buffer_count++;
+
+ SLOGD("[DECODER][OUTPUT] buffer[%d] %p, count[%u -> %u]",
+ hal_buffer->index, hal_buffer,
+ ipc_buffer->output_buffer_count - 1, ipc_buffer->output_buffer_count);
+
+ g_mutex_unlock(&ipc_buffer->lock);
+
+ g_mutex_lock(&ipc_message->lock);
+
+ if (ipc_message->user_cb) {
+ ((hal_codec_message_cb)ipc_message->user_cb)(hal_message, ipc_message->user_cb_data);
+ g_mutex_unlock(&ipc_message->lock);
+ return;
+ }
+
+ g_mutex_unlock(&ipc_message->lock);
+
+ SLOGW("no msg cb for handle[%p]", handle);
+
+ if (hal_message->type == HAL_CODEC_MESSAGE_TYPE_OUTPUT_BUFFER) {
+ SLOGW("release output buffer[%d]", hal_message->buffer->index);
+ hal_codec_ipc_release_output_buffer(handle, hal_message->buffer->index);
+ }
+}
+
+
+static void __hal_codec_ipc_message_cb(void *user_data, bundle *b_msg)
+{
+ int ret = 0;
+ int ipc_ret = 0;
+ void *b_data = NULL;
+ size_t hal_message_size = 0;
+ size_t hal_buffer_size = 0;
+
+ hal_codec_message_s *hal_message = NULL;
+ hal_codec_buffer_s *hal_buffer = NULL;
+
+ hal_codec_ipc_s *handle = (hal_codec_ipc_s *)user_data;
+ hal_codec_ipc_buffer_s *ipc_buffer = NULL;
+ hal_codec_ipc_message_s *ipc_message = NULL;
+
+ HAL_CODEC_RETURN_IF_FAILED(handle);
+ HAL_CODEC_RETURN_IF_FAILED(b_msg);
+
+ /* message */
+ ipc_ret = bundle_get_byte(b_msg, HAL_CODEC_IPC_PARAM_KEY_MESSAGE, (void **)&hal_message, &hal_message_size);
+ if (ipc_ret != BUNDLE_ERROR_NONE ||
+ hal_message_size != sizeof(hal_codec_message_s)) {
+ SLOGE("get message from bundle failed[0x%x], size[%zu:%zu]",
+ ipc_ret, hal_message_size, sizeof(hal_codec_message_s));
+ return;
+ }
+
+ if (handle->type == HAL_CODEC_TYPE_DECODER &&
+ hal_message->type == HAL_CODEC_MESSAGE_TYPE_OUTPUT_BUFFER) {
+ SLOGE("It's DECODER OUTPUT");
+ return;
+ }
+
ipc_buffer = &handle->ipc_buffer;
ipc_message = &handle->ipc_message;
hal_buffer = g_memdup2(b_data, hal_buffer_size);
- if (handle->type == HAL_CODEC_TYPE_DECODER)
- ret = __hal_codec_ipc_hal_buffer_set_decoder_output(hal_buffer, fd_handle);
- else
- ret = __hal_codec_ipc_hal_buffer_set_encoder_output(hal_buffer, b_msg);
-
+ ret = __hal_codec_ipc_hal_buffer_set_encoder_output(hal_buffer, b_msg);
if (ret != HAL_CODEC_ERROR_NONE) {
g_free(hal_buffer);
return;
if (ipc_buffer->output_buffers[hal_buffer->index]) {
SLOGE("[OUTPUT] duplicated buffer index[%d]", hal_buffer->index);
+ g_free(hal_buffer->planes.plane[0].data);
g_free(hal_buffer);
g_mutex_unlock(&ipc_buffer->lock);
return;
ipc_buffer->output_buffer_count++;
- SLOGD("[%s][OUTPUT] buffer[%d] %p, count[%u -> %u]",
- handle->type == HAL_CODEC_TYPE_DECODER ? "DECODER" : "ENCODER",
+ SLOGD("[ENCODER][OUTPUT] buffer[%d] %p, count[%u -> %u]",
hal_buffer->index, hal_buffer,
ipc_buffer->output_buffer_count - 1, ipc_buffer->output_buffer_count);
hal_codec_ipc_message_s *ipc_message = NULL;
hal_codec_ipc_async_return_s *ipc_async_return = NULL;
+ rpc_port_proxy_codec_message_fd_h msg_fd_handle = NULL;
rpc_port_proxy_codec_message_h msg_handle = NULL;
rpc_port_proxy_codec_async_return_h async_return_handle = NULL;
HAL_CODEC_RETURN_VAL_IF_FAILED(handle, HAL_CODEC_ERROR_INVALID_PARAMETER);
- /* message callback */
- ipc_ret = rpc_port_proxy_codec_message_create(&msg_handle);
+ /* message fd callback for decoder output */
+ ipc_ret = rpc_port_proxy_codec_message_fd_create(&msg_fd_handle);
if (ipc_ret != RPC_PORT_ERROR_NONE) {
- SLOGE("msg handle create failed[0x%x]", ipc_ret);
+ SLOGE("message_fd handle create failed[0x%x]", ipc_ret);
return HAL_CODEC_ERROR_OUT_OF_MEMORY;
}
+ ipc_ret = rpc_port_proxy_codec_message_fd_set_callback(msg_fd_handle,
+ __hal_codec_ipc_message_fd_cb, handle);
+ if (ipc_ret != RPC_PORT_ERROR_NONE) {
+ SLOGE("set message_fd callback failed[0x%x]", ipc_ret);
+ ret = HAL_CODEC_ERROR_INTERNAL;
+ goto _CB_HANDLE_NEW_FAILED;
+ }
+
+ rpc_port_proxy_codec_message_fd_set_once(msg_fd_handle, false);
+
+ /* message callback for encoder output and other messages */
+ ipc_ret = rpc_port_proxy_codec_message_create(&msg_handle);
+ if (ipc_ret != RPC_PORT_ERROR_NONE) {
+ SLOGE("message handle create failed[0x%x]", ipc_ret);
+ ret = HAL_CODEC_ERROR_OUT_OF_MEMORY;
+ goto _CB_HANDLE_NEW_FAILED;
+ }
+
ipc_ret = rpc_port_proxy_codec_message_set_callback(msg_handle,
__hal_codec_ipc_message_cb, handle);
if (ipc_ret != RPC_PORT_ERROR_NONE) {
- SLOGE("set msg callback failed[0x%x]", ipc_ret);
+ SLOGE("set message callback failed[0x%x]", ipc_ret);
ret = HAL_CODEC_ERROR_INTERNAL;
goto _CB_HANDLE_NEW_FAILED;
}
g_cond_init(&ipc_async_return->cond[i]);
}
- SLOGI("new cb handle: msg[%p], async_return[%p]", msg_handle, async_return_handle);
+ SLOGI("new cb handle: msg_fd[%p], msg[%p], async_return[%p]",
+ msg_fd_handle, msg_handle, async_return_handle);
- ipc_message->handle = msg_handle;
+ ipc_message->msg_fd_handle = msg_fd_handle;
+ ipc_message->msg_handle = msg_handle;
ipc_async_return->handle = async_return_handle;
return HAL_CODEC_ERROR_NONE;
_CB_HANDLE_NEW_FAILED:
+ if (msg_fd_handle)
+ rpc_port_proxy_codec_message_fd_destroy(msg_fd_handle);
+
if (msg_handle)
rpc_port_proxy_codec_message_destroy(msg_handle);
ipc_async_return->handle = NULL;
}
- if (ipc_message->handle) {
- SLOGI("msg handle[%p]", ipc_message->handle);
+ if (ipc_message->msg_fd_handle) {
+ SLOGI("msg_fd handle[%p]", ipc_message->msg_fd_handle);
+
+ ipc_ret = rpc_port_proxy_codec_message_fd_dispose(handle->rpc_handle, ipc_message->msg_fd_handle);
+ if (ipc_ret != RPC_PORT_ERROR_NONE) {
+ SLOGE("msg_fd handle dispose failed[0x%x], try to destroy", ipc_ret);
+ rpc_port_proxy_codec_message_fd_destroy(ipc_message->msg_fd_handle);
+ }
+
+ ipc_message->msg_fd_handle = NULL;
+ }
+
+ if (ipc_message->msg_handle) {
+ SLOGI("msg handle[%p]", ipc_message->msg_handle);
- ipc_ret = rpc_port_proxy_codec_message_dispose(handle->rpc_handle, ipc_message->handle);
+ ipc_ret = rpc_port_proxy_codec_message_dispose(handle->rpc_handle, ipc_message->msg_handle);
if (ipc_ret != RPC_PORT_ERROR_NONE) {
SLOGE("msg handle dispose failed[0x%x], try to destroy", ipc_ret);
- rpc_port_proxy_codec_message_destroy(ipc_message->handle);
+ rpc_port_proxy_codec_message_destroy(ipc_message->msg_handle);
}
- ipc_message->handle = NULL;
+ ipc_message->msg_handle = NULL;
}
g_mutex_clear(&ipc_message->lock);
goto _INIT_FAILED;
ipc_ret = rpc_port_proxy_codec_invoke_init(new_handle->rpc_handle, type,
- new_handle->ipc_message.handle, new_handle->ipc_async_return.handle);
+ new_handle->ipc_message.msg_fd_handle, new_handle->ipc_message.msg_handle,
+ new_handle->ipc_async_return.handle);
if (ipc_ret != RPC_PORT_ERROR_NONE) {
SLOGE("invoke init failed[0x%x]", ret);
ret = HAL_CODEC_ERROR_INTERNAL;
typedef struct _hal_codec_service_s {
hal_codec_type_e type;
void *codec_handle;
+ rpc_port_stub_codec_message_fd_h msg_fd_handle;
rpc_port_stub_codec_message_h msg_handle;
rpc_port_stub_codec_async_return_h async_return_handle;
GMutex cb_lock;
return HAL_CODEC_ERROR_INTERNAL;
}
- rpc_port_stub_array_file_desc_create(&fd_handle);
-
switch (message->type) {
case HAL_CODEC_MESSAGE_TYPE_INPUT_BUFFER_USED:
buffer = message->buffer;
bundle_add_byte(b_msg, HAL_CODEC_IPC_PARAM_KEY_BUFFER, (const void *)buffer, sizeof(hal_codec_buffer_s));
- if (buffer->memory.num_fd > 0) {
- HAL_CODEC_SERVICE_LOGD("[OUTPUT_BUFFER] buffer[%d] num_fd[%u] fd[%d:%d]",
+ if (service_handle->type == HAL_CODEC_TYPE_DECODER) {
+ rpc_port_stub_array_file_desc_create(&fd_handle);
+
+ HAL_CODEC_SERVICE_LOGD("[DECODER][OUTPUT] buffer[%d] num_fd[%u] fd[%d:%d]",
buffer->index, buffer->memory.num_fd, buffer->memory.fd[0], buffer->memory.fd[1]);
ipc_ret = rpc_port_stub_array_file_desc_set(fd_handle, (int *)buffer->memory.fd, buffer->memory.num_fd);
HAL_CODEC_SERVICE_LOGE("[OUTPUT_BUFFER] set fd failed: num_fd[%u], fd[%d:%d]",
buffer->memory.num_fd, buffer->memory.fd[0], buffer->memory.fd[1]);
}
- }
-
- if (service_handle->type == HAL_CODEC_TYPE_ENCODER) {
- HAL_CODEC_SERVICE_LOGD("[OUTPUT_BUFFER] buffer[%d] data[0] bytesused[%u]",
+ } else {
+ HAL_CODEC_SERVICE_LOGD("[ENCODER][OUTPUT] buffer[%d] data[0] bytesused[%u]",
buffer->index, buffer->planes.plane[0].bytesused);
ipc_ret = bundle_add_byte(b_msg, HAL_CODEC_IPC_PARAM_KEY_PLANE0_DATA,
goto _SERVICE_MESSAGE_CB_DONE;
}
- ipc_ret = rpc_port_stub_codec_message_invoke(service_handle->msg_handle, b_msg, fd_handle);
+ if (fd_handle)
+ ipc_ret = rpc_port_stub_codec_message_fd_invoke(service_handle->msg_fd_handle, b_msg, fd_handle);
+ else
+ ipc_ret = rpc_port_stub_codec_message_invoke(service_handle->msg_handle, b_msg);
if (ipc_ret != RPC_PORT_ERROR_NONE) {
HAL_CODEC_SERVICE_LOGE("Failed to invoke message_cb");
g_mutex_unlock(&service_handle->cb_lock);
_SERVICE_MESSAGE_CB_DONE:
bundle_free(b_msg);
- rpc_port_stub_array_file_desc_destroy(fd_handle);
+ if (fd_handle)
+ rpc_port_stub_array_file_desc_destroy(fd_handle);
return HAL_CODEC_ERROR_NONE;
}
g_free(job);
if (return_type != RPC_PORT_STUB_ASYNC_RETURN_TYPE_CODEC_NONE) {
+ SLOGD("async return type[%d]: ret[0x%x]", return_type, ret);
ipc_ret = rpc_port_stub_codec_async_return_invoke(service_handle->async_return_handle, return_type, ret);
if (ipc_ret != RPC_PORT_ERROR_NONE)
HAL_CODEC_SERVICE_LOGE("Failed async_return_cb: type[%d], ret[0x%x]", return_type, ipc_ret);
static int __hal_codec_service_cb_handle_new(hal_codec_service_s *service_handle,
- rpc_port_stub_codec_message_h msg_handle, rpc_port_stub_codec_async_return_h async_return_handle)
+ rpc_port_stub_codec_message_fd_h msg_fd_handle, rpc_port_stub_codec_message_h msg_handle,
+ rpc_port_stub_codec_async_return_h async_return_handle)
{
int rpc_ret = RPC_PORT_ERROR_NONE;
+ rpc_port_stub_codec_message_fd_h msg_fd_handle_new = NULL;
rpc_port_stub_codec_message_h msg_handle_new = NULL;
rpc_port_stub_codec_async_return_h async_return_handle_new = NULL;
HAL_CODEC_SERVICE_RETURN_VAL_IF_FAILED(service_handle, HAL_CODEC_ERROR_INVALID_PARAMETER);
+ HAL_CODEC_SERVICE_RETURN_VAL_IF_FAILED(msg_fd_handle, HAL_CODEC_ERROR_INVALID_PARAMETER);
HAL_CODEC_SERVICE_RETURN_VAL_IF_FAILED(msg_handle, HAL_CODEC_ERROR_INVALID_PARAMETER);
HAL_CODEC_SERVICE_RETURN_VAL_IF_FAILED(async_return_handle, HAL_CODEC_ERROR_INVALID_PARAMETER);
+ rpc_ret = rpc_port_stub_codec_message_fd_clone(msg_fd_handle, &msg_fd_handle_new);
+ if (rpc_ret != RPC_PORT_ERROR_NONE) {
+ HAL_CODEC_SERVICE_LOGE("message_fd handle clone failed[0x%x]", rpc_ret);
+ return HAL_CODEC_ERROR_INTERNAL;
+ }
+
rpc_ret = rpc_port_stub_codec_message_clone(msg_handle, &msg_handle_new);
if (rpc_ret != RPC_PORT_ERROR_NONE) {
HAL_CODEC_SERVICE_LOGE("message handle clone failed[0x%x]", rpc_ret);
+ rpc_port_stub_codec_message_fd_destroy(msg_fd_handle_new);
return HAL_CODEC_ERROR_INTERNAL;
}
rpc_ret = rpc_port_stub_codec_async_return_clone(async_return_handle, &async_return_handle_new);
if (rpc_ret != RPC_PORT_ERROR_NONE) {
HAL_CODEC_SERVICE_LOGE("async return handle clone failed[0x%x]", rpc_ret);
+ rpc_port_stub_codec_message_fd_destroy(msg_fd_handle_new);
rpc_port_stub_codec_message_destroy(msg_handle_new);
return HAL_CODEC_ERROR_INTERNAL;
}
- HAL_CODEC_SERVICE_LOGI("new cb handle: message[%p], async_return[%p]",
- msg_handle_new, async_return_handle);
+ HAL_CODEC_SERVICE_LOGI("new cb handle: message_fd[%p], message[%p], async_return[%p]",
+ msg_fd_handle_new, msg_handle_new, async_return_handle);
+ service_handle->msg_fd_handle = msg_fd_handle_new;
service_handle->msg_handle = msg_handle_new;
service_handle->async_return_handle = async_return_handle_new;
static int _hal_codec_service_backend_init(rpc_port_stub_codec_context_h context, int type,
- rpc_port_stub_codec_message_h msg_handle, rpc_port_stub_codec_async_return_h async_return_handle, void *user_data)
+ rpc_port_stub_codec_message_fd_h msg_fd_handle, rpc_port_stub_codec_message_h msg_handle,
+ rpc_port_stub_codec_async_return_h async_return_handle, void *user_data)
{
int ret = HAL_CODEC_ERROR_NONE;
int rpc_ret = RPC_PORT_ERROR_NONE;
goto _BACKEND_INIT_FAILED;
}
- ret = __hal_codec_service_cb_handle_new(service_handle, msg_handle, async_return_handle);
+ ret = __hal_codec_service_cb_handle_new(service_handle, msg_fd_handle, msg_handle, async_return_handle);
if (ret != HAL_CODEC_ERROR_NONE)
goto _BACKEND_INIT_FAILED;
#define DECODE_FRAME_HEIGHT 1080
#define ENCODE_FRAME_WIDTH 1920
#define ENCODE_FRAME_HEIGHT 1080
+#define ENCODE_FRAME_TEST_NUM 60
+#define ENCODE_FRAME_INDEX_MAX 16
#define DECODER_SUPPORT_CHECK \
do {\
case HAL_CODEC_MESSAGE_TYPE_INPUT_BUFFER_USED:
cout << "[INPUT_BUFFER_USED] buffer[" << message->buffer->index << "] "<< message->buffer;
cout << " size[" << message->buffer->planes.plane[0].bytesused << "]" << endl;
+ if (gHalHandleEnc) {
+ g_free(message->buffer);
+ message->buffer = nullptr;
+ }
break;
case HAL_CODEC_MESSAGE_TYPE_OUTPUT_BUFFER:
if (message->buffer->meta.flags & HAL_CODEC_BUFFER_FLAG_EOS) {
gsize mappedFileLength_ {};
gchar *mappedFileContents_ {};
gsize mappedFileOffset_ {};
- hal_codec_buffer_s buffer_[CONTENTS_H264_FRAME_NUM + 1] {};
};
if (buffer_[gFeedCount].meta.flags & HAL_CODEC_BUFFER_FLAG_EOS) {
cout << "[FeedDataDecode] Remove Feed thread" << endl;
return G_SOURCE_REMOVE;
- } else {
- gFeedCount++;
- return G_SOURCE_CONTINUE;
}
+
+ gFeedCount++;
+ return G_SOURCE_CONTINUE;
}
+
+ hal_codec_buffer_s buffer_[CONTENTS_H264_FRAME_NUM + 1] {};
};
int FeedDataEncode(void)
{
- memset(&buffer_[gFeedCount], 0x0, sizeof(hal_codec_buffer_s));
+ int ret_get_state = 0;
+ hal_codec_buffer_s *inputBuffer = g_new0(hal_codec_buffer_s, 1);
+ hal_codec_state_e state = HAL_CODEC_STATE_INITIALIZED;
- buffer_[gFeedCount].index = (int)gFeedCount;
- buffer_[gFeedCount].meta.timestamp = (uint64_t)gFeedCount * 1000000000; /* ns */
+ inputBuffer->index = (int)(gFeedCount % ENCODE_FRAME_INDEX_MAX);
+ inputBuffer->meta.timestamp = (uint64_t)gFeedCount * 1000000000; /* ns */
+
+ cout << "[FeedEncode] count: " << gFeedCount << ", tSurface_: " << tSurface_ << endl;
- if (gFeedCount < CONTENTS_NV12_FRAME_NUM) {
- buffer_[gFeedCount].size = tsInfo_.size;
- buffer_[gFeedCount].planes.num_planes = tsInfo_.num_planes;
+ ret_get_state = hal_codec_get_state(gHalHandleEnc, &state);
+ if (ret_get_state != HAL_CODEC_ERROR_NONE)
+ cout << "[GET_STATE FAILED] " << ret_get_state << endl;
+ else
+ cout << "[GET_STATE] " << state << endl;
+
+ if (gFeedCount < ENCODE_FRAME_TEST_NUM) {
+ inputBuffer->size = tsInfo_.size;
+ inputBuffer->planes.num_planes = tsInfo_.num_planes;
for (uint32_t i = 0 ; i < tsInfo_.num_planes ; i++) {
- buffer_[gFeedCount].planes.plane[i].data = tsInfo_.planes[i].ptr;
- buffer_[gFeedCount].planes.plane[i].size = tsInfo_.planes[i].size;
- buffer_[gFeedCount].planes.plane[i].bytesused = tsInfo_.planes[i].size;
+ inputBuffer->planes.plane[i].data = tsInfo_.planes[i].ptr;
+ inputBuffer->planes.plane[i].size = tsInfo_.planes[i].size;
+ inputBuffer->planes.plane[i].bytesused = tsInfo_.planes[i].size;
}
- buffer_[gFeedCount].memory.num_fd = tbm_surface_internal_get_num_bos(tSurface_);
+ inputBuffer->memory.num_fd = tbm_surface_internal_get_num_bos(tSurface_);
for (int i = 0 ; i < tbm_surface_internal_get_num_bos(tSurface_) ; i++) {
- buffer_[gFeedCount].memory.fd[i] = tFd_[i];
+ inputBuffer->memory.fd[i] = tFd_[i];
}
- cout << "[FeedDataEncode] buffer[" << gFeedCount << "] " << &buffer_[gFeedCount] << endl;
+ cout << "[FeedDataEncode] buffer[" << gFeedCount << "] " << inputBuffer << endl;
} else {
- buffer_[gFeedCount].memory.num_fd = 0;
- buffer_[gFeedCount].meta.flags = HAL_CODEC_BUFFER_FLAG_EOS;
+ inputBuffer->memory.num_fd = 0;
+ inputBuffer->meta.flags = HAL_CODEC_BUFFER_FLAG_EOS;
cout << "[FeedDataEncode] Send EOS" << endl;
}
- ret = hal_codec_encode(gHalHandleEnc, &buffer_[gFeedCount]);
+ ret = hal_codec_encode(gHalHandleEnc, inputBuffer);
if (ret != HAL_CODEC_ERROR_NONE)
cout << "[FeedDataEncode] failed " << ret << endl;
- if (buffer_[gFeedCount].meta.flags & HAL_CODEC_BUFFER_FLAG_EOS) {
+ if (inputBuffer->meta.flags & HAL_CODEC_BUFFER_FLAG_EOS) {
cout << "[FeedDataEncode] Remove Feed thread" << endl;
return G_SOURCE_REMOVE;
}
return self->FeedDataEncode();
}, this);
- gTimeoutSourceID = g_timeout_add(3000, [](gpointer user_data) -> gboolean {
- cout << "[ENCODE] timeout(3000ms) encoded count: " << gOutputCount << endl;
+ gTimeoutSourceID = g_timeout_add(5000, [](gpointer user_data) -> gboolean {
+ cout << "[ENCODE] timeout(5000ms) encoded count: " << gOutputCount << endl;
g_main_loop_quit(gMainLoop);
return G_SOURCE_REMOVE;
}, nullptr);