fix #151, always reap ts whatever audio or video packet. 0.9.223.
正在显示
6 个修改的文件
包含
22 行增加
和
20 行删除
| @@ -208,6 +208,7 @@ Supported operating systems and hardware: | @@ -208,6 +208,7 @@ Supported operating systems and hardware: | ||
| 208 | * 2013-10-17, Created.<br/> | 208 | * 2013-10-17, Created.<br/> |
| 209 | 209 | ||
| 210 | ## History | 210 | ## History |
| 211 | +* 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. | ||
| 211 | * v1.0, 2014-10-08, fix [#162](https://github.com/winlinvip/simple-rtmp-server/issues/162), failed if no epoll. 0.9.222. | 212 | * v1.0, 2014-10-08, fix [#162](https://github.com/winlinvip/simple-rtmp-server/issues/162), failed if no epoll. 0.9.222. |
| 212 | * 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. | 213 | * 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. |
| 213 | * v1.0, 2014-09-26, fix hls bug, refine config and log, according to clion of jetbrains. 0.9.216. | 214 | * v1.0, 2014-09-26, fix hls bug, refine config and log, according to clion of jetbrains. 0.9.216. |
| @@ -135,6 +135,8 @@ u_int8_t mpegts_header[] = { | @@ -135,6 +135,8 @@ u_int8_t mpegts_header[] = { | ||
| 135 | /* PMT */ | 135 | /* PMT */ |
| 136 | 0xe1, 0x00, | 136 | 0xe1, 0x00, |
| 137 | 0xf0, 0x00, | 137 | 0xf0, 0x00, |
| 138 | + // must generate header with/without video, @see: | ||
| 139 | + // https://github.com/winlinvip/simple-rtmp-server/issues/40 | ||
| 138 | 0x1b, 0xe1, 0x00, 0xf0, 0x00, /* h264, pid=0x100=256 */ | 140 | 0x1b, 0xe1, 0x00, 0xf0, 0x00, /* h264, pid=0x100=256 */ |
| 139 | 0x0f, 0xe1, 0x01, 0xf0, 0x00, /* aac, pid=0x101=257 */ | 141 | 0x0f, 0xe1, 0x01, 0xf0, 0x00, /* aac, pid=0x101=257 */ |
| 140 | /*0x03, 0xe1, 0x01, 0xf0, 0x00,*/ /* mp3 */ | 142 | /*0x03, 0xe1, 0x01, 0xf0, 0x00,*/ /* mp3 */ |
| @@ -967,8 +969,6 @@ SrsHlsCache::SrsHlsCache() | @@ -967,8 +969,6 @@ SrsHlsCache::SrsHlsCache() | ||
| 967 | 969 | ||
| 968 | af = new SrsMpegtsFrame(); | 970 | af = new SrsMpegtsFrame(); |
| 969 | vf = new SrsMpegtsFrame(); | 971 | vf = new SrsMpegtsFrame(); |
| 970 | - | ||
| 971 | - video_count = 0; | ||
| 972 | } | 972 | } |
| 973 | 973 | ||
| 974 | SrsHlsCache::~SrsHlsCache() | 974 | SrsHlsCache::~SrsHlsCache() |
| @@ -999,9 +999,6 @@ int SrsHlsCache::on_publish(SrsHlsMuxer* muxer, SrsRequest* req, int64_t segment | @@ -999,9 +999,6 @@ int SrsHlsCache::on_publish(SrsHlsMuxer* muxer, SrsRequest* req, int64_t segment | ||
| 999 | // get the hls path config | 999 | // get the hls path config |
| 1000 | std::string hls_path = _srs_config->get_hls_path(vhost); | 1000 | std::string hls_path = _srs_config->get_hls_path(vhost); |
| 1001 | 1001 | ||
| 1002 | - // reset video count for new publish session. | ||
| 1003 | - video_count = 0; | ||
| 1004 | - | ||
| 1005 | // TODO: FIXME: support load exists m3u8, to continue publish stream. | 1002 | // TODO: FIXME: support load exists m3u8, to continue publish stream. |
| 1006 | // for the HLS donot requires the EXT-X-MEDIA-SEQUENCE be monotonically increase. | 1003 | // for the HLS donot requires the EXT-X-MEDIA-SEQUENCE be monotonically increase. |
| 1007 | 1004 | ||
| @@ -1082,9 +1079,13 @@ int SrsHlsCache::write_audio(SrsAvcAacCodec* codec, SrsHlsMuxer* muxer, int64_t | @@ -1082,9 +1079,13 @@ int SrsHlsCache::write_audio(SrsAvcAacCodec* codec, SrsHlsMuxer* muxer, int64_t | ||
| 1082 | } | 1079 | } |
| 1083 | } | 1080 | } |
| 1084 | 1081 | ||
| 1085 | - // for pure audio | ||
| 1086 | - // start new segment when duration overflow. | ||
| 1087 | - if (video_count == 0 && muxer->is_segment_overflow()) { | 1082 | + // reap when current source is pure audio. |
| 1083 | + // it maybe changed when stream info changed, | ||
| 1084 | + // for example, pure audio when start, audio/video when publishing, | ||
| 1085 | + // pure audio again for audio disabled. | ||
| 1086 | + // so we reap event when the audio incoming when segment overflow. | ||
| 1087 | + // @see https://github.com/winlinvip/simple-rtmp-server/issues/151 | ||
| 1088 | + if (muxer->is_segment_overflow()) { | ||
| 1088 | if ((ret = reap_segment("audio", muxer, af->pts)) != ERROR_SUCCESS) { | 1089 | if ((ret = reap_segment("audio", muxer, af->pts)) != ERROR_SUCCESS) { |
| 1089 | return ret; | 1090 | return ret; |
| 1090 | } | 1091 | } |
| @@ -1098,8 +1099,6 @@ int SrsHlsCache::write_video( | @@ -1098,8 +1099,6 @@ int SrsHlsCache::write_video( | ||
| 1098 | { | 1099 | { |
| 1099 | int ret = ERROR_SUCCESS; | 1100 | int ret = ERROR_SUCCESS; |
| 1100 | 1101 | ||
| 1101 | - video_count++; | ||
| 1102 | - | ||
| 1103 | // write video to cache. | 1102 | // write video to cache. |
| 1104 | if ((ret = cache_video(codec, sample)) != ERROR_SUCCESS) { | 1103 | if ((ret = cache_video(codec, sample)) != ERROR_SUCCESS) { |
| 1105 | return ret; | 1104 | return ret; |
| @@ -239,14 +239,6 @@ private: | @@ -239,14 +239,6 @@ private: | ||
| 239 | int64_t audio_buffer_start_pts; | 239 | int64_t audio_buffer_start_pts; |
| 240 | // time jitter for aac | 240 | // time jitter for aac |
| 241 | SrsHlsAacJitter* aac_jitter; | 241 | SrsHlsAacJitter* aac_jitter; |
| 242 | -private: | ||
| 243 | - /** | ||
| 244 | - * for pure audio HLS application, | ||
| 245 | - * the video count used to count the video, | ||
| 246 | - * if zero and audio buffer overflow, reap the ts, | ||
| 247 | - * just like we got a keyframe. | ||
| 248 | - */ | ||
| 249 | - u_int32_t video_count; | ||
| 250 | public: | 242 | public: |
| 251 | SrsHlsCache(); | 243 | SrsHlsCache(); |
| 252 | virtual ~SrsHlsCache(); | 244 | virtual ~SrsHlsCache(); |
| @@ -400,7 +400,7 @@ int SrsGopCache::cache(SrsSharedPtrMessage* msg) | @@ -400,7 +400,7 @@ int SrsGopCache::cache(SrsSharedPtrMessage* msg) | ||
| 400 | } | 400 | } |
| 401 | 401 | ||
| 402 | // no acceptable video or pure audio, disable the cache. | 402 | // no acceptable video or pure audio, disable the cache. |
| 403 | - if (cached_video_count == 0) { | 403 | + if (pure_audio()) { |
| 404 | srs_verbose("ignore any frame util got a h264 video frame."); | 404 | srs_verbose("ignore any frame util got a h264 video frame."); |
| 405 | return ret; | 405 | return ret; |
| 406 | } | 406 | } |
| @@ -482,6 +482,11 @@ int64_t SrsGopCache::start_time() | @@ -482,6 +482,11 @@ int64_t SrsGopCache::start_time() | ||
| 482 | return msg->header.timestamp; | 482 | return msg->header.timestamp; |
| 483 | } | 483 | } |
| 484 | 484 | ||
| 485 | +bool SrsGopCache::pure_audio() | ||
| 486 | +{ | ||
| 487 | + return cached_video_count == 0; | ||
| 488 | +} | ||
| 489 | + | ||
| 485 | std::map<std::string, SrsSource*> SrsSource::pool; | 490 | std::map<std::string, SrsSource*> SrsSource::pool; |
| 486 | 491 | ||
| 487 | int SrsSource::find(SrsRequest* req, SrsSource** ppsource) | 492 | int SrsSource::find(SrsRequest* req, SrsSource** ppsource) |
| @@ -263,6 +263,11 @@ public: | @@ -263,6 +263,11 @@ public: | ||
| 263 | * @return 0 if no packets. | 263 | * @return 0 if no packets. |
| 264 | */ | 264 | */ |
| 265 | virtual int64_t start_time(); | 265 | virtual int64_t start_time(); |
| 266 | + /** | ||
| 267 | + * whether current stream is pure audio, | ||
| 268 | + * when no video in gop cache, the stream is pure audio right now. | ||
| 269 | + */ | ||
| 270 | + virtual bool pure_audio(); | ||
| 266 | }; | 271 | }; |
| 267 | 272 | ||
| 268 | /** | 273 | /** |
| @@ -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 "0" | 32 | #define VERSION_MAJOR "0" |
| 33 | #define VERSION_MINOR "9" | 33 | #define VERSION_MINOR "9" |
| 34 | -#define VERSION_REVISION "222" | 34 | +#define VERSION_REVISION "223" |
| 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION | 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION |
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
-
请 注册 或 登录 后发表评论