|
|
@ -739,6 +739,7 @@ SrsRtcRtpBuilder::SrsRtcRtpBuilder(SrsFrameToRtcBridge* bridge, uint32_t assrc,
|
|
|
|
codec_ = new SrsAudioTranscoder();
|
|
|
|
codec_ = new SrsAudioTranscoder();
|
|
|
|
latest_codec_ = SrsAudioCodecIdForbidden;
|
|
|
|
latest_codec_ = SrsAudioCodecIdForbidden;
|
|
|
|
keep_bframe = false;
|
|
|
|
keep_bframe = false;
|
|
|
|
|
|
|
|
keep_avc_nalu_sei = true;
|
|
|
|
merge_nalus = false;
|
|
|
|
merge_nalus = false;
|
|
|
|
meta = new SrsMetaCache();
|
|
|
|
meta = new SrsMetaCache();
|
|
|
|
audio_sequence = 0;
|
|
|
|
audio_sequence = 0;
|
|
|
@ -771,8 +772,10 @@ srs_error_t SrsRtcRtpBuilder::initialize(SrsRequest* r)
|
|
|
|
format->try_annexb_first = _srs_config->try_annexb_first(r->vhost);
|
|
|
|
format->try_annexb_first = _srs_config->try_annexb_first(r->vhost);
|
|
|
|
|
|
|
|
|
|
|
|
keep_bframe = _srs_config->get_rtc_keep_bframe(req->vhost);
|
|
|
|
keep_bframe = _srs_config->get_rtc_keep_bframe(req->vhost);
|
|
|
|
|
|
|
|
keep_avc_nalu_sei = _srs_config->get_rtc_keep_avc_nalu_sei(req->vhost);
|
|
|
|
merge_nalus = _srs_config->get_rtc_server_merge_nalus();
|
|
|
|
merge_nalus = _srs_config->get_rtc_server_merge_nalus();
|
|
|
|
srs_trace("RTC bridge from RTMP, keep_bframe=%d, merge_nalus=%d", keep_bframe, merge_nalus);
|
|
|
|
srs_trace("RTC bridge from RTMP, keep_bframe=%d, keep_avc_nalu_sei=%d, merge_nalus=%d",
|
|
|
|
|
|
|
|
keep_bframe, keep_avc_nalu_sei, merge_nalus);
|
|
|
|
|
|
|
|
|
|
|
|
return err;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1013,12 +1016,6 @@ srs_error_t SrsRtcRtpBuilder::on_video(SrsSharedPtrMessage* msg)
|
|
|
|
for (int i = 0; i < nn_samples; i++) {
|
|
|
|
for (int i = 0; i < nn_samples; i++) {
|
|
|
|
SrsSample* sample = samples[i];
|
|
|
|
SrsSample* sample = samples[i];
|
|
|
|
|
|
|
|
|
|
|
|
// We always ignore bframe here, if config to discard bframe,
|
|
|
|
|
|
|
|
// the bframe flag will not be set.
|
|
|
|
|
|
|
|
if (sample->bframe) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sample->size <= kRtpMaxPayloadSize) {
|
|
|
|
if (sample->size <= kRtpMaxPayloadSize) {
|
|
|
|
if ((err = package_single_nalu(msg, sample, pkts)) != srs_success) {
|
|
|
|
if ((err = package_single_nalu(msg, sample, pkts)) != srs_success) {
|
|
|
|
return srs_error_wrap(err, "package single nalu");
|
|
|
|
return srs_error_wrap(err, "package single nalu");
|
|
|
@ -1050,14 +1047,27 @@ srs_error_t SrsRtcRtpBuilder::filter(SrsSharedPtrMessage* msg, SrsFormat* format
|
|
|
|
// Update samples to shared frame.
|
|
|
|
// Update samples to shared frame.
|
|
|
|
for (int i = 0; i < format->video->nb_samples; ++i) {
|
|
|
|
for (int i = 0; i < format->video->nb_samples; ++i) {
|
|
|
|
SrsSample* sample = &format->video->samples[i];
|
|
|
|
SrsSample* sample = &format->video->samples[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!keep_avc_nalu_sei && format->vcodec->id == SrsVideoCodecIdAVC) {
|
|
|
|
|
|
|
|
SrsAvcNaluType avc_nalu_type;
|
|
|
|
|
|
|
|
// TODO: FIXME use static method to parse avc nalu type.
|
|
|
|
|
|
|
|
if ((err = SrsVideoFrame::parse_avc_nalu_type(sample, avc_nalu_type)) != srs_success) {
|
|
|
|
|
|
|
|
return srs_error_wrap(err, "parse avc nalu_type");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (avc_nalu_type == SrsAvcNaluTypeSEI) {
|
|
|
|
|
|
|
|
// srs_warn("skip avc nalu type SEI, size=%d", sample->size);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Because RTC does not support B-frame, so we will drop them.
|
|
|
|
// Because RTC does not support B-frame, so we will drop them.
|
|
|
|
// TODO: Drop B-frame in better way, which not cause picture corruption.
|
|
|
|
// TODO: Drop B-frame in better way, which not cause picture corruption.
|
|
|
|
if (!keep_bframe) {
|
|
|
|
if (!keep_bframe && format->vcodec->id == SrsVideoCodecIdAVC) {
|
|
|
|
if ((err = sample->parse_bframe()) != srs_success) {
|
|
|
|
bool is_b_frame;
|
|
|
|
|
|
|
|
if ((err = SrsVideoFrame::parse_avc_b_frame(sample, is_b_frame)) != srs_success) {
|
|
|
|
return srs_error_wrap(err, "parse bframe");
|
|
|
|
return srs_error_wrap(err, "parse bframe");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sample->bframe) {
|
|
|
|
if (is_b_frame) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1137,12 +1147,6 @@ srs_error_t SrsRtcRtpBuilder::package_nalus(SrsSharedPtrMessage* msg, const vect
|
|
|
|
for (int i = 0; i < (int)samples.size(); i++) {
|
|
|
|
for (int i = 0; i < (int)samples.size(); i++) {
|
|
|
|
SrsSample* sample = samples[i];
|
|
|
|
SrsSample* sample = samples[i];
|
|
|
|
|
|
|
|
|
|
|
|
// We always ignore bframe here, if config to discard bframe,
|
|
|
|
|
|
|
|
// the bframe flag will not be set.
|
|
|
|
|
|
|
|
if (sample->bframe) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!sample->size) {
|
|
|
|
if (!sample->size) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|