mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 11:21:52 +00:00
For #939, always enable fast FLV streaming.
This commit is contained in:
parent
d57c85827c
commit
a2a6ca8258
7 changed files with 12 additions and 40 deletions
|
@ -146,6 +146,7 @@ For previous versions, please read:
|
|||
|
||||
## V3 changes
|
||||
|
||||
* v3.0, 2020-02-04, For [#939][bug #939], always enable fast FLV streaming.
|
||||
* <strong>v3.0, 2020-02-02, [3.0 beta0(3.0.112)][r3.0b0] released. 121709 lines.</strong>
|
||||
* v3.0, 2020-01-29, Support isolate version file. 3.0.112
|
||||
* v3.0, 2020-01-29, Fix [#1206][bug #1206], dispose ingester while server quiting. 3.0.111
|
||||
|
@ -1637,6 +1638,7 @@ Winlin
|
|||
[bug #1303]: https://github.com/ossrs/srs/issues/1303
|
||||
[bug #1230]: https://github.com/ossrs/srs/issues/1230
|
||||
[bug #1206]: https://github.com/ossrs/srs/issues/1206
|
||||
[bug #939]: https://github.com/ossrs/srs/issues/939
|
||||
[bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx
|
||||
|
||||
[exo #828]: https://github.com/google/ExoPlayer/pull/828
|
||||
|
|
|
@ -300,7 +300,6 @@ srs_error_t SrsFlvStreamEncoder::dump_cache(SrsConsumer* /*consumer*/, SrsRtmpJi
|
|||
return srs_success;
|
||||
}
|
||||
|
||||
#ifdef SRS_PERF_FAST_FLV_ENCODER
|
||||
SrsFastFlvStreamEncoder::SrsFastFlvStreamEncoder()
|
||||
{
|
||||
}
|
||||
|
@ -313,7 +312,6 @@ srs_error_t SrsFastFlvStreamEncoder::write_tags(SrsSharedPtrMessage** msgs, int
|
|||
{
|
||||
return enc->write_tags(msgs, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
SrsAacStreamEncoder::SrsAacStreamEncoder()
|
||||
{
|
||||
|
@ -511,7 +509,6 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
|
|||
srs_assert(entry);
|
||||
if (srs_string_ends_with(entry->pattern, ".flv")) {
|
||||
w->header()->set_content_type("video/x-flv");
|
||||
#ifdef SRS_PERF_FAST_FLV_ENCODER
|
||||
bool realtime = _srs_config->get_realtime_enabled(req->vhost);
|
||||
if (realtime) {
|
||||
enc_desc = "FLV";
|
||||
|
@ -520,10 +517,6 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
|
|||
enc_desc = "FastFLV";
|
||||
enc = new SrsFastFlvStreamEncoder();
|
||||
}
|
||||
#else
|
||||
enc_desc = "FLV";
|
||||
enc = new SrsFlvStreamEncoder();
|
||||
#endif
|
||||
} else if (srs_string_ends_with(entry->pattern, ".aac")) {
|
||||
w->header()->set_content_type("audio/x-aac");
|
||||
enc_desc = "AAC";
|
||||
|
@ -576,10 +569,8 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef SRS_PERF_FAST_FLV_ENCODER
|
||||
SrsFastFlvStreamEncoder* ffe = dynamic_cast<SrsFastFlvStreamEncoder*>(enc);
|
||||
#endif
|
||||
|
||||
|
||||
// Use receive thread to accept the close event to avoid FD leak.
|
||||
// @see https://github.com/ossrs/srs/issues/636#issuecomment-298208427
|
||||
SrsHttpMessage* hr = dynamic_cast<SrsHttpMessage*>(r);
|
||||
|
@ -639,16 +630,12 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
|
|||
}
|
||||
|
||||
// sendout all messages.
|
||||
#ifdef SRS_PERF_FAST_FLV_ENCODER
|
||||
if (ffe) {
|
||||
err = ffe->write_tags(msgs.msgs, count);
|
||||
} else {
|
||||
err = streaming_send_messages(enc, msgs.msgs, count);
|
||||
}
|
||||
#else
|
||||
err = streaming_send_messages(enc, msgs.msgs, count);
|
||||
#endif
|
||||
|
||||
|
||||
// free the messages.
|
||||
for (int i = 0; i < count; i++) {
|
||||
SrsSharedPtrMessage* msg = msgs.msgs[i];
|
||||
|
|
|
@ -97,7 +97,6 @@ public:
|
|||
virtual srs_error_t dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter);
|
||||
};
|
||||
|
||||
#ifdef SRS_PERF_FAST_FLV_ENCODER
|
||||
// A Fast HTTP FLV Live Streaming, to write multiple tags by writev.
|
||||
// @see https://github.com/ossrs/srs/issues/405
|
||||
class SrsFastFlvStreamEncoder : public SrsFlvStreamEncoder
|
||||
|
@ -109,7 +108,6 @@ public:
|
|||
// Write the tags in a time.
|
||||
virtual srs_error_t write_tags(SrsSharedPtrMessage** msgs, int count);
|
||||
};
|
||||
#endif
|
||||
|
||||
// Transmux RTMP to HTTP TS Streaming.
|
||||
class SrsTsStreamEncoder : public ISrsBufferEncoder
|
||||
|
|
|
@ -177,13 +177,6 @@
|
|||
#undef SRS_PERF_SO_SNDBUF_SIZE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* define the following macro to enable the fast flv encoder.
|
||||
* @see https://github.com/ossrs/srs/issues/405
|
||||
*/
|
||||
#undef SRS_PERF_FAST_FLV_ENCODER
|
||||
#define SRS_PERF_FAST_FLV_ENCODER
|
||||
|
||||
/**
|
||||
* whether ensure glibc memory check.
|
||||
*/
|
||||
|
|
|
@ -353,23 +353,19 @@ SrsFlvTransmuxer::SrsFlvTransmuxer()
|
|||
{
|
||||
writer = NULL;
|
||||
|
||||
#ifdef SRS_PERF_FAST_FLV_ENCODER
|
||||
nb_tag_headers = 0;
|
||||
tag_headers = NULL;
|
||||
nb_iovss_cache = 0;
|
||||
iovss_cache = NULL;
|
||||
nb_ppts = 0;
|
||||
ppts = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
SrsFlvTransmuxer::~SrsFlvTransmuxer()
|
||||
{
|
||||
#ifdef SRS_PERF_FAST_FLV_ENCODER
|
||||
srs_freepa(tag_headers);
|
||||
srs_freepa(iovss_cache);
|
||||
srs_freepa(ppts);
|
||||
#endif
|
||||
}
|
||||
|
||||
srs_error_t SrsFlvTransmuxer::initialize(ISrsWriter* fw)
|
||||
|
@ -379,15 +375,19 @@ srs_error_t SrsFlvTransmuxer::initialize(ISrsWriter* fw)
|
|||
return srs_success;
|
||||
}
|
||||
|
||||
srs_error_t SrsFlvTransmuxer::write_header()
|
||||
srs_error_t SrsFlvTransmuxer::write_header(bool has_video, bool has_audio)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
|
||||
uint8_t av_flag = 0;
|
||||
av_flag += (has_audio? 4:0);
|
||||
av_flag += (has_video? 1:0);
|
||||
|
||||
// 9bytes header and 4bytes first previous-tag-size
|
||||
char flv_header[] = {
|
||||
'F', 'L', 'V', // Signatures "FLV"
|
||||
(char)0x01, // File version (for example, 0x01 for FLV version 1)
|
||||
(char)0x05, // 4, audio; 1, video; 5 audio+video.
|
||||
(char)av_flag, // 4, audio; 1, video; 5 audio+video.
|
||||
(char)0x00, (char)0x00, (char)0x00, (char)0x09 // DataOffset UI32 The length of this header in bytes
|
||||
};
|
||||
|
||||
|
@ -472,7 +472,6 @@ int SrsFlvTransmuxer::size_tag(int data_size)
|
|||
return SRS_FLV_TAG_HEADER_SIZE + data_size + SRS_FLV_PREVIOUS_TAG_SIZE;
|
||||
}
|
||||
|
||||
#ifdef SRS_PERF_FAST_FLV_ENCODER
|
||||
srs_error_t SrsFlvTransmuxer::write_tags(SrsSharedPtrMessage** msgs, int count)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
@ -542,7 +541,6 @@ srs_error_t SrsFlvTransmuxer::write_tags(SrsSharedPtrMessage** msgs, int count)
|
|||
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
void SrsFlvTransmuxer::cache_metadata(char type, char* data, int size, char* cache)
|
||||
{
|
||||
|
|
|
@ -362,7 +362,7 @@ public:
|
|||
// 1. E.2 The FLV header
|
||||
// 2. PreviousTagSize0 UI32 Always 0
|
||||
// that is, 9+4=13bytes.
|
||||
virtual srs_error_t write_header();
|
||||
virtual srs_error_t write_header(bool has_video = true, bool has_audio = true);
|
||||
virtual srs_error_t write_header(char flv_header[9]);
|
||||
// Write flv metadata.
|
||||
// @param type, the type of data, or other message type.
|
||||
|
@ -381,7 +381,6 @@ public:
|
|||
// including the tag header, body, and 4bytes previous tag size.
|
||||
// @remark assert data_size is not negative.
|
||||
static int size_tag(int data_size);
|
||||
#ifdef SRS_PERF_FAST_FLV_ENCODER
|
||||
private:
|
||||
// The cache tag header.
|
||||
int nb_tag_headers;
|
||||
|
@ -395,7 +394,6 @@ private:
|
|||
public:
|
||||
// Write the tags in a time.
|
||||
virtual srs_error_t write_tags(SrsSharedPtrMessage** msgs, int count);
|
||||
#endif
|
||||
private:
|
||||
virtual void cache_metadata(char type, char* data, int size, char* cache);
|
||||
virtual void cache_audio(int64_t timestamp, char* data, int size, char* cache);
|
||||
|
|
|
@ -912,7 +912,6 @@ VOID TEST(KernelFLVTest, CoverWriterErrorCase)
|
|||
HELPER_EXPECT_FAILED(m.write_video(0, NULL, 0));
|
||||
}
|
||||
|
||||
#ifdef SRS_PERF_FAST_FLV_ENCODER
|
||||
if (true) {
|
||||
MockSrsFileWriter w;
|
||||
HELPER_EXPECT_SUCCESS(w.open(""));
|
||||
|
@ -963,7 +962,6 @@ VOID TEST(KernelFLVTest, CoverWriterErrorCase)
|
|||
SrsSharedPtrMessage* msgs = &msg;
|
||||
HELPER_EXPECT_FAILED(m.write_tags(&msgs, 1));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
VOID TEST(KernelFLVTest, CoverReaderErrorCase)
|
||||
|
@ -4028,7 +4026,6 @@ VOID TEST(KernelFLVTest, CoverAll)
|
|||
EXPECT_TRUE(s.is_video());
|
||||
}
|
||||
|
||||
#ifdef SRS_PERF_FAST_FLV_ENCODER
|
||||
if (true) {
|
||||
MockSrsFileWriter f;
|
||||
SrsFlvTransmuxer mux;
|
||||
|
@ -4045,7 +4042,6 @@ VOID TEST(KernelFLVTest, CoverAll)
|
|||
|
||||
EXPECT_EQ(16, f.tellg());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
VOID TEST(KernelFLVTest, CoverSharedPtrMessage)
|
||||
|
|
Loading…
Reference in a new issue