我写这个问题是为了看看是否有人可能知道这段代码会发生什么。写了以下几行,目的是删除TS数据包的标头位,但是代码有几个问题。
这是代码:
static GstPadProbeReturn TS_Packet (GstPad *padd, GstPadProbeInfo *info, gpointer user_data)
{
guint8 *byte;
gchar *paquete;
gsize count_print=0;
GstBitReader *bytes_cabecera;
GstMapInfo map;
GstBuffer *buffer;
if (GST_EVENT_TYPE (GST_PAD_PROBE_INFO_DATA (info)) != GST_EVENT_EOS){
buffer = GST_PAD_PROBE_INFO_BUFFER (info);
buffer = gst_buffer_make_writable (buffer);
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
byte=(guint8 *)map.data;
while(count_print<map.size){
g_print("\n");
g_print("-Paquete numero del paquete: %d-\n",i);
i=i+1;
for(n=0; n<8 ;n++){
paquete[n]=byte[n+count_print];
g_print(" %02x ",byte[count_print+n]);
}/*for*/
g_print("\n");
bytes_cabecera=gst_bit_reader_new(paquete, map.size);
g_print(" ->stream header (32bits)-\n");
guint8 sync = gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,8);
if(sync==71){
g_print(" Sync_byte: %02x (available) \n",sync);
}else{
g_print(" Sync_byte: %02x (no available) \n",sync);
}/*else*/
guint8 transport_error_indicator = gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,1);
if(transport_error_indicator==0){
g_print(" Transport_error_indicator: %d (No_error)\n", transport_error_indicator);
}else if (transport_error_indicator==1){
g_print(" Transport_error_indicator: %d (Error)\n", transport_error_indicator);
}/*cierro casos de error*/
guint8 Payload_start_indicator = gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,1);
if(Payload_start_indicator==0){
g_print(" Payload_start_indicator: %d (No_Star_indicator_avalible)\n", Payload_start_indicator);
}else if (Payload_start_indicator==1){
g_print(" Payload_start_indicator: %d (Start_indicator_avalible)\n", Payload_start_indicator);
}/*cierro casos de payload start indicator*/
guint8 transport_priority = gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,1);
if(transport_priority==0){
g_print(" Transport_priority: %d (No_Priority_avalibe)\n", transport_priority);
}else if (transport_priority==1){
g_print(" Transport_priority: %d (Priority_avalible)\n", transport_priority);
}/*cierro casos de Priority*/
guint16 pid_ts= gst_bit_reader_get_bits_uint16_unchecked(bytes_cabecera,13);
g_print(" PID: %02d \n",pid_ts);
guint8 scramblin_control= gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,2);
if(scramblin_control==0){
g_print(" Scrambling control: %d (Not scrambled)\n", scramblin_control);
}else if (scramblin_control==1){
g_print(" Scrambling control: %d ( Reserved for future use)\n", scramblin_control);
}else if (scramblin_control==2){
g_print(" Scrambling control: %d (Scrambled with even key)\n", scramblin_control);
}else if (scramblin_control==3){
g_print(" Scrambling control: %d (Scrambled with odd key)\n", scramblin_control);
}/*cierro el if del scramblin*/
guint8 Adaptation_field_exist= gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,1);
if(Adaptation_field_exist==0){
g_print(" Adaptation field_exist: %d (No exist)\n", Adaptation_field_exist);
}else if (Adaptation_field_exist==1){
g_print(" Adaptation field_exist: %d (Exist)\n", Adaptation_field_exist);
}/*cAdaptation field*/
guint8 Contains_payload= gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,1);
if(Contains_payload==0){
g_print(" Contains payload: %d (No exist)\n", Contains_payload);
}else if (Contains_payload==1){
g_print(" Contains payload: %d (Exist)\n", Contains_payload);
}/*cAdaptation field*/
guint8 Continuity_counter= gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,4);
g_print(" Continuity counter: %d \n",Continuity_counter);
if(Adaptation_field_exist==1){
g_print(" ->Adaptation Field-\n");
guint8 Adaptation_field_lenght= gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,8);
g_print(" Adaptation field lenght: %d \n",Adaptation_field_lenght);
guint8 Discontinuity_indicator= gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,1);
g_print(" Discontinuity indicator: %d \n",Discontinuity_indicator);
guint8 Random_acces= gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,1);
g_print(" Random Access indicator: %d \n",Random_acces);
guint8 Stream_priority= gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,1);
g_print(" ES_priority indicator: %d \n",Stream_priority);
guint8 PCR_Flag= gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,1);
g_print(" Flag PCR: %d \n",PCR_Flag);
guint8 OPCR_Flag= gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,1);
g_print(" Flag OPCR: %d \n",OPCR_Flag);
//guint8 Splicing_point_flag= gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,1);
//g_print(" Flag Splicing point: %d \n",Splicing_point_flag);
//guint8 Transport_private_data_flag= gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,1);
//g_print(" Flag Transport private data point: %d \n",Transport_private_data_flag);
//guint8 Adaptation_field_extension_flag= gst_bit_reader_get_bits_uint8_unchecked(bytes_cabecera,1);
//g_print(" Adaptation field extension flag: %d \n",Adaptation_field_extension_flag);
}/*cierro el caso para mi adaptation field*/
g_print("\n");
count_print=count_print+188;
}/*cierro el while*/
gst_buffer_unmap (buffer, &map);
}/*general*/
return GST_PAD_PROBE_OK;
}/*pad probe*/
问题和怀疑:
1)当我添加更多分析元素&#34;拼接点标记&#34; eclipse不执行代码,somo显示行g:print,并完成。
2)条件if(n,n&lt; 8; n ++)是否给它一个大于8的值只显示ts文件的有限数量的包,而不是全部。 有谁知道为什么会出现这些问题,或者以不同的方式做同样的事情呢?
答案 0 :(得分:0)
通过此修改,我现在可以调整8 188中的一个并查看所有项目。