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 <pj/errno.h>
|
||||
#include <pj/list.h>
|
||||
#include <pj/pool.h>
|
||||
|
||||
|
@ -323,6 +324,9 @@ typedef struct pjmedia_codec_op
|
|||
/**
|
||||
* Initialize codec using the specified attribute.
|
||||
*
|
||||
* Application should call #pjmedia_codec_init() instead of
|
||||
* calling this function directly.
|
||||
*
|
||||
* @param codec The codec instance.
|
||||
* @param pool Pool to use when the codec needs to allocate
|
||||
* some memory.
|
||||
|
@ -338,6 +342,9 @@ typedef struct pjmedia_codec_op
|
|||
* and fills in the unspecified values (such as enc_ptime, when
|
||||
* 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 param Codec initialization parameter.
|
||||
*
|
||||
|
@ -350,6 +357,9 @@ typedef struct pjmedia_codec_op
|
|||
* Close and shutdown codec, releasing all resources allocated by
|
||||
* this codec, if any.
|
||||
*
|
||||
* Application should call #pjmedia_codec_close() instead of
|
||||
* calling this function directly.
|
||||
*
|
||||
* @param codec The codec instance.
|
||||
*
|
||||
* @return PJ_SUCCESS on success.
|
||||
|
@ -365,6 +375,9 @@ typedef struct pjmedia_codec_op
|
|||
* Application can expect changing trivial codec settings such as
|
||||
* changing VAD setting to succeed.
|
||||
*
|
||||
* Application should call #pjmedia_codec_modify() instead of
|
||||
* calling this function directly.
|
||||
*
|
||||
* @param codec The codec instance.
|
||||
* @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
|
||||
* 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 pkt The input 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
|
||||
* 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 input The input 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
|
||||
* frames before decoding each frame.
|
||||
*
|
||||
* Application should call #pjmedia_codec_decode() instead of
|
||||
* calling this function directly.
|
||||
*
|
||||
* @param codec The codec instance.
|
||||
* @param input The input 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.
|
||||
*
|
||||
* Application should call #pjmedia_codec_recover() instead of
|
||||
* calling this function directly.
|
||||
*
|
||||
* @param codec The codec instance.
|
||||
* @param out_size The length of buffer in the output frame.
|
||||
* @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.
|
||||
*
|
||||
* Application should call #pjmedia_vid_codec_init() instead of
|
||||
* calling this function directly.
|
||||
*
|
||||
* @param codec The codec instance.
|
||||
* @param pool Pool to use when the codec needs to allocate
|
||||
* some memory.
|
||||
|
@ -129,6 +132,9 @@ typedef struct pjmedia_vid_codec_op
|
|||
* the encoder format, as it may need to be negotiated with remote
|
||||
* preferences via SDP fmtp).
|
||||
*
|
||||
* Application should call #pjmedia_vid_codec_open() instead of
|
||||
* calling this function directly.
|
||||
*
|
||||
* @param codec The codec instance.
|
||||
* @param param Codec initialization parameter.
|
||||
*
|
||||
|
@ -141,6 +147,9 @@ typedef struct pjmedia_vid_codec_op
|
|||
* Close and shutdown codec, releasing all resources allocated by
|
||||
* this codec, if any.
|
||||
*
|
||||
* Application should call #pjmedia_vid_codec_close() instead of
|
||||
* calling this function directly.
|
||||
*
|
||||
* @param codec The codec instance.
|
||||
*
|
||||
* @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
|
||||
* 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 param The new codec parameter.
|
||||
*
|
||||
|
@ -164,6 +176,9 @@ typedef struct pjmedia_vid_codec_op
|
|||
/**
|
||||
* 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 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
|
||||
* 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 bits The picture 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
|
||||
* 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 pkt The input 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
|
||||
* in opening the codec.
|
||||
*
|
||||
* Application should call #pjmedia_vid_codec_encode() instead of
|
||||
* calling this function directly.
|
||||
*
|
||||
* @param codec The codec instance.
|
||||
* @param input The input 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
|
||||
* using #get_param().
|
||||
*
|
||||
* Application should call #pjmedia_vid_codec_decode() instead of
|
||||
* calling this function directly.
|
||||
*
|
||||
* @param codec The codec instance.
|
||||
* @param input The input 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.
|
||||
*
|
||||
* Application should call #pjmedia_vid_codec_recover() instead of
|
||||
* calling this function directly.
|
||||
*
|
||||
* @param codec The codec instance.
|
||||
* @param out_size The length of buffer in the output frame.
|
||||
* @param output The output frame where generated signal
|
||||
|
@ -432,7 +462,7 @@ typedef struct pjmedia_vid_codec_mgr pjmedia_vid_codec_mgr;
|
|||
* @param codec The codec to be initialized.
|
||||
* @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);
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
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->factory = factory;
|
||||
ff = PJ_POOL_ZALLOC_T(pool, ffmpeg_private);
|
||||
|
|
|
@ -515,7 +515,7 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
|
|||
|
||||
frame_out.buf = p_out_samp + samples_count;
|
||||
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);
|
||||
|
||||
|
@ -564,7 +564,7 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
|
|||
do {
|
||||
frame_out.buf = p_out_samp + samples_count;
|
||||
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);
|
||||
if (status != PJ_SUCCESS)
|
||||
|
@ -619,7 +619,7 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
|
|||
do {
|
||||
frame_out.buf = p_out_samp + samples_count;
|
||||
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);
|
||||
if (status != PJ_SUCCESS)
|
||||
|
@ -670,7 +670,7 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
|
|||
|
||||
frame_out.buf = p_out_samp + samples_count;
|
||||
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);
|
||||
if (status != 0) {
|
||||
LOGERR_((port->info.name.ptr, "codec decode() error",
|
||||
|
@ -774,7 +774,7 @@ static pj_status_t get_frame_ext( pjmedia_port *port, pjmedia_frame *frame)
|
|||
frame_in.bit_info = bit_info;
|
||||
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);
|
||||
if (status != PJ_SUCCESS) {
|
||||
LOGERR_((port->info.name.ptr, "codec decode() error",
|
||||
|
@ -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) */
|
||||
status = PJ_SUCCESS;
|
||||
if (stream->codec->op->recover) {
|
||||
status = (*stream->codec->op->recover)(stream->codec,
|
||||
0, frame);
|
||||
status = pjmedia_codec_recover(stream->codec, 0, frame);
|
||||
}
|
||||
|
||||
/* No PLC or PLC failed */
|
||||
|
@ -1248,7 +1247,7 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
|
|||
silence_frame.timestamp.u32.lo = pj_ntohl(stream->enc->rtp.out_hdr.ts);
|
||||
|
||||
/* Encode! */
|
||||
status = stream->codec->op->encode( stream->codec, &silence_frame,
|
||||
status = pjmedia_codec_encode( stream->codec, &silence_frame,
|
||||
channel->out_pkt_size -
|
||||
sizeof(pjmedia_rtp_hdr),
|
||||
&frame_out);
|
||||
|
@ -1272,7 +1271,7 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
|
|||
(frame->type == PJMEDIA_FRAME_TYPE_EXTENDED))
|
||||
{
|
||||
/* Encode! */
|
||||
status = stream->codec->op->encode( stream->codec, frame,
|
||||
status = pjmedia_codec_encode( stream->codec, frame,
|
||||
channel->out_pkt_size -
|
||||
sizeof(pjmedia_rtp_hdr),
|
||||
&frame_out);
|
||||
|
@ -1425,7 +1424,7 @@ static pj_status_t put_frame( pjmedia_port *port,
|
|||
PJMEDIA_STREAM_VAD_SUSPEND_MSEC / 1000)
|
||||
{
|
||||
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"));
|
||||
}
|
||||
|
||||
|
@ -1691,12 +1690,8 @@ static void on_rx_rtp( void *data,
|
|||
ts.u64 = pj_ntohl(hdr->ts);
|
||||
|
||||
/* Parse the payload. */
|
||||
status = (*stream->codec->op->parse)(stream->codec,
|
||||
(void*)payload,
|
||||
payloadlen,
|
||||
&ts,
|
||||
&count,
|
||||
frames);
|
||||
status = pjmedia_codec_parse(stream->codec, (void*)payload,
|
||||
payloadlen, &ts, &count, frames);
|
||||
if (status != PJ_SUCCESS) {
|
||||
LOGERR_((stream->port.info.name.ptr,
|
||||
"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;
|
||||
|
||||
/* 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)
|
||||
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) {
|
||||
stream->codec_param.setting.vad = 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"));
|
||||
}
|
||||
|
||||
|
@ -2440,7 +2435,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_destroy( pjmedia_stream *stream )
|
|||
/* Free 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);
|
||||
stream->codec = NULL;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ static void sort_codecs(pjmedia_vid_codec_mgr *mgr);
|
|||
/*
|
||||
* 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)
|
||||
{
|
||||
pj_bzero(codec, sizeof(*codec));
|
||||
|
|
|
@ -335,7 +335,7 @@ static pj_status_t stream_event_cb(pjmedia_event_subscription *esub,
|
|||
switch (event->type) {
|
||||
case PJMEDIA_EVENT_FMT_CHANGED:
|
||||
/* 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 */
|
||||
pjmedia_format_copy(&stream->dec->port.info.fmt,
|
||||
|
@ -763,7 +763,7 @@ static pj_status_t put_frame(pjmedia_port *port,
|
|||
frame_out.size = 0;
|
||||
|
||||
/* Encode! */
|
||||
status = (*stream->codec->op->encode)(stream->codec, frame,
|
||||
status = pjmedia_vid_codec_encode(stream->codec, frame,
|
||||
channel->buf_size -
|
||||
sizeof(pjmedia_rtp_hdr),
|
||||
&frame_out);
|
||||
|
@ -784,8 +784,7 @@ static pj_status_t put_frame(pjmedia_port *port,
|
|||
pj_size_t payload_len;
|
||||
|
||||
/* Generate RTP payload */
|
||||
status = (*stream->codec->op->packetize)(
|
||||
stream->codec,
|
||||
status = pjmedia_vid_codec_packetize(stream->codec,
|
||||
(pj_uint8_t*)frame_out.buf,
|
||||
frame_out.size,
|
||||
&processed,
|
||||
|
@ -932,7 +931,7 @@ static pj_status_t get_frame(pjmedia_port *port,
|
|||
psize = 0;
|
||||
}
|
||||
|
||||
status = (*stream->codec->op->unpacketize)(
|
||||
status = pjmedia_vid_codec_unpacketize(
|
||||
stream->codec,
|
||||
p, psize,
|
||||
(pj_uint8_t*)channel->buf,
|
||||
|
@ -965,7 +964,7 @@ static pj_status_t get_frame(pjmedia_port *port,
|
|||
frame_in.type = PJMEDIA_FRAME_TYPE_VIDEO;
|
||||
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);
|
||||
if (status != PJ_SUCCESS) {
|
||||
LOGERR_((port->info.name.ptr, "codec decode() error",
|
||||
|
@ -1239,10 +1238,10 @@ PJ_DEF(pj_status_t) pjmedia_vid_stream_create(
|
|||
PJMEDIA_STREAM_RESV_PAYLOAD_LEN;
|
||||
|
||||
/* 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)
|
||||
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)
|
||||
return status;
|
||||
|
||||
|
@ -1445,7 +1444,7 @@ PJ_DEF(pj_status_t) pjmedia_vid_stream_destroy( pjmedia_vid_stream *stream )
|
|||
|
||||
/* Free 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);
|
||||
stream->codec = NULL;
|
||||
}
|
||||
|
|
|
@ -73,13 +73,13 @@ static int codec_test_encode(pjmedia_codec_mgr *mgr,
|
|||
codec_param.info.avg_bps = bitrate;
|
||||
codec_param.setting.vad = 0;
|
||||
|
||||
status = codec->op->init(codec, pool);
|
||||
status = pjmedia_codec_init(codec, pool);
|
||||
if (status != PJ_SUCCESS) {
|
||||
rc = -60;
|
||||
goto on_return;
|
||||
}
|
||||
|
||||
status = codec->op->open(codec, &codec_param);
|
||||
status = pjmedia_codec_open(codec, &codec_param);
|
||||
if (status != PJ_SUCCESS) {
|
||||
rc = -70;
|
||||
goto on_return;
|
||||
|
@ -117,7 +117,7 @@ static int codec_test_encode(pjmedia_codec_mgr *mgr,
|
|||
break;
|
||||
|
||||
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);
|
||||
if (status != PJ_SUCCESS) {
|
||||
rc = -95;
|
||||
|
@ -188,7 +188,7 @@ on_return:
|
|||
fclose(fref);
|
||||
|
||||
if (codec) {
|
||||
codec->op->close(codec);
|
||||
pjmedia_codec_close(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.setting.vad = 0;
|
||||
|
||||
status = codec->op->init(codec, pool);
|
||||
status = pjmedia_codec_init(codec, pool);
|
||||
if (status != PJ_SUCCESS) {
|
||||
rc = -60;
|
||||
goto on_return;
|
||||
}
|
||||
|
||||
status = codec->op->open(codec, &codec_param);
|
||||
status = pjmedia_codec_open(codec, &codec_param);
|
||||
if (status != PJ_SUCCESS) {
|
||||
rc = -70;
|
||||
goto on_return;
|
||||
|
@ -387,7 +387,7 @@ static int codec_test_decode(pjmedia_codec_mgr *mgr,
|
|||
|
||||
if (has_frame) {
|
||||
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)
|
||||
{
|
||||
rc = -100;
|
||||
|
@ -399,14 +399,14 @@ static int codec_test_decode(pjmedia_codec_mgr *mgr,
|
|||
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)
|
||||
{
|
||||
rc = -120;
|
||||
goto on_return;
|
||||
}
|
||||
} else {
|
||||
if (codec->op->recover(codec, samples_per_frame*2,
|
||||
if (pjmedia_codec_recover(codec, samples_per_frame*2,
|
||||
&out_frame) != PJ_SUCCESS)
|
||||
{
|
||||
rc = -125;
|
||||
|
@ -483,7 +483,7 @@ on_return:
|
|||
fclose(input);
|
||||
|
||||
if (codec) {
|
||||
codec->op->close(codec);
|
||||
pjmedia_codec_close(codec);
|
||||
pjmedia_codec_mgr_dealloc_codec(mgr, codec);
|
||||
}
|
||||
|
||||
|
|
|
@ -692,7 +692,7 @@ static pj_status_t codec_put_frame(struct pjmedia_port *this_port,
|
|||
|
||||
out_frame.buf = 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);
|
||||
pj_assert(status == PJ_SUCCESS);
|
||||
|
||||
|
@ -701,7 +701,7 @@ static pj_status_t codec_put_frame(struct pjmedia_port *this_port,
|
|||
unsigned frame_cnt = PJ_ARRAY_SIZE(parsed_frm);
|
||||
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,
|
||||
&frame_cnt, parsed_frm);
|
||||
pj_assert(status == PJ_SUCCESS);
|
||||
|
@ -709,7 +709,7 @@ static pj_status_t codec_put_frame(struct pjmedia_port *this_port,
|
|||
for (i=0; i<frame_cnt; ++i) {
|
||||
pcm_frm.buf = cp->pcm;
|
||||
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);
|
||||
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;
|
||||
|
||||
cp->codec->op->close(cp->codec);
|
||||
pjmedia_codec_close(cp->codec);
|
||||
pjmedia_codec_mgr_dealloc_codec(pjmedia_endpt_get_codec_mgr(cp->endpt),
|
||||
cp->codec);
|
||||
cp->codec_deinit();
|
||||
|
@ -782,11 +782,11 @@ static pjmedia_port* codec_encode_decode( pj_pool_t *pool,
|
|||
if (status != PJ_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
status = (*cp->codec->op->init)(cp->codec, pool);
|
||||
status = pjmedia_codec_init(cp->codec, pool);
|
||||
if (status != PJ_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
status = cp->codec->op->open(cp->codec, &codec_param);
|
||||
status = pjmedia_codec_open(cp->codec, &codec_param);
|
||||
if (status != PJ_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ static pj_status_t codec_on_event(pjmedia_event_subscription *esub,
|
|||
|
||||
++event->proc_cnt;
|
||||
|
||||
status = codec->op->get_param(codec, &codec_param);
|
||||
status = pjmedia_vid_codec_get_param(codec, &codec_param);
|
||||
if (status != PJ_SUCCESS)
|
||||
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.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 !BYPASS_PACKETIZER
|
||||
|
@ -82,7 +83,8 @@ static pj_status_t codec_put_frame(pjmedia_port *port,
|
|||
pj_uint8_t *payload;
|
||||
pj_size_t payload_len;
|
||||
|
||||
status = codec->op->packetize(codec,
|
||||
status = pjmedia_vid_codec_packetize(
|
||||
codec,
|
||||
(pj_uint8_t*)enc_frame.buf,
|
||||
enc_frame.size, &pos,
|
||||
(const pj_uint8_t**)&payload,
|
||||
|
@ -92,7 +94,8 @@ static pj_status_t codec_put_frame(pjmedia_port *port,
|
|||
if (status != PJ_SUCCESS)
|
||||
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_size,
|
||||
&unpack_pos);
|
||||
|
@ -112,7 +115,8 @@ static pj_status_t codec_put_frame(pjmedia_port *port,
|
|||
}
|
||||
#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;
|
||||
}
|
||||
#endif
|
||||
|
@ -276,12 +280,12 @@ static int encode_decode_test(pj_pool_t *pool, const char *codec_id)
|
|||
rc = 250; goto on_return;
|
||||
}
|
||||
|
||||
status = codec->op->init(codec, pool);
|
||||
status = pjmedia_vid_codec_init(codec, pool);
|
||||
if (status != PJ_SUCCESS) {
|
||||
rc = 251; goto on_return;
|
||||
}
|
||||
|
||||
status = codec->op->open(codec, &codec_param);
|
||||
status = pjmedia_vid_codec_open(codec, &codec_param);
|
||||
if (status != PJ_SUCCESS) {
|
||||
rc = 252; goto on_return;
|
||||
}
|
||||
|
@ -414,7 +418,7 @@ on_return:
|
|||
pjmedia_vid_port_destroy(renderer);
|
||||
}
|
||||
if (codec) {
|
||||
codec->op->close(codec);
|
||||
pjmedia_vid_codec_close(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);
|
||||
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;
|
||||
|
||||
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);
|
||||
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;
|
||||
|
||||
return PJ_SUCCESS;
|
||||
|
@ -282,14 +282,14 @@ static int aviplay(pj_pool_t *pool, const char *fname)
|
|||
rc = 250; goto on_return;
|
||||
}
|
||||
|
||||
status = codec->op->init(codec, pool);
|
||||
status = pjmedia_vid_codec_init(codec, pool);
|
||||
if (status != PJ_SUCCESS) {
|
||||
rc = 251; goto on_return;
|
||||
}
|
||||
|
||||
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) {
|
||||
rc = 252; goto on_return;
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ on_return:
|
|||
if (vid_port)
|
||||
pjmedia_port_destroy(vid_port);
|
||||
if (codec) {
|
||||
codec->op->close(codec);
|
||||
pjmedia_vid_codec_close(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 */
|
||||
CHECK( pjmedia_codec_mgr_alloc_codec(cm, pci, &codec) );
|
||||
CHECK( codec->op->init(codec, pool) );
|
||||
CHECK( codec->op->open(codec, ¶m) );
|
||||
CHECK( pjmedia_codec_init(codec, pool) );
|
||||
CHECK( pjmedia_codec_open(codec, ¶m) );
|
||||
|
||||
for (;;) {
|
||||
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 */
|
||||
frm_bit.buf = 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 */
|
||||
if (frm_bit.size == 0 || frm_bit.type != PJMEDIA_FRAME_TYPE_AUDIO) {
|
||||
|
@ -180,7 +181,7 @@ static pj_status_t enc_dec_test(const char *codec_id,
|
|||
*/
|
||||
ts.u64 = 0;
|
||||
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) );
|
||||
CHECK( (cnt==1 ? PJ_SUCCESS : -1) );
|
||||
|
||||
|
@ -190,11 +191,11 @@ static pj_status_t enc_dec_test(const char *codec_id,
|
|||
|
||||
if ((pj_rand() % 100) < (int)lost_pct) {
|
||||
/* 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));
|
||||
} else {
|
||||
/* Decode */
|
||||
CHECK( codec->op->decode(codec, &frames[0], sizeof(pcmbuf),
|
||||
CHECK( pjmedia_codec_decode(codec, &frames[0], sizeof(pcmbuf),
|
||||
&out_frm) );
|
||||
}
|
||||
|
||||
|
@ -210,7 +211,7 @@ static pj_status_t enc_dec_test(const char *codec_id,
|
|||
pjmedia_port_destroy(wavin);
|
||||
|
||||
/* Close codec */
|
||||
codec->op->close(codec);
|
||||
pjmedia_codec_close(codec);
|
||||
pjmedia_codec_mgr_dealloc_codec(cm, codec);
|
||||
|
||||
/* 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.codec) {
|
||||
pjmedia_codec_mgr *cmgr;
|
||||
app.codec->op->close(app.codec);
|
||||
pjmedia_codec_close(app.codec);
|
||||
cmgr = pjmedia_endpt_get_codec_mgr(app.mept);
|
||||
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 */
|
||||
T( pjmedia_codec_mgr_alloc_codec(cmgr, ci, &app.codec) );
|
||||
T( app.codec->op->init(app.codec, app.pool) );
|
||||
T( app.codec->op->open(app.codec, ¶m) );
|
||||
T( pjmedia_codec_init(app.codec, app.pool) );
|
||||
T( pjmedia_codec_open(app.codec, ¶m) );
|
||||
|
||||
/* Open WAV file */
|
||||
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 */
|
||||
ts.u64 = 0;
|
||||
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) );
|
||||
|
||||
/* 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.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) );
|
||||
T( pjmedia_port_put_frame(app.wav, &pcm_frame) );
|
||||
samples_cnt += samples_per_frame;
|
||||
|
@ -314,7 +314,7 @@ static void pcap2wav(const char *wav_filename, const pj_str_t *srtp_crypto,
|
|||
pcm_frame.size = samples_per_frame * 2;
|
||||
|
||||
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) );
|
||||
} else {
|
||||
pj_bzero(pcm_frame.buf, pcm_frame.size);
|
||||
|
|
Loading…
Reference in New Issue