Skip to content

Commit

Permalink
fix #409: support pure video hls. 2.0.172.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed May 29, 2015
1 parent 3ad030f commit 5caafad
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ Remark:
## History

### SRS 2.0 history
* v2.0, 2015-05-29, fix [#409](https://github.com/simple-rtmp-server/srs/issues/409) support pure video hls. 2.0.172.
* v2.0, 2015-05-28, support [srs-dolphin][srs-dolphin], the multiple-process SRS.
* v2.0, 2015-05-24, fix [#404](https://github.com/simple-rtmp-server/srs/issues/404) register handler then start http thread. 2.0.167.
* v2.0, 2015-05-23, refine the thread, protocol, kbps code. 2.0.166
Expand Down
2 changes: 1 addition & 1 deletion trunk/conf/full.conf
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ vhost with-hls.srs.com {
# when codec changed, write the PAT/PMT table, but maybe ok util next ts.
# so user can set the default codec for mp3.
# the available audio codec:
# aac, mp3
# aac, mp3, an
# default: aac
hls_acodec aac;
# the default video codec of hls.
Expand Down
3 changes: 3 additions & 0 deletions trunk/src/app/srs_app_hls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts)
} else if (default_acodec_str == "aac") {
default_acodec = SrsCodecAudioAAC;
srs_info("hls: use default aac acodec");
} else if (default_acodec_str == "an") {
default_acodec = SrsCodecAudioDisabled;
srs_info("hls: use default an acodec for pure video");
} else {
srs_warn("hls: use aac for other codec=%s", default_acodec_str.c_str());
}
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 171
#define VERSION_REVISION 172

// server info.
#define RTMP_SIG_SRS_KEY "SRS"
Expand Down
3 changes: 3 additions & 0 deletions trunk/src/kernel/srs_kernel_codec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ enum SrsCodecAudio
// set to the max value to reserved, for array map.
SrsCodecAudioReserved1 = 16,

// for user to disable audio, for example, use pure video hls.
SrsCodecAudioDisabled = 17,

SrsCodecAudioLinearPCMPlatformEndian = 0,
SrsCodecAudioADPCM = 1,
SrsCodecAudioMP3 = 2,
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/kernel/srs_kernel_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define ERROR_HTTP_DVR_CREATE_REQUEST 3053
#define ERROR_HTTP_DVR_NO_TAEGET 3054
#define ERROR_ADTS_ID_NOT_AAC 3055
// HDS error code
#define ERROR_HDS_OPEN_F4M_FAILED 3056
#define ERROR_HDS_WRITE_F4M_FAILED 3057
#define ERROR_HDS_OPEN_BOOTSTRAP_FAILED 3058
#define ERROR_HDS_WRITE_BOOTSTRAP_FAILED 3059
#define ERROR_HDS_OPEN_FRAGMENT_FAILED 3060
#define ERROR_HDS_WRITE_FRAGMENT_FAILED 3061
#define ERROR_HLS_NO_STREAM 3062

///////////////////////////////////////////////////////
// HTTP/StreamCaster protocol error.
Expand Down
31 changes: 25 additions & 6 deletions trunk/src/kernel/srs_kernel_ts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,12 @@ int SrsTsContext::encode(SrsFileWriter* writer, SrsTsMessage* msg, SrsCodecVideo
vs = SrsTsStreamVideoH264;
video_pid = TS_VIDEO_AVC_PID;
break;
case SrsCodecVideoDisabled:
vs = SrsTsStreamReserved;
break;
case SrsCodecVideoReserved:
case SrsCodecVideoReserved1:
case SrsCodecVideoReserved2:
case SrsCodecVideoDisabled:
case SrsCodecVideoSorensonH263:
case SrsCodecVideoScreenVideo:
case SrsCodecVideoOn2VP6:
Expand All @@ -323,6 +325,9 @@ int SrsTsContext::encode(SrsFileWriter* writer, SrsTsMessage* msg, SrsCodecVideo
as = SrsTsStreamAudioMp3;
audio_pid = TS_AUDIO_MP3_PID;
break;
case SrsCodecAudioDisabled:
as = SrsTsStreamReserved;
break;
case SrsCodecAudioReserved1:
case SrsCodecAudioLinearPCMPlatformEndian:
case SrsCodecAudioADPCM:
Expand All @@ -340,6 +345,12 @@ int SrsTsContext::encode(SrsFileWriter* writer, SrsTsMessage* msg, SrsCodecVideo
break;
}

if (as == SrsTsStreamReserved && vs == SrsTsStreamReserved) {
ret = ERROR_HLS_NO_STREAM;
srs_error("hls: no video or audio stream, vcodec=%d, acodec=%d. ret=%d", vc, ac, ret);
return ret;
}

// when any codec changed, write PAT/PMT table.
if (vcodec != vc || acodec != ac) {
vcodec = vc;
Expand All @@ -360,6 +371,12 @@ int SrsTsContext::encode(SrsFileWriter* writer, SrsTsMessage* msg, SrsCodecVideo
int SrsTsContext::encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as)
{
int ret = ERROR_SUCCESS;

if (vs != SrsTsStreamVideoH264 && as != SrsTsStreamAudioAAC && as != SrsTsStreamAudioMp3) {
ret = ERROR_HLS_NO_STREAM;
srs_error("hls: no pmt pcr pid, vs=%d, as=%d. ret=%d", vs, as, ret);
return ret;
}

int16_t pmt_number = TS_PMT_NUMBER;
int16_t pmt_pid = TS_PMT_PID;
Expand Down Expand Up @@ -754,15 +771,17 @@ SrsTsPacket* SrsTsPacket::create_pmt(SrsTsContext* context, int16_t pmt_number,
pmt->last_section_number = 0;
pmt->program_info_length = 0;

// use audio to carray pcr by default.
// for hls, there must be atleast one audio channel.
pmt->PCR_PID = apid;
pmt->infos.push_back(new SrsTsPayloadPMTESInfo(as, apid));

// if h.264 specified, use video to carry pcr.
if (vs == SrsTsStreamVideoH264) {
pmt->PCR_PID = vpid;
pmt->infos.push_back(new SrsTsPayloadPMTESInfo(vs, vpid));
} else if (as == SrsTsStreamAudioAAC || as == SrsTsStreamAudioMp3) {
// use audio to carray pcr by default.
// for hls, there must be atleast one audio channel.
pmt->PCR_PID = apid;
pmt->infos.push_back(new SrsTsPayloadPMTESInfo(as, apid));
} else {
srs_assert(false);
}

pmt->CRC_32 = 0; // calc in encode.
Expand Down

0 comments on commit 5caafad

Please sign in to comment.