for #250, demux PES stream ok, only support h.264(annexb) and aac(adts) in mpegts over udp. 3.0.109.
正在显示
5 个修改的文件
包含
32 行增加
和
6 行删除
| @@ -38,6 +38,7 @@ using namespace std; | @@ -38,6 +38,7 @@ using namespace std; | ||
| 38 | #include <srs_kernel_buffer.hpp> | 38 | #include <srs_kernel_buffer.hpp> |
| 39 | #include <srs_kernel_file.hpp> | 39 | #include <srs_kernel_file.hpp> |
| 40 | #include <srs_core_autofree.hpp> | 40 | #include <srs_core_autofree.hpp> |
| 41 | +#include <srs_kernel_utility.hpp> | ||
| 41 | 42 | ||
| 42 | #ifdef SRS_AUTO_STREAM_CASTER | 43 | #ifdef SRS_AUTO_STREAM_CASTER |
| 43 | 44 | ||
| @@ -160,8 +161,8 @@ int SrsMpegtsOverUdp::on_ts_message(SrsTsMessage* msg) | @@ -160,8 +161,8 @@ int SrsMpegtsOverUdp::on_ts_message(SrsTsMessage* msg) | ||
| 160 | // for example, when SrsTsStream of SrsTsChannel indicates stream_type is SrsTsStreamVideoMpeg4 and SrsTsStreamAudioMpeg4, | 161 | // 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 | // 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 | // @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). | 164 | + // stream_number is 0, where I guess the elementary is specified in annexb format(H.264-AVC-ISO_IEC_14496-10.pdf, page 211). |
| 165 | + // because when audio stream_number is 0, the elementary is ADTS(aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 75, 1.A.2.2 ADTS). | ||
| 165 | 166 | ||
| 166 | // about the bytes of PES_packet_data_byte, defined in hls-mpeg-ts-iso13818-1.pdf, page 58 | 167 | // 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 | // PES_packet_data_byte ¨C PES_packet_data_bytes shall be contiguous bytes of data from the elementary stream |
| @@ -193,11 +194,19 @@ int SrsMpegtsOverUdp::on_ts_message(SrsTsMessage* msg) | @@ -193,11 +194,19 @@ int SrsMpegtsOverUdp::on_ts_message(SrsTsMessage* msg) | ||
| 193 | // 14496-2 video stream number xxxx | 194 | // 14496-2 video stream number xxxx |
| 194 | // ((stream_id >> 4) & 0x0f) == SrsTsPESStreamIdVideo | 195 | // ((stream_id >> 4) & 0x0f) == SrsTsPESStreamIdVideo |
| 195 | 196 | ||
| 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, | 197 | + srs_trace("mpegts: got %s stream=%s, dts=%"PRId64", pts=%"PRId64", size=%d, us=%d, cc=%d, sid=%#x(%s-%d)", |
| 198 | + (msg->channel->apply == SrsTsPidApplyVideo)? "Video":"Audio", srs_ts_stream2string(msg->channel->stream).c_str(), | ||
| 199 | + msg->dts, msg->pts, msg->payload->length(), 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 | msg->is_audio()? "A":msg->is_video()? "V":"N", msg->stream_number()); |
| 200 | 201 | ||
| 202 | + // when not audio/video, or not adts/annexb format, donot support. | ||
| 203 | + if (msg->stream_number() != 0) { | ||
| 204 | + ret = ERROR_STREAM_CASTER_TS_ES; | ||
| 205 | + srs_error("mpegts: unsupported stream format, sid=%#x(%s-%d). ret=%d", | ||
| 206 | + msg->sid, msg->is_audio()? "A":msg->is_video()? "V":"N", msg->stream_number(), ret); | ||
| 207 | + return ret; | ||
| 208 | + } | ||
| 209 | + | ||
| 201 | // TODO: FIXME: implements it. | 210 | // TODO: FIXME: implements it. |
| 202 | return ret; | 211 | return ret; |
| 203 | } | 212 | } |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR 2 | 32 | #define VERSION_MAJOR 2 |
| 33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
| 34 | -#define VERSION_REVISION 108 | 34 | +#define VERSION_REVISION 109 |
| 35 | 35 | ||
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
| @@ -227,6 +227,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -227,6 +227,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 227 | #define ERROR_STREAM_CASTER_TS_PAT 4017 | 227 | #define ERROR_STREAM_CASTER_TS_PAT 4017 |
| 228 | #define ERROR_STREAM_CASTER_TS_PMT 4018 | 228 | #define ERROR_STREAM_CASTER_TS_PMT 4018 |
| 229 | #define ERROR_STREAM_CASTER_TS_PSE 4019 | 229 | #define ERROR_STREAM_CASTER_TS_PSE 4019 |
| 230 | +#define ERROR_STREAM_CASTER_TS_ES 4020 | ||
| 230 | 231 | ||
| 231 | /** | 232 | /** |
| 232 | * whether the error code is an system control error. | 233 | * whether the error code is an system control error. |
| @@ -402,6 +402,21 @@ SrsMpegtsFrame::SrsMpegtsFrame() | @@ -402,6 +402,21 @@ SrsMpegtsFrame::SrsMpegtsFrame() | ||
| 402 | key = false; | 402 | key = false; |
| 403 | } | 403 | } |
| 404 | 404 | ||
| 405 | +string srs_ts_stream2string(SrsTsStream stream) | ||
| 406 | +{ | ||
| 407 | + switch (stream) { | ||
| 408 | + case SrsTsStreamReserved: return "Reserved"; | ||
| 409 | + case SrsTsStreamAudioMp3: return "MP3"; | ||
| 410 | + case SrsTsStreamAudioAAC: return "AAC"; | ||
| 411 | + case SrsTsStreamAudioAC3: return "AC3"; | ||
| 412 | + case SrsTsStreamAudioDTS: return "AudioDTS"; | ||
| 413 | + case SrsTsStreamVideoH264: return "H.264"; | ||
| 414 | + case SrsTsStreamVideoMpeg4: return "MP4"; | ||
| 415 | + case SrsTsStreamAudioMpeg4: return "MP4A"; | ||
| 416 | + default: return "Other"; | ||
| 417 | + } | ||
| 418 | +} | ||
| 419 | + | ||
| 405 | SrsTsChannel::SrsTsChannel() | 420 | SrsTsChannel::SrsTsChannel() |
| 406 | { | 421 | { |
| 407 | pid = 0; | 422 | pid = 0; |
| @@ -174,6 +174,7 @@ enum SrsTsStream | @@ -174,6 +174,7 @@ enum SrsTsStream | ||
| 174 | SrsTsStreamAudioAC3 = 0x81, | 174 | SrsTsStreamAudioAC3 = 0x81, |
| 175 | SrsTsStreamAudioDTS = 0x8a, | 175 | SrsTsStreamAudioDTS = 0x8a, |
| 176 | }; | 176 | }; |
| 177 | +std::string srs_ts_stream2string(SrsTsStream stream); | ||
| 177 | 178 | ||
| 178 | /** | 179 | /** |
| 179 | * the ts channel. | 180 | * the ts channel. |
-
请 注册 或 登录 后发表评论