blob: 8cedc4a9be62a0e2015c04385e8289a1cec82c48 [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020014#include "api/video/video_frame.h"
Danil Chapovalov355b8d22021-08-13 16:50:37 +020015#include "api/video_codecs/video_decoder.h"
Jonas Orelande02f9ee2022-03-25 12:43:14 +010016#include "api/webrtc_key_value_config.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/include/module.h"
Niels Möller834a5542019-09-23 10:31:16 +020018#include "modules/rtp_rtcp/source/rtp_video_header.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "modules/video_coding/include/video_coding_defines.h"
Henrik Kjellander2557b862015-11-18 22:00:21 +010020
philipel9d3ab612015-12-21 04:12:39 -080021namespace webrtc {
Henrik Kjellander2557b862015-11-18 22:00:21 +010022
23class Clock;
24class EncodedImageCallback;
Anders Carlsson7eb8e9f2018-05-18 10:33:04 +020025class VideoDecoder;
Henrik Kjellander2557b862015-11-18 22:00:21 +010026class VideoEncoder;
Henrik Kjellander2557b862015-11-18 22:00:21 +010027struct CodecSpecificInfo;
28
philipel9d3ab612015-12-21 04:12:39 -080029class VideoCodingModule : public Module {
30 public:
tommia5c18d72017-03-20 10:43:23 -070031 // DEPRECATED.
Jonas Orelande02f9ee2022-03-25 12:43:14 +010032 static VideoCodingModule* Create(
33 Clock* clock,
34 const WebRtcKeyValueConfig* field_trials = nullptr);
Henrik Kjellander2557b862015-11-18 22:00:21 +010035
philipel9d3ab612015-12-21 04:12:39 -080036 /*
Yves Gerey665174f2018-06-19 15:03:05 +020037 * Receiver
38 */
Henrik Kjellander2557b862015-11-18 22:00:21 +010039
philipel9d3ab612015-12-21 04:12:39 -080040 // Register possible receive codecs, can be called multiple times for
41 // different codecs.
42 // The module will automatically switch between registered codecs depending on
43 // the
44 // payload type of incoming frames. The actual decoder will be created when
45 // needed.
46 //
47 // Input:
Niels Möller582102c2020-08-07 16:19:56 +020048 // - payload_type : RTP payload type
Danil Chapovalov355b8d22021-08-13 16:50:37 +020049 // - settings : Settings for the decoder to be registered.
philipel9d3ab612015-12-21 04:12:39 -080050 //
Danil Chapovalovba0a3062021-08-13 18:15:55 +020051 virtual void RegisterReceiveCodec(uint8_t payload_type,
Danil Chapovalov355b8d22021-08-13 16:50:37 +020052 const VideoDecoder::Settings& settings) = 0;
Niels Möller582102c2020-08-07 16:19:56 +020053
Anders Carlsson7eb8e9f2018-05-18 10:33:04 +020054 // Register an external decoder object.
55 //
56 // Input:
57 // - externalDecoder : Decoder object to be used for decoding frames.
58 // - payloadType : The payload type which this decoder is bound to.
59 virtual void RegisterExternalDecoder(VideoDecoder* externalDecoder,
60 uint8_t payloadType) = 0;
61
philipel9d3ab612015-12-21 04:12:39 -080062 // Register a receive callback. Will be called whenever there is a new frame
63 // ready
64 // for rendering.
65 //
66 // Input:
67 // - receiveCallback : The callback object to be used by the
68 // module when a
69 // frame is ready for rendering.
70 // De-register with a NULL pointer.
71 //
72 // Return value : VCM_OK, on success.
73 // < 0, on error.
74 virtual int32_t RegisterReceiveCallback(
75 VCMReceiveCallback* receiveCallback) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +010076
philipel9d3ab612015-12-21 04:12:39 -080077 // Register a frame type request callback. This callback will be called when
78 // the
79 // module needs to request specific frame types from the send side.
80 //
81 // Input:
82 // - frameTypeCallback : The callback object to be used by the
83 // module when
84 // requesting a specific type of frame from
85 // the send side.
86 // De-register with a NULL pointer.
87 //
88 // Return value : VCM_OK, on success.
89 // < 0, on error.
90 virtual int32_t RegisterFrameTypeCallback(
91 VCMFrameTypeCallback* frameTypeCallback) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +010092
philipel9d3ab612015-12-21 04:12:39 -080093 // Registers a callback which is called whenever the receive side of the VCM
94 // encounters holes in the packet sequence and needs packets to be
95 // retransmitted.
96 //
97 // Input:
98 // - callback : The callback to be registered in the VCM.
99 //
100 // Return value : VCM_OK, on success.
101 // <0, on error.
102 virtual int32_t RegisterPacketRequestCallback(
103 VCMPacketRequestCallback* callback) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100104
philipel9d3ab612015-12-21 04:12:39 -0800105 // Waits for the next frame in the jitter buffer to become complete
106 // (waits no longer than maxWaitTimeMs), then passes it to the decoder for
107 // decoding.
108 // Should be called as often as possible to get the most out of the decoder.
109 //
110 // Return value : VCM_OK, on success.
111 // < 0, on error.
112 virtual int32_t Decode(uint16_t maxWaitTimeMs = 200) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100113
philipel9d3ab612015-12-21 04:12:39 -0800114 // Insert a parsed packet into the receiver side of the module. Will be placed
115 // in the
116 // jitter buffer waiting for the frame to become complete. Returns as soon as
117 // the packet
118 // has been placed in the jitter buffer.
119 //
120 // Input:
121 // - incomingPayload : Payload of the packet.
122 // - payloadLength : Length of the payload.
Niels Möllerbe7a0ec2019-04-25 10:02:52 +0200123 // - rtp_header : The parsed RTP header.
124 // - video_header : The relevant extensions and payload header.
philipel9d3ab612015-12-21 04:12:39 -0800125 //
126 // Return value : VCM_OK, on success.
127 // < 0, on error.
128 virtual int32_t IncomingPacket(const uint8_t* incomingPayload,
129 size_t payloadLength,
Niels Möllerbe7a0ec2019-04-25 10:02:52 +0200130 const RTPHeader& rtp_header,
131 const RTPVideoHeader& video_header) = 0;
132
philipel9d3ab612015-12-21 04:12:39 -0800133 // Sets the maximum number of sequence numbers that we are allowed to NACK
134 // and the oldest sequence number that we will consider to NACK. If a
Artem Titovdcd7fc72021-08-09 13:02:57 +0200135 // sequence number older than `max_packet_age_to_nack` is missing
philipel9d3ab612015-12-21 04:12:39 -0800136 // a key frame will be requested. A key frame will also be requested if the
137 // time of incomplete or non-continuous frames in the jitter buffer is above
Artem Titovdcd7fc72021-08-09 13:02:57 +0200138 // `max_incomplete_time_ms`.
philipel9d3ab612015-12-21 04:12:39 -0800139 virtual void SetNackSettings(size_t max_nack_list_size,
140 int max_packet_age_to_nack,
141 int max_incomplete_time_ms) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100142};
143
144} // namespace webrtc
145
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200146#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_