for #250, add comments for elemetary stream specifed by stream_id.
正在显示
3 个修改的文件
包含
191 行增加
和
69 行删除
| @@ -36,6 +36,8 @@ using namespace std; | @@ -36,6 +36,8 @@ using namespace std; | ||
| 36 | #include <srs_kernel_stream.hpp> | 36 | #include <srs_kernel_stream.hpp> |
| 37 | #include <srs_kernel_ts.hpp> | 37 | #include <srs_kernel_ts.hpp> |
| 38 | #include <srs_kernel_buffer.hpp> | 38 | #include <srs_kernel_buffer.hpp> |
| 39 | +#include <srs_kernel_file.hpp> | ||
| 40 | +#include <srs_core_autofree.hpp> | ||
| 39 | 41 | ||
| 40 | #ifdef SRS_AUTO_STREAM_CASTER | 42 | #ifdef SRS_AUTO_STREAM_CASTER |
| 41 | 43 | ||
| @@ -72,6 +74,39 @@ int SrsMpegtsOverUdp::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf) | @@ -72,6 +74,39 @@ int SrsMpegtsOverUdp::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf) | ||
| 72 | // append to buffer. | 74 | // append to buffer. |
| 73 | buffer->append(buf, nb_buf); | 75 | buffer->append(buf, nb_buf); |
| 74 | 76 | ||
| 77 | + srs_info("udp: got %s:%d packet %d/%d bytes", | ||
| 78 | + peer_ip.c_str(), peer_port, nb_buf, buffer->length()); | ||
| 79 | + | ||
| 80 | + // collect nMB data to parse in a time. | ||
| 81 | + // TODO: FIXME: comment the following for release. | ||
| 82 | + //if (buffer->length() < 3 * 1024 * 1024) return ret; | ||
| 83 | + // TODO: FIXME: remove the debug to file. | ||
| 84 | +#if 0 | ||
| 85 | + SrsFileWriter fw; | ||
| 86 | + if ((ret = fw.open("latest.ts")) != ERROR_SUCCESS) { | ||
| 87 | + return ret; | ||
| 88 | + } | ||
| 89 | + if ((ret = fw.write(buffer->bytes(), buffer->length(), NULL)) != ERROR_SUCCESS) { | ||
| 90 | + return ret; | ||
| 91 | + } | ||
| 92 | + fw.close(); | ||
| 93 | +#endif | ||
| 94 | +#if 0 | ||
| 95 | + SrsFileReader fr; | ||
| 96 | + if ((ret = fr.open("latest.ts")) != ERROR_SUCCESS) { | ||
| 97 | + return ret; | ||
| 98 | + } | ||
| 99 | + buffer->erase(buffer->length()); | ||
| 100 | + int nb_fbuf = fr.filesize(); | ||
| 101 | + char* fbuf = new char[nb_fbuf]; | ||
| 102 | + SrsAutoFree(char, fbuf); | ||
| 103 | + if ((ret = fr.read(fbuf, nb_fbuf, NULL)) != ERROR_SUCCESS) { | ||
| 104 | + return ret; | ||
| 105 | + } | ||
| 106 | + fr.close(); | ||
| 107 | + buffer->append(fbuf, nb_fbuf); | ||
| 108 | +#endif | ||
| 109 | + | ||
| 75 | // find the sync byte of mpegts. | 110 | // find the sync byte of mpegts. |
| 76 | char* p = buffer->bytes(); | 111 | char* p = buffer->bytes(); |
| 77 | for (int i = 0; i < buffer->length(); i++) { | 112 | for (int i = 0; i < buffer->length(); i++) { |
| @@ -87,12 +122,10 @@ int SrsMpegtsOverUdp::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf) | @@ -87,12 +122,10 @@ int SrsMpegtsOverUdp::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf) | ||
| 87 | 122 | ||
| 88 | // drop ts packet when size not modulus by 188 | 123 | // drop ts packet when size not modulus by 188 |
| 89 | if (buffer->length() < SRS_TS_PACKET_SIZE) { | 124 | if (buffer->length() < SRS_TS_PACKET_SIZE) { |
| 90 | - srs_info("udp: wait %s:%d packet %d/%d bytes", | 125 | + srs_warn("udp: wait %s:%d packet %d/%d bytes", |
| 91 | peer_ip.c_str(), peer_port, nb_buf, buffer->length()); | 126 | peer_ip.c_str(), peer_port, nb_buf, buffer->length()); |
| 92 | return ret; | 127 | return ret; |
| 93 | } | 128 | } |
| 94 | - srs_info("udp: got %s:%d packet %d/%d bytes", | ||
| 95 | - peer_ip.c_str(), peer_port, nb_buf, buffer->length()); | ||
| 96 | 129 | ||
| 97 | // use stream to parse ts packet. | 130 | // use stream to parse ts packet. |
| 98 | int nb_packet = buffer->length() / SRS_TS_PACKET_SIZE; | 131 | int nb_packet = buffer->length() / SRS_TS_PACKET_SIZE; |
| @@ -122,6 +155,49 @@ int SrsMpegtsOverUdp::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf) | @@ -122,6 +155,49 @@ int SrsMpegtsOverUdp::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf) | ||
| 122 | int SrsMpegtsOverUdp::on_ts_message(SrsTsMessage* msg) | 155 | int SrsMpegtsOverUdp::on_ts_message(SrsTsMessage* msg) |
| 123 | { | 156 | { |
| 124 | int ret = ERROR_SUCCESS; | 157 | int ret = ERROR_SUCCESS; |
| 158 | + | ||
| 159 | + // about the bytes of msg, specified by elementary stream which indicates by PES_packet_data_byte and stream_id | ||
| 160 | + // for example, when SrsTsStream of SrsTsChannel indicates stream_type is SrsTsStreamVideoMpeg4 and SrsTsStreamAudioMpeg4, | ||
| 161 | + // the elementary stream can be mux in "2.11 Carriage of ISO/IEC 14496 data" in hls-mpeg-ts-iso13818-1.pdf, page 103 | ||
| 162 | + // @remark, the most popular stream_id is 0xe0 for h.264 over mpegts, which indicates the stream_id is video and | ||
| 163 | + // stream_number is 0, where I guess the elementary is specified in 13818-2(video part). | ||
| 164 | + // because when audio stream_number is 0, the elementary is ADTS specified in 13818-7(aac part). | ||
| 165 | + | ||
| 166 | + // about the bytes of PES_packet_data_byte, defined in hls-mpeg-ts-iso13818-1.pdf, page 58 | ||
| 167 | + // PES_packet_data_byte ¨C PES_packet_data_bytes shall be contiguous bytes of data from the elementary stream | ||
| 168 | + // indicated by the packet¡¯s stream_id or PID. When the elementary stream data conforms to ITU-T | ||
| 169 | + // Rec. H.262 | ISO/IEC 13818-2 or ISO/IEC 13818-3, the PES_packet_data_bytes shall be byte aligned to the bytes of this | ||
| 170 | + // Recommendation | International Standard. The byte-order of the elementary stream shall be preserved. The number of | ||
| 171 | + // PES_packet_data_bytes, N, is specified by the PES_packet_length field. N shall be equal to the value indicated in the | ||
| 172 | + // PES_packet_length minus the number of bytes between the last byte of the PES_packet_length field and the first | ||
| 173 | + // PES_packet_data_byte. | ||
| 174 | + // | ||
| 175 | + // In the case of a private_stream_1, private_stream_2, ECM_stream, or EMM_stream, the contents of the | ||
| 176 | + // PES_packet_data_byte field are user definable and will not be specified by ITU-T | ISO/IEC in the future. | ||
| 177 | + | ||
| 178 | + // about the bytes of stream_id, define in hls-mpeg-ts-iso13818-1.pdf, page 49 | ||
| 179 | + // stream_id ¨C In Program Streams, the stream_id specifies the type and number of the elementary stream as defined by the | ||
| 180 | + // stream_id Table 2-18. In Transport Streams, the stream_id may be set to any valid value which correctly describes the | ||
| 181 | + // elementary stream type as defined in Table 2-18. In Transport Streams, the elementary stream type is specified in the | ||
| 182 | + // Program Specific Information as specified in 2.4.4. | ||
| 183 | + | ||
| 184 | + // about the stream_id table, define in Table 2-18 ¨C Stream_id assignments, hls-mpeg-ts-iso13818-1.pdf, page 52. | ||
| 185 | + // | ||
| 186 | + // 110x xxxx | ||
| 187 | + // ISO/IEC 13818-3 or ISO/IEC 11172-3 or ISO/IEC 13818-7 or ISO/IEC | ||
| 188 | + // 14496-3 audio stream number x xxxx | ||
| 189 | + // ((sid >> 5) & 0x07) == SrsTsPESStreamIdAudio | ||
| 190 | + // | ||
| 191 | + // 1110 xxxx | ||
| 192 | + // ITU-T Rec. H.262 | ISO/IEC 13818-2 or ISO/IEC 11172-2 or ISO/IEC | ||
| 193 | + // 14496-2 video stream number xxxx | ||
| 194 | + // ((stream_id >> 4) & 0x0f) == SrsTsPESStreamIdVideo | ||
| 195 | + | ||
| 196 | + srs_trace("mpegts: got %s dts=%"PRId64", pts=%"PRId64", size=%d, us=%d, cc=%d, sid=%#x(%s-%d)", | ||
| 197 | + (msg->channel->apply == SrsTsPidApplyVideo)? "Video":"Audio", msg->dts, msg->pts, msg->payload->length(), | ||
| 198 | + msg->packet->payload_unit_start_indicator, msg->continuity_counter, msg->sid, | ||
| 199 | + msg->is_audio()? "A":msg->is_video()? "V":"N", msg->stream_number()); | ||
| 200 | + | ||
| 125 | // TODO: FIXME: implements it. | 201 | // TODO: FIXME: implements it. |
| 126 | return ret; | 202 | return ret; |
| 127 | } | 203 | } |
| @@ -421,6 +421,7 @@ SrsTsMessage::SrsTsMessage(SrsTsChannel* c, SrsTsPacket* p) | @@ -421,6 +421,7 @@ SrsTsMessage::SrsTsMessage(SrsTsChannel* c, SrsTsPacket* p) | ||
| 421 | packet = p; | 421 | packet = p; |
| 422 | 422 | ||
| 423 | dts = pts = 0; | 423 | dts = pts = 0; |
| 424 | + sid = (SrsTsPESStreamId)0x00; | ||
| 424 | continuity_counter = 0; | 425 | continuity_counter = 0; |
| 425 | PES_packet_length = 0; | 426 | PES_packet_length = 0; |
| 426 | payload = new SrsSimpleBuffer(); | 427 | payload = new SrsSimpleBuffer(); |
| @@ -474,6 +475,26 @@ bool SrsTsMessage::fresh() | @@ -474,6 +475,26 @@ bool SrsTsMessage::fresh() | ||
| 474 | return payload->length() == 0; | 475 | return payload->length() == 0; |
| 475 | } | 476 | } |
| 476 | 477 | ||
| 478 | +bool SrsTsMessage::is_audio() | ||
| 479 | +{ | ||
| 480 | + return ((sid >> 5) & 0x07) == SrsTsPESStreamIdAudio; | ||
| 481 | +} | ||
| 482 | + | ||
| 483 | +bool SrsTsMessage::is_video() | ||
| 484 | +{ | ||
| 485 | + return ((sid >> 4) & 0x0f) == SrsTsPESStreamIdVideo; | ||
| 486 | +} | ||
| 487 | + | ||
| 488 | +int SrsTsMessage::stream_number() | ||
| 489 | +{ | ||
| 490 | + if (is_audio()) { | ||
| 491 | + return sid & 0x1f; | ||
| 492 | + } else if (is_video()) { | ||
| 493 | + return sid & 0x0f; | ||
| 494 | + } | ||
| 495 | + return -1; | ||
| 496 | +} | ||
| 497 | + | ||
| 477 | ISrsTsHandler::ISrsTsHandler() | 498 | ISrsTsHandler::ISrsTsHandler() |
| 478 | { | 499 | { |
| 479 | } | 500 | } |
| @@ -945,21 +966,22 @@ int SrsTsPayloadPES::decode(SrsStream* stream, SrsTsMessage** ppmsg) | @@ -945,21 +966,22 @@ int SrsTsPayloadPES::decode(SrsStream* stream, SrsTsMessage** ppmsg) | ||
| 945 | // should be 1 for the fresh msg. | 966 | // should be 1 for the fresh msg. |
| 946 | if (msg->fresh() && !packet->payload_unit_start_indicator) { | 967 | if (msg->fresh() && !packet->payload_unit_start_indicator) { |
| 947 | ret = ERROR_STREAM_CASTER_TS_PSE; | 968 | ret = ERROR_STREAM_CASTER_TS_PSE; |
| 948 | - srs_error("ts: PES fresh packet length=%d, unit_start=%d. ret=%d", | ||
| 949 | - msg->PES_packet_length, packet->payload_unit_start_indicator, ret); | 969 | + srs_error("ts: PES fresh packet length=%d, us=%d, cc=%d. ret=%d", |
| 970 | + msg->PES_packet_length, packet->payload_unit_start_indicator, packet->continuity_counter, | ||
| 971 | + ret); | ||
| 950 | return ret; | 972 | return ret; |
| 951 | } | 973 | } |
| 952 | 974 | ||
| 953 | // check when not fresh and PES_packet_length>0, | 975 | // check when not fresh and PES_packet_length>0, |
| 954 | // the payload_unit_start_indicator should never be 1 when not completed. | 976 | // the payload_unit_start_indicator should never be 1 when not completed. |
| 955 | if (!msg->fresh() && msg->PES_packet_length > 0 | 977 | if (!msg->fresh() && msg->PES_packet_length > 0 |
| 956 | - && packet->payload_unit_start_indicator | ||
| 957 | && !msg->completed(packet->payload_unit_start_indicator) | 978 | && !msg->completed(packet->payload_unit_start_indicator) |
| 979 | + && packet->payload_unit_start_indicator | ||
| 958 | ) { | 980 | ) { |
| 959 | ret = ERROR_STREAM_CASTER_TS_PSE; | 981 | ret = ERROR_STREAM_CASTER_TS_PSE; |
| 960 | - srs_error("ts: PES packet length=%d, payload=%d, unit_start=%d. ret=%d", | ||
| 961 | - msg->PES_packet_length, msg->payload->length(), | ||
| 962 | - packet->payload_unit_start_indicator, ret); | 982 | + srs_error("ts: PES packet length=%d, payload=%d, us=%d, cc=%d. ret=%d", |
| 983 | + msg->PES_packet_length, msg->payload->length(), packet->payload_unit_start_indicator, | ||
| 984 | + packet->continuity_counter, ret); | ||
| 963 | 985 | ||
| 964 | // reparse current msg. | 986 | // reparse current msg. |
| 965 | stream->skip(stream->pos() * -1); | 987 | stream->skip(stream->pos() * -1); |
| @@ -975,7 +997,7 @@ int SrsTsPayloadPES::decode(SrsStream* stream, SrsTsMessage** ppmsg) | @@ -975,7 +997,7 @@ int SrsTsPayloadPES::decode(SrsStream* stream, SrsTsMessage** ppmsg) | ||
| 975 | if (msg->continuity_counter >= packet->continuity_counter | 997 | if (msg->continuity_counter >= packet->continuity_counter |
| 976 | && ((msg->continuity_counter + 1) & 0x0f) > packet->continuity_counter | 998 | && ((msg->continuity_counter + 1) & 0x0f) > packet->continuity_counter |
| 977 | ) { | 999 | ) { |
| 978 | - srs_warn("ts: drop PES %dB for duplicated continuity=%#x", msg->continuity_counter); | 1000 | + srs_warn("ts: drop PES %dB for duplicated cc=%#x", msg->continuity_counter); |
| 979 | stream->skip(stream->size() - stream->pos()); | 1001 | stream->skip(stream->size() - stream->pos()); |
| 980 | return ret; | 1002 | return ret; |
| 981 | } | 1003 | } |
| @@ -1037,8 +1059,10 @@ int SrsTsPayloadPES::decode(SrsStream* stream, SrsTsMessage** ppmsg) | @@ -1037,8 +1059,10 @@ int SrsTsPayloadPES::decode(SrsStream* stream, SrsTsMessage** ppmsg) | ||
| 1037 | } | 1059 | } |
| 1038 | int pos_packet = stream->pos(); | 1060 | int pos_packet = stream->pos(); |
| 1039 | 1061 | ||
| 1040 | - // @remark SrsTsPESStreamIdAudio and SrsTsPESStreamIdVideo is not used here. | 1062 | + // @remark the sid indicates the elementary stream format. |
| 1063 | + // the SrsTsPESStreamIdAudio and SrsTsPESStreamIdVideo is start by 0b110 or 0b1110 | ||
| 1041 | SrsTsPESStreamId sid = (SrsTsPESStreamId)stream_id; | 1064 | SrsTsPESStreamId sid = (SrsTsPESStreamId)stream_id; |
| 1065 | + msg->sid = sid; | ||
| 1042 | 1066 | ||
| 1043 | if (sid != SrsTsPESStreamIdProgramStreamMap | 1067 | if (sid != SrsTsPESStreamIdProgramStreamMap |
| 1044 | && sid != SrsTsPESStreamIdPaddingStream | 1068 | && sid != SrsTsPESStreamIdPaddingStream |
| @@ -162,6 +162,7 @@ enum SrsTsStream | @@ -162,6 +162,7 @@ enum SrsTsStream | ||
| 162 | // ISO/IEC 14496-2 Visual | 162 | // ISO/IEC 14496-2 Visual |
| 163 | SrsTsStreamVideoMpeg4 = 0x10, | 163 | SrsTsStreamVideoMpeg4 = 0x10, |
| 164 | // ISO/IEC 14496-3 Audio with the LATM transport syntax as defined in ISO/IEC 14496-3 / AMD 1 | 164 | // ISO/IEC 14496-3 Audio with the LATM transport syntax as defined in ISO/IEC 14496-3 / AMD 1 |
| 165 | + SrsTsStreamAudioMpeg4 = 0x11, | ||
| 165 | // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in PES packets | 166 | // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in PES packets |
| 166 | // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in ISO/IEC14496_sections. | 167 | // ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in ISO/IEC14496_sections. |
| 167 | // ISO/IEC 13818-6 Synchronized Download Protocol | 168 | // ISO/IEC 13818-6 Synchronized Download Protocol |
| @@ -189,18 +190,82 @@ struct SrsTsChannel | @@ -189,18 +190,82 @@ struct SrsTsChannel | ||
| 189 | }; | 190 | }; |
| 190 | 191 | ||
| 191 | /** | 192 | /** |
| 193 | +* the stream_id of PES payload of ts packet. | ||
| 194 | +* Table 2-18 – Stream_id assignments, hls-mpeg-ts-iso13818-1.pdf, page 52. | ||
| 195 | +*/ | ||
| 196 | +enum SrsTsPESStreamId | ||
| 197 | +{ | ||
| 198 | + // program_stream_map | ||
| 199 | + SrsTsPESStreamIdProgramStreamMap = 0xbc, // 0b10111100 | ||
| 200 | + // private_stream_1 | ||
| 201 | + SrsTsPESStreamIdPrivateStream1 = 0xbd, // 0b10111101 | ||
| 202 | + // padding_stream | ||
| 203 | + SrsTsPESStreamIdPaddingStream = 0xbe, // 0b10111110 | ||
| 204 | + // private_stream_2 | ||
| 205 | + SrsTsPESStreamIdPrivateStream2 = 0xbf, // 0b10111111 | ||
| 206 | + | ||
| 207 | + // 110x xxxx | ||
| 208 | + // ISO/IEC 13818-3 or ISO/IEC 11172-3 or ISO/IEC 13818-7 or ISO/IEC | ||
| 209 | + // 14496-3 audio stream number x xxxx | ||
| 210 | + // ((sid >> 5) & 0x07) == SrsTsPESStreamIdAudio | ||
| 211 | + SrsTsPESStreamIdAudio = 0x06, // 0b110 | ||
| 212 | + | ||
| 213 | + // 1110 xxxx | ||
| 214 | + // ITU-T Rec. H.262 | ISO/IEC 13818-2 or ISO/IEC 11172-2 or ISO/IEC | ||
| 215 | + // 14496-2 video stream number xxxx | ||
| 216 | + // ((stream_id >> 4) & 0x0f) == SrsTsPESStreamIdVideo | ||
| 217 | + SrsTsPESStreamIdVideo = 0x0e, // 0b1110 | ||
| 218 | + | ||
| 219 | + // ECM_stream | ||
| 220 | + SrsTsPESStreamIdEcmStream = 0xf0, // 0b11110000 | ||
| 221 | + // EMM_stream | ||
| 222 | + SrsTsPESStreamIdEmmStream = 0xf1, // 0b11110001 | ||
| 223 | + // DSMCC_stream | ||
| 224 | + SrsTsPESStreamIdDsmccStream = 0xf2, // 0b11110010 | ||
| 225 | + // 13522_stream | ||
| 226 | + SrsTsPESStreamId13522Stream = 0xf3, // 0b11110011 | ||
| 227 | + // H_222_1_type_A | ||
| 228 | + SrsTsPESStreamIdH2221TypeA = 0xf4, // 0b11110100 | ||
| 229 | + // H_222_1_type_B | ||
| 230 | + SrsTsPESStreamIdH2221TypeB = 0xf5, // 0b11110101 | ||
| 231 | + // H_222_1_type_C | ||
| 232 | + SrsTsPESStreamIdH2221TypeC = 0xf6, // 0b11110110 | ||
| 233 | + // H_222_1_type_D | ||
| 234 | + SrsTsPESStreamIdH2221TypeD = 0xf7, // 0b11110111 | ||
| 235 | + // H_222_1_type_E | ||
| 236 | + SrsTsPESStreamIdH2221TypeE = 0xf8, // 0b11111000 | ||
| 237 | + // ancillary_stream | ||
| 238 | + SrsTsPESStreamIdAncillaryStream = 0xf9, // 0b11111001 | ||
| 239 | + // SL_packetized_stream | ||
| 240 | + SrsTsPESStreamIdSlPacketizedStream = 0xfa, // 0b11111010 | ||
| 241 | + // FlexMux_stream | ||
| 242 | + SrsTsPESStreamIdFlexMuxStream = 0xfb, // 0b11111011 | ||
| 243 | + // reserved data stream | ||
| 244 | + // 1111 1100 … 1111 1110 | ||
| 245 | + // program_stream_directory | ||
| 246 | + SrsTsPESStreamIdProgramStreamDirectory = 0xff, // 0b11111111 | ||
| 247 | +}; | ||
| 248 | + | ||
| 249 | +/** | ||
| 192 | * the media audio/video message parsed from PES packet. | 250 | * the media audio/video message parsed from PES packet. |
| 193 | */ | 251 | */ |
| 194 | class SrsTsMessage | 252 | class SrsTsMessage |
| 195 | { | 253 | { |
| 196 | -private: | 254 | +public: |
| 197 | SrsTsChannel* channel; | 255 | SrsTsChannel* channel; |
| 198 | SrsTsPacket* packet; | 256 | SrsTsPacket* packet; |
| 199 | public: | 257 | public: |
| 258 | + // the timestamp in 90khz | ||
| 200 | int64_t dts; | 259 | int64_t dts; |
| 201 | int64_t pts; | 260 | int64_t pts; |
| 261 | + // the id of pes stream to indicates the payload codec. | ||
| 262 | + // @remark use is_audio() and is_video() to check it, and stream_number() to finger it out. | ||
| 263 | + SrsTsPESStreamId sid; | ||
| 264 | + // the size of payload, 0 indicates the length() of payload. | ||
| 202 | u_int16_t PES_packet_length; | 265 | u_int16_t PES_packet_length; |
| 266 | + // the chunk id. | ||
| 203 | u_int8_t continuity_counter; | 267 | u_int8_t continuity_counter; |
| 268 | + // the payload bytes. | ||
| 204 | SrsSimpleBuffer* payload; | 269 | SrsSimpleBuffer* payload; |
| 205 | public: | 270 | public: |
| 206 | SrsTsMessage(SrsTsChannel* c, SrsTsPacket* p); | 271 | SrsTsMessage(SrsTsChannel* c, SrsTsPacket* p); |
| @@ -223,6 +288,20 @@ public: | @@ -223,6 +288,20 @@ public: | ||
| 223 | * whether the message is fresh. | 288 | * whether the message is fresh. |
| 224 | */ | 289 | */ |
| 225 | virtual bool fresh(); | 290 | virtual bool fresh(); |
| 291 | +public: | ||
| 292 | + /** | ||
| 293 | + * whether the sid indicates the elementary stream audio. | ||
| 294 | + */ | ||
| 295 | + virtual bool is_audio(); | ||
| 296 | + /** | ||
| 297 | + * whether the sid indicates the elementary stream video. | ||
| 298 | + */ | ||
| 299 | + virtual bool is_video(); | ||
| 300 | + /** | ||
| 301 | + * when audio or video, get the stream number which specifies the format of stream. | ||
| 302 | + * @return the stream number for audio/video; otherwise, -1. | ||
| 303 | + */ | ||
| 304 | + virtual int stream_number(); | ||
| 226 | }; | 305 | }; |
| 227 | 306 | ||
| 228 | /** | 307 | /** |
| @@ -723,63 +802,6 @@ public: | @@ -723,63 +802,6 @@ public: | ||
| 723 | }; | 802 | }; |
| 724 | 803 | ||
| 725 | /** | 804 | /** |
| 726 | -* the stream_id of PES payload of ts packet. | ||
| 727 | -* Table 2-18 – Stream_id assignments, hls-mpeg-ts-iso13818-1.pdf, page 52. | ||
| 728 | -*/ | ||
| 729 | -enum SrsTsPESStreamId | ||
| 730 | -{ | ||
| 731 | - // program_stream_map | ||
| 732 | - SrsTsPESStreamIdProgramStreamMap = 0xbc, // 0b10111100 | ||
| 733 | - // private_stream_1 | ||
| 734 | - SrsTsPESStreamIdPrivateStream1 = 0xbd, // 0b10111101 | ||
| 735 | - // padding_stream | ||
| 736 | - SrsTsPESStreamIdPaddingStream = 0xbe, // 0b10111110 | ||
| 737 | - // private_stream_2 | ||
| 738 | - SrsTsPESStreamIdPrivateStream2 = 0xbf, // 0b10111111 | ||
| 739 | - | ||
| 740 | - // 110x xxxx | ||
| 741 | - // ISO/IEC 13818-3 or ISO/IEC 11172-3 or ISO/IEC 13818-7 or ISO/IEC | ||
| 742 | - // 14496-3 audio stream number x xxxx | ||
| 743 | - // (stream_id>>5)&0x07 == SrsTsPESStreamIdAudio | ||
| 744 | - SrsTsPESStreamIdAudio = 0x06, // 0b110 | ||
| 745 | - | ||
| 746 | - // 1110 xxxx | ||
| 747 | - // ITU-T Rec. H.262 | ISO/IEC 13818-2 or ISO/IEC 11172-2 or ISO/IEC | ||
| 748 | - // 14496-2 video stream number xxxx | ||
| 749 | - // (stream_id>>4)&0x0f == SrsTsPESStreamIdVideo | ||
| 750 | - SrsTsPESStreamIdVideo = 0x0e, // 0b1110 | ||
| 751 | - | ||
| 752 | - // ECM_stream | ||
| 753 | - SrsTsPESStreamIdEcmStream = 0xf0, // 0b11110000 | ||
| 754 | - // EMM_stream | ||
| 755 | - SrsTsPESStreamIdEmmStream = 0xf1, // 0b11110001 | ||
| 756 | - // DSMCC_stream | ||
| 757 | - SrsTsPESStreamIdDsmccStream = 0xf2, // 0b11110010 | ||
| 758 | - // 13522_stream | ||
| 759 | - SrsTsPESStreamId13522Stream = 0xf3, // 0b11110011 | ||
| 760 | - // H_222_1_type_A | ||
| 761 | - SrsTsPESStreamIdH2221TypeA = 0xf4, // 0b11110100 | ||
| 762 | - // H_222_1_type_B | ||
| 763 | - SrsTsPESStreamIdH2221TypeB = 0xf5, // 0b11110101 | ||
| 764 | - // H_222_1_type_C | ||
| 765 | - SrsTsPESStreamIdH2221TypeC = 0xf6, // 0b11110110 | ||
| 766 | - // H_222_1_type_D | ||
| 767 | - SrsTsPESStreamIdH2221TypeD = 0xf7, // 0b11110111 | ||
| 768 | - // H_222_1_type_E | ||
| 769 | - SrsTsPESStreamIdH2221TypeE = 0xf8, // 0b11111000 | ||
| 770 | - // ancillary_stream | ||
| 771 | - SrsTsPESStreamIdAncillaryStream = 0xf9, // 0b11111001 | ||
| 772 | - // SL_packetized_stream | ||
| 773 | - SrsTsPESStreamIdSlPacketizedStream = 0xfa, // 0b11111010 | ||
| 774 | - // FlexMux_stream | ||
| 775 | - SrsTsPESStreamIdFlexMuxStream = 0xfb, // 0b11111011 | ||
| 776 | - // reserved data stream | ||
| 777 | - // 1111 1100 … 1111 1110 | ||
| 778 | - // program_stream_directory | ||
| 779 | - SrsTsPESStreamIdProgramStreamDirectory = 0xff, // 0b11111111 | ||
| 780 | -}; | ||
| 781 | - | ||
| 782 | -/** | ||
| 783 | * the PES payload of ts packet. | 805 | * the PES payload of ts packet. |
| 784 | * 2.4.3.6 PES packet, hls-mpeg-ts-iso13818-1.pdf, page 49 | 806 | * 2.4.3.6 PES packet, hls-mpeg-ts-iso13818-1.pdf, page 49 |
| 785 | */ | 807 | */ |
-
请 注册 或 登录 后发表评论