From 919a85b1031bd626198c519ada721034da13e08d Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 25 Jan 2015 17:06:49 +0800 Subject: [PATCH] for #301, hls support h.264+mp3, ok for vlc. 2.0.107 --- README.md | 1 + trunk/src/app/srs_app_hls.cpp | 13 ++++++++++--- trunk/src/app/srs_app_hls.hpp | 8 +++++++- trunk/src/app/srs_app_http.cpp | 1 + trunk/src/core/srs_core.hpp | 2 +- trunk/src/kernel/srs_kernel_ts.cpp | 6 +++--- trunk/src/kernel/srs_kernel_ts.hpp | 2 +- 7 files changed, 24 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3c9291dac..4a90c4916 100755 --- a/README.md +++ b/README.md @@ -521,6 +521,7 @@ Supported operating systems and hardware: ### SRS 2.0 history +* v2.0, 2015-01-25, for [#301](https://github.com/winlinvip/simple-rtmp-server/issues/301), hls support h.264+mp3, ok for vlc. 2.0.107 * v2.0, 2015-01-25, for [#301](https://github.com/winlinvip/simple-rtmp-server/issues/301), http ts stream support h.264+mp3. 2.0.106 * v2.0, 2015-01-25, hotfix [#268](https://github.com/winlinvip/simple-rtmp-server/issues/268), refine the pcr start at 0, dts/pts plus delay. 2.0.105 * v2.0, 2015-01-25, hotfix [#151](https://github.com/winlinvip/simple-rtmp-server/issues/151), refine pcr=dts-800ms and use dts/pts directly. 2.0.104 diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index 30ce65943..a9da852e2 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -92,6 +92,7 @@ SrsHlsMuxer::SrsHlsMuxer() hls_fragment = hls_window = 0; _sequence_no = 0; current = NULL; + acodec = SrsCodecAudioReserved1; } SrsHlsMuxer::~SrsHlsMuxer() @@ -170,6 +171,11 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts) } srs_info("open HLS muxer success. path=%s, tmp=%s", current->full_path.c_str(), tmp_file.c_str()); + + // set the segment muxer audio codec. + if (acodec != SrsCodecAudioReserved1) { + current->muxer->update_acodec(acodec); + } return ret; } @@ -199,11 +205,12 @@ bool SrsHlsMuxer::is_segment_absolutely_overflow() return current->duration >= 2 * hls_fragment; } -int SrsHlsMuxer::update_acodec(SrsCodecAudio acodec) +int SrsHlsMuxer::update_acodec(SrsCodecAudio ac) { srs_assert(current); srs_assert(current->muxer); - return current->muxer->update_acodec(acodec); + acodec = ac; + return current->muxer->update_acodec(ac); } int SrsHlsMuxer::flush_audio(SrsMpegtsFrame* af, SrsSimpleBuffer* ab) @@ -801,7 +808,7 @@ int SrsHls::on_audio(SrsSharedPtrMessage* __audio) } // ignore sequence header - if (sample->aac_packet_type == SrsCodecAudioTypeSequenceHeader) { + if (acodec == SrsCodecAudioAAC && sample->aac_packet_type == SrsCodecAudioTypeSequenceHeader) { return hls_cache->on_sequence_header(muxer); } diff --git a/trunk/src/app/srs_app_hls.hpp b/trunk/src/app/srs_app_hls.hpp index 2fe45ec93..824730e01 100644 --- a/trunk/src/app/srs_app_hls.hpp +++ b/trunk/src/app/srs_app_hls.hpp @@ -118,6 +118,12 @@ private: * current writing segment. */ SrsHlsSegment* current; + /** + * the current audio codec, when open new muxer, + * set the muxer audio codec. + * @see https://github.com/winlinvip/simple-rtmp-server/issues/301 + */ + SrsCodecAudio acodec; public: SrsHlsMuxer(); virtual ~SrsHlsMuxer(); @@ -144,7 +150,7 @@ public: */ virtual bool is_segment_absolutely_overflow(); public: - virtual int update_acodec(SrsCodecAudio acodec); + virtual int update_acodec(SrsCodecAudio ac); virtual int flush_audio(SrsMpegtsFrame* af, SrsSimpleBuffer* ab); virtual int flush_video(SrsMpegtsFrame* af, SrsSimpleBuffer* ab, SrsMpegtsFrame* vf, SrsSimpleBuffer* vb); /** diff --git a/trunk/src/app/srs_app_http.cpp b/trunk/src/app/srs_app_http.cpp index a63658f16..6402615b8 100644 --- a/trunk/src/app/srs_app_http.cpp +++ b/trunk/src/app/srs_app_http.cpp @@ -352,6 +352,7 @@ int SrsGoHttpFileServer::serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage* _mime[".zip"] = "application/zip"; _mime[".rar"] = "application/x-rar-compressed"; _mime[".xml"] = "text/xml;charset=utf-8"; + _mime[".html"] = "text/html;charset=utf-8"; _mime[".js"] = "text/javascript"; _mime[".css"] = "text/css;charset=utf-8"; _mime[".ico"] = "image/x-icon"; diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index ac75ff4ed..0e1d5d7db 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -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 106 +#define VERSION_REVISION 107 // server info. #define RTMP_SIG_SRS_KEY "SRS" diff --git a/trunk/src/kernel/srs_kernel_ts.cpp b/trunk/src/kernel/srs_kernel_ts.cpp index 6f3da8910..827ae6601 100644 --- a/trunk/src/kernel/srs_kernel_ts.cpp +++ b/trunk/src/kernel/srs_kernel_ts.cpp @@ -430,14 +430,14 @@ int SrsTSMuxer::open(string _path) return ret; } -int SrsTSMuxer::update_acodec(SrsCodecAudio acodec) +int SrsTSMuxer::update_acodec(SrsCodecAudio ac) { int ret = ERROR_SUCCESS; - if (current == acodec) { + if (current == ac) { return ret; } - current = acodec; + current = ac; return ret; } diff --git a/trunk/src/kernel/srs_kernel_ts.hpp b/trunk/src/kernel/srs_kernel_ts.hpp index 3f534b171..a1fe00095 100644 --- a/trunk/src/kernel/srs_kernel_ts.hpp +++ b/trunk/src/kernel/srs_kernel_ts.hpp @@ -85,7 +85,7 @@ public: * @remark for audio aac codec, for example, SRS1, it's ok to write PSI when open ts. * @see https://github.com/winlinvip/simple-rtmp-server/issues/301 */ - virtual int update_acodec(SrsCodecAudio acodec); + virtual int update_acodec(SrsCodecAudio ac); /** * write an audio frame to ts, * @remark write PSI first when not write yet.