| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | #ifndef MEDIA_ENGINE_UNHANDLED_PACKETS_BUFFER_H_ |
| 12 | #define MEDIA_ENGINE_UNHANDLED_PACKETS_BUFFER_H_ |
| 13 |
| 14 | #include <stdint.h> |
| 15 |
| 16 | #include <functional> |
| 17 | #include <tuple> |
| 18 | #include <utility> |
| 19 | #include <vector> |
| 20 |
| 21 | #include "rtc_base/copy_on_write_buffer.h" |
| 22 |
| 23 | namespace cricket { |
| 24 |
| 25 | class UnhandledPacketsBuffer { |
| 26 | public: |
| 27 | // Visible for testing. |
| 28 | static constexpr size_t kMaxStashedPackets = 50; |
| 29 |
| 30 | UnhandledPacketsBuffer(); |
| 31 | ~UnhandledPacketsBuffer(); |
| 32 |
| 33 | // Store packet in buffer. |
| 34 | void AddPacket(uint32_t ssrc, |
| 35 | int64_t packet_time_us, |
| 36 | rtc::CopyOnWriteBuffer packet); |
| 37 |
| 38 | // Feed all packets with |ssrcs| into |consumer|. |
| 39 | void BackfillPackets( |
| 40 | rtc::ArrayView<const uint32_t> ssrcs, |
| 41 | std::function<void(uint32_t, int64_t, rtc::CopyOnWriteBuffer)> consumer); |
| 42 |
| 43 | private: |
| 44 | size_t insert_pos_ = 0; |
| 45 | struct PacketWithMetadata { |
| 46 | uint32_t ssrc; |
| 47 | int64_t packet_time_us; |
| 48 | rtc::CopyOnWriteBuffer packet; |
| 49 | }; |
| 50 | std::vector<PacketWithMetadata> buffer_; |
| 51 | }; |
| 52 |
| 53 | } // namespace cricket |
| 54 |
| 55 | #endif // MEDIA_ENGINE_UNHANDLED_PACKETS_BUFFER_H_ |
| 56 |