RtpInboundHandler extends SimpleChannelInboundHandler<RtpPacket> { public void updateMode(ConnectionMode mode) { switch (mode) { case INACTIVE: case SEND_ONLY: this.context.setLoopable(false); this.context.setReceivable(false); break; case RECV_ONLY: this.context.setLoopable(false); this.context.setReceivable(true); break; case SEND_RECV: case CONFERENCE: this.context.setLoopable(false); this.context.setReceivable(true); break; case NETWORK_LOOPBACK: this.context.setLoopable(true); this.context.setReceivable(false); break; default: this.context.setLoopable(false); this.context.setReceivable(false); break; } } RtpInboundHandler(RtpInboundHandlerGlobalContext context); void activate(); void deactivate(); boolean isActive(); void updateMode(ConnectionMode mode); void setFormatMap(RTPFormats formats); void useJitterBuffer(boolean use); RTPInput getRtpInput(); DtmfInput getDtmfInput();  }
@Test public void testUpdateMode() { final Clock clock = mock(Clock.class); final RtpStatistics statistics = mock(RtpStatistics.class); final JitterBuffer jitterBuffer = mock(JitterBuffer.class); final RTPInput rtpInput = mock(RTPInput.class); final DtmfInput dtmfInput = mock(DtmfInput.class); final RtpInboundHandlerGlobalContext context = spy(new RtpInboundHandlerGlobalContext(clock, statistics, jitterBuffer, rtpInput, dtmfInput)); this.handler = new RtpInboundHandler(context); handler.activate(); handler.updateMode(ConnectionMode.RECV_ONLY); verify(context).setLoopable(false); verify(context).setReceivable(true); }