blob: 09840e17215336ca54daf4cb6e9db917a943fbba [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.
Danil Chapovalov1de4b622017-12-13 13:35:10 +010043 void SetRemb(int64_t bitrate_bps, std::vector<uint32_t> ssrcs);
Danil Chapovalovc0fd5f92017-11-16 14:35:32 +010044 // Stops sending REMB in following compound packets.
45 void UnsetRemb();
46
Danil Chapovalov327c43c2017-11-27 17:23:04 +010047 // Reports missing packets, https://tools.ietf.org/html/rfc4585#section-6.2.1
48 void SendNack(uint32_t ssrc, std::vector<uint16_t> sequence_numbers);
49
50 // Requests new key frame.
Danil Chapovalov2ddf98d2017-11-22 14:00:41 +010051 // using PLI, https://tools.ietf.org/html/rfc4585#section-6.3.1.1
Danil Chapovalov8d19e032017-11-28 19:53:33 +010052 void SendPictureLossIndication(uint32_t ssrc);
Danil Chapovalov2ddf98d2017-11-22 14:00:41 +010053 // using FIR, https://tools.ietf.org/html/rfc5104#section-4.3.1.2
54 void SendFullIntraRequest(std::vector<uint32_t> ssrcs);
Danil Chapovalova7e418c2017-11-21 11:08:53 +010055
Danil Chapovalovc0fd5f92017-11-16 14:35:32 +010056 private:
57 rtc::TaskQueue* const task_queue_;
58 std::unique_ptr<RtcpTransceiverImpl> rtcp_transceiver_;
59 rtc::WeakPtrFactory<RtcpTransceiverImpl> ptr_factory_;
60 // TaskQueue, and thus tasks posted to it, may outlive this.
61 // Thus when Posting task class always pass copy of the weak_ptr to access
62 // the RtcpTransceiver and never guarantee it still will be alive when task
63 // runs.
64 rtc::WeakPtr<RtcpTransceiverImpl> ptr_;
65
66 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtcpTransceiver);
67};
68
69} // namespace webrtc
70
71#endif // MODULES_RTP_RTCP_SOURCE_RTCP_TRANSCEIVER_H_