blob: 9d461d13a98d57264dbb65ec4881e5290eddd8b5 [file] [log] [blame]
Stefan Holmere5904162015-03-26 11:11:06 +01001/*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 *
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
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 WEBRTC_MODULES_PACING_INCLUDE_PACKET_ROUTER_H_
12#define WEBRTC_MODULES_PACING_INCLUDE_PACKET_ROUTER_H_
13
14#include <list>
15
16#include "webrtc/base/constructormagic.h"
sprang867fb522015-08-03 04:38:41 -070017#include "webrtc/base/criticalsection.h"
Stefan Holmere5904162015-03-26 11:11:06 +010018#include "webrtc/base/scoped_ptr.h"
19#include "webrtc/base/thread_annotations.h"
20#include "webrtc/common_types.h"
21#include "webrtc/modules/pacing/include/paced_sender.h"
sprangebbf8a82015-09-21 15:11:14 -070022#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
Stefan Holmere5904162015-03-26 11:11:06 +010023
24namespace webrtc {
25
Stefan Holmere5904162015-03-26 11:11:06 +010026class RtpRtcp;
sprangebbf8a82015-09-21 15:11:14 -070027namespace rtcp {
28class TransportFeedback;
29} // namespace rtcp
Stefan Holmere5904162015-03-26 11:11:06 +010030
31// PacketRouter routes outgoing data to the correct sending RTP module, based
32// on the simulcast layer in RTPVideoHeader.
sprangebbf8a82015-09-21 15:11:14 -070033class PacketRouter : public PacedSender::Callback,
34 public TransportSequenceNumberAllocator {
Stefan Holmere5904162015-03-26 11:11:06 +010035 public:
36 PacketRouter();
37 virtual ~PacketRouter();
38
39 void AddRtpModule(RtpRtcp* rtp_module);
40 void RemoveRtpModule(RtpRtcp* rtp_module);
41
42 // Implements PacedSender::Callback.
43 bool TimeToSendPacket(uint32_t ssrc,
44 uint16_t sequence_number,
45 int64_t capture_timestamp,
46 bool retransmission) override;
47
48 size_t TimeToSendPadding(size_t bytes) override;
49
sprang867fb522015-08-03 04:38:41 -070050 void SetTransportWideSequenceNumber(uint16_t sequence_number);
sprangebbf8a82015-09-21 15:11:14 -070051 uint16_t AllocateSequenceNumber() override;
Stefan Holmere5904162015-03-26 11:11:06 +010052
sprang233bd872015-09-08 13:25:16 -070053 // Send transport feedback packet to send-side.
54 virtual bool SendFeedback(rtcp::TransportFeedback* packet);
55
sprang867fb522015-08-03 04:38:41 -070056 private:
57 rtc::CriticalSection modules_lock_;
Stefan Holmere5904162015-03-26 11:11:06 +010058 // Map from ssrc to sending rtp module.
sprang867fb522015-08-03 04:38:41 -070059 std::list<RtpRtcp*> rtp_modules_ GUARDED_BY(modules_lock_);
60
61 volatile int transport_seq_;
Stefan Holmere5904162015-03-26 11:11:06 +010062
henrikg3c089d72015-09-16 05:37:44 -070063 RTC_DISALLOW_COPY_AND_ASSIGN(PacketRouter);
Stefan Holmere5904162015-03-26 11:11:06 +010064};
65} // namespace webrtc
66#endif // WEBRTC_MODULES_PACING_INCLUDE_PACKET_ROUTER_H_