NetEq now works with packets as values, rather than pointers.

PacketList is now list<Packet> instead of list<Packet*>.
Splicing the lists in NetEqImpl::InsertPacketInternal instead of
moving packets. Avoid moving the packet when doing Rfc3389Cng.
Removed PacketBuffer::DeleteFirstPacket and DeleteAllPackets.

BUG=chromium:657300

Review-Url: https://codereview.webrtc.org/2425223002
Cr-Commit-Position: refs/heads/master@{#14747}
diff --git a/webrtc/modules/audio_coding/neteq/packet_buffer.h b/webrtc/modules/audio_coding/neteq/packet_buffer.h
index 63e006c..a26d6c5 100644
--- a/webrtc/modules/audio_coding/neteq/packet_buffer.h
+++ b/webrtc/modules/audio_coding/neteq/packet_buffer.h
@@ -51,7 +51,7 @@
   // the packet object.
   // Returns PacketBuffer::kOK on success, PacketBuffer::kFlushed if the buffer
   // was flushed due to overfilling.
-  virtual int InsertPacket(Packet* packet);
+  virtual int InsertPacket(Packet&& packet);
 
   // Inserts a list of packets into the buffer. The buffer will take over
   // ownership of the packet objects.
@@ -85,13 +85,9 @@
   // NULL if the buffer is empty.
   virtual const Packet* PeekNextPacket() const;
 
-  // Extracts the first packet in the buffer and returns a pointer to it.
-  // Returns NULL if the buffer is empty. The caller is responsible for deleting
-  // the packet.
-  // Subsequent packets with the same timestamp as the one extracted will be
-  // discarded and properly deleted. The number of discarded packets will be
-  // written to the output variable |discard_count|.
-  virtual Packet* GetNextPacket(size_t* discard_count);
+  // Extracts the first packet in the buffer and returns it.
+  // Returns an empty optional if the buffer is empty.
+  virtual rtc::Optional<Packet> GetNextPacket();
 
   // Discards the first packet in the buffer. The packet is deleted.
   // Returns PacketBuffer::kBufferEmpty if the buffer is empty,
@@ -123,15 +119,6 @@
 
   virtual void BufferStat(int* num_packets, int* max_num_packets) const;
 
-  // Static method that properly deletes the first packet, and its payload
-  // array, in |packet_list|. Returns false if |packet_list| already was empty,
-  // otherwise true.
-  static bool DeleteFirstPacket(PacketList* packet_list);
-
-  // Static method that properly deletes all packets, and their payload arrays,
-  // in |packet_list|.
-  static void DeleteAllPackets(PacketList* packet_list);
-
   // Static method returning true if |timestamp| is older than |timestamp_limit|
   // but less than |horizon_samples| behind |timestamp_limit|. For instance,
   // with timestamp_limit = 100 and horizon_samples = 10, a timestamp in the