From c5cd650fdddba6ecb19569a57cb186b7e238a182 Mon Sep 17 00:00:00 2001 From: Herman Chen Date: Thu, 16 Sep 2021 14:49:14 +0800 Subject: [PATCH] [mpi]: Add start / stop / pause / resume ctrl cmd 1. Move mpp_start / mpp_stop function to control command. 2. Add pause / resume control command. Change-Id: I525668a2831eb8f23e12fbd7c1cb29c11fdcc868 Signed-off-by: Herman Chen --- inc/rk_mpi.h | 27 --------------------------- inc/rk_mpi_cmd.h | 10 ++++++++++ mpp/inc/mpp.h | 3 +++ mpp/mpi.cpp | 28 ---------------------------- mpp/mpp.cpp | 24 ++++++++++++++++++++++++ 5 files changed, 37 insertions(+), 55 deletions(-) diff --git a/inc/rk_mpi.h b/inc/rk_mpi.h index 88863f22..2cce8973 100644 --- a/inc/rk_mpi.h +++ b/inc/rk_mpi.h @@ -240,33 +240,6 @@ MPP_RET mpp_create(MppCtx *ctx, MppApi **mpi); * error code. For details, please refer mpp_err.h. */ MPP_RET mpp_init(MppCtx ctx, MppCtxType type, MppCodingType coding); -/** - * @ingroup rk_mpi - * @brief Call after mpp_init to start mpp working. - * Control SET_CFG can be called both before and after mpp_start. - * Before mpp_start is called both global param and dynamic param can be set. - * After mpp_start is called only dynamic param can be set. - * This funciton purpose is to stop recieving global param and do - * preparation for processing data flow. - * This function will call internal context start function. - * @param[in] ctx The context of mpp, created by mpp_create(). - * @return 0 for success, others for failure. The return value is an - * error code. For details, please refer mpp_err.h. - */ -MPP_RET mpp_start(MppCtx ctx); -/** - * @ingroup rk_mpi - * @brief Call before mpp_destroy to stop mpp working. - * Control SET_CFG can be called after starting. - * Before mpp_stop is called only dynamic param can be set. - * After mpp_stop is called both global param and dynamic param can be set. - * This funciton purpose is to stop processing data and do preparation - * to receive global param. - * @param[in] ctx The context of mpp, created by mpp_create(). - * @return 0 for success, others for failure. The return value is an - * error code. For details, please refer mpp_err.h. - */ -MPP_RET mpp_stop(MppCtx ctx); /** * @ingroup rk_mpi * @brief Destroy mpp context and free both context and mpi structure, diff --git a/inc/rk_mpi_cmd.h b/inc/rk_mpi_cmd.h index ae63da4c..42741903 100644 --- a/inc/rk_mpi_cmd.h +++ b/inc/rk_mpi_cmd.h @@ -37,6 +37,9 @@ /* separate encoder / decoder control command to different segment */ #define CMD_CFG_ID_MASK (0x0000FF00) +/* mpp status control command */ +#define CMD_STATE_OPS (0x00000100) + /* decoder control command */ #define CMD_DEC_CFG_ALL (0x00000000) #define CMD_DEC_QUERY (0x00000100) @@ -70,6 +73,13 @@ typedef enum { */ MPP_SET_INPUT_TIMEOUT, /* parameter type RK_S64 */ MPP_SET_OUTPUT_TIMEOUT, /* parameter type RK_S64 */ + + MPP_STATE_CMD_BASE = CMD_MODULE_MPP | CMD_STATE_OPS, + MPP_START, + MPP_STOP, + MPP_PAUSE, + MPP_RESUME, + MPP_CMD_END, MPP_CODEC_CMD_BASE = CMD_MODULE_CODEC, diff --git a/mpp/inc/mpp.h b/mpp/inc/mpp.h index 8e9f4aaa..68562c38 100644 --- a/mpp/inc/mpp.h +++ b/mpp/inc/mpp.h @@ -103,6 +103,9 @@ public: MPP_RET start(); MPP_RET stop(); + MPP_RET pause(); + MPP_RET resume(); + MPP_RET put_packet(MppPacket packet); MPP_RET get_frame(MppFrame *frame); diff --git a/mpp/mpi.cpp b/mpp/mpi.cpp index 77cb7fb1..4e300da0 100644 --- a/mpp/mpi.cpp +++ b/mpp/mpi.cpp @@ -519,34 +519,6 @@ MPP_RET mpp_destroy(MppCtx ctx) return ret; } -MPP_RET mpp_start(MppCtx ctx) -{ - mpi_dbg_func("enter ctx %p\n", ctx); - - MpiImpl *p = (MpiImpl*)ctx; - MPP_RET ret = check_mpp_ctx(p); - - if (MPP_OK == ret) - ret = p->ctx->start(); - - mpi_dbg_func("leave ctx %p ret %d\n", ctx, ret); - return ret; -} - -MPP_RET mpp_stop(MppCtx ctx) -{ - mpi_dbg_func("enter ctx %p\n", ctx); - - MpiImpl *p = (MpiImpl*)ctx; - MPP_RET ret = check_mpp_ctx(p); - - if (MPP_OK == ret) - ret = p->ctx->stop(); - - mpi_dbg_func("leave ctx %p ret %d\n", ctx, ret); - return ret; -} - MPP_RET mpp_check_support_format(MppCtxType type, MppCodingType coding) { MPP_RET ret = MPP_NOK; diff --git a/mpp/mpp.cpp b/mpp/mpp.cpp index 7070f4ee..bd70b29f 100644 --- a/mpp/mpp.cpp +++ b/mpp/mpp.cpp @@ -298,6 +298,16 @@ MPP_RET Mpp::stop() return MPP_OK; } +MPP_RET Mpp::pause() +{ + return MPP_OK; +} + +MPP_RET Mpp::resume() +{ + return MPP_OK; +} + MPP_RET Mpp::put_packet(MppPacket packet) { if (!mInitDone) @@ -855,6 +865,20 @@ MPP_RET Mpp::control_mpp(MpiCmd cmd, MppParam param) mOutputTimeout = timeout; } break; + case MPP_START : { + start(); + } break; + case MPP_STOP : { + stop(); + } break; + + case MPP_PAUSE : { + pause(); + } break; + case MPP_RESUME : { + resume(); + } break; + default : { ret = MPP_NOK; } break;