mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix #151, always reap ts whatever audio or video packet. 0.9.223.
This commit is contained in:
parent
13b092704d
commit
9789335d0b
6 changed files with 22 additions and 20 deletions
|
@ -208,6 +208,7 @@ Supported operating systems and hardware:
|
||||||
* 2013-10-17, Created.<br/>
|
* 2013-10-17, Created.<br/>
|
||||||
|
|
||||||
## History
|
## 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-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-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.
|
* 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[] = {
|
||||||
/* PMT */
|
/* PMT */
|
||||||
0xe1, 0x00,
|
0xe1, 0x00,
|
||||||
0xf0, 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 */
|
0x1b, 0xe1, 0x00, 0xf0, 0x00, /* h264, pid=0x100=256 */
|
||||||
0x0f, 0xe1, 0x01, 0xf0, 0x00, /* aac, pid=0x101=257 */
|
0x0f, 0xe1, 0x01, 0xf0, 0x00, /* aac, pid=0x101=257 */
|
||||||
/*0x03, 0xe1, 0x01, 0xf0, 0x00,*/ /* mp3 */
|
/*0x03, 0xe1, 0x01, 0xf0, 0x00,*/ /* mp3 */
|
||||||
|
@ -967,8 +969,6 @@ SrsHlsCache::SrsHlsCache()
|
||||||
|
|
||||||
af = new SrsMpegtsFrame();
|
af = new SrsMpegtsFrame();
|
||||||
vf = new SrsMpegtsFrame();
|
vf = new SrsMpegtsFrame();
|
||||||
|
|
||||||
video_count = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsHlsCache::~SrsHlsCache()
|
SrsHlsCache::~SrsHlsCache()
|
||||||
|
@ -999,9 +999,6 @@ int SrsHlsCache::on_publish(SrsHlsMuxer* muxer, SrsRequest* req, int64_t segment
|
||||||
// get the hls path config
|
// get the hls path config
|
||||||
std::string hls_path = _srs_config->get_hls_path(vhost);
|
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.
|
// TODO: FIXME: support load exists m3u8, to continue publish stream.
|
||||||
// for the HLS donot requires the EXT-X-MEDIA-SEQUENCE be monotonically increase.
|
// 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
|
// reap when current source is pure audio.
|
||||||
// start new segment when duration overflow.
|
// it maybe changed when stream info changed,
|
||||||
if (video_count == 0 && muxer->is_segment_overflow()) {
|
// 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) {
|
if ((ret = reap_segment("audio", muxer, af->pts)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1098,8 +1099,6 @@ int SrsHlsCache::write_video(
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
video_count++;
|
|
||||||
|
|
||||||
// write video to cache.
|
// write video to cache.
|
||||||
if ((ret = cache_video(codec, sample)) != ERROR_SUCCESS) {
|
if ((ret = cache_video(codec, sample)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -239,14 +239,6 @@ private:
|
||||||
int64_t audio_buffer_start_pts;
|
int64_t audio_buffer_start_pts;
|
||||||
// time jitter for aac
|
// time jitter for aac
|
||||||
SrsHlsAacJitter* aac_jitter;
|
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:
|
public:
|
||||||
SrsHlsCache();
|
SrsHlsCache();
|
||||||
virtual ~SrsHlsCache();
|
virtual ~SrsHlsCache();
|
||||||
|
|
|
@ -400,7 +400,7 @@ int SrsGopCache::cache(SrsSharedPtrMessage* msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// no acceptable video or pure audio, disable the cache.
|
// 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.");
|
srs_verbose("ignore any frame util got a h264 video frame.");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -482,6 +482,11 @@ int64_t SrsGopCache::start_time()
|
||||||
return msg->header.timestamp;
|
return msg->header.timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SrsGopCache::pure_audio()
|
||||||
|
{
|
||||||
|
return cached_video_count == 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::map<std::string, SrsSource*> SrsSource::pool;
|
std::map<std::string, SrsSource*> SrsSource::pool;
|
||||||
|
|
||||||
int SrsSource::find(SrsRequest* req, SrsSource** ppsource)
|
int SrsSource::find(SrsRequest* req, SrsSource** ppsource)
|
||||||
|
|
|
@ -263,6 +263,11 @@ public:
|
||||||
* @return 0 if no packets.
|
* @return 0 if no packets.
|
||||||
*/
|
*/
|
||||||
virtual int64_t start_time();
|
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();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// current release version
|
// current release version
|
||||||
#define VERSION_MAJOR "0"
|
#define VERSION_MAJOR "0"
|
||||||
#define VERSION_MINOR "9"
|
#define VERSION_MINOR "9"
|
||||||
#define VERSION_REVISION "222"
|
#define VERSION_REVISION "223"
|
||||||
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
|
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
|
||||||
// server info.
|
// server info.
|
||||||
#define RTMP_SIG_SRS_KEY "SRS"
|
#define RTMP_SIG_SRS_KEY "SRS"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue