modules/audio_coding/neteq/packet_buffer_unittest.cc
TEST(PacketBuffer, InsertPacketListChangePayloadType) {
  PacketBuffer buffer(10);  // 10 packets.
  PacketGenerator gen(0, 0, 0, 10);
  PacketList list;
  const int payload_len = 10;

  // Insert 10 small packets.
  for (int i = 0; i < 10; ++i) {
    Packet* packet = gen.NextPacket(payload_len);
    list.push_back(packet);
  }
  // Insert 11th packet of another payload type (not CNG).
  Packet* packet = gen.NextPacket(payload_len);
  packet->header.payloadType = 1;
  list.push_back(packet);


  MockDecoderDatabase decoder_database;
  EXPECT_CALL(decoder_database, IsComfortNoise(_))
      .WillRepeatedly(Return(false));
  EXPECT_CALL(decoder_database, IsDtmf(_))
      .WillRepeatedly(Return(false));
  uint8_t current_pt = 0xFF;
  uint8_t current_cng_pt = 0xFF;
  EXPECT_EQ(PacketBuffer::kFlushed, buffer.InsertPacketList(&list,
                                                            decoder_database,
                                                            &current_pt,
                                                            &current_cng_pt));
  EXPECT_TRUE(list.empty());  // The PacketBuffer should have depleted the list.
  EXPECT_EQ(1u, buffer.NumPacketsInBuffer());  // Only the last packet.
  EXPECT_EQ(1, current_pt);  // Current payload type changed to 0.
  EXPECT_EQ(0xFF, current_cng_pt);  // CNG payload type not changed.

  buffer.Flush();  // Clean up.

  EXPECT_CALL(decoder_database, Die());  // Called when object is deleted.
}
// Test inserting a list of packets. Last packet is of a different payload type.
// Expecting the buffer to flush.
// TODO(hlundin): Remove this test when legacy operation is no longer needed.
Test inserting a list of packets. Last packet is of a different payload type.
Expecting the buffer to flush.
TODO(hlundin): Remove this test when legacy operation is no longer needed.
Test inserting a list of packets . Last packet is of a different payload type . Expecting the buffer to flush . TODO ( hlundin ) : Remove this test when legacy operation is no longer needed .
TEST(PacketBuffer, InsertPacketListChangePayloadType) {
  PacketBuffer buffer(10);  
  PacketGenerator gen(0, 0, 0, 10);
  PacketList list;
  const int payload_len = 10;
  for (int i = 0; i < 10; ++i) {
    Packet* packet = gen.NextPacket(payload_len);
    list.push_back(packet);
  }
  Packet* packet = gen.NextPacket(payload_len);
  packet->header.payloadType = 1;
  list.push_back(packet);
  MockDecoderDatabase decoder_database;
  EXPECT_CALL(decoder_database, IsComfortNoise(_))
      .WillRepeatedly(Return(false));
  EXPECT_CALL(decoder_database, IsDtmf(_))
      .WillRepeatedly(Return(false));
  uint8_t current_pt = 0xFF;
  uint8_t current_cng_pt = 0xFF;
  EXPECT_EQ(PacketBuffer::kFlushed, buffer.InsertPacketList(&list,
                                                            decoder_database,
                                                            &current_pt,
                                                            &current_cng_pt));
  EXPECT_TRUE(list.empty());  
  EXPECT_EQ(1u, buffer.NumPacketsInBuffer());  
  EXPECT_EQ(1, current_pt);  
  EXPECT_EQ(0xFF, current_cng_pt);  
  buffer.Flush();  
  EXPECT_CALL(decoder_database, Die());  
}
TEST ( PacketBuffer , InsertPacketListChangePayloadType ) { PacketBuffer buffer ( 10 ) ; PacketGenerator gen ( 0 , 0 , 0 , 10 ) ; PacketList list ; const int payload_len = 10 ; for ( int i = 0 ; i < 10 ; ++ i ) { Packet * packet = gen . NextPacket ( payload_len ) ; list . push_back ( packet ) ; } Packet * packet = gen . NextPacket ( payload_len ) ; packet -> header . payloadType = 1 ; list . push_back ( packet ) ; MockDecoderDatabase decoder_database ; EXPECT_CALL ( decoder_database , IsComfortNoise ( _ ) ) . WillRepeatedly ( Return ( false ) ) ; EXPECT_CALL ( decoder_database , IsDtmf ( _ ) ) . WillRepeatedly ( Return ( false ) ) ; uint8_t current_pt = 0xFF ; uint8_t current_cng_pt = 0xFF ; EXPECT_EQ ( PacketBuffer :: kFlushed , buffer . InsertPacketList ( & list , decoder_database , & current_pt , & current_cng_pt ) ) ; EXPECT_TRUE ( list . empty ( ) ) ; EXPECT_EQ ( 1u , buffer . NumPacketsInBuffer ( ) ) ; EXPECT_EQ ( 1 , current_pt ) ; EXPECT_EQ ( 0xFF , current_cng_pt ) ; buffer . Flush ( ) ; EXPECT_CALL ( decoder_database , Die ( ) ) ; }
Test inserting a list of packets.
Test inserting a list of packets .
// 10 packets. // Insert 10 small packets. // Insert 11th packet of another payload type (not CNG). // The PacketBuffer should have depleted the list. // Only the last packet. // Current payload type changed to 0. // CNG payload type not changed. // Clean up. // Called when object is deleted.