blob: 4e0ac56405008109f13a75002b811b7913355a88 [file] [log] [blame]
Niels Möllerfa89d842019-01-30 16:33:45 +01001/*
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#ifndef VIDEO_ENCODER_KEY_FRAME_CALLBACK_H_
11#define VIDEO_ENCODER_KEY_FRAME_CALLBACK_H_
12
13#include <vector>
14
15#include "api/media_transport_interface.h"
16#include "api/video/video_stream_encoder_interface.h"
17#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
18#include "rtc_base/critical_section.h"
19#include "system_wrappers/include/clock.h"
20
21namespace webrtc {
22
23class VideoStreamEncoderInterface;
24
25// This class receives keyframe requests from either Mediatransport or the
26// RtpRtcp module.
27// TODO(bugs.webrtc.org/9719): Should be eliminated when RtpMediaTransport is
28// implemented.
29class EncoderKeyFrameCallback : public RtcpIntraFrameObserver,
30 public MediaTransportKeyFrameRequestCallback {
31 public:
32 EncoderKeyFrameCallback(Clock* clock,
33 const std::vector<uint32_t>& ssrcs,
34 VideoStreamEncoderInterface* encoder);
35 void OnReceivedIntraFrameRequest(uint32_t ssrc) override;
36
37 // Implements MediaTransportKeyFrameRequestCallback
38 void OnKeyFrameRequested(uint64_t channel_id) override;
39
40 private:
41 bool HasSsrc(uint32_t ssrc);
42
43 Clock* const clock_;
44 const std::vector<uint32_t> ssrcs_;
45 VideoStreamEncoderInterface* const video_stream_encoder_;
46
47 rtc::CriticalSection crit_;
48 int64_t time_last_intra_request_ms_ RTC_GUARDED_BY(crit_);
49};
50
51} // namespace webrtc
52
53#endif // VIDEO_ENCODER_KEY_FRAME_CALLBACK_H_