diff --git a/README.md b/README.md
index 29d9abbb2..c7e42605c 100755
--- a/README.md
+++ b/README.md
@@ -208,6 +208,7 @@ Supported operating systems and hardware:
* 2013-10-17, Created.
## History
+* v1.0, 2014-10-08, fix [#151](https://github.com/winlinvip/simple-rtmp-server/issues/151), always reap ts whatever audio or video packet. 0.9.223.
* v1.0, 2014-10-08, fix [#162](https://github.com/winlinvip/simple-rtmp-server/issues/162), failed if no epoll. 0.9.222.
* v1.0, 2014-09-30, fix [#180](https://github.com/winlinvip/simple-rtmp-server/issues/180), crash for multiple edge publishing the same stream. 0.9.220.
* v1.0, 2014-09-26, fix hls bug, refine config and log, according to clion of jetbrains. 0.9.216.
diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp
index 965df258c..8cd71c8e1 100644
--- a/trunk/src/app/srs_app_hls.cpp
+++ b/trunk/src/app/srs_app_hls.cpp
@@ -135,6 +135,8 @@ u_int8_t mpegts_header[] = {
/* PMT */
0xe1, 0x00,
0xf0, 0x00,
+ // must generate header with/without video, @see:
+ // https://github.com/winlinvip/simple-rtmp-server/issues/40
0x1b, 0xe1, 0x00, 0xf0, 0x00, /* h264, pid=0x100=256 */
0x0f, 0xe1, 0x01, 0xf0, 0x00, /* aac, pid=0x101=257 */
/*0x03, 0xe1, 0x01, 0xf0, 0x00,*/ /* mp3 */
@@ -967,8 +969,6 @@ SrsHlsCache::SrsHlsCache()
af = new SrsMpegtsFrame();
vf = new SrsMpegtsFrame();
-
- video_count = 0;
}
SrsHlsCache::~SrsHlsCache()
@@ -999,9 +999,6 @@ int SrsHlsCache::on_publish(SrsHlsMuxer* muxer, SrsRequest* req, int64_t segment
// get the hls path config
std::string hls_path = _srs_config->get_hls_path(vhost);
- // reset video count for new publish session.
- video_count = 0;
-
// TODO: FIXME: support load exists m3u8, to continue publish stream.
// for the HLS donot requires the EXT-X-MEDIA-SEQUENCE be monotonically increase.
@@ -1082,9 +1079,13 @@ int SrsHlsCache::write_audio(SrsAvcAacCodec* codec, SrsHlsMuxer* muxer, int64_t
}
}
- // for pure audio
- // start new segment when duration overflow.
- if (video_count == 0 && muxer->is_segment_overflow()) {
+ // reap when current source is pure audio.
+ // it maybe changed when stream info changed,
+ // for example, pure audio when start, audio/video when publishing,
+ // pure audio again for audio disabled.
+ // so we reap event when the audio incoming when segment overflow.
+ // @see https://github.com/winlinvip/simple-rtmp-server/issues/151
+ if (muxer->is_segment_overflow()) {
if ((ret = reap_segment("audio", muxer, af->pts)) != ERROR_SUCCESS) {
return ret;
}
@@ -1098,8 +1099,6 @@ int SrsHlsCache::write_video(
{
int ret = ERROR_SUCCESS;
- video_count++;
-
// write video to cache.
if ((ret = cache_video(codec, sample)) != ERROR_SUCCESS) {
return ret;
diff --git a/trunk/src/app/srs_app_hls.hpp b/trunk/src/app/srs_app_hls.hpp
index 694499ae4..d31820367 100644
--- a/trunk/src/app/srs_app_hls.hpp
+++ b/trunk/src/app/srs_app_hls.hpp
@@ -239,14 +239,6 @@ private:
int64_t audio_buffer_start_pts;
// time jitter for aac
SrsHlsAacJitter* aac_jitter;
-private:
- /**
- * for pure audio HLS application,
- * the video count used to count the video,
- * if zero and audio buffer overflow, reap the ts,
- * just like we got a keyframe.
- */
- u_int32_t video_count;
public:
SrsHlsCache();
virtual ~SrsHlsCache();
diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp
index ea4f27d2a..64fd2d0e0 100644
--- a/trunk/src/app/srs_app_source.cpp
+++ b/trunk/src/app/srs_app_source.cpp
@@ -400,7 +400,7 @@ int SrsGopCache::cache(SrsSharedPtrMessage* msg)
}
// no acceptable video or pure audio, disable the cache.
- if (cached_video_count == 0) {
+ if (pure_audio()) {
srs_verbose("ignore any frame util got a h264 video frame.");
return ret;
}
@@ -482,6 +482,11 @@ int64_t SrsGopCache::start_time()
return msg->header.timestamp;
}
+bool SrsGopCache::pure_audio()
+{
+ return cached_video_count == 0;
+}
+
std::map SrsSource::pool;
int SrsSource::find(SrsRequest* req, SrsSource** ppsource)
diff --git a/trunk/src/app/srs_app_source.hpp b/trunk/src/app/srs_app_source.hpp
index fc6241e28..1759ebf7e 100644
--- a/trunk/src/app/srs_app_source.hpp
+++ b/trunk/src/app/srs_app_source.hpp
@@ -263,6 +263,11 @@ public:
* @return 0 if no packets.
*/
virtual int64_t start_time();
+ /**
+ * whether current stream is pure audio,
+ * when no video in gop cache, the stream is pure audio right now.
+ */
+ virtual bool pure_audio();
};
/**
diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp
index af99bc8a4..ac34b5646 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 "0"
#define VERSION_MINOR "9"
-#define VERSION_REVISION "222"
+#define VERSION_REVISION "223"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info.
#define RTMP_SIG_SRS_KEY "SRS"