winlin

for #301, hls support h.264+mp3, ok for vlc. 2.0.107

@@ -521,6 +521,7 @@ Supported operating systems and hardware: @@ -521,6 +521,7 @@ Supported operating systems and hardware:
521 521
522 ### SRS 2.0 history 522 ### SRS 2.0 history
523 523
  524 +* 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
524 * 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 525 * 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
525 * 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 526 * 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
526 * 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 527 * 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
@@ -92,6 +92,7 @@ SrsHlsMuxer::SrsHlsMuxer() @@ -92,6 +92,7 @@ SrsHlsMuxer::SrsHlsMuxer()
92 hls_fragment = hls_window = 0; 92 hls_fragment = hls_window = 0;
93 _sequence_no = 0; 93 _sequence_no = 0;
94 current = NULL; 94 current = NULL;
  95 + acodec = SrsCodecAudioReserved1;
95 } 96 }
96 97
97 SrsHlsMuxer::~SrsHlsMuxer() 98 SrsHlsMuxer::~SrsHlsMuxer()
@@ -170,6 +171,11 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts) @@ -170,6 +171,11 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts)
170 } 171 }
171 srs_info("open HLS muxer success. path=%s, tmp=%s", 172 srs_info("open HLS muxer success. path=%s, tmp=%s",
172 current->full_path.c_str(), tmp_file.c_str()); 173 current->full_path.c_str(), tmp_file.c_str());
  174 +
  175 + // set the segment muxer audio codec.
  176 + if (acodec != SrsCodecAudioReserved1) {
  177 + current->muxer->update_acodec(acodec);
  178 + }
173 179
174 return ret; 180 return ret;
175 } 181 }
@@ -199,11 +205,12 @@ bool SrsHlsMuxer::is_segment_absolutely_overflow() @@ -199,11 +205,12 @@ bool SrsHlsMuxer::is_segment_absolutely_overflow()
199 return current->duration >= 2 * hls_fragment; 205 return current->duration >= 2 * hls_fragment;
200 } 206 }
201 207
202 -int SrsHlsMuxer::update_acodec(SrsCodecAudio acodec) 208 +int SrsHlsMuxer::update_acodec(SrsCodecAudio ac)
203 { 209 {
204 srs_assert(current); 210 srs_assert(current);
205 srs_assert(current->muxer); 211 srs_assert(current->muxer);
206 - return current->muxer->update_acodec(acodec); 212 + acodec = ac;
  213 + return current->muxer->update_acodec(ac);
207 } 214 }
208 215
209 int SrsHlsMuxer::flush_audio(SrsMpegtsFrame* af, SrsSimpleBuffer* ab) 216 int SrsHlsMuxer::flush_audio(SrsMpegtsFrame* af, SrsSimpleBuffer* ab)
@@ -801,7 +808,7 @@ int SrsHls::on_audio(SrsSharedPtrMessage* __audio) @@ -801,7 +808,7 @@ int SrsHls::on_audio(SrsSharedPtrMessage* __audio)
801 } 808 }
802 809
803 // ignore sequence header 810 // ignore sequence header
804 - if (sample->aac_packet_type == SrsCodecAudioTypeSequenceHeader) { 811 + if (acodec == SrsCodecAudioAAC && sample->aac_packet_type == SrsCodecAudioTypeSequenceHeader) {
805 return hls_cache->on_sequence_header(muxer); 812 return hls_cache->on_sequence_header(muxer);
806 } 813 }
807 814
@@ -118,6 +118,12 @@ private: @@ -118,6 +118,12 @@ private:
118 * current writing segment. 118 * current writing segment.
119 */ 119 */
120 SrsHlsSegment* current; 120 SrsHlsSegment* current;
  121 + /**
  122 + * the current audio codec, when open new muxer,
  123 + * set the muxer audio codec.
  124 + * @see https://github.com/winlinvip/simple-rtmp-server/issues/301
  125 + */
  126 + SrsCodecAudio acodec;
121 public: 127 public:
122 SrsHlsMuxer(); 128 SrsHlsMuxer();
123 virtual ~SrsHlsMuxer(); 129 virtual ~SrsHlsMuxer();
@@ -144,7 +150,7 @@ public: @@ -144,7 +150,7 @@ public:
144 */ 150 */
145 virtual bool is_segment_absolutely_overflow(); 151 virtual bool is_segment_absolutely_overflow();
146 public: 152 public:
147 - virtual int update_acodec(SrsCodecAudio acodec); 153 + virtual int update_acodec(SrsCodecAudio ac);
148 virtual int flush_audio(SrsMpegtsFrame* af, SrsSimpleBuffer* ab); 154 virtual int flush_audio(SrsMpegtsFrame* af, SrsSimpleBuffer* ab);
149 virtual int flush_video(SrsMpegtsFrame* af, SrsSimpleBuffer* ab, SrsMpegtsFrame* vf, SrsSimpleBuffer* vb); 155 virtual int flush_video(SrsMpegtsFrame* af, SrsSimpleBuffer* ab, SrsMpegtsFrame* vf, SrsSimpleBuffer* vb);
150 /** 156 /**
@@ -352,6 +352,7 @@ int SrsGoHttpFileServer::serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage* @@ -352,6 +352,7 @@ int SrsGoHttpFileServer::serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
352 _mime[".zip"] = "application/zip"; 352 _mime[".zip"] = "application/zip";
353 _mime[".rar"] = "application/x-rar-compressed"; 353 _mime[".rar"] = "application/x-rar-compressed";
354 _mime[".xml"] = "text/xml;charset=utf-8"; 354 _mime[".xml"] = "text/xml;charset=utf-8";
  355 + _mime[".html"] = "text/html;charset=utf-8";
355 _mime[".js"] = "text/javascript"; 356 _mime[".js"] = "text/javascript";
356 _mime[".css"] = "text/css;charset=utf-8"; 357 _mime[".css"] = "text/css;charset=utf-8";
357 _mime[".ico"] = "image/x-icon"; 358 _mime[".ico"] = "image/x-icon";
@@ -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 106 34 +#define VERSION_REVISION 107
35 35
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"
@@ -430,14 +430,14 @@ int SrsTSMuxer::open(string _path) @@ -430,14 +430,14 @@ int SrsTSMuxer::open(string _path)
430 return ret; 430 return ret;
431 } 431 }
432 432
433 -int SrsTSMuxer::update_acodec(SrsCodecAudio acodec) 433 +int SrsTSMuxer::update_acodec(SrsCodecAudio ac)
434 { 434 {
435 int ret = ERROR_SUCCESS; 435 int ret = ERROR_SUCCESS;
436 436
437 - if (current == acodec) { 437 + if (current == ac) {
438 return ret; 438 return ret;
439 } 439 }
440 - current = acodec; 440 + current = ac;
441 441
442 return ret; 442 return ret;
443 } 443 }
@@ -85,7 +85,7 @@ public: @@ -85,7 +85,7 @@ public:
85 * @remark for audio aac codec, for example, SRS1, it's ok to write PSI when open ts. 85 * @remark for audio aac codec, for example, SRS1, it's ok to write PSI when open ts.
86 * @see https://github.com/winlinvip/simple-rtmp-server/issues/301 86 * @see https://github.com/winlinvip/simple-rtmp-server/issues/301
87 */ 87 */
88 - virtual int update_acodec(SrsCodecAudio acodec); 88 + virtual int update_acodec(SrsCodecAudio ac);
89 /** 89 /**
90 * write an audio frame to ts, 90 * write an audio frame to ts,
91 * @remark write PSI first when not write yet. 91 * @remark write PSI first when not write yet.