blob: 86a5bc3995944f2e93ba9d3090bb7864bd922276 [file] [log] [blame]
Henrik Kjellander2557b862015-11-18 22:00:21 +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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_
12#define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_
Henrik Kjellander2557b862015-11-18 22:00:21 +010013
Ying Wang3b790f32018-01-19 17:58:57 +010014#include "api/fec_controller.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#include "api/video/video_frame.h"
Niels Möllera46bd4b2018-06-08 14:03:44 +020016#include "api/video_codecs/video_codec.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/include/module.h"
18#include "modules/include/module_common_types.h"
19#include "modules/video_coding/include/video_coding_defines.h"
Niels Möller689983f2018-11-07 16:36:22 +010020#include "rtc_base/deprecation.h"
Henrik Kjellander2557b862015-11-18 22:00:21 +010021
philipel9d3ab612015-12-21 04:12:39 -080022namespace webrtc {
Henrik Kjellander2557b862015-11-18 22:00:21 +010023
24class Clock;
25class EncodedImageCallback;
Anders Carlsson7eb8e9f2018-05-18 10:33:04 +020026class VideoDecoder;
Henrik Kjellander2557b862015-11-18 22:00:21 +010027class VideoEncoder;
Henrik Kjellander2557b862015-11-18 22:00:21 +010028struct CodecSpecificInfo;
29
philipel9d3ab612015-12-21 04:12:39 -080030class VideoCodingModule : public Module {
31 public:
32 enum SenderNackMode { kNackNone, kNackAll, kNackSelective };
Henrik Kjellander2557b862015-11-18 22:00:21 +010033
tommia5c18d72017-03-20 10:43:23 -070034 // DEPRECATED.
Niels Möller689983f2018-11-07 16:36:22 +010035 static VideoCodingModule* Create(Clock* clock);
Henrik Kjellander2557b862015-11-18 22:00:21 +010036
philipel9d3ab612015-12-21 04:12:39 -080037 /*
Yves Gerey665174f2018-06-19 15:03:05 +020038 * Receiver
39 */
Henrik Kjellander2557b862015-11-18 22:00:21 +010040
philipel9d3ab612015-12-21 04:12:39 -080041 // Register possible receive codecs, can be called multiple times for
42 // different codecs.
43 // The module will automatically switch between registered codecs depending on
44 // the
45 // payload type of incoming frames. The actual decoder will be created when
46 // needed.
47 //
48 // Input:
49 // - receiveCodec : Settings for the codec to be registered.
50 // - numberOfCores : Number of CPU cores that the decoder is allowed
51 // to use.
52 // - requireKeyFrame : Set this to true if you don't want any delta
53 // frames
54 // to be decoded until the first key frame has been
55 // decoded.
56 //
57 // Return value : VCM_OK, on success.
58 // < 0, on error.
59 virtual int32_t RegisterReceiveCodec(const VideoCodec* receiveCodec,
60 int32_t numberOfCores,
61 bool requireKeyFrame = false) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +010062
Anders Carlsson7eb8e9f2018-05-18 10:33:04 +020063 // Register an external decoder object.
64 //
65 // Input:
66 // - externalDecoder : Decoder object to be used for decoding frames.
67 // - payloadType : The payload type which this decoder is bound to.
68 virtual void RegisterExternalDecoder(VideoDecoder* externalDecoder,
69 uint8_t payloadType) = 0;
70
philipel9d3ab612015-12-21 04:12:39 -080071 // Register a receive callback. Will be called whenever there is a new frame
72 // ready
73 // for rendering.
74 //
75 // Input:
76 // - receiveCallback : The callback object to be used by the
77 // module when a
78 // frame is ready for rendering.
79 // De-register with a NULL pointer.
80 //
81 // Return value : VCM_OK, on success.
82 // < 0, on error.
83 virtual int32_t RegisterReceiveCallback(
84 VCMReceiveCallback* receiveCallback) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +010085
philipel9d3ab612015-12-21 04:12:39 -080086 // Register a frame type request callback. This callback will be called when
87 // the
88 // module needs to request specific frame types from the send side.
89 //
90 // Input:
91 // - frameTypeCallback : The callback object to be used by the
92 // module when
93 // requesting a specific type of frame from
94 // the send side.
95 // De-register with a NULL pointer.
96 //
97 // Return value : VCM_OK, on success.
98 // < 0, on error.
99 virtual int32_t RegisterFrameTypeCallback(
100 VCMFrameTypeCallback* frameTypeCallback) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100101
philipel9d3ab612015-12-21 04:12:39 -0800102 // Registers a callback which is called whenever the receive side of the VCM
103 // encounters holes in the packet sequence and needs packets to be
104 // retransmitted.
105 //
106 // Input:
107 // - callback : The callback to be registered in the VCM.
108 //
109 // Return value : VCM_OK, on success.
110 // <0, on error.
111 virtual int32_t RegisterPacketRequestCallback(
112 VCMPacketRequestCallback* callback) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100113
philipel9d3ab612015-12-21 04:12:39 -0800114 // Waits for the next frame in the jitter buffer to become complete
115 // (waits no longer than maxWaitTimeMs), then passes it to the decoder for
116 // decoding.
117 // Should be called as often as possible to get the most out of the decoder.
118 //
119 // Return value : VCM_OK, on success.
120 // < 0, on error.
121 virtual int32_t Decode(uint16_t maxWaitTimeMs = 200) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100122
philipel9d3ab612015-12-21 04:12:39 -0800123 // Insert a parsed packet into the receiver side of the module. Will be placed
124 // in the
125 // jitter buffer waiting for the frame to become complete. Returns as soon as
126 // the packet
127 // has been placed in the jitter buffer.
128 //
129 // Input:
130 // - incomingPayload : Payload of the packet.
131 // - payloadLength : Length of the payload.
132 // - rtpInfo : The parsed header.
133 //
134 // Return value : VCM_OK, on success.
135 // < 0, on error.
136 virtual int32_t IncomingPacket(const uint8_t* incomingPayload,
137 size_t payloadLength,
138 const WebRtcRTPHeader& rtpInfo) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100139
philipel9d3ab612015-12-21 04:12:39 -0800140 // Robustness APIs
Henrik Kjellander2557b862015-11-18 22:00:21 +0100141
tommia5c18d72017-03-20 10:43:23 -0700142 // DEPRECATED.
philipel9d3ab612015-12-21 04:12:39 -0800143 // Set the receiver robustness mode. The mode decides how the receiver
tommia5c18d72017-03-20 10:43:23 -0700144 // responds to losses in the stream. The type of counter-measure is selected
145 // through the robustnessMode parameter. The errorMode parameter decides if it
146 // is allowed to display frames corrupted by losses. Note that not all
philipel9d3ab612015-12-21 04:12:39 -0800147 // combinations of the two parameters are feasible. An error will be
148 // returned for invalid combinations.
149 // Input:
150 // - robustnessMode : selected robustness mode.
151 // - errorMode : selected error mode.
152 //
153 // Return value : VCM_OK, on success;
154 // < 0, on error.
tommia5c18d72017-03-20 10:43:23 -0700155 enum ReceiverRobustness { kNone, kHardNack };
Niels Möller375b3462019-01-10 15:35:56 +0100156 virtual int SetReceiverRobustnessMode(ReceiverRobustness robustnessMode) = 0;
Niels Möller977cd172019-01-10 09:22:46 +0100157
philipel9d3ab612015-12-21 04:12:39 -0800158 // Sets the maximum number of sequence numbers that we are allowed to NACK
159 // and the oldest sequence number that we will consider to NACK. If a
160 // sequence number older than |max_packet_age_to_nack| is missing
161 // a key frame will be requested. A key frame will also be requested if the
162 // time of incomplete or non-continuous frames in the jitter buffer is above
163 // |max_incomplete_time_ms|.
164 virtual void SetNackSettings(size_t max_nack_list_size,
165 int max_packet_age_to_nack,
166 int max_incomplete_time_ms) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100167};
168
169} // namespace webrtc
170
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200171#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_