Skip to content

Commit

Permalink
for ossrs#250, demux PES stream ok, only support h.264(annexb) and aa…
Browse files Browse the repository at this point in the history
…c(adts) in mpegts over udp. 3.0.109.
  • Loading branch information
winlinvip committed Jan 31, 2015
1 parent bce78fd commit 66fccdb
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
19 changes: 14 additions & 5 deletions trunk/src/app/srs_app_mpegts_udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ using namespace std;
#include <srs_kernel_buffer.hpp>
#include <srs_kernel_file.hpp>
#include <srs_core_autofree.hpp>
#include <srs_kernel_utility.hpp>

#ifdef SRS_AUTO_STREAM_CASTER

Expand Down Expand Up @@ -160,8 +161,8 @@ int SrsMpegtsOverUdp::on_ts_message(SrsTsMessage* msg)
// for example, when SrsTsStream of SrsTsChannel indicates stream_type is SrsTsStreamVideoMpeg4 and SrsTsStreamAudioMpeg4,
// the elementary stream can be mux in "2.11 Carriage of ISO/IEC 14496 data" in hls-mpeg-ts-iso13818-1.pdf, page 103
// @remark, the most popular stream_id is 0xe0 for h.264 over mpegts, which indicates the stream_id is video and
// stream_number is 0, where I guess the elementary is specified in 13818-2(video part).
// because when audio stream_number is 0, the elementary is ADTS specified in 13818-7(aac part).
// stream_number is 0, where I guess the elementary is specified in annexb format(H.264-AVC-ISO_IEC_14496-10.pdf, page 211).
// 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).

// about the bytes of PES_packet_data_byte, defined in hls-mpeg-ts-iso13818-1.pdf, page 58
// PES_packet_data_byte ¨C PES_packet_data_bytes shall be contiguous bytes of data from the elementary stream
Expand Down Expand Up @@ -193,11 +194,19 @@ int SrsMpegtsOverUdp::on_ts_message(SrsTsMessage* msg)
// 14496-2 video stream number xxxx
// ((stream_id >> 4) & 0x0f) == SrsTsPESStreamIdVideo

srs_trace("mpegts: got %s dts=%"PRId64", pts=%"PRId64", size=%d, us=%d, cc=%d, sid=%#x(%s-%d)",
(msg->channel->apply == SrsTsPidApplyVideo)? "Video":"Audio", msg->dts, msg->pts, msg->payload->length(),
msg->packet->payload_unit_start_indicator, msg->continuity_counter, msg->sid,
srs_trace("mpegts: got %s stream=%s, dts=%"PRId64", pts=%"PRId64", size=%d, us=%d, cc=%d, sid=%#x(%s-%d)",
(msg->channel->apply == SrsTsPidApplyVideo)? "Video":"Audio", srs_ts_stream2string(msg->channel->stream).c_str(),
msg->dts, msg->pts, msg->payload->length(), msg->packet->payload_unit_start_indicator, msg->continuity_counter, msg->sid,
msg->is_audio()? "A":msg->is_video()? "V":"N", msg->stream_number());

// when not audio/video, or not adts/annexb format, donot support.
if (msg->stream_number() != 0) {
ret = ERROR_STREAM_CASTER_TS_ES;
srs_error("mpegts: unsupported stream format, sid=%#x(%s-%d). ret=%d",
msg->sid, msg->is_audio()? "A":msg->is_video()? "V":"N", msg->stream_number(), ret);
return ret;
}

// TODO: FIXME: implements it.
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 108
#define VERSION_REVISION 109

// server info.
#define RTMP_SIG_SRS_KEY "SRS"
Expand Down
1 change: 1 addition & 0 deletions trunk/src/kernel/srs_kernel_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define ERROR_STREAM_CASTER_TS_PAT 4017
#define ERROR_STREAM_CASTER_TS_PMT 4018
#define ERROR_STREAM_CASTER_TS_PSE 4019
#define ERROR_STREAM_CASTER_TS_ES 4020

/**
* whether the error code is an system control error.
Expand Down
15 changes: 15 additions & 0 deletions trunk/src/kernel/srs_kernel_ts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,21 @@ SrsMpegtsFrame::SrsMpegtsFrame()
key = false;
}

string srs_ts_stream2string(SrsTsStream stream)
{
switch (stream) {
case SrsTsStreamReserved: return "Reserved";
case SrsTsStreamAudioMp3: return "MP3";
case SrsTsStreamAudioAAC: return "AAC";
case SrsTsStreamAudioAC3: return "AC3";
case SrsTsStreamAudioDTS: return "AudioDTS";
case SrsTsStreamVideoH264: return "H.264";
case SrsTsStreamVideoMpeg4: return "MP4";
case SrsTsStreamAudioMpeg4: return "MP4A";
default: return "Other";
}
}

SrsTsChannel::SrsTsChannel()
{
pid = 0;
Expand Down
1 change: 1 addition & 0 deletions trunk/src/kernel/srs_kernel_ts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ enum SrsTsStream
SrsTsStreamAudioAC3 = 0x81,
SrsTsStreamAudioDTS = 0x8a,
};
std::string srs_ts_stream2string(SrsTsStream stream);

/**
* the ts channel.
Expand Down

0 comments on commit 66fccdb

Please sign in to comment.