<div><br></div><div><div><div id="c6" class="bz_comment" style="margin-bottom: 2em;"><pre class="bz_comment_text" id="comment_text_6" style="font-size: medium; width: 50em;"> I am not so familiar with the buffer handling. Maybe the following codes related?
Who cam take a moment help me to find it out.My project is blocked by it. Thanks</pre><pre class="bz_comment_text" id="comment_text_6" style="font-size: medium; width: 50em;">if (gst_structure_has_field(structure, "codec_data")) {
extra_data_buf = (GValue *) gst_structure_get_value(structure, "codec_data");
if (extra_data_buf) {
info->configdata = gst_buffer_copy(gst_value_get_buffer(extra_data_buf));
AML_DUMP_BUFFER(info->configdata, "Audio Codec Data");
}
}
====================
int extract_adts_header(StreamInfo *info,codec_para_t *pcodec, GstBuffer *buffer)
{
adts_header_t hdr;
guint8 *p = NULL;
guint8 *buf;
GstMapInfo map;
if (info->configdata) {
gst_buffer_map(info->configdata, &map, GST_MAP_READ);
p = map.data;
hdr.profile = (*p >> 3) - 1;
hdr.sample_freq_idx = (*p & 0x7) << 1 | (*(p + 1) >> 7);
hdr.channel_configuration = (*(p + 1) & 0x7f) >> 3;
gst_buffer_unmap(info->configdata, &map);
} else {
return 0;
}
hdr.syncword = 0xfff;
hdr.id = 0;
hdr.layer = 0;
hdr.protection_absent = 1;
hdr.private_bit = 0;
hdr.original_copy = 0;
hdr.home = 0;
hdr.copyright_identification_bit = 0;
hdr.copyright_identification_start = 0;
hdr.aac_frame_length = 0;
hdr.adts_buffer_fullness = 0x7ff;
gst_buffer_map(buffer, &map, GST_MAP_WRITE);
buf = map.data;
if (buf) {
buf[0] = (char) (hdr.syncword >> 4);
buf[1] = (char) ((hdr.syncword & 0xf << 4) ;
buf[2] = (char) ((hdr.profile << 6) ;
buf[3] = (char) (((hdr.channel_configuration & 0x3) << 6));
buf[4] = (char) ((hdr.aac_frame_length >> 3) & 0xff);
buf[5] = (char) (((hdr.aac_frame_length & 0x7) << 5);
buf[6] = (char) (((hdr.adts_buffer_fullness & 0x3f) << 2);
gst_buffer_unmap(buffer, &map);
gst_buffer_unref(info->configdata);
info->configdata = gst_buffer_copy(buffer);
gst_buffer_set_size(info->configdata, ADTS_HEADER_SIZE);
} else {
return -1;
}
return 0;
}
=================================
gint adts_startcode(StreamInfo* info, codec_para_t *pcodec, GstBuffer *buffer)
{
gint8 *buf ;
int i;
int size = ADTS_HEADER_SIZE + gst_buffer_get_size(buffer); // 13bit valid
size &= 0x1fff;
guint8 *adts_header=NULL;
GstBuffer *buffer1;
GstMapInfo map;
if (!info->configdata) {
return 0;
}
while (buffer&&gst_buffer_get_size(buffer)>=ADTS_HEADER_SIZE) {
buffer1 = gst_buffer_new_and_alloc(ADTS_HEADER_SIZE);
if (buffer1) {
gst_buffer_copy_into(buffer1, buffer, GST_BUFFER_COPY_DEEP, 0, ADTS_HEADER_SIZE);
gst_buffer_map(buffer1, &map, GST_MAP_READ);
adts_header=map.data;
//gst_buffer_unmap(buffer1, &map);
if (((adts_header[0] << 4) != 0xFFF)
break;
if (((*(adts_header + 4) & 0xFF) << 3))
break;
}
else break;
GST_WARNING(" AAC es has adts header,don't add again");
gst_buffer_unmap(buffer1, &map);
if(adts_header){
gst_buffer_unref(buffer1);
buffer1=NULL;
}
return 0;
}
if(adts_header){
gst_buffer_unmap(buffer1, &map);
gst_buffer_unref(buffer1);
buffer1=NULL;
}
gst_buffer_map(info->configdata, &map, GST_MAP_WRITE);
buf = map.data;
if (buf!=NULL) {
buf[3] = (buf[3] & 0xfc) | (size >> 11);
buf[4] = (size >> 3) & 0xff;
buf[5] = ((size & 0x7) << 5);
if ( gst_buffer_get_size(info->configdata) == ADTS_HEADER_SIZE) {
codec_write(pcodec,buf,gst_buffer_get_size(info->configdata));
}
}
gst_buffer_unmap(info->configdata, &map);
return 0;
}</pre></div><div id="c7" class="bz_comment" style="margin-bottom: 2em;"><div class="bz_comment_head" style="padding-top: 0.1em; padding-bottom: 0.1em; padding-left: 0.5em; background-color: rgb(224, 224, 224);"><span class="bz_comment_actions" style="margin: 0px 0.5em; float: right; font-family: Verdana, sans-serif; font-size: small; line-height: normal;">[<a class="bz_reply_link" href="https://bugzilla.gnome.org/show_bug.cgi?id=767642#add_comment" style="color: rgb(102, 51, 102);">reply</a>] <a href="https://bugzilla.gnome.org/show_bug.cgi?id=767642#" class="bz_collapse_comment" id="comment_link_7" title="Toggle comment display" style="color: rgb(102, 51, 102); text-decoration: none;">[−]</a></span><span class="bz_comment_number" style="margin: 0px 0.5em; float: right; font-family: Verdana, sans-serif; font-size: small; line-height: normal;"><a href="https://bugzilla.gnome.org/show_bug.cgi?id=767642#c7" style="color: rgb(102, 51, 102);">Comment 7</a></span><div><br></div><span class="bz_comment_user" style="margin: 0px 0.5em; font-family: Verdana, sans-serif; font-size: small; line-height: normal;"></span></div></div></div><div><ul>
</ul></div></div>