blob: 4e571ee85a6e0320a833463524a61b5f3a464386 [file] [log] [blame]
Danil Chapovalovc0fd5f92017-11-16 14:35:32 +01001/*
2 * Copyright (c) 2017 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 MODULES_RTP_RTCP_SOURCE_RTCP_TRANSCEIVER_H_
12#define MODULES_RTP_RTCP_SOURCE_RTCP_TRANSCEIVER_H_
13
14#include <memory>
15#include <string>
16#include <vector>
17
18#include "modules/rtp_rtcp/source/rtcp_transceiver_config.h"
19#include "modules/rtp_rtcp/source/rtcp_transceiver_impl.h"
20#include "rtc_base/constructormagic.h"
21#include "rtc_base/copyonwritebuffer.h"
22#include "rtc_base/task_queue.h"
23#include "rtc_base/weak_ptr.h"
24
25namespace webrtc {
26//
27// Manage incoming and outgoing rtcp messages for multiple BUNDLED streams.
28//
29// This class is thread-safe wrapper of RtcpTransceiverImpl
30class RtcpTransceiver {
31 public:
32 explicit RtcpTransceiver(const RtcpTransceiverConfig& config);
33 ~RtcpTransceiver();
34
35 // Handles incoming rtcp packets.
36 void ReceivePacket(rtc::CopyOnWriteBuffer packet);
37
38 // Sends RTCP packets starting with a sender or receiver report.
39 void SendCompoundPacket();
40
41 // (REMB) Receiver Estimated Max Bitrate.
42 // Includes REMB in following compound packets.
43 void SetRemb(int bitrate_bps, std::vector<uint32_t> ssrcs);
44 // Stops sending REMB in following compound packets.
45 void UnsetRemb();
46
Danil Chapovalova7e418c2017-11-21 11:08:53 +010047 void RequestKeyFrame(std::vector<uint32_t> ssrcs);
48
Danil Chapovalovc0fd5f92017-11-16 14:35:32 +010049 private:
50 rtc::TaskQueue* const task_queue_;
51 std::unique_ptr<RtcpTransceiverImpl> rtcp_transceiver_;
52 rtc::WeakPtrFactory<RtcpTransceiverImpl> ptr_factory_;
53 // TaskQueue, and thus tasks posted to it, may outlive this.
54 // Thus when Posting task class always pass copy of the weak_ptr to access
55 // the RtcpTransceiver and never guarantee it still will be alive when task
56 // runs.
57 rtc::WeakPtr<RtcpTransceiverImpl> ptr_;
58
59 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtcpTransceiver);
60};
61
62} // namespace webrtc
63
64#endif // MODULES_RTP_RTCP_SOURCE_RTCP_TRANSCEIVER_H_