blob: 236d466038a45fb8897cdd60f865f676ede834d2 [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"
Niels Möllera46bd4b2018-06-08 14:03:44 +020015#include "api/video_codecs/video_codec.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "modules/include/module.h"
Niels Möller834a5542019-09-23 10:31:16 +020017#include "modules/rtp_rtcp/source/rtp_video_header.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "modules/video_coding/include/video_coding_defines.h"
Henrik Kjellander2557b862015-11-18 22:00:21 +010019
philipel9d3ab612015-12-21 04:12:39 -080020namespace webrtc {
Henrik Kjellander2557b862015-11-18 22:00:21 +010021
22class Clock;
23class EncodedImageCallback;
Anders Carlsson7eb8e9f2018-05-18 10:33:04 +020024class VideoDecoder;
Henrik Kjellander2557b862015-11-18 22:00:21 +010025class VideoEncoder;
Henrik Kjellander2557b862015-11-18 22:00:21 +010026struct CodecSpecificInfo;
27
philipel9d3ab612015-12-21 04:12:39 -080028class VideoCodingModule : public Module {
29 public:
tommia5c18d72017-03-20 10:43:23 -070030 // DEPRECATED.
Niels Möller689983f2018-11-07 16:36:22 +010031 static VideoCodingModule* Create(Clock* clock);
Henrik Kjellander2557b862015-11-18 22:00:21 +010032
philipel9d3ab612015-12-21 04:12:39 -080033 /*
Yves Gerey665174f2018-06-19 15:03:05 +020034 * Receiver
35 */
Henrik Kjellander2557b862015-11-18 22:00:21 +010036
philipel9d3ab612015-12-21 04:12:39 -080037 // Register possible receive codecs, can be called multiple times for
38 // different codecs.
39 // The module will automatically switch between registered codecs depending on
40 // the
41 // payload type of incoming frames. The actual decoder will be created when
42 // needed.
43 //
44 // Input:
Niels Möller582102c2020-08-07 16:19:56 +020045 // - payload_type : RTP payload type
philipel9d3ab612015-12-21 04:12:39 -080046 // - receiveCodec : Settings for the codec to be registered.
47 // - numberOfCores : Number of CPU cores that the decoder is allowed
48 // to use.
philipel9d3ab612015-12-21 04:12:39 -080049 //
50 // Return value : VCM_OK, on success.
51 // < 0, on error.
Niels Möller582102c2020-08-07 16:19:56 +020052 // TODO(nisse): Method without explicit payload type is deprecated.
philipel9d3ab612015-12-21 04:12:39 -080053 virtual int32_t RegisterReceiveCodec(const VideoCodec* receiveCodec,
Niels Möller18c83d32020-08-07 14:14:49 +020054 int32_t numberOfCores) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +010055
Niels Möller582102c2020-08-07 16:19:56 +020056 virtual int32_t RegisterReceiveCodec(uint8_t payload_type,
57 const VideoCodec* receiveCodec,
58 int32_t numberOfCores) = 0;
59
Anders Carlsson7eb8e9f2018-05-18 10:33:04 +020060 // Register an external decoder object.
61 //
62 // Input:
63 // - externalDecoder : Decoder object to be used for decoding frames.
64 // - payloadType : The payload type which this decoder is bound to.
65 virtual void RegisterExternalDecoder(VideoDecoder* externalDecoder,
66 uint8_t payloadType) = 0;
67
philipel9d3ab612015-12-21 04:12:39 -080068 // Register a receive callback. Will be called whenever there is a new frame
69 // ready
70 // for rendering.
71 //
72 // Input:
73 // - receiveCallback : The callback object to be used by the
74 // module when a
75 // frame is ready for rendering.
76 // De-register with a NULL pointer.
77 //
78 // Return value : VCM_OK, on success.
79 // < 0, on error.
80 virtual int32_t RegisterReceiveCallback(
81 VCMReceiveCallback* receiveCallback) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +010082
philipel9d3ab612015-12-21 04:12:39 -080083 // Register a frame type request callback. This callback will be called when
84 // the
85 // module needs to request specific frame types from the send side.
86 //
87 // Input:
88 // - frameTypeCallback : The callback object to be used by the
89 // module when
90 // requesting a specific type of frame from
91 // the send side.
92 // De-register with a NULL pointer.
93 //
94 // Return value : VCM_OK, on success.
95 // < 0, on error.
96 virtual int32_t RegisterFrameTypeCallback(
97 VCMFrameTypeCallback* frameTypeCallback) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +010098
philipel9d3ab612015-12-21 04:12:39 -080099 // Registers a callback which is called whenever the receive side of the VCM
100 // encounters holes in the packet sequence and needs packets to be
101 // retransmitted.
102 //
103 // Input:
104 // - callback : The callback to be registered in the VCM.
105 //
106 // Return value : VCM_OK, on success.
107 // <0, on error.
108 virtual int32_t RegisterPacketRequestCallback(
109 VCMPacketRequestCallback* callback) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100110
philipel9d3ab612015-12-21 04:12:39 -0800111 // Waits for the next frame in the jitter buffer to become complete
112 // (waits no longer than maxWaitTimeMs), then passes it to the decoder for
113 // decoding.
114 // Should be called as often as possible to get the most out of the decoder.
115 //
116 // Return value : VCM_OK, on success.
117 // < 0, on error.
118 virtual int32_t Decode(uint16_t maxWaitTimeMs = 200) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100119
philipel9d3ab612015-12-21 04:12:39 -0800120 // Insert a parsed packet into the receiver side of the module. Will be placed
121 // in the
122 // jitter buffer waiting for the frame to become complete. Returns as soon as
123 // the packet
124 // has been placed in the jitter buffer.
125 //
126 // Input:
127 // - incomingPayload : Payload of the packet.
128 // - payloadLength : Length of the payload.
Niels Möllerbe7a0ec2019-04-25 10:02:52 +0200129 // - rtp_header : The parsed RTP header.
130 // - video_header : The relevant extensions and payload header.
philipel9d3ab612015-12-21 04:12:39 -0800131 //
132 // Return value : VCM_OK, on success.
133 // < 0, on error.
134 virtual int32_t IncomingPacket(const uint8_t* incomingPayload,
135 size_t payloadLength,
Niels Möllerbe7a0ec2019-04-25 10:02:52 +0200136 const RTPHeader& rtp_header,
137 const RTPVideoHeader& video_header) = 0;
138
philipel9d3ab612015-12-21 04:12:39 -0800139 // Sets the maximum number of sequence numbers that we are allowed to NACK
140 // and the oldest sequence number that we will consider to NACK. If a
141 // sequence number older than |max_packet_age_to_nack| is missing
142 // a key frame will be requested. A key frame will also be requested if the
143 // time of incomplete or non-continuous frames in the jitter buffer is above
144 // |max_incomplete_time_ms|.
145 virtual void SetNackSettings(size_t max_nack_list_size,
146 int max_packet_age_to_nack,
147 int max_incomplete_time_ms) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100148};
149
150} // namespace webrtc
151
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200152#endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_