blob: baad38f5f68c487c4281b3c4d06edfd0553686c3 [file] [log] [blame]
mflodman@webrtc.org02270cd2015-02-06 13:10:19 +00001/*
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_VIDEO_ENGINE_PAYLOAD_ROUTER_H_
12#define WEBRTC_VIDEO_ENGINE_PAYLOAD_ROUTER_H_
13
14#include <list>
15#include <vector>
16
17#include "webrtc/base/constructormagic.h"
18#include "webrtc/base/thread_annotations.h"
19#include "webrtc/common_types.h"
20#include "webrtc/system_wrappers/interface/scoped_ptr.h"
21
22namespace webrtc {
23
24class CriticalSectionWrapper;
25class RTPFragmentationHeader;
26class RtpRtcp;
27struct RTPVideoHeader;
28
29// PayloadRouter routes outgoing data to the correct sending RTP module, based
30// on the simulcast layer in RTPVideoHeader.
31class PayloadRouter {
32 public:
33 PayloadRouter();
34 ~PayloadRouter();
35
mflodman@webrtc.orga4ef2ce2015-02-12 09:54:18 +000036 static size_t DefaultMaxPayloadLength();
37
mflodman@webrtc.org02270cd2015-02-06 13:10:19 +000038 // Rtp modules are assumed to be sorted in simulcast index order.
39 void SetSendingRtpModules(const std::list<RtpRtcp*>& rtp_modules);
40
41 // PayloadRouter will only route packets if being active, all packets will be
42 // dropped otherwise.
43 void set_active(bool active);
44 bool active();
45
46 // Input parameters according to the signature of RtpRtcp::SendOutgoingData.
47 // Returns true if the packet was routed / sent, false otherwise.
48 bool RoutePayload(FrameType frame_type,
49 int8_t payload_type,
50 uint32_t time_stamp,
51 int64_t capture_time_ms,
52 const uint8_t* payload_data,
53 size_t payload_size,
54 const RTPFragmentationHeader* fragmentation,
55 const RTPVideoHeader* rtp_video_hdr);
56
mflodman@webrtc.orga4ef2ce2015-02-12 09:54:18 +000057 // Returns the maximum allowed data payload length, given the configured MTU
58 // and RTP headers.
59 size_t MaxPayloadLength() const;
60
mflodman@webrtc.org02270cd2015-02-06 13:10:19 +000061 private:
62 scoped_ptr<CriticalSectionWrapper> crit_;
63
64 // Active sending RTP modules, in layer order.
65 std::vector<RtpRtcp*> rtp_modules_ GUARDED_BY(crit_.get());
66 bool active_ GUARDED_BY(crit_.get());
67
68 DISALLOW_COPY_AND_ASSIGN(PayloadRouter);
69};
70
71} // namespace webrtc
72
73#endif // WEBRTC_VIDEO_ENGINE_PAYLOAD_ROUTER_H_