Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_ |
| 12 | #define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_ |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 13 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 14 | #include "api/video/video_frame.h" |
Niels Möller | a46bd4b | 2018-06-08 14:03:44 +0200 | [diff] [blame] | 15 | #include "api/video_codecs/video_codec.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "modules/include/module.h" |
| 17 | #include "modules/include/module_common_types.h" |
| 18 | #include "modules/video_coding/include/video_coding_defines.h" |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 19 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 20 | namespace webrtc { |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 21 | |
| 22 | class Clock; |
| 23 | class EncodedImageCallback; |
Anders Carlsson | 7eb8e9f | 2018-05-18 10:33:04 +0200 | [diff] [blame] | 24 | class VideoDecoder; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 25 | class VideoEncoder; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 26 | struct CodecSpecificInfo; |
| 27 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 28 | class VideoCodingModule : public Module { |
| 29 | public: |
tommi | a5c18d7 | 2017-03-20 10:43:23 -0700 | [diff] [blame] | 30 | // DEPRECATED. |
Niels Möller | 689983f | 2018-11-07 16:36:22 +0100 | [diff] [blame] | 31 | static VideoCodingModule* Create(Clock* clock); |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 32 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 33 | /* |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 34 | * Receiver |
| 35 | */ |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 36 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 37 | // 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: |
| 45 | // - receiveCodec : Settings for the codec to be registered. |
| 46 | // - numberOfCores : Number of CPU cores that the decoder is allowed |
| 47 | // to use. |
| 48 | // - requireKeyFrame : Set this to true if you don't want any delta |
| 49 | // frames |
| 50 | // to be decoded until the first key frame has been |
| 51 | // decoded. |
| 52 | // |
| 53 | // Return value : VCM_OK, on success. |
| 54 | // < 0, on error. |
| 55 | virtual int32_t RegisterReceiveCodec(const VideoCodec* receiveCodec, |
| 56 | int32_t numberOfCores, |
| 57 | bool requireKeyFrame = false) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 58 | |
Anders Carlsson | 7eb8e9f | 2018-05-18 10:33:04 +0200 | [diff] [blame] | 59 | // Register an external decoder object. |
| 60 | // |
| 61 | // Input: |
| 62 | // - externalDecoder : Decoder object to be used for decoding frames. |
| 63 | // - payloadType : The payload type which this decoder is bound to. |
| 64 | virtual void RegisterExternalDecoder(VideoDecoder* externalDecoder, |
| 65 | uint8_t payloadType) = 0; |
| 66 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 67 | // Register a receive callback. Will be called whenever there is a new frame |
| 68 | // ready |
| 69 | // for rendering. |
| 70 | // |
| 71 | // Input: |
| 72 | // - receiveCallback : The callback object to be used by the |
| 73 | // module when a |
| 74 | // frame is ready for rendering. |
| 75 | // De-register with a NULL pointer. |
| 76 | // |
| 77 | // Return value : VCM_OK, on success. |
| 78 | // < 0, on error. |
| 79 | virtual int32_t RegisterReceiveCallback( |
| 80 | VCMReceiveCallback* receiveCallback) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 81 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 82 | // Register a frame type request callback. This callback will be called when |
| 83 | // the |
| 84 | // module needs to request specific frame types from the send side. |
| 85 | // |
| 86 | // Input: |
| 87 | // - frameTypeCallback : The callback object to be used by the |
| 88 | // module when |
| 89 | // requesting a specific type of frame from |
| 90 | // the send side. |
| 91 | // De-register with a NULL pointer. |
| 92 | // |
| 93 | // Return value : VCM_OK, on success. |
| 94 | // < 0, on error. |
| 95 | virtual int32_t RegisterFrameTypeCallback( |
| 96 | VCMFrameTypeCallback* frameTypeCallback) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 97 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 98 | // Registers a callback which is called whenever the receive side of the VCM |
| 99 | // encounters holes in the packet sequence and needs packets to be |
| 100 | // retransmitted. |
| 101 | // |
| 102 | // Input: |
| 103 | // - callback : The callback to be registered in the VCM. |
| 104 | // |
| 105 | // Return value : VCM_OK, on success. |
| 106 | // <0, on error. |
| 107 | virtual int32_t RegisterPacketRequestCallback( |
| 108 | VCMPacketRequestCallback* callback) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 109 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 110 | // Waits for the next frame in the jitter buffer to become complete |
| 111 | // (waits no longer than maxWaitTimeMs), then passes it to the decoder for |
| 112 | // decoding. |
| 113 | // Should be called as often as possible to get the most out of the decoder. |
| 114 | // |
| 115 | // Return value : VCM_OK, on success. |
| 116 | // < 0, on error. |
| 117 | virtual int32_t Decode(uint16_t maxWaitTimeMs = 200) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 118 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 119 | // Insert a parsed packet into the receiver side of the module. Will be placed |
| 120 | // in the |
| 121 | // jitter buffer waiting for the frame to become complete. Returns as soon as |
| 122 | // the packet |
| 123 | // has been placed in the jitter buffer. |
| 124 | // |
| 125 | // Input: |
| 126 | // - incomingPayload : Payload of the packet. |
| 127 | // - payloadLength : Length of the payload. |
Niels Möller | be7a0ec | 2019-04-25 10:02:52 +0200 | [diff] [blame] | 128 | // - rtp_header : The parsed RTP header. |
| 129 | // - video_header : The relevant extensions and payload header. |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 130 | // |
| 131 | // Return value : VCM_OK, on success. |
| 132 | // < 0, on error. |
| 133 | virtual int32_t IncomingPacket(const uint8_t* incomingPayload, |
| 134 | size_t payloadLength, |
Niels Möller | be7a0ec | 2019-04-25 10:02:52 +0200 | [diff] [blame] | 135 | const RTPHeader& rtp_header, |
| 136 | const RTPVideoHeader& video_header) = 0; |
| 137 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 138 | // Sets the maximum number of sequence numbers that we are allowed to NACK |
| 139 | // and the oldest sequence number that we will consider to NACK. If a |
| 140 | // sequence number older than |max_packet_age_to_nack| is missing |
| 141 | // a key frame will be requested. A key frame will also be requested if the |
| 142 | // time of incomplete or non-continuous frames in the jitter buffer is above |
| 143 | // |max_incomplete_time_ms|. |
| 144 | virtual void SetNackSettings(size_t max_nack_list_size, |
| 145 | int max_packet_age_to_nack, |
| 146 | int max_incomplete_time_ms) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | } // namespace webrtc |
| 150 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 151 | #endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_ |