blob: 3cc0bb0a618952dd101b1b7774aa8822208ff6e7 [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
36 // Rtp modules are assumed to be sorted in simulcast index order.
37 void SetSendingRtpModules(const std::list<RtpRtcp*>& rtp_modules);
38
39 // PayloadRouter will only route packets if being active, all packets will be
40 // dropped otherwise.
41 void set_active(bool active);
42 bool active();
43
44 // Input parameters according to the signature of RtpRtcp::SendOutgoingData.
45 // Returns true if the packet was routed / sent, false otherwise.
46 bool RoutePayload(FrameType frame_type,
47 int8_t payload_type,
48 uint32_t time_stamp,
49 int64_t capture_time_ms,
50 const uint8_t* payload_data,
51 size_t payload_size,
52 const RTPFragmentationHeader* fragmentation,
53 const RTPVideoHeader* rtp_video_hdr);
54
55 private:
56 scoped_ptr<CriticalSectionWrapper> crit_;
57
58 // Active sending RTP modules, in layer order.
59 std::vector<RtpRtcp*> rtp_modules_ GUARDED_BY(crit_.get());
60 bool active_ GUARDED_BY(crit_.get());
61
62 DISALLOW_COPY_AND_ASSIGN(PayloadRouter);
63};
64
65} // namespace webrtc
66
67#endif // WEBRTC_VIDEO_ENGINE_PAYLOAD_ROUTER_H_