-
How to decode a packetized MPEG4A-LATMMedia_Dev 2011. 7. 4. 15:48반응형
http://www.rfc-editor.org/rfc/rfc3016.txt
If you need compatibility with 3g , then use it . LATM .
This is explained LATEM follow to RFC.
1.2 MPEG-4 Audio RTP payload format
MPEG-4 Audio is a new kind of audio standard that integrates many
different types of audio coding tools. Low-overhead MPEG-4 Audio
Transport Multiplex (LATM) manages the sequences of audio data with
relatively small overhead. In audio-only applications, then, it is
desirable for LATM-based MPEG-4 Audio bit streams to be directly
mapped onto the RTP packets without using MPEG-4 Systems.
While LATM has several multiplexing features as follows;
- Carrying configuration information with audio data,
- Concatenation of multiple audio frames in one audio stream,
RTP sample codes
RTP_LATM sample code
http://open.phonyx.eu/browser/mpeg4ip-1.5.0.1/player/plugin/rtp/rfc3016/latm.cpp?rev=21
SO, couldn’t find it, don’t know where describe this logic of LATM.
Just said with this code.
Facing 0xff On header of MPEG4A-LATM when phrasing data.
It means be data more after this 0xff. So, this Audio data size is more than 255.
You can find about it at 129 } while (value == 0xff);
static bool start_next_frame (rtp_plugin_data_t *pifptr,
uint8_t **buffer,
uint32_t *buflen,
frame_timestamp_t *ts,
void **userdata)
{
latm_rtp_data_t *iptr = (latm_rtp_data_t *)pifptr;
uint64_t timetick;
rtp_packet *rpak;
uint32_t rtp_ts;
uint8_t *dptr;
uint32_t dlen;
uint32_t calc_len;
uint64_t ntp_ts;
if (iptr->m_rpak != NULL) {
(iptr->m_vft->free_pak)(iptr->m_rpak);
iptr->m_rpak = NULL;
}
rpak = (iptr->m_vft->get_head_and_check)(iptr->m_ifptr, false, 0);
if (rpak == NULL) return false;
dlen = rpak->rtp_data_len;
dptr = rpak->rtp_data;
rtp_ts = rpak->rtp_pak_ts;
ntp_ts = rpak->pd.rtp_pd_timestamp;
calc_len = 0;
uint8_t value;
do {
value = *dptr++;
calc_len += value;
dlen--;
} while (value == 0xff);
#if 0
latm_message(LOG_DEBUG, latmrtp, "len %u header %u",
calc_len, rpak->rtp_data_len - dlen);
#endif
if (rpak->rtp_pak_m != 0) {
// just one packet - we should have frame length
if (calc_len != dlen) {
latm_message(LOG_ERR, latmrtp, "header length not correct %u %u",
calc_len, dlen);
return false;
}
iptr->m_rpak = rpak;
*buffer = dptr;
*buflen = dlen;
} else {
if (calc_len > iptr->m_frag_buffer_len) {
iptr->m_frag_buffer = (uint8_t *)realloc(iptr->m_frag_buffer, calc_len);
iptr->m_frag_buffer_len = calc_len;
}
memcpy(iptr->m_frag_buffer, dptr, dlen);
calc_len -= dlen;
uint32_t offset = dlen;
(iptr->m_vft->free_pak)(rpak);
do {
rpak = iptr->m_vft->get_head_and_check(iptr->m_ifptr,
true,
rtp_ts);
if (rpak == NULL) return false;
if (calc_len < rpak->rtp_data_len) {
latm_message(LOG_ERR, latmrtp, "Illegal frag len - remaining %u pak len %u", calc_len, rpak->rtp_data_len);
return false;
}
memcpy(iptr->m_frag_buffer + offset,
rpak->rtp_data,
rpak->rtp_data_len);
calc_len -= rpak->rtp_data_len;
offset += rpak->rtp_data_len;
} while (calc_len > 0);
}
timetick = iptr->m_vft->rtp_ts_to_msec(iptr->m_ifptr,
rtp_ts,
ntp_ts,
0);
ts->audio_freq_timestamp = rtp_ts;
ts->msec_timestamp = timetick;
ts->timestamp_is_pts = true;
return (true);
}
반응형'Media_Dev' 카테고리의 다른 글
SSRC: 32 bits (0) 2011.10.10 How to set PES or Header wheninput to MPEG-2 TS system with H.264 (0) 2011.09.14 Use a vector when time to bufferring !! No ordinary Array (0) 2011.06.21 3GP (0) 2011.06.11 Designing IP-Based Video Conferencing Systems: Dealing with Lip Synchronization (0) 2011.05.11