Commit 35a69f81 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Handle reception of RTCP PLI and FIR feedback messages for VP8.

parent 7ba7fe33
......@@ -208,6 +208,10 @@ typedef enum _MSRecorderState MSRecorderState;
MS_FILTER_METHOD(MSFilterVideoEncoderInterface, 2, const MSVideoConfiguration **)
#define MS_VIDEO_ENCODER_SET_CONFIGURATION \
MS_FILTER_METHOD(MSFilterVideoEncoderInterface, 3, const MSVideoConfiguration *)
#define MS_VIDEO_ENCODER_NOTIFY_PLI \
MS_FILTER_METHOD_NO_ARG(MSFilterVideoEncoderInterface, 4)
#define MS_VIDEO_ENCODER_NOTIFY_FIR \
MS_FILTER_METHOD(MSFilterVideoEncoderInterface, 5, uint8_t *)
/** Interface definitions for audio capture */
/* Start numbering from the end for hacks */
......
......@@ -122,6 +122,7 @@ typedef struct EncState {
vpx_codec_enc_cfg_t cfg;
long long frame_count;
unsigned int mtu;
int last_fir_seq_nr;
#ifdef USE_VIDEO_STARTER
VideoStarter starter;
#endif
......@@ -154,6 +155,7 @@ static void enc_init(MSFilter *f) {
MS_VIDEO_SIZE_ASSIGN(vsize, CIF);
s->vconf = ms_video_find_best_configuration_for_size(s->vconf_list, vsize);
s->frame_count = 0;
s->last_fir_seq_nr = -1;
s->cfg.g_w = s->vconf.vsize.width;
s->cfg.g_h = s->vconf.vsize.height;
/* encoder automatically places keyframes */
......@@ -391,6 +393,22 @@ static int enc_req_vfu(MSFilter *f, void *unused){
return 0;
}
static int enc_notify_pli(MSFilter *f, void *data) {
EncState *s = (EncState *)f->data;
s->req_vfu = TRUE; /* For the moment generate Intra Frame on Picture Loss Indication */
return 0;
}
static int enc_notify_fir(MSFilter *f, void *data) {
EncState *s = (EncState *)f->data;
uint8_t seq_nr = *((uint8_t *)data);
if (seq_nr != s->last_fir_seq_nr) {
s->req_vfu = TRUE;
s->last_fir_seq_nr = seq_nr;
}
return 0;
}
static int enc_get_configuration_list(MSFilter *f, void *data) {
EncState *s = (EncState *)f->data;
const MSVideoConfiguration **vconf_list = (const MSVideoConfiguration **)data;
......@@ -409,6 +427,8 @@ static MSFilterMethod enc_methods[] = {
{ MS_FILTER_SET_MTU, enc_set_mtu },
{ MS_FILTER_REQ_VFU, enc_req_vfu },
{ MS_VIDEO_ENCODER_REQ_VFU, enc_req_vfu },
{ MS_VIDEO_ENCODER_NOTIFY_PLI, enc_notify_pli },
{ MS_VIDEO_ENCODER_NOTIFY_FIR, enc_notify_fir },
{ MS_VIDEO_ENCODER_GET_CONFIGURATION_LIST, enc_get_configuration_list },
{ MS_VIDEO_ENCODER_SET_CONFIGURATION, enc_set_configuration },
{ 0, NULL }
......
......@@ -86,6 +86,34 @@ static void video_stream_process_rtcp(MediaStream *media_stream, mblk_t *m){
if (stream->ms.rc)
ms_bitrate_controller_process_rtcp(stream->ms.rc,m);
}
} else if (rtcp_is_PSFB(m)) {
if (rtcp_PSFB_get_type(m) == RTCP_PSFB_FIR) {
/* Special case for FIR where the packet sender ssrc must be equal to 0. */
if ((rtcp_PSFB_get_media_source_ssrc(m) == rtp_session_get_recv_ssrc(stream->ms.sessions.rtp_session))
&& (rtcp_PSFB_get_packet_sender_ssrc(m) == 0)) {
unsigned int i;
for (i = 0; ; i++) {
rtcp_fb_fir_fci_t *fci = rtcp_PSFB_fir_get_fci(m, i);
if (fci == NULL) break;
if (rtcp_PSFB_fir_fci_get_ssrc(fci) == rtp_session_get_send_ssrc(stream->ms.sessions.rtp_session)) {
uint8_t seq_nr = rtcp_PSFB_fir_fci_get_seq_nr(fci);
ms_filter_call_method(stream->ms.encoder, MS_VIDEO_ENCODER_NOTIFY_FIR, &seq_nr);
break;
}
}
}
} else {
if ((rtcp_PSFB_get_media_source_ssrc(m) == rtp_session_get_recv_ssrc(stream->ms.sessions.rtp_session))
&& (rtcp_PSFB_get_packet_sender_ssrc(m) == rtp_session_get_send_ssrc(stream->ms.sessions.rtp_session))) {
switch (rtcp_PSFB_get_type(m)) {
case RTCP_PSFB_PLI:
ms_filter_call_method_noarg(stream->ms.encoder, MS_VIDEO_ENCODER_NOTIFY_PLI);
break;
default:
break;
}
}
}
}
}while(rtcp_next_packet(m));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment