Skip to content

Commit

Permalink
[mpi]: Add start / stop / pause / resume ctrl cmd
Browse files Browse the repository at this point in the history
1. Move mpp_start / mpp_stop function to control command.
2. Add pause / resume control command.

Change-Id: I525668a2831eb8f23e12fbd7c1cb29c11fdcc868
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
  • Loading branch information
HermanChen committed Sep 17, 2021
1 parent db487e5 commit c5cd650
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 55 deletions.
27 changes: 0 additions & 27 deletions inc/rk_mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions inc/rk_mpi_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions mpp/inc/mpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ class Mpp
MPP_RET start();
MPP_RET stop();

MPP_RET pause();
MPP_RET resume();

MPP_RET put_packet(MppPacket packet);
MPP_RET get_frame(MppFrame *frame);

Expand Down
28 changes: 0 additions & 28 deletions mpp/mpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 24 additions & 0 deletions mpp/mpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c5cd650

Please sign in to comment.