| OLD | NEW | 
|     1 /* |     1 /* | 
|     2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |     2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 
|     3  * |     3  * | 
|     4  *  Use of this source code is governed by a BSD-style license |     4  *  Use of this source code is governed by a BSD-style license | 
|     5  *  that can be found in the LICENSE file in the root of the source |     5  *  that can be found in the LICENSE file in the root of the source | 
|     6  *  tree. An additional intellectual property rights grant can be found |     6  *  tree. An additional intellectual property rights grant can be found | 
|     7  *  in the file PATENTS.  All contributing project authors may |     7  *  in the file PATENTS.  All contributing project authors may | 
|     8  *  be found in the AUTHORS file in the root of the source tree. |     8  *  be found in the AUTHORS file in the root of the source tree. | 
|     9  */ |     9  */ | 
|    10  |    10  | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|    21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" |    21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" | 
|    22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" |    22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/compound_packet.h" | 
|    23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h" |    23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h" | 
|    24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" |    24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" | 
|    25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" |    25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" | 
|    26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" |    26 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" | 
|    27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" |    27 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h" | 
|    28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h" |    28 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h" | 
|    29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" |    29 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h" | 
|    30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" |    30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" | 
|    31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rpsi.h" |  | 
|    32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" |    31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" | 
|    33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" |    32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h" | 
|    34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.h" |  | 
|    35 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h" |    33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.h" | 
|    36 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |    34 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 
|    37 #include "webrtc/modules/rtp_rtcp/source/rtcp_receiver.h" |    35 #include "webrtc/modules/rtp_rtcp/source/rtcp_receiver.h" | 
|    38 #include "webrtc/modules/rtp_rtcp/source/time_util.h" |    36 #include "webrtc/modules/rtp_rtcp/source/time_util.h" | 
|    39 #include "webrtc/system_wrappers/include/ntp_time.h" |    37 #include "webrtc/system_wrappers/include/ntp_time.h" | 
|    40 #include "webrtc/test/gmock.h" |    38 #include "webrtc/test/gmock.h" | 
|    41 #include "webrtc/test/gtest.h" |    39 #include "webrtc/test/gtest.h" | 
|    42  |    40  | 
|    43 namespace webrtc { |    41 namespace webrtc { | 
|    44 namespace { |    42 namespace { | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|    58  |    56  | 
|    59 class MockRtcpPacketTypeCounterObserver : public RtcpPacketTypeCounterObserver { |    57 class MockRtcpPacketTypeCounterObserver : public RtcpPacketTypeCounterObserver { | 
|    60  public: |    58  public: | 
|    61   MOCK_METHOD2(RtcpPacketTypesCounterUpdated, |    59   MOCK_METHOD2(RtcpPacketTypesCounterUpdated, | 
|    62                void(uint32_t, const RtcpPacketTypeCounter&)); |    60                void(uint32_t, const RtcpPacketTypeCounter&)); | 
|    63 }; |    61 }; | 
|    64  |    62  | 
|    65 class MockRtcpIntraFrameObserver : public RtcpIntraFrameObserver { |    63 class MockRtcpIntraFrameObserver : public RtcpIntraFrameObserver { | 
|    66  public: |    64  public: | 
|    67   MOCK_METHOD1(OnReceivedIntraFrameRequest, void(uint32_t)); |    65   MOCK_METHOD1(OnReceivedIntraFrameRequest, void(uint32_t)); | 
|    68   MOCK_METHOD2(OnReceivedSLI, void(uint32_t, uint8_t)); |  | 
|    69   MOCK_METHOD2(OnReceivedRPSI, void(uint32_t, uint64_t)); |  | 
|    70 }; |    66 }; | 
|    71  |    67  | 
|    72 class MockRtcpCallbackImpl : public RtcpStatisticsCallback { |    68 class MockRtcpCallbackImpl : public RtcpStatisticsCallback { | 
|    73  public: |    69  public: | 
|    74   MOCK_METHOD2(StatisticsUpdated, void(const RtcpStatistics&, uint32_t)); |    70   MOCK_METHOD2(StatisticsUpdated, void(const RtcpStatistics&, uint32_t)); | 
|    75   MOCK_METHOD2(CNameChanged, void(const char*, uint32_t)); |    71   MOCK_METHOD2(CNameChanged, void(const char*, uint32_t)); | 
|    76 }; |    72 }; | 
|    77  |    73  | 
|    78 class MockTransportFeedbackObserver : public TransportFeedbackObserver { |    74 class MockTransportFeedbackObserver : public TransportFeedbackObserver { | 
|    79  public: |    75  public: | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   169 TEST_F(RtcpReceiverTest, InvalidFeedbackPacketIsIgnored) { |   165 TEST_F(RtcpReceiverTest, InvalidFeedbackPacketIsIgnored) { | 
|   170   // Too short feedback packet. |   166   // Too short feedback packet. | 
|   171   const uint8_t bad_packet[] = {0x81, rtcp::Rtpfb::kPacketType, 0, 0}; |   167   const uint8_t bad_packet[] = {0x81, rtcp::Rtpfb::kPacketType, 0, 0}; | 
|   172  |   168  | 
|   173   // TODO(danilchap): Add expectation RtcpPacketTypesCounterUpdated |   169   // TODO(danilchap): Add expectation RtcpPacketTypesCounterUpdated | 
|   174   // is not called once parser would be adjusted to avoid that callback on |   170   // is not called once parser would be adjusted to avoid that callback on | 
|   175   // semi-valid packets. |   171   // semi-valid packets. | 
|   176   InjectRtcpPacket(bad_packet); |   172   InjectRtcpPacket(bad_packet); | 
|   177 } |   173 } | 
|   178  |   174  | 
|   179 TEST_F(RtcpReceiverTest, RpsiWithFractionalPaddingIsIgnored) { |  | 
|   180   // Padding size represent fractional number of bytes. |  | 
|   181   const uint8_t kPaddingSizeBits = 0x0b; |  | 
|   182   // clang-format off |  | 
|   183   const uint8_t bad_packet[] = {0x80 | rtcp::Rpsi::kFeedbackMessageType, |  | 
|   184                                       rtcp::Rpsi::kPacketType, 0, 3, |  | 
|   185                                 0x12, 0x34, 0x56, 0x78, |  | 
|   186                                 0x98, 0x76, 0x54, 0x32, |  | 
|   187                                 kPaddingSizeBits, 0x00, 0x00, 0x00}; |  | 
|   188   // clang-format on |  | 
|   189   EXPECT_CALL(intra_frame_observer_, OnReceivedRPSI(_, _)).Times(0); |  | 
|   190   InjectRtcpPacket(bad_packet); |  | 
|   191 } |  | 
|   192  |  | 
|   193 TEST_F(RtcpReceiverTest, RpsiWithTooLargePaddingIsIgnored) { |  | 
|   194   // Padding size exceeds packet size. |  | 
|   195   const uint8_t kPaddingSizeBits = 0xa8; |  | 
|   196   // clang-format off |  | 
|   197   const uint8_t bad_packet[] = {0x80 | rtcp::Rpsi::kFeedbackMessageType, |  | 
|   198                                       rtcp::Rpsi::kPacketType, 0, 3, |  | 
|   199                                 0x12, 0x34, 0x56, 0x78, |  | 
|   200                                 0x98, 0x76, 0x54, 0x32, |  | 
|   201                                 kPaddingSizeBits, 0x00, 0x00, 0x00}; |  | 
|   202   // clang-format on |  | 
|   203   EXPECT_CALL(intra_frame_observer_, OnReceivedRPSI(_, _)).Times(0); |  | 
|   204   InjectRtcpPacket(bad_packet); |  | 
|   205 } |  | 
|   206  |  | 
|   207 // With parsing using rtcp classes this test will make no sense. |  | 
|   208 // With current stateful parser this test was failing. |  | 
|   209 TEST_F(RtcpReceiverTest, TwoHalfValidRpsiAreIgnored) { |  | 
|   210   // clang-format off |  | 
|   211   const uint8_t bad_packet[] = {0x80 | rtcp::Rpsi::kFeedbackMessageType, |  | 
|   212                                       rtcp::Rpsi::kPacketType, 0, 2, |  | 
|   213                                 0x12, 0x34, 0x56, 0x78, |  | 
|   214                                 0x98, 0x76, 0x54, 0x32, |  | 
|   215                                 0x80 | rtcp::Rpsi::kFeedbackMessageType, |  | 
|   216                                       rtcp::Rpsi::kPacketType, 0, 2, |  | 
|   217                                 0x12, 0x34, 0x56, 0x78, |  | 
|   218                                 0x98, 0x76, 0x54, 0x32}; |  | 
|   219   // clang-format on |  | 
|   220   EXPECT_CALL(intra_frame_observer_, OnReceivedRPSI(_, _)).Times(0); |  | 
|   221   InjectRtcpPacket(bad_packet); |  | 
|   222 } |  | 
|   223  |  | 
|   224 TEST_F(RtcpReceiverTest, InjectRpsiPacket) { |  | 
|   225   const uint64_t kPictureId = 0x123456789; |  | 
|   226   rtcp::Rpsi rpsi; |  | 
|   227   rpsi.SetPictureId(kPictureId); |  | 
|   228  |  | 
|   229   EXPECT_CALL(intra_frame_observer_, OnReceivedRPSI(_, kPictureId)); |  | 
|   230   InjectRtcpPacket(rpsi); |  | 
|   231 } |  | 
|   232  |  | 
|   233 TEST_F(RtcpReceiverTest, InjectSrPacket) { |   175 TEST_F(RtcpReceiverTest, InjectSrPacket) { | 
|   234   RTCPSenderInfo info; |   176   RTCPSenderInfo info; | 
|   235   EXPECT_EQ(-1, rtcp_receiver_.SenderInfoReceived(&info)); |   177   EXPECT_EQ(-1, rtcp_receiver_.SenderInfoReceived(&info)); | 
|   236  |   178  | 
|   237   int64_t now = system_clock_.TimeInMilliseconds(); |   179   int64_t now = system_clock_.TimeInMilliseconds(); | 
|   238   rtcp::SenderReport sr; |   180   rtcp::SenderReport sr; | 
|   239   sr.SetSenderSsrc(kSenderSsrc); |   181   sr.SetSenderSsrc(kSenderSsrc); | 
|   240  |   182  | 
|   241   EXPECT_CALL(rtp_rtcp_impl_, OnReceivedRtcpReportBlocks(IsEmpty())); |   183   EXPECT_CALL(rtp_rtcp_impl_, OnReceivedRtcpReportBlocks(IsEmpty())); | 
|   242   EXPECT_CALL(bandwidth_observer_, |   184   EXPECT_CALL(bandwidth_observer_, | 
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   677 } |   619 } | 
|   678  |   620  | 
|   679 TEST_F(RtcpReceiverTest, FirPacketNotToUsIgnored) { |   621 TEST_F(RtcpReceiverTest, FirPacketNotToUsIgnored) { | 
|   680   rtcp::Fir fir; |   622   rtcp::Fir fir; | 
|   681   fir.AddRequestTo(kNotToUsSsrc, 13); |   623   fir.AddRequestTo(kNotToUsSsrc, 13); | 
|   682  |   624  | 
|   683   EXPECT_CALL(intra_frame_observer_, OnReceivedIntraFrameRequest(_)).Times(0); |   625   EXPECT_CALL(intra_frame_observer_, OnReceivedIntraFrameRequest(_)).Times(0); | 
|   684   InjectRtcpPacket(fir); |   626   InjectRtcpPacket(fir); | 
|   685 } |   627 } | 
|   686  |   628  | 
|   687 TEST_F(RtcpReceiverTest, InjectSliPacket) { |  | 
|   688   const uint8_t kPictureId = 40; |  | 
|   689   rtcp::Sli sli; |  | 
|   690   sli.AddPictureId(kPictureId); |  | 
|   691  |  | 
|   692   EXPECT_CALL(intra_frame_observer_, OnReceivedSLI(_, kPictureId)); |  | 
|   693   InjectRtcpPacket(sli); |  | 
|   694 } |  | 
|   695  |  | 
|   696 TEST_F(RtcpReceiverTest, ExtendedReportsPacketWithZeroReportBlocksIgnored) { |   629 TEST_F(RtcpReceiverTest, ExtendedReportsPacketWithZeroReportBlocksIgnored) { | 
|   697   rtcp::ExtendedReports xr; |   630   rtcp::ExtendedReports xr; | 
|   698   xr.SetSenderSsrc(kSenderSsrc); |   631   xr.SetSenderSsrc(kSenderSsrc); | 
|   699  |   632  | 
|   700   InjectRtcpPacket(xr); |   633   InjectRtcpPacket(xr); | 
|   701 } |   634 } | 
|   702  |   635  | 
|   703 // VOiP reports are ignored. |   636 // VOiP reports are ignored. | 
|   704 TEST_F(RtcpReceiverTest, InjectExtendedReportsVoipPacket) { |   637 TEST_F(RtcpReceiverTest, InjectExtendedReportsVoipPacket) { | 
|   705   const uint8_t kLossRate = 123; |   638   const uint8_t kLossRate = 123; | 
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1309  |  1242  | 
|  1310   rtcp::ExtendedReports xr; |  1243   rtcp::ExtendedReports xr; | 
|  1311   xr.SetTargetBitrate(bitrate); |  1244   xr.SetTargetBitrate(bitrate); | 
|  1312  |  1245  | 
|  1313   EXPECT_CALL(bitrate_allocation_observer_, |  1246   EXPECT_CALL(bitrate_allocation_observer_, | 
|  1314               OnBitrateAllocationUpdated(expected_allocation)); |  1247               OnBitrateAllocationUpdated(expected_allocation)); | 
|  1315   InjectRtcpPacket(xr); |  1248   InjectRtcpPacket(xr); | 
|  1316 } |  1249 } | 
|  1317  |  1250  | 
|  1318 }  // namespace webrtc |  1251 }  // namespace webrtc | 
| OLD | NEW |