blob: c1b332a6bfc6b1ad6e7af0bea989b0803a648c89 [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"
17#include "webrtc/base/scoped_ptr.h"
18#include "webrtc/base/thread_annotations.h"
19#include "webrtc/common_types.h"
20#include "webrtc/modules/pacing/include/paced_sender.h"
21
22namespace webrtc {
23
24class CriticalSectionWrapper;
25class RTPFragmentationHeader;
26class RtpRtcp;
27struct RTPVideoHeader;
28
29// PacketRouter routes outgoing data to the correct sending RTP module, based
30// on the simulcast layer in RTPVideoHeader.
31class PacketRouter : public PacedSender::Callback {
32 public:
33 PacketRouter();
34 virtual ~PacketRouter();
35
36 void AddRtpModule(RtpRtcp* rtp_module);
37 void RemoveRtpModule(RtpRtcp* rtp_module);
38
39 // Implements PacedSender::Callback.
40 bool TimeToSendPacket(uint32_t ssrc,
41 uint16_t sequence_number,
42 int64_t capture_timestamp,
43 bool retransmission) override;
44
45 size_t TimeToSendPadding(size_t bytes) override;
46
47 private:
48 // TODO(holmer): When the new video API has launched, remove crit_ and
49 // assume rtp_modules_ will never change during a call. We should then also
50 // switch rtp_modules_ to a map from ssrc to rtp module.
51 rtc::scoped_ptr<CriticalSectionWrapper> crit_;
52
53 // Map from ssrc to sending rtp module.
54 std::list<RtpRtcp*> rtp_modules_ GUARDED_BY(crit_.get());
55
56 DISALLOW_COPY_AND_ASSIGN(PacketRouter);
57};
58} // namespace webrtc
59#endif // WEBRTC_MODULES_PACING_INCLUDE_PACKET_ROUTER_H_