Fix #1295: Added thin wrapper for audio and video codec operations.
git-svn-id: https://svn.pjsip.org/repos/pjproject/branches/projects/2.0-dev@3663 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
4cd97b4da7
commit
96f8dca165
|
@ -27,6 +27,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pjmedia/port.h>
|
#include <pjmedia/port.h>
|
||||||
|
#include <pj/errno.h>
|
||||||
#include <pj/list.h>
|
#include <pj/list.h>
|
||||||
#include <pj/pool.h>
|
#include <pj/pool.h>
|
||||||
|
|
||||||
|
@ -323,6 +324,9 @@ typedef struct pjmedia_codec_op
|
||||||
/**
|
/**
|
||||||
* Initialize codec using the specified attribute.
|
* Initialize codec using the specified attribute.
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_codec_init() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
* @param pool Pool to use when the codec needs to allocate
|
* @param pool Pool to use when the codec needs to allocate
|
||||||
* some memory.
|
* some memory.
|
||||||
|
@ -338,6 +342,9 @@ typedef struct pjmedia_codec_op
|
||||||
* and fills in the unspecified values (such as enc_ptime, when
|
* and fills in the unspecified values (such as enc_ptime, when
|
||||||
* encoder ptime is different than decoder ptime).
|
* encoder ptime is different than decoder ptime).
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_codec_open() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
* @param param Codec initialization parameter.
|
* @param param Codec initialization parameter.
|
||||||
*
|
*
|
||||||
|
@ -350,6 +357,9 @@ typedef struct pjmedia_codec_op
|
||||||
* Close and shutdown codec, releasing all resources allocated by
|
* Close and shutdown codec, releasing all resources allocated by
|
||||||
* this codec, if any.
|
* this codec, if any.
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_codec_close() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
*
|
*
|
||||||
* @return PJ_SUCCESS on success.
|
* @return PJ_SUCCESS on success.
|
||||||
|
@ -365,6 +375,9 @@ typedef struct pjmedia_codec_op
|
||||||
* Application can expect changing trivial codec settings such as
|
* Application can expect changing trivial codec settings such as
|
||||||
* changing VAD setting to succeed.
|
* changing VAD setting to succeed.
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_codec_modify() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
* @param param The new codec parameter.
|
* @param param The new codec parameter.
|
||||||
*
|
*
|
||||||
|
@ -379,6 +392,9 @@ typedef struct pjmedia_codec_op
|
||||||
* have ptime that is equal to basic frame ptime (i.e. the value of
|
* have ptime that is equal to basic frame ptime (i.e. the value of
|
||||||
* info.frm_ptime in #pjmedia_codec_param).
|
* info.frm_ptime in #pjmedia_codec_param).
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_codec_parse() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance
|
* @param codec The codec instance
|
||||||
* @param pkt The input packet.
|
* @param pkt The input packet.
|
||||||
* @param pkt_size Size of the packet.
|
* @param pkt_size Size of the packet.
|
||||||
|
@ -403,6 +419,9 @@ typedef struct pjmedia_codec_op
|
||||||
* PCM samples MUST have ptime that is multiplication of base frame
|
* PCM samples MUST have ptime that is multiplication of base frame
|
||||||
* ptime (i.e. the value of info.frm_ptime in #pjmedia_codec_param).
|
* ptime (i.e. the value of info.frm_ptime in #pjmedia_codec_param).
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_codec_encode() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
* @param input The input frame.
|
* @param input The input frame.
|
||||||
* @param out_size The length of buffer in the output frame.
|
* @param out_size The length of buffer in the output frame.
|
||||||
|
@ -422,6 +441,9 @@ typedef struct pjmedia_codec_op
|
||||||
* Application can achieve this by parsing the packet into base
|
* Application can achieve this by parsing the packet into base
|
||||||
* frames before decoding each frame.
|
* frames before decoding each frame.
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_codec_decode() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
* @param input The input frame.
|
* @param input The input frame.
|
||||||
* @param out_size The length of buffer in the output frame.
|
* @param out_size The length of buffer in the output frame.
|
||||||
|
@ -437,6 +459,9 @@ typedef struct pjmedia_codec_op
|
||||||
/**
|
/**
|
||||||
* Instruct the codec to recover a missing frame.
|
* Instruct the codec to recover a missing frame.
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_codec_recover() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
* @param out_size The length of buffer in the output frame.
|
* @param out_size The length of buffer in the output frame.
|
||||||
* @param output The output frame where generated signal
|
* @param output The output frame where generated signal
|
||||||
|
@ -912,6 +937,169 @@ PJ_DECL(pj_status_t) pjmedia_codec_mgr_dealloc_codec(pjmedia_codec_mgr *mgr,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize codec using the specified attribute.
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
* @param pool Pool to use when the codec needs to allocate some memory.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success.
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_codec_init( pjmedia_codec *codec,
|
||||||
|
pj_pool_t *pool )
|
||||||
|
{
|
||||||
|
return (*codec->op->init)(codec, pool);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the codec and initialize with the specified parameter.
|
||||||
|
* Upon successful initialization, the codec may modify the parameter
|
||||||
|
* and fills in the unspecified values (such as enc_ptime, when
|
||||||
|
* encoder ptime is different than decoder ptime).
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
* @param param Codec initialization parameter.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success.
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_codec_open( pjmedia_codec *codec,
|
||||||
|
pjmedia_codec_param *param )
|
||||||
|
{
|
||||||
|
return (*codec->op->open)(codec, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close and shutdown codec, releasing all resources allocated by
|
||||||
|
* this codec, if any.
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success.
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_codec_close( pjmedia_codec *codec )
|
||||||
|
{
|
||||||
|
return (*codec->op->close)(codec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify the codec parameter after the codec is open.
|
||||||
|
* Note that not all codec parameters can be modified during run-time.
|
||||||
|
* When the parameter cannot be changed, this function will return
|
||||||
|
* non-PJ_SUCCESS, and the original parameters will not be changed.
|
||||||
|
*
|
||||||
|
* Application can expect changing trivial codec settings such as
|
||||||
|
* changing VAD setting to succeed.
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
* @param param The new codec parameter.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success.
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_codec_modify(pjmedia_codec *codec,
|
||||||
|
const pjmedia_codec_param *param)
|
||||||
|
{
|
||||||
|
return (*codec->op->modify)(codec, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instruct the codec to inspect the specified payload/packet and
|
||||||
|
* split the packet into individual base frames. Each output frames will
|
||||||
|
* have ptime that is equal to basic frame ptime (i.e. the value of
|
||||||
|
* info.frm_ptime in #pjmedia_codec_param).
|
||||||
|
*
|
||||||
|
* @param codec The codec instance
|
||||||
|
* @param pkt The input packet.
|
||||||
|
* @param pkt_size Size of the packet.
|
||||||
|
* @param timestamp The timestamp of the first sample in the packet.
|
||||||
|
* @param frame_cnt On input, specifies the maximum number of frames
|
||||||
|
* in the array. On output, the codec must fill
|
||||||
|
* with number of frames detected in the packet.
|
||||||
|
* @param frames On output, specifies the frames that have been
|
||||||
|
* detected in the packet.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success.
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_codec_parse( pjmedia_codec *codec,
|
||||||
|
void *pkt,
|
||||||
|
pj_size_t pkt_size,
|
||||||
|
const pj_timestamp *timestamp,
|
||||||
|
unsigned *frame_cnt,
|
||||||
|
pjmedia_frame frames[] )
|
||||||
|
{
|
||||||
|
return (*codec->op->parse)(codec, pkt, pkt_size, timestamp,
|
||||||
|
frame_cnt, frames);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instruct the codec to encode the specified input frame. The input
|
||||||
|
* PCM samples MUST have ptime that is multiplication of base frame
|
||||||
|
* ptime (i.e. the value of info.frm_ptime in #pjmedia_codec_param).
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
* @param input The input frame.
|
||||||
|
* @param out_size The length of buffer in the output frame.
|
||||||
|
* @param output The output frame.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success;
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_codec_encode(
|
||||||
|
pjmedia_codec *codec,
|
||||||
|
const struct pjmedia_frame *input,
|
||||||
|
unsigned out_size,
|
||||||
|
struct pjmedia_frame *output )
|
||||||
|
{
|
||||||
|
return (*codec->op->encode)(codec, input, out_size, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instruct the codec to decode the specified input frame. The input
|
||||||
|
* frame MUST have ptime that is exactly equal to base frame
|
||||||
|
* ptime (i.e. the value of info.frm_ptime in #pjmedia_codec_param).
|
||||||
|
* Application can achieve this by parsing the packet into base
|
||||||
|
* frames before decoding each frame.
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
* @param input The input frame.
|
||||||
|
* @param out_size The length of buffer in the output frame.
|
||||||
|
* @param output The output frame.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success;
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_codec_decode(
|
||||||
|
pjmedia_codec *codec,
|
||||||
|
const struct pjmedia_frame *input,
|
||||||
|
unsigned out_size,
|
||||||
|
struct pjmedia_frame *output )
|
||||||
|
{
|
||||||
|
return (*codec->op->decode)(codec, input, out_size, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instruct the codec to recover a missing frame.
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
* @param out_size The length of buffer in the output frame.
|
||||||
|
* @param output The output frame where generated signal
|
||||||
|
* will be placed.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success;
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_codec_recover( pjmedia_codec *codec,
|
||||||
|
unsigned out_size,
|
||||||
|
struct pjmedia_frame *output )
|
||||||
|
{
|
||||||
|
if (codec->op && codec->op->recover)
|
||||||
|
return (*codec->op->recover)(codec, out_size, output);
|
||||||
|
else
|
||||||
|
return PJ_ENOTSUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -113,6 +113,9 @@ typedef struct pjmedia_vid_codec_op
|
||||||
/**
|
/**
|
||||||
* Initialize codec using the specified attribute.
|
* Initialize codec using the specified attribute.
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_vid_codec_init() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
* @param pool Pool to use when the codec needs to allocate
|
* @param pool Pool to use when the codec needs to allocate
|
||||||
* some memory.
|
* some memory.
|
||||||
|
@ -129,6 +132,9 @@ typedef struct pjmedia_vid_codec_op
|
||||||
* the encoder format, as it may need to be negotiated with remote
|
* the encoder format, as it may need to be negotiated with remote
|
||||||
* preferences via SDP fmtp).
|
* preferences via SDP fmtp).
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_vid_codec_open() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
* @param param Codec initialization parameter.
|
* @param param Codec initialization parameter.
|
||||||
*
|
*
|
||||||
|
@ -141,6 +147,9 @@ typedef struct pjmedia_vid_codec_op
|
||||||
* Close and shutdown codec, releasing all resources allocated by
|
* Close and shutdown codec, releasing all resources allocated by
|
||||||
* this codec, if any.
|
* this codec, if any.
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_vid_codec_close() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
*
|
*
|
||||||
* @return PJ_SUCCESS on success.
|
* @return PJ_SUCCESS on success.
|
||||||
|
@ -153,6 +162,9 @@ typedef struct pjmedia_vid_codec_op
|
||||||
* When the parameter cannot be changed, this function will return
|
* When the parameter cannot be changed, this function will return
|
||||||
* non-PJ_SUCCESS, and the original parameters will not be changed.
|
* non-PJ_SUCCESS, and the original parameters will not be changed.
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_vid_codec_modify() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
* @param param The new codec parameter.
|
* @param param The new codec parameter.
|
||||||
*
|
*
|
||||||
|
@ -164,6 +176,9 @@ typedef struct pjmedia_vid_codec_op
|
||||||
/**
|
/**
|
||||||
* Get the codec parameter after the codec is opened.
|
* Get the codec parameter after the codec is opened.
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_vid_codec_get_param() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
* @param param The codec parameter.
|
* @param param The codec parameter.
|
||||||
*
|
*
|
||||||
|
@ -181,6 +196,9 @@ typedef struct pjmedia_vid_codec_op
|
||||||
* performance reason, the packetization will be done in-place, so the
|
* performance reason, the packetization will be done in-place, so the
|
||||||
* original bitstream may be modified by this function.
|
* original bitstream may be modified by this function.
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_vid_codec_packetize() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance
|
* @param codec The codec instance
|
||||||
* @param bits The picture bitstream.
|
* @param bits The picture bitstream.
|
||||||
* @param bits_len The length of the bitstream.
|
* @param bits_len The length of the bitstream.
|
||||||
|
@ -211,6 +229,9 @@ typedef struct pjmedia_vid_codec_op
|
||||||
* application should keep calling this function with payload pointer
|
* application should keep calling this function with payload pointer
|
||||||
* set to NULL, as the packetizer need to update its internal state.
|
* set to NULL, as the packetizer need to update its internal state.
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_vid_codec_unpacketize() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance
|
* @param codec The codec instance
|
||||||
* @param pkt The input packet.
|
* @param pkt The input packet.
|
||||||
* @param pkt_size Size of the packet.
|
* @param pkt_size Size of the packet.
|
||||||
|
@ -235,6 +256,9 @@ typedef struct pjmedia_vid_codec_op
|
||||||
* MUST contain only one picture with appropriate format as specified
|
* MUST contain only one picture with appropriate format as specified
|
||||||
* in opening the codec.
|
* in opening the codec.
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_vid_codec_encode() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
* @param input The input frame.
|
* @param input The input frame.
|
||||||
* @param out_size The length of buffer in the output frame.
|
* @param out_size The length of buffer in the output frame.
|
||||||
|
@ -256,6 +280,9 @@ typedef struct pjmedia_vid_codec_op
|
||||||
* parameter will also be updated, and application can query the format by
|
* parameter will also be updated, and application can query the format by
|
||||||
* using #get_param().
|
* using #get_param().
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_vid_codec_decode() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
* @param input The input frame.
|
* @param input The input frame.
|
||||||
* @param out_size The length of buffer in the output frame.
|
* @param out_size The length of buffer in the output frame.
|
||||||
|
@ -271,6 +298,9 @@ typedef struct pjmedia_vid_codec_op
|
||||||
/**
|
/**
|
||||||
* Instruct the codec to recover a missing frame.
|
* Instruct the codec to recover a missing frame.
|
||||||
*
|
*
|
||||||
|
* Application should call #pjmedia_vid_codec_recover() instead of
|
||||||
|
* calling this function directly.
|
||||||
|
*
|
||||||
* @param codec The codec instance.
|
* @param codec The codec instance.
|
||||||
* @param out_size The length of buffer in the output frame.
|
* @param out_size The length of buffer in the output frame.
|
||||||
* @param output The output frame where generated signal
|
* @param output The output frame where generated signal
|
||||||
|
@ -432,8 +462,8 @@ typedef struct pjmedia_vid_codec_mgr pjmedia_vid_codec_mgr;
|
||||||
* @param codec The codec to be initialized.
|
* @param codec The codec to be initialized.
|
||||||
* @param sig Codec's object signature (see signatures.h)
|
* @param sig Codec's object signature (see signatures.h)
|
||||||
*/
|
*/
|
||||||
PJ_DECL(void) pjmedia_vid_codec_init(pjmedia_vid_codec *codec,
|
PJ_DECL(void) pjmedia_vid_codec_reset(pjmedia_vid_codec *codec,
|
||||||
pjmedia_obj_sig sig);
|
pjmedia_obj_sig sig);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize codec manager. If there is no the default video codec manager,
|
* Initialize codec manager. If there is no the default video codec manager,
|
||||||
|
@ -699,6 +729,229 @@ PJ_DECL(pj_status_t) pjmedia_vid_codec_mgr_dealloc_codec(
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize codec using the specified attribute.
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
* @param pool Pool to use when the codec needs to allocate
|
||||||
|
* some memory.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success.
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_vid_codec_init( pjmedia_vid_codec *codec,
|
||||||
|
pj_pool_t *pool )
|
||||||
|
{
|
||||||
|
return (*codec->op->init)(codec, pool);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the codec and initialize with the specified parameter.
|
||||||
|
* Upon successful initialization, the codec may modify the parameter
|
||||||
|
* and fills in the unspecified values (such as size or frame rate of
|
||||||
|
* the encoder format, as it may need to be negotiated with remote
|
||||||
|
* preferences via SDP fmtp).
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
* @param param Codec initialization parameter.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success.
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_vid_codec_open(
|
||||||
|
pjmedia_vid_codec *codec,
|
||||||
|
pjmedia_vid_codec_param *param )
|
||||||
|
{
|
||||||
|
return (*codec->op->open)(codec, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close and shutdown codec, releasing all resources allocated by
|
||||||
|
* this codec, if any.
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success.
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_vid_codec_close( pjmedia_vid_codec *codec )
|
||||||
|
{
|
||||||
|
return (*codec->op->close)(codec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify the codec parameter after the codec is open.
|
||||||
|
* Note that not all codec parameters can be modified during run-time.
|
||||||
|
* When the parameter cannot be changed, this function will return
|
||||||
|
* non-PJ_SUCCESS, and the original parameters will not be changed.
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
* @param param The new codec parameter.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success.
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_vid_codec_modify(
|
||||||
|
pjmedia_vid_codec *codec,
|
||||||
|
const pjmedia_vid_codec_param *param)
|
||||||
|
{
|
||||||
|
return (*codec->op->modify)(codec, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the codec parameter after the codec is opened.
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
* @param param The codec parameter.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success.
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_vid_codec_get_param(
|
||||||
|
pjmedia_vid_codec *codec,
|
||||||
|
pjmedia_vid_codec_param *param)
|
||||||
|
{
|
||||||
|
return (*codec->op->get_param)(codec, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instruct the codec to generate a payload/packet from a picture
|
||||||
|
* bitstream to be sent (via network). The maximum payload size or
|
||||||
|
* MTU is configurable via enc_mtu field of #pjmedia_vid_codec_param.
|
||||||
|
* For a long bitstream, application usually need to call this function
|
||||||
|
* multiple times until the whole bitstream is sent. Note that, for
|
||||||
|
* performance reason, the packetization will be done in-place, so the
|
||||||
|
* original bitstream may be modified by this function.
|
||||||
|
*
|
||||||
|
* @param codec The codec instance
|
||||||
|
* @param bits The picture bitstream.
|
||||||
|
* @param bits_len The length of the bitstream.
|
||||||
|
* @param bits_pos On input, the start position of the bitstream
|
||||||
|
* to be packetized. On output, the next position for
|
||||||
|
* next packet.
|
||||||
|
* @param pkt The pointer of the generated payload.
|
||||||
|
* @param pkt_len The payload length.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success.
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_vid_codec_packetize(
|
||||||
|
pjmedia_vid_codec *codec,
|
||||||
|
pj_uint8_t *bits,
|
||||||
|
pj_size_t bits_len,
|
||||||
|
unsigned *bits_pos,
|
||||||
|
const pj_uint8_t **pkt,
|
||||||
|
pj_size_t *pkt_len )
|
||||||
|
{
|
||||||
|
return (*codec->op->packetize)(codec, bits, bits_len, bits_pos,
|
||||||
|
pkt, pkt_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instruct the codec to parse a payload and append it into a picture
|
||||||
|
* bitstream. A picture bitstreams may need to be reconstructed from
|
||||||
|
* one or more payloads. Note that this function will not provide the
|
||||||
|
* detection of picture boundary, so application should manage the
|
||||||
|
* picture boundary detection by itself, e.g: for RTP delivery, payloads
|
||||||
|
* belong to the same picture will share the same RTP timestamp and also
|
||||||
|
* there is marker bit in the RTP header that is usually reserved for
|
||||||
|
* end-of-picture flag. Also note that in case of noticing packet lost,
|
||||||
|
* application should keep calling this function with payload pointer
|
||||||
|
* set to NULL, as the packetizer need to update its internal state.
|
||||||
|
*
|
||||||
|
* @param codec The codec instance
|
||||||
|
* @param pkt The input packet.
|
||||||
|
* @param pkt_size Size of the packet.
|
||||||
|
* @param timestamp The timestamp of the first sample in the packet.
|
||||||
|
* @param frame_cnt On input, specifies the maximum number of frames
|
||||||
|
* in the array. On output, the codec must fill
|
||||||
|
* with number of frames detected in the packet.
|
||||||
|
* @param frames On output, specifies the frames that have been
|
||||||
|
* detected in the packet.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success.
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_vid_codec_unpacketize(
|
||||||
|
pjmedia_vid_codec *codec,
|
||||||
|
const pj_uint8_t *payload,
|
||||||
|
pj_size_t payload_len,
|
||||||
|
pj_uint8_t *bits,
|
||||||
|
pj_size_t bits_len,
|
||||||
|
unsigned *bits_pos )
|
||||||
|
{
|
||||||
|
return (*codec->op->unpacketize)(codec, payload, payload_len, bits,
|
||||||
|
bits_len, bits_pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instruct the codec to encode the specified input frame. The input
|
||||||
|
* MUST contain only one picture with appropriate format as specified
|
||||||
|
* in opening the codec.
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
* @param input The input frame.
|
||||||
|
* @param out_size The length of buffer in the output frame.
|
||||||
|
* @param output The output frame.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success;
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_vid_codec_encode(
|
||||||
|
pjmedia_vid_codec *codec,
|
||||||
|
const pjmedia_frame *input,
|
||||||
|
unsigned out_size,
|
||||||
|
pjmedia_frame *output)
|
||||||
|
{
|
||||||
|
return (*codec->op->encode)(codec, input, out_size, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instruct the codec to decode the specified input frame. The input
|
||||||
|
* frame MUST contain exactly one picture. Note that the decoded picture
|
||||||
|
* format may different to the current setting, e.g: the format specified
|
||||||
|
* in the #pjmedia_vid_codec_param when opening the codec, in this case the
|
||||||
|
* PJMEDIA_EVENT_FMT_CHANGED event will be emitted by the codec. The codec
|
||||||
|
* parameter will also be updated, and application can query the format by
|
||||||
|
* using #get_param().
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
* @param input The input frame.
|
||||||
|
* @param out_size The length of buffer in the output frame.
|
||||||
|
* @param output The output frame.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success;
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_vid_codec_decode(
|
||||||
|
pjmedia_vid_codec *codec,
|
||||||
|
const pjmedia_frame *input,
|
||||||
|
unsigned out_size,
|
||||||
|
pjmedia_frame *output)
|
||||||
|
{
|
||||||
|
return (*codec->op->decode)(codec, input, out_size, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instruct the codec to recover a missing frame.
|
||||||
|
*
|
||||||
|
* @param codec The codec instance.
|
||||||
|
* @param out_size The length of buffer in the output frame.
|
||||||
|
* @param output The output frame where generated signal
|
||||||
|
* will be placed.
|
||||||
|
*
|
||||||
|
* @return PJ_SUCCESS on success;
|
||||||
|
*/
|
||||||
|
PJ_INLINE(pj_status_t) pjmedia_vid_codec_recover(
|
||||||
|
pjmedia_vid_codec *codec,
|
||||||
|
unsigned out_size,
|
||||||
|
pjmedia_frame *output)
|
||||||
|
{
|
||||||
|
if (codec->op && codec->op->recover)
|
||||||
|
return (*codec->op->recover)(codec, out_size, output);
|
||||||
|
else
|
||||||
|
return PJ_ENOTSUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -886,7 +886,7 @@ static pj_status_t ffmpeg_alloc_codec( pjmedia_vid_codec_factory *factory,
|
||||||
status = PJ_ENOMEM;
|
status = PJ_ENOMEM;
|
||||||
goto on_error;
|
goto on_error;
|
||||||
}
|
}
|
||||||
pjmedia_vid_codec_init(codec, PJMEDIA_SIG_VID_CODEC_FFMPEG);
|
pjmedia_vid_codec_reset(codec, PJMEDIA_SIG_VID_CODEC_FFMPEG);
|
||||||
codec->op = &ffmpeg_op;
|
codec->op = &ffmpeg_op;
|
||||||
codec->factory = factory;
|
codec->factory = factory;
|
||||||
ff = PJ_POOL_ZALLOC_T(pool, ffmpeg_private);
|
ff = PJ_POOL_ZALLOC_T(pool, ffmpeg_private);
|
||||||
|
|
|
@ -515,9 +515,9 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
|
||||||
|
|
||||||
frame_out.buf = p_out_samp + samples_count;
|
frame_out.buf = p_out_samp + samples_count;
|
||||||
frame_out.size = frame->size - samples_count*2;
|
frame_out.size = frame->size - samples_count*2;
|
||||||
status = (*stream->codec->op->recover)(stream->codec,
|
status = pjmedia_codec_recover(stream->codec,
|
||||||
frame_out.size,
|
frame_out.size,
|
||||||
&frame_out);
|
&frame_out);
|
||||||
|
|
||||||
++stream->plc_cnt;
|
++stream->plc_cnt;
|
||||||
|
|
||||||
|
@ -564,9 +564,9 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
|
||||||
do {
|
do {
|
||||||
frame_out.buf = p_out_samp + samples_count;
|
frame_out.buf = p_out_samp + samples_count;
|
||||||
frame_out.size = frame->size - samples_count*2;
|
frame_out.size = frame->size - samples_count*2;
|
||||||
status = (*stream->codec->op->recover)(stream->codec,
|
status = pjmedia_codec_recover(stream->codec,
|
||||||
frame_out.size,
|
frame_out.size,
|
||||||
&frame_out);
|
&frame_out);
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -619,9 +619,9 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
|
||||||
do {
|
do {
|
||||||
frame_out.buf = p_out_samp + samples_count;
|
frame_out.buf = p_out_samp + samples_count;
|
||||||
frame_out.size = frame->size - samples_count*2;
|
frame_out.size = frame->size - samples_count*2;
|
||||||
status = (*stream->codec->op->recover)(stream->codec,
|
status = pjmedia_codec_recover(stream->codec,
|
||||||
frame_out.size,
|
frame_out.size,
|
||||||
&frame_out);
|
&frame_out);
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
break;
|
break;
|
||||||
samples_count += samples_per_frame;
|
samples_count += samples_per_frame;
|
||||||
|
@ -670,8 +670,8 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
|
||||||
|
|
||||||
frame_out.buf = p_out_samp + samples_count;
|
frame_out.buf = p_out_samp + samples_count;
|
||||||
frame_out.size = frame->size - samples_count*BYTES_PER_SAMPLE;
|
frame_out.size = frame->size - samples_count*BYTES_PER_SAMPLE;
|
||||||
status = stream->codec->op->decode( stream->codec, &frame_in,
|
status = pjmedia_codec_decode( stream->codec, &frame_in,
|
||||||
frame_out.size, &frame_out);
|
frame_out.size, &frame_out);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
LOGERR_((port->info.name.ptr, "codec decode() error",
|
LOGERR_((port->info.name.ptr, "codec decode() error",
|
||||||
status));
|
status));
|
||||||
|
@ -774,8 +774,8 @@ static pj_status_t get_frame_ext( pjmedia_port *port, pjmedia_frame *frame)
|
||||||
frame_in.bit_info = bit_info;
|
frame_in.bit_info = bit_info;
|
||||||
frame_in.type = PJMEDIA_FRAME_TYPE_AUDIO;
|
frame_in.type = PJMEDIA_FRAME_TYPE_AUDIO;
|
||||||
|
|
||||||
status = stream->codec->op->decode( stream->codec, &frame_in,
|
status = pjmedia_codec_decode( stream->codec, &frame_in,
|
||||||
0, frame);
|
0, frame);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
LOGERR_((port->info.name.ptr, "codec decode() error",
|
LOGERR_((port->info.name.ptr, "codec decode() error",
|
||||||
status));
|
status));
|
||||||
|
@ -801,8 +801,7 @@ static pj_status_t get_frame_ext( pjmedia_port *port, pjmedia_frame *frame)
|
||||||
/* Try to generate frame by invoking PLC (when any) */
|
/* Try to generate frame by invoking PLC (when any) */
|
||||||
status = PJ_SUCCESS;
|
status = PJ_SUCCESS;
|
||||||
if (stream->codec->op->recover) {
|
if (stream->codec->op->recover) {
|
||||||
status = (*stream->codec->op->recover)(stream->codec,
|
status = pjmedia_codec_recover(stream->codec, 0, frame);
|
||||||
0, frame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No PLC or PLC failed */
|
/* No PLC or PLC failed */
|
||||||
|
@ -1248,10 +1247,10 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
|
||||||
silence_frame.timestamp.u32.lo = pj_ntohl(stream->enc->rtp.out_hdr.ts);
|
silence_frame.timestamp.u32.lo = pj_ntohl(stream->enc->rtp.out_hdr.ts);
|
||||||
|
|
||||||
/* Encode! */
|
/* Encode! */
|
||||||
status = stream->codec->op->encode( stream->codec, &silence_frame,
|
status = pjmedia_codec_encode( stream->codec, &silence_frame,
|
||||||
channel->out_pkt_size -
|
channel->out_pkt_size -
|
||||||
sizeof(pjmedia_rtp_hdr),
|
sizeof(pjmedia_rtp_hdr),
|
||||||
&frame_out);
|
&frame_out);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
LOGERR_((stream->port.info.name.ptr,
|
LOGERR_((stream->port.info.name.ptr,
|
||||||
"Codec encode() error", status));
|
"Codec encode() error", status));
|
||||||
|
@ -1272,10 +1271,10 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
|
||||||
(frame->type == PJMEDIA_FRAME_TYPE_EXTENDED))
|
(frame->type == PJMEDIA_FRAME_TYPE_EXTENDED))
|
||||||
{
|
{
|
||||||
/* Encode! */
|
/* Encode! */
|
||||||
status = stream->codec->op->encode( stream->codec, frame,
|
status = pjmedia_codec_encode( stream->codec, frame,
|
||||||
channel->out_pkt_size -
|
channel->out_pkt_size -
|
||||||
sizeof(pjmedia_rtp_hdr),
|
sizeof(pjmedia_rtp_hdr),
|
||||||
&frame_out);
|
&frame_out);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
LOGERR_((stream->port.info.name.ptr,
|
LOGERR_((stream->port.info.name.ptr,
|
||||||
"Codec encode() error", status));
|
"Codec encode() error", status));
|
||||||
|
@ -1425,7 +1424,7 @@ static pj_status_t put_frame( pjmedia_port *port,
|
||||||
PJMEDIA_STREAM_VAD_SUSPEND_MSEC / 1000)
|
PJMEDIA_STREAM_VAD_SUSPEND_MSEC / 1000)
|
||||||
{
|
{
|
||||||
stream->codec_param.setting.vad = stream->vad_enabled;
|
stream->codec_param.setting.vad = stream->vad_enabled;
|
||||||
stream->codec->op->modify(stream->codec, &stream->codec_param);
|
pjmedia_codec_modify(stream->codec, &stream->codec_param);
|
||||||
PJ_LOG(4,(stream->port.info.name.ptr,"VAD re-enabled"));
|
PJ_LOG(4,(stream->port.info.name.ptr,"VAD re-enabled"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1691,12 +1690,8 @@ static void on_rx_rtp( void *data,
|
||||||
ts.u64 = pj_ntohl(hdr->ts);
|
ts.u64 = pj_ntohl(hdr->ts);
|
||||||
|
|
||||||
/* Parse the payload. */
|
/* Parse the payload. */
|
||||||
status = (*stream->codec->op->parse)(stream->codec,
|
status = pjmedia_codec_parse(stream->codec, (void*)payload,
|
||||||
(void*)payload,
|
payloadlen, &ts, &count, frames);
|
||||||
payloadlen,
|
|
||||||
&ts,
|
|
||||||
&count,
|
|
||||||
frames);
|
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
LOGERR_((stream->port.info.name.ptr,
|
LOGERR_((stream->port.info.name.ptr,
|
||||||
"Codec parse() error",
|
"Codec parse() error",
|
||||||
|
@ -2058,7 +2053,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
|
||||||
stream->codec_param.setting.frm_per_pkt = 1;
|
stream->codec_param.setting.frm_per_pkt = 1;
|
||||||
|
|
||||||
/* Open the codec. */
|
/* Open the codec. */
|
||||||
status = stream->codec->op->open(stream->codec, &stream->codec_param);
|
status = pjmedia_codec_open(stream->codec, &stream->codec_param);
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
goto err_cleanup;
|
goto err_cleanup;
|
||||||
|
|
||||||
|
@ -2137,7 +2132,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
|
||||||
if (PJMEDIA_STREAM_VAD_SUSPEND_MSEC > 0 && stream->vad_enabled) {
|
if (PJMEDIA_STREAM_VAD_SUSPEND_MSEC > 0 && stream->vad_enabled) {
|
||||||
stream->codec_param.setting.vad = 0;
|
stream->codec_param.setting.vad = 0;
|
||||||
stream->ts_vad_disabled = 0;
|
stream->ts_vad_disabled = 0;
|
||||||
stream->codec->op->modify(stream->codec, &stream->codec_param);
|
pjmedia_codec_modify(stream->codec, &stream->codec_param);
|
||||||
PJ_LOG(4,(stream->port.info.name.ptr,"VAD temporarily disabled"));
|
PJ_LOG(4,(stream->port.info.name.ptr,"VAD temporarily disabled"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2440,7 +2435,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_destroy( pjmedia_stream *stream )
|
||||||
/* Free codec. */
|
/* Free codec. */
|
||||||
|
|
||||||
if (stream->codec) {
|
if (stream->codec) {
|
||||||
stream->codec->op->close(stream->codec);
|
pjmedia_codec_close(stream->codec);
|
||||||
pjmedia_codec_mgr_dealloc_codec(stream->codec_mgr, stream->codec);
|
pjmedia_codec_mgr_dealloc_codec(stream->codec_mgr, stream->codec);
|
||||||
stream->codec = NULL;
|
stream->codec = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ static void sort_codecs(pjmedia_vid_codec_mgr *mgr);
|
||||||
/*
|
/*
|
||||||
* Initialize pjmedia_vid_codec structure with default values.
|
* Initialize pjmedia_vid_codec structure with default values.
|
||||||
*/
|
*/
|
||||||
PJ_DEF(void) pjmedia_vid_codec_init(pjmedia_vid_codec *codec,
|
PJ_DEF(void) pjmedia_vid_codec_reset(pjmedia_vid_codec *codec,
|
||||||
pjmedia_obj_sig sig)
|
pjmedia_obj_sig sig)
|
||||||
{
|
{
|
||||||
pj_bzero(codec, sizeof(*codec));
|
pj_bzero(codec, sizeof(*codec));
|
||||||
|
|
|
@ -335,7 +335,7 @@ static pj_status_t stream_event_cb(pjmedia_event_subscription *esub,
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case PJMEDIA_EVENT_FMT_CHANGED:
|
case PJMEDIA_EVENT_FMT_CHANGED:
|
||||||
/* Update param from codec */
|
/* Update param from codec */
|
||||||
stream->codec->op->get_param(stream->codec, stream->info.codec_param);
|
pjmedia_vid_codec_get_param(stream->codec, stream->info.codec_param);
|
||||||
|
|
||||||
/* Update decoding channel port info */
|
/* Update decoding channel port info */
|
||||||
pjmedia_format_copy(&stream->dec->port.info.fmt,
|
pjmedia_format_copy(&stream->dec->port.info.fmt,
|
||||||
|
@ -763,10 +763,10 @@ static pj_status_t put_frame(pjmedia_port *port,
|
||||||
frame_out.size = 0;
|
frame_out.size = 0;
|
||||||
|
|
||||||
/* Encode! */
|
/* Encode! */
|
||||||
status = (*stream->codec->op->encode)(stream->codec, frame,
|
status = pjmedia_vid_codec_encode(stream->codec, frame,
|
||||||
channel->buf_size -
|
channel->buf_size -
|
||||||
sizeof(pjmedia_rtp_hdr),
|
sizeof(pjmedia_rtp_hdr),
|
||||||
&frame_out);
|
&frame_out);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
LOGERR_((channel->port.info.name.ptr,
|
LOGERR_((channel->port.info.name.ptr,
|
||||||
"Codec encode() error", status));
|
"Codec encode() error", status));
|
||||||
|
@ -784,13 +784,12 @@ static pj_status_t put_frame(pjmedia_port *port,
|
||||||
pj_size_t payload_len;
|
pj_size_t payload_len;
|
||||||
|
|
||||||
/* Generate RTP payload */
|
/* Generate RTP payload */
|
||||||
status = (*stream->codec->op->packetize)(
|
status = pjmedia_vid_codec_packetize(stream->codec,
|
||||||
stream->codec,
|
(pj_uint8_t*)frame_out.buf,
|
||||||
(pj_uint8_t*)frame_out.buf,
|
frame_out.size,
|
||||||
frame_out.size,
|
&processed,
|
||||||
&processed,
|
(const pj_uint8_t**)&payload,
|
||||||
(const pj_uint8_t**)&payload,
|
&payload_len);
|
||||||
&payload_len);
|
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
LOGERR_((channel->port.info.name.ptr,
|
LOGERR_((channel->port.info.name.ptr,
|
||||||
"Codec pack() error", status));
|
"Codec pack() error", status));
|
||||||
|
@ -932,7 +931,7 @@ static pj_status_t get_frame(pjmedia_port *port,
|
||||||
psize = 0;
|
psize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = (*stream->codec->op->unpacketize)(
|
status = pjmedia_vid_codec_unpacketize(
|
||||||
stream->codec,
|
stream->codec,
|
||||||
p, psize,
|
p, psize,
|
||||||
(pj_uint8_t*)channel->buf,
|
(pj_uint8_t*)channel->buf,
|
||||||
|
@ -965,8 +964,8 @@ static pj_status_t get_frame(pjmedia_port *port,
|
||||||
frame_in.type = PJMEDIA_FRAME_TYPE_VIDEO;
|
frame_in.type = PJMEDIA_FRAME_TYPE_VIDEO;
|
||||||
frame_in.timestamp.u64 = last_ts;
|
frame_in.timestamp.u64 = last_ts;
|
||||||
|
|
||||||
status = stream->codec->op->decode(stream->codec, &frame_in,
|
status = pjmedia_vid_codec_decode(stream->codec, &frame_in,
|
||||||
frame->size, frame);
|
frame->size, frame);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
LOGERR_((port->info.name.ptr, "codec decode() error",
|
LOGERR_((port->info.name.ptr, "codec decode() error",
|
||||||
status));
|
status));
|
||||||
|
@ -1239,10 +1238,10 @@ PJ_DEF(pj_status_t) pjmedia_vid_stream_create(
|
||||||
PJMEDIA_STREAM_RESV_PAYLOAD_LEN;
|
PJMEDIA_STREAM_RESV_PAYLOAD_LEN;
|
||||||
|
|
||||||
/* Init and open the codec. */
|
/* Init and open the codec. */
|
||||||
status = stream->codec->op->init(stream->codec, pool);
|
status = pjmedia_vid_codec_init(stream->codec, pool);
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
status = stream->codec->op->open(stream->codec, info->codec_param);
|
status = pjmedia_vid_codec_open(stream->codec, info->codec_param);
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
@ -1445,7 +1444,7 @@ PJ_DEF(pj_status_t) pjmedia_vid_stream_destroy( pjmedia_vid_stream *stream )
|
||||||
|
|
||||||
/* Free codec. */
|
/* Free codec. */
|
||||||
if (stream->codec) {
|
if (stream->codec) {
|
||||||
stream->codec->op->close(stream->codec);
|
pjmedia_vid_codec_close(stream->codec);
|
||||||
pjmedia_vid_codec_mgr_dealloc_codec(stream->codec_mgr, stream->codec);
|
pjmedia_vid_codec_mgr_dealloc_codec(stream->codec_mgr, stream->codec);
|
||||||
stream->codec = NULL;
|
stream->codec = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,13 +73,13 @@ static int codec_test_encode(pjmedia_codec_mgr *mgr,
|
||||||
codec_param.info.avg_bps = bitrate;
|
codec_param.info.avg_bps = bitrate;
|
||||||
codec_param.setting.vad = 0;
|
codec_param.setting.vad = 0;
|
||||||
|
|
||||||
status = codec->op->init(codec, pool);
|
status = pjmedia_codec_init(codec, pool);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
rc = -60;
|
rc = -60;
|
||||||
goto on_return;
|
goto on_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = codec->op->open(codec, &codec_param);
|
status = pjmedia_codec_open(codec, &codec_param);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
rc = -70;
|
rc = -70;
|
||||||
goto on_return;
|
goto on_return;
|
||||||
|
@ -117,7 +117,7 @@ static int codec_test_encode(pjmedia_codec_mgr *mgr,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
out_frame.size = samples_per_frame;
|
out_frame.size = samples_per_frame;
|
||||||
status = codec->op->encode(codec, &in_frame, samples_per_frame,
|
status = pjmedia_codec_encode(codec, &in_frame, samples_per_frame,
|
||||||
&out_frame);
|
&out_frame);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
rc = -95;
|
rc = -95;
|
||||||
|
@ -188,7 +188,7 @@ on_return:
|
||||||
fclose(fref);
|
fclose(fref);
|
||||||
|
|
||||||
if (codec) {
|
if (codec) {
|
||||||
codec->op->close(codec);
|
pjmedia_codec_close(codec);
|
||||||
pjmedia_codec_mgr_dealloc_codec(mgr, codec);
|
pjmedia_codec_mgr_dealloc_codec(mgr, codec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,13 +326,13 @@ static int codec_test_decode(pjmedia_codec_mgr *mgr,
|
||||||
codec_param.info.avg_bps = bitrate;
|
codec_param.info.avg_bps = bitrate;
|
||||||
codec_param.setting.vad = 0;
|
codec_param.setting.vad = 0;
|
||||||
|
|
||||||
status = codec->op->init(codec, pool);
|
status = pjmedia_codec_init(codec, pool);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
rc = -60;
|
rc = -60;
|
||||||
goto on_return;
|
goto on_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = codec->op->open(codec, &codec_param);
|
status = pjmedia_codec_open(codec, &codec_param);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
rc = -70;
|
rc = -70;
|
||||||
goto on_return;
|
goto on_return;
|
||||||
|
@ -387,8 +387,8 @@ static int codec_test_decode(pjmedia_codec_mgr *mgr,
|
||||||
|
|
||||||
if (has_frame) {
|
if (has_frame) {
|
||||||
count = 2;
|
count = 2;
|
||||||
if (codec->op->parse(codec, pkt, encoded_len, &ts,
|
if (pjmedia_codec_parse(codec, pkt, encoded_len, &ts,
|
||||||
&count, in_frame) != PJ_SUCCESS)
|
&count, in_frame) != PJ_SUCCESS)
|
||||||
{
|
{
|
||||||
rc = -100;
|
rc = -100;
|
||||||
goto on_return;
|
goto on_return;
|
||||||
|
@ -399,15 +399,15 @@ static int codec_test_decode(pjmedia_codec_mgr *mgr,
|
||||||
goto on_return;
|
goto on_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (codec->op->decode(codec, &in_frame[0], samples_per_frame*2,
|
if (pjmedia_codec_decode(codec, &in_frame[0], samples_per_frame*2,
|
||||||
&out_frame) != PJ_SUCCESS)
|
&out_frame) != PJ_SUCCESS)
|
||||||
{
|
{
|
||||||
rc = -120;
|
rc = -120;
|
||||||
goto on_return;
|
goto on_return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (codec->op->recover(codec, samples_per_frame*2,
|
if (pjmedia_codec_recover(codec, samples_per_frame*2,
|
||||||
&out_frame) != PJ_SUCCESS)
|
&out_frame) != PJ_SUCCESS)
|
||||||
{
|
{
|
||||||
rc = -125;
|
rc = -125;
|
||||||
goto on_return;
|
goto on_return;
|
||||||
|
@ -483,7 +483,7 @@ on_return:
|
||||||
fclose(input);
|
fclose(input);
|
||||||
|
|
||||||
if (codec) {
|
if (codec) {
|
||||||
codec->op->close(codec);
|
pjmedia_codec_close(codec);
|
||||||
pjmedia_codec_mgr_dealloc_codec(mgr, codec);
|
pjmedia_codec_mgr_dealloc_codec(mgr, codec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -692,8 +692,8 @@ static pj_status_t codec_put_frame(struct pjmedia_port *this_port,
|
||||||
|
|
||||||
out_frame.buf = cp->pkt;
|
out_frame.buf = cp->pkt;
|
||||||
out_frame.size = sizeof(cp->pkt);
|
out_frame.size = sizeof(cp->pkt);
|
||||||
status = cp->codec->op->encode(cp->codec, frame, sizeof(cp->pkt),
|
status = pjmedia_codec_encode(cp->codec, frame, sizeof(cp->pkt),
|
||||||
&out_frame);
|
&out_frame);
|
||||||
pj_assert(status == PJ_SUCCESS);
|
pj_assert(status == PJ_SUCCESS);
|
||||||
|
|
||||||
if (out_frame.size != 0) {
|
if (out_frame.size != 0) {
|
||||||
|
@ -701,16 +701,16 @@ static pj_status_t codec_put_frame(struct pjmedia_port *this_port,
|
||||||
unsigned frame_cnt = PJ_ARRAY_SIZE(parsed_frm);
|
unsigned frame_cnt = PJ_ARRAY_SIZE(parsed_frm);
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
status = cp->codec->op->parse(cp->codec, out_frame.buf,
|
status = pjmedia_codec_parse(cp->codec, out_frame.buf,
|
||||||
out_frame.size, &out_frame.timestamp,
|
out_frame.size, &out_frame.timestamp,
|
||||||
&frame_cnt, parsed_frm);
|
&frame_cnt, parsed_frm);
|
||||||
pj_assert(status == PJ_SUCCESS);
|
pj_assert(status == PJ_SUCCESS);
|
||||||
|
|
||||||
for (i=0; i<frame_cnt; ++i) {
|
for (i=0; i<frame_cnt; ++i) {
|
||||||
pcm_frm.buf = cp->pcm;
|
pcm_frm.buf = cp->pcm;
|
||||||
pcm_frm.size = sizeof(cp->pkt);
|
pcm_frm.size = sizeof(cp->pkt);
|
||||||
status = cp->codec->op->decode(cp->codec, &parsed_frm[i],
|
status = pjmedia_codec_decode(cp->codec, &parsed_frm[i],
|
||||||
sizeof(cp->pcm), &pcm_frm);
|
sizeof(cp->pcm), &pcm_frm);
|
||||||
pj_assert(status == PJ_SUCCESS);
|
pj_assert(status == PJ_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -722,7 +722,7 @@ static pj_status_t codec_on_destroy(struct pjmedia_port *this_port)
|
||||||
{
|
{
|
||||||
struct codec_port *cp = (struct codec_port*)this_port;
|
struct codec_port *cp = (struct codec_port*)this_port;
|
||||||
|
|
||||||
cp->codec->op->close(cp->codec);
|
pjmedia_codec_close(cp->codec);
|
||||||
pjmedia_codec_mgr_dealloc_codec(pjmedia_endpt_get_codec_mgr(cp->endpt),
|
pjmedia_codec_mgr_dealloc_codec(pjmedia_endpt_get_codec_mgr(cp->endpt),
|
||||||
cp->codec);
|
cp->codec);
|
||||||
cp->codec_deinit();
|
cp->codec_deinit();
|
||||||
|
@ -782,11 +782,11 @@ static pjmedia_port* codec_encode_decode( pj_pool_t *pool,
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
status = (*cp->codec->op->init)(cp->codec, pool);
|
status = pjmedia_codec_init(cp->codec, pool);
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
status = cp->codec->op->open(cp->codec, &codec_param);
|
status = pjmedia_codec_open(cp->codec, &codec_param);
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ static pj_status_t codec_on_event(pjmedia_event_subscription *esub,
|
||||||
|
|
||||||
++event->proc_cnt;
|
++event->proc_cnt;
|
||||||
|
|
||||||
status = codec->op->get_param(codec, &codec_param);
|
status = pjmedia_vid_codec_get_param(codec, &codec_param);
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
@ -69,7 +69,8 @@ static pj_status_t codec_put_frame(pjmedia_port *port,
|
||||||
enc_frame.buf = port_data->enc_buf;
|
enc_frame.buf = port_data->enc_buf;
|
||||||
enc_frame.size = port_data->enc_buf_size;
|
enc_frame.size = port_data->enc_buf_size;
|
||||||
|
|
||||||
status = codec->op->encode(codec, frame, enc_frame.size, &enc_frame);
|
status = pjmedia_vid_codec_encode(codec, frame, enc_frame.size,
|
||||||
|
&enc_frame);
|
||||||
if (status != PJ_SUCCESS) goto on_error;
|
if (status != PJ_SUCCESS) goto on_error;
|
||||||
|
|
||||||
#if !BYPASS_PACKETIZER
|
#if !BYPASS_PACKETIZER
|
||||||
|
@ -82,17 +83,19 @@ static pj_status_t codec_put_frame(pjmedia_port *port,
|
||||||
pj_uint8_t *payload;
|
pj_uint8_t *payload;
|
||||||
pj_size_t payload_len;
|
pj_size_t payload_len;
|
||||||
|
|
||||||
status = codec->op->packetize(codec,
|
status = pjmedia_vid_codec_packetize(
|
||||||
(pj_uint8_t*)enc_frame.buf,
|
codec,
|
||||||
enc_frame.size, &pos,
|
(pj_uint8_t*)enc_frame.buf,
|
||||||
(const pj_uint8_t**)&payload,
|
enc_frame.size, &pos,
|
||||||
&payload_len);
|
(const pj_uint8_t**)&payload,
|
||||||
|
&payload_len);
|
||||||
if (status == PJ_ENOTSUP)
|
if (status == PJ_ENOTSUP)
|
||||||
break;
|
break;
|
||||||
if (status != PJ_SUCCESS)
|
if (status != PJ_SUCCESS)
|
||||||
goto on_error;
|
goto on_error;
|
||||||
|
|
||||||
status = codec->op->unpacketize(codec, payload, payload_len,
|
status = pjmedia_vid_codec_unpacketize(
|
||||||
|
codec, payload, payload_len,
|
||||||
port_data->pack_buf,
|
port_data->pack_buf,
|
||||||
port_data->pack_buf_size,
|
port_data->pack_buf_size,
|
||||||
&unpack_pos);
|
&unpack_pos);
|
||||||
|
@ -112,7 +115,8 @@ static pj_status_t codec_put_frame(pjmedia_port *port,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
status = codec->op->decode(codec, &enc_frame, frame->size, frame);
|
status = pjmedia_vid_codec_decode(codec, &enc_frame,
|
||||||
|
frame->size, frame);
|
||||||
if (status != PJ_SUCCESS) goto on_error;
|
if (status != PJ_SUCCESS) goto on_error;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -276,12 +280,12 @@ static int encode_decode_test(pj_pool_t *pool, const char *codec_id)
|
||||||
rc = 250; goto on_return;
|
rc = 250; goto on_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = codec->op->init(codec, pool);
|
status = pjmedia_vid_codec_init(codec, pool);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
rc = 251; goto on_return;
|
rc = 251; goto on_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = codec->op->open(codec, &codec_param);
|
status = pjmedia_vid_codec_open(codec, &codec_param);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
rc = 252; goto on_return;
|
rc = 252; goto on_return;
|
||||||
}
|
}
|
||||||
|
@ -414,7 +418,7 @@ on_return:
|
||||||
pjmedia_vid_port_destroy(renderer);
|
pjmedia_vid_port_destroy(renderer);
|
||||||
}
|
}
|
||||||
if (codec) {
|
if (codec) {
|
||||||
codec->op->close(codec);
|
pjmedia_vid_codec_close(codec);
|
||||||
pjmedia_vid_codec_mgr_dealloc_codec(NULL, codec);
|
pjmedia_vid_codec_mgr_dealloc_codec(NULL, codec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ static pj_status_t codec_get_frame(pjmedia_port *port,
|
||||||
status = pjmedia_port_get_frame(port_data->src_port, frame);
|
status = pjmedia_port_get_frame(port_data->src_port, frame);
|
||||||
if (status != PJ_SUCCESS) goto on_error;
|
if (status != PJ_SUCCESS) goto on_error;
|
||||||
|
|
||||||
status = codec->op->decode(codec, frame, frame->size, &enc_frame);
|
status = pjmedia_vid_codec_decode(codec, frame, frame->size, &enc_frame);
|
||||||
if (status != PJ_SUCCESS) goto on_error;
|
if (status != PJ_SUCCESS) goto on_error;
|
||||||
|
|
||||||
frame->size = frame_size;
|
frame->size = frame_size;
|
||||||
|
@ -163,7 +163,7 @@ static pj_status_t codec_get_frame(pjmedia_port *port,
|
||||||
status = pjmedia_port_get_frame(port_data->src_port, &enc_frame);
|
status = pjmedia_port_get_frame(port_data->src_port, &enc_frame);
|
||||||
if (status != PJ_SUCCESS) goto on_error;
|
if (status != PJ_SUCCESS) goto on_error;
|
||||||
|
|
||||||
status = codec->op->decode(codec, &enc_frame, frame->size, frame);
|
status = pjmedia_vid_codec_decode(codec, &enc_frame, frame->size, frame);
|
||||||
if (status != PJ_SUCCESS) goto on_error;
|
if (status != PJ_SUCCESS) goto on_error;
|
||||||
|
|
||||||
return PJ_SUCCESS;
|
return PJ_SUCCESS;
|
||||||
|
@ -282,14 +282,14 @@ static int aviplay(pj_pool_t *pool, const char *fname)
|
||||||
rc = 250; goto on_return;
|
rc = 250; goto on_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = codec->op->init(codec, pool);
|
status = pjmedia_vid_codec_init(codec, pool);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
rc = 251; goto on_return;
|
rc = 251; goto on_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pjmedia_format_copy(&codec_param.dec_fmt, ¶m.vidparam.fmt);
|
pjmedia_format_copy(&codec_param.dec_fmt, ¶m.vidparam.fmt);
|
||||||
|
|
||||||
status = codec->op->open(codec, &codec_param);
|
status = pjmedia_vid_codec_open(codec, &codec_param);
|
||||||
if (status != PJ_SUCCESS) {
|
if (status != PJ_SUCCESS) {
|
||||||
rc = 252; goto on_return;
|
rc = 252; goto on_return;
|
||||||
}
|
}
|
||||||
|
@ -438,7 +438,7 @@ on_return:
|
||||||
if (vid_port)
|
if (vid_port)
|
||||||
pjmedia_port_destroy(vid_port);
|
pjmedia_port_destroy(vid_port);
|
||||||
if (codec) {
|
if (codec) {
|
||||||
codec->op->close(codec);
|
pjmedia_vid_codec_close(codec);
|
||||||
pjmedia_vid_codec_mgr_dealloc_codec(NULL, codec);
|
pjmedia_vid_codec_mgr_dealloc_codec(NULL, codec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,8 +137,8 @@ static pj_status_t enc_dec_test(const char *codec_id,
|
||||||
|
|
||||||
/* Alloc codec */
|
/* Alloc codec */
|
||||||
CHECK( pjmedia_codec_mgr_alloc_codec(cm, pci, &codec) );
|
CHECK( pjmedia_codec_mgr_alloc_codec(cm, pci, &codec) );
|
||||||
CHECK( codec->op->init(codec, pool) );
|
CHECK( pjmedia_codec_init(codec, pool) );
|
||||||
CHECK( codec->op->open(codec, ¶m) );
|
CHECK( pjmedia_codec_open(codec, ¶m) );
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
pjmedia_frame frm_pcm, frm_bit, out_frm, frames[4];
|
pjmedia_frame frm_pcm, frm_bit, out_frm, frames[4];
|
||||||
|
@ -162,7 +162,8 @@ static pj_status_t enc_dec_test(const char *codec_id,
|
||||||
/* Encode */
|
/* Encode */
|
||||||
frm_bit.buf = bitstream;
|
frm_bit.buf = bitstream;
|
||||||
frm_bit.size = sizeof(bitstream);
|
frm_bit.size = sizeof(bitstream);
|
||||||
CHECK(codec->op->encode(codec, &frm_pcm, sizeof(bitstream), &frm_bit));
|
CHECK(pjmedia_codec_encode(codec, &frm_pcm, sizeof(bitstream),
|
||||||
|
&frm_bit));
|
||||||
|
|
||||||
/* On DTX, write zero frame to wavout to maintain duration */
|
/* On DTX, write zero frame to wavout to maintain duration */
|
||||||
if (frm_bit.size == 0 || frm_bit.type != PJMEDIA_FRAME_TYPE_AUDIO) {
|
if (frm_bit.size == 0 || frm_bit.type != PJMEDIA_FRAME_TYPE_AUDIO) {
|
||||||
|
@ -180,8 +181,8 @@ static pj_status_t enc_dec_test(const char *codec_id,
|
||||||
*/
|
*/
|
||||||
ts.u64 = 0;
|
ts.u64 = 0;
|
||||||
cnt = PJ_ARRAY_SIZE(frames);
|
cnt = PJ_ARRAY_SIZE(frames);
|
||||||
CHECK( codec->op->parse(codec, bitstream, frm_bit.size, &ts, &cnt,
|
CHECK( pjmedia_codec_parse(codec, bitstream, frm_bit.size, &ts, &cnt,
|
||||||
frames) );
|
frames) );
|
||||||
CHECK( (cnt==1 ? PJ_SUCCESS : -1) );
|
CHECK( (cnt==1 ? PJ_SUCCESS : -1) );
|
||||||
|
|
||||||
/* Decode or simulate packet loss */
|
/* Decode or simulate packet loss */
|
||||||
|
@ -190,11 +191,11 @@ static pj_status_t enc_dec_test(const char *codec_id,
|
||||||
|
|
||||||
if ((pj_rand() % 100) < (int)lost_pct) {
|
if ((pj_rand() % 100) < (int)lost_pct) {
|
||||||
/* Simulate loss */
|
/* Simulate loss */
|
||||||
CHECK( codec->op->recover(codec, sizeof(pcmbuf), &out_frm) );
|
CHECK( pjmedia_codec_recover(codec, sizeof(pcmbuf), &out_frm) );
|
||||||
TRACE_((THIS_FILE, "%d.%03d Packet lost", T));
|
TRACE_((THIS_FILE, "%d.%03d Packet lost", T));
|
||||||
} else {
|
} else {
|
||||||
/* Decode */
|
/* Decode */
|
||||||
CHECK( codec->op->decode(codec, &frames[0], sizeof(pcmbuf),
|
CHECK( pjmedia_codec_decode(codec, &frames[0], sizeof(pcmbuf),
|
||||||
&out_frm) );
|
&out_frm) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +211,7 @@ static pj_status_t enc_dec_test(const char *codec_id,
|
||||||
pjmedia_port_destroy(wavin);
|
pjmedia_port_destroy(wavin);
|
||||||
|
|
||||||
/* Close codec */
|
/* Close codec */
|
||||||
codec->op->close(codec);
|
pjmedia_codec_close(codec);
|
||||||
pjmedia_codec_mgr_dealloc_codec(cm, codec);
|
pjmedia_codec_mgr_dealloc_codec(cm, codec);
|
||||||
|
|
||||||
/* Release pool */
|
/* Release pool */
|
||||||
|
|
|
@ -98,7 +98,7 @@ static void err_exit(const char *title, pj_status_t status)
|
||||||
if (app.pcap) pj_pcap_close(app.pcap);
|
if (app.pcap) pj_pcap_close(app.pcap);
|
||||||
if (app.codec) {
|
if (app.codec) {
|
||||||
pjmedia_codec_mgr *cmgr;
|
pjmedia_codec_mgr *cmgr;
|
||||||
app.codec->op->close(app.codec);
|
pjmedia_codec_close(app.codec);
|
||||||
cmgr = pjmedia_endpt_get_codec_mgr(app.mept);
|
cmgr = pjmedia_endpt_get_codec_mgr(app.mept);
|
||||||
pjmedia_codec_mgr_dealloc_codec(cmgr, app.codec);
|
pjmedia_codec_mgr_dealloc_codec(cmgr, app.codec);
|
||||||
}
|
}
|
||||||
|
@ -259,8 +259,8 @@ static void pcap2wav(const char *wav_filename, const pj_str_t *srtp_crypto,
|
||||||
|
|
||||||
/* Alloc and init codec */
|
/* Alloc and init codec */
|
||||||
T( pjmedia_codec_mgr_alloc_codec(cmgr, ci, &app.codec) );
|
T( pjmedia_codec_mgr_alloc_codec(cmgr, ci, &app.codec) );
|
||||||
T( app.codec->op->init(app.codec, app.pool) );
|
T( pjmedia_codec_init(app.codec, app.pool) );
|
||||||
T( app.codec->op->open(app.codec, ¶m) );
|
T( pjmedia_codec_open(app.codec, ¶m) );
|
||||||
|
|
||||||
/* Open WAV file */
|
/* Open WAV file */
|
||||||
samples_per_frame = ci->clock_rate * param.info.frm_ptime / 1000;
|
samples_per_frame = ci->clock_rate * param.info.frm_ptime / 1000;
|
||||||
|
@ -284,7 +284,7 @@ static void pcap2wav(const char *wav_filename, const pj_str_t *srtp_crypto,
|
||||||
/* Parse first packet */
|
/* Parse first packet */
|
||||||
ts.u64 = 0;
|
ts.u64 = 0;
|
||||||
frame_cnt = PJ_ARRAY_SIZE(frames);
|
frame_cnt = PJ_ARRAY_SIZE(frames);
|
||||||
T( app.codec->op->parse(app.codec, pkt0.payload, pkt0.payload_len,
|
T( pjmedia_codec_parse(app.codec, pkt0.payload, pkt0.payload_len,
|
||||||
&ts, &frame_cnt, frames) );
|
&ts, &frame_cnt, frames) );
|
||||||
|
|
||||||
/* Decode and write to WAV file */
|
/* Decode and write to WAV file */
|
||||||
|
@ -295,7 +295,7 @@ static void pcap2wav(const char *wav_filename, const pj_str_t *srtp_crypto,
|
||||||
pcm_frame.buf = pcm;
|
pcm_frame.buf = pcm;
|
||||||
pcm_frame.size = samples_per_frame * 2;
|
pcm_frame.size = samples_per_frame * 2;
|
||||||
|
|
||||||
T( app.codec->op->decode(app.codec, &frames[i], pcm_frame.size,
|
T( pjmedia_codec_decode(app.codec, &frames[i], pcm_frame.size,
|
||||||
&pcm_frame) );
|
&pcm_frame) );
|
||||||
T( pjmedia_port_put_frame(app.wav, &pcm_frame) );
|
T( pjmedia_port_put_frame(app.wav, &pcm_frame) );
|
||||||
samples_cnt += samples_per_frame;
|
samples_cnt += samples_per_frame;
|
||||||
|
@ -314,8 +314,8 @@ static void pcap2wav(const char *wav_filename, const pj_str_t *srtp_crypto,
|
||||||
pcm_frame.size = samples_per_frame * 2;
|
pcm_frame.size = samples_per_frame * 2;
|
||||||
|
|
||||||
if (app.codec->op->recover) {
|
if (app.codec->op->recover) {
|
||||||
T( app.codec->op->recover(app.codec, pcm_frame.size,
|
T( pjmedia_codec_recover(app.codec, pcm_frame.size,
|
||||||
&pcm_frame) );
|
&pcm_frame) );
|
||||||
} else {
|
} else {
|
||||||
pj_bzero(pcm_frame.buf, pcm_frame.size);
|
pj_bzero(pcm_frame.buf, pcm_frame.size);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue