blob: 6326bed9c13cdb7d966619b3634039768f54af8e [file] [log] [blame]
mflodman@webrtc.org3be58632012-09-06 08:19:40 +00001/*
2 * Copyright (c) 2012 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// TODO(mflodman) ViEEncoder has a time check to not send key frames too often,
12// move the logic to this class.
13
Peter Boström7623ce42015-12-09 12:13:30 +010014#ifndef WEBRTC_VIDEO_ENCODER_STATE_FEEDBACK_H_
15#define WEBRTC_VIDEO_ENCODER_STATE_FEEDBACK_H_
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000016
Peter Boström5cb9ce42015-05-05 15:16:30 +020017#include <vector>
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000018
Tommi97888bd2016-01-21 23:24:59 +010019#include "webrtc/base/criticalsection.h"
Peter Boström45c44f02016-02-19 17:36:01 +010020#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
pbos@webrtc.orgf5d4cb12013-05-17 13:44:48 +000021#include "webrtc/typedefs.h"
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000022
23namespace webrtc {
24
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000025class ViEEncoder;
26
Peter Boström45c44f02016-02-19 17:36:01 +010027class EncoderStateFeedback : public RtcpIntraFrameObserver {
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000028 public:
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000029 EncoderStateFeedback();
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000030
pbos8ff04d62015-07-20 08:01:17 -070031 // Adds an encoder to receive feedback for a set of SSRCs.
Peter Boström45c44f02016-02-19 17:36:01 +010032 void Init(const std::vector<uint32_t>& ssrc, ViEEncoder* encoder);
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000033
Peter Boström45c44f02016-02-19 17:36:01 +010034 // Removes the registered encoder. Necessary since RTP modules outlive
35 // ViEEncoder.
36 // TODO(pbos): Make sure RTP modules are not running when tearing down
37 // ViEEncoder, then remove this function.
38 void TearDown();
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000039
Peter Boström45c44f02016-02-19 17:36:01 +010040 void OnReceivedIntraFrameRequest(uint32_t ssrc) override;
41 void OnReceivedSLI(uint32_t ssrc, uint8_t picture_id) override;
42 void OnReceivedRPSI(uint32_t ssrc, uint64_t picture_id) override;
43 void OnLocalSsrcChanged(uint32_t old_ssrc, uint32_t new_ssrc) override;
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000044
45 private:
Peter Boström45c44f02016-02-19 17:36:01 +010046 bool HasSsrc(uint32_t ssrc) EXCLUSIVE_LOCKS_REQUIRED(crit_);
pbosd8de1152016-02-01 09:00:51 -080047 rtc::CriticalSection crit_;
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000048
Peter Boström45c44f02016-02-19 17:36:01 +010049 std::vector<uint32_t> ssrcs_ GUARDED_BY(crit_);
50 ViEEncoder* vie_encoder_ GUARDED_BY(crit_);
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000051};
52
53} // namespace webrtc
54
Peter Boström7623ce42015-12-09 12:13:30 +010055#endif // WEBRTC_VIDEO_ENCODER_STATE_FEEDBACK_H_