winlin

print the nalu of avc

@@ -2105,6 +2105,7 @@ int consume(TSMessage* msg, AacMuxer* aac_muxer) @@ -2105,6 +2105,7 @@ int consume(TSMessage* msg, AacMuxer* aac_muxer)
2105 (msg->dts == 0)? msg->pts : msg->dts, msg->packet_data_size); 2105 (msg->dts == 0)? msg->pts : msg->dts, msg->packet_data_size);
2106 2106
2107 // parse H264 video. 2107 // parse H264 video.
  2108 + bool first = true;
2108 while (p < last) { 2109 while (p < last) {
2109 TSH264Codec h264; 2110 TSH264Codec h264;
2110 if ((ret = h264.parse(msg, last, p)) != 0) { 2111 if ((ret = h264.parse(msg, last, p)) != 0) {
@@ -2112,8 +2113,55 @@ int consume(TSMessage* msg, AacMuxer* aac_muxer) @@ -2112,8 +2113,55 @@ int consume(TSMessage* msg, AacMuxer* aac_muxer)
2112 } 2113 }
2113 trace("ts+h264 video raw data parsed, size: %d, 0x%02x 0x%02x 0x%02x 0x%02x", 2114 trace("ts+h264 video raw data parsed, size: %d, 0x%02x 0x%02x 0x%02x 0x%02x",
2114 h264.size, h264.at(0), h264.at(1), h264.at(2), h264.at(3)); 2115 h264.size, h264.at(0), h264.at(1), h264.at(2), h264.at(3));
  2116 +
  2117 + // first?
  2118 + if (!first) {
  2119 + continue;
  2120 + }
  2121 + first = false;
2115 2122
2116 // TODO: process video. 2123 // TODO: process video.
  2124 +
  2125 + // directly check the sequence header for test_22m.flv
  2126 + if (h264.at(0) == 0x67 && h264.at(1) == 0x00 && h264.at(2) == 0x1f && h264.at(3) == 0xac) {
  2127 + trace("ts+h264 directly find the sequence header for test_22m.flv");
  2128 + }
  2129 + // 7.3.1 NAL unit syntax, hls-mpeg-ts-iso13818-1.pdf, page 44
  2130 + char* pp = (char*)h264.raw_data;
  2131 + int8_t nal_unit_type = *pp++;
  2132 + int8_t nal_ref_idc = (nal_unit_type >> 5) & 0x03;
  2133 + nal_unit_type &= 0x1f;
  2134 + if (nal_ref_idc != 0) {
  2135 + trace("ts+h264 got an SPS or PPS.");
  2136 + }
  2137 + if (nal_unit_type == 7) {
  2138 + trace("ts+h264 got an SPS.");
  2139 + } else if (nal_unit_type == 8) {
  2140 + trace("ts+h264 got an PPS.");
  2141 + } else if (nal_unit_type == 9) {
  2142 + trace("ts+h264 got an Picture delimiter.");
  2143 + int8_t pic_type = *pp++;
  2144 + pic_type = (pic_type >> 6) & 0x07;
  2145 + if (pic_type == 0) {
  2146 + trace("ts+h264 got an I picture.");
  2147 + } else if (pic_type == 1) {
  2148 + trace("ts+h264 got an I,P picture.");
  2149 + } else if (pic_type == 2) {
  2150 + trace("ts+h264 got an I,P,B picture.");
  2151 + } else if (pic_type == 3) {
  2152 + trace("ts+h264 got an SI picture.");
  2153 + } else if (pic_type == 4) {
  2154 + trace("ts+h264 got an SI,SP picture.");
  2155 + } else if (pic_type == 5) {
  2156 + trace("ts+h264 got an I,SI picture.");
  2157 + } else if (pic_type == 6) {
  2158 + trace("ts+h264 got an I,SI,P,SP picture.");
  2159 + } else if (pic_type == 7) {
  2160 + trace("ts+h264 got an I,SI,P,SP,B picture.");
  2161 + }
  2162 + } else {
  2163 + trace("ts+h264 got an unknown unit type: %d.", nal_unit_type);
  2164 + }
2117 } 2165 }
2118 } 2166 }
2119 2167