tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

video_coding.h (5637B)


      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 
     11 #ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_
     12 #define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_
     13 
     14 #include <cstddef>
     15 #include <cstdint>
     16 #include <memory>
     17 
     18 #include "api/environment/environment.h"
     19 #include "api/rtp_headers.h"
     20 #include "api/video_codecs/video_decoder.h"
     21 #include "modules/rtp_rtcp/source/rtp_video_header.h"
     22 #include "modules/video_coding/include/video_coding_defines.h"
     23 
     24 namespace webrtc {
     25 
     26 class VideoCodingModule {
     27 public:
     28  [[deprecated]] static std::unique_ptr<VideoCodingModule> CreateDeprecated(
     29      const Environment& env);
     30 
     31  virtual ~VideoCodingModule() = default;
     32 
     33  /*
     34   *   Receiver
     35   */
     36 
     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  //      - payload_type      : RTP payload type
     46  //      - settings          : Settings for the decoder to be registered.
     47  //
     48  virtual void RegisterReceiveCodec(uint8_t payload_type,
     49                                    const VideoDecoder::Settings& settings) = 0;
     50 
     51  // Register an external decoder object.
     52  //
     53  // Input:
     54  //      - externalDecoder : Decoder object to be used for decoding frames.
     55  //      - payloadType     : The payload type which this decoder is bound to.
     56  virtual void RegisterExternalDecoder(VideoDecoder* externalDecoder,
     57                                       uint8_t payloadType) = 0;
     58 
     59  // Register a receive callback. Will be called whenever there is a new frame
     60  // ready
     61  // for rendering.
     62  //
     63  // Input:
     64  //      - receiveCallback        : The callback object to be used by the
     65  //      module when a
     66  //                                 frame is ready for rendering.
     67  //                                 De-register with a NULL pointer.
     68  //
     69  // Return value      : VCM_OK, on success.
     70  //                     < 0,    on error.
     71  virtual int32_t RegisterReceiveCallback(
     72      VCMReceiveCallback* receiveCallback) = 0;
     73 
     74  // Register a frame type request callback. This callback will be called when
     75  // the
     76  // module needs to request specific frame types from the send side.
     77  //
     78  // Input:
     79  //      - frameTypeCallback      : The callback object to be used by the
     80  //      module when
     81  //                                 requesting a specific type of frame from
     82  //                                 the send side.
     83  //                                 De-register with a NULL pointer.
     84  //
     85  // Return value      : VCM_OK, on success.
     86  //                     < 0,    on error.
     87  virtual int32_t RegisterFrameTypeCallback(
     88      VCMFrameTypeCallback* frameTypeCallback) = 0;
     89 
     90  // Registers a callback which is called whenever the receive side of the VCM
     91  // encounters holes in the packet sequence and needs packets to be
     92  // retransmitted.
     93  //
     94  // Input:
     95  //              - callback      : The callback to be registered in the VCM.
     96  //
     97  // Return value     : VCM_OK,     on success.
     98  //                    <0,         on error.
     99  virtual int32_t RegisterPacketRequestCallback(
    100      VCMPacketRequestCallback* callback) = 0;
    101 
    102  // Waits for the next frame in the jitter buffer to become complete
    103  // (waits no longer than maxWaitTimeMs), then passes it to the decoder for
    104  // decoding.
    105  // Should be called as often as possible to get the most out of the decoder.
    106  //
    107  // Return value      : VCM_OK, on success.
    108  //                     < 0,    on error.
    109  virtual int32_t Decode(uint16_t maxWaitTimeMs = 200) = 0;
    110 
    111  // Insert a parsed packet into the receiver side of the module. Will be placed
    112  // in the
    113  // jitter buffer waiting for the frame to become complete. Returns as soon as
    114  // the packet
    115  // has been placed in the jitter buffer.
    116  //
    117  // Input:
    118  //      - incomingPayload      : Payload of the packet.
    119  //      - payloadLength        : Length of the payload.
    120  //      - rtp_header           : The parsed RTP header.
    121  //      - video_header         : The relevant extensions and payload header.
    122  //
    123  // Return value      : VCM_OK, on success.
    124  //                     < 0,    on error.
    125  virtual int32_t IncomingPacket(const uint8_t* incomingPayload,
    126                                 size_t payloadLength,
    127                                 const RTPHeader& rtp_header,
    128                                 const RTPVideoHeader& video_header) = 0;
    129 
    130  // Sets the maximum number of sequence numbers that we are allowed to NACK
    131  // and the oldest sequence number that we will consider to NACK. If a
    132  // sequence number older than `max_packet_age_to_nack` is missing
    133  // a key frame will be requested. A key frame will also be requested if the
    134  // time of incomplete or non-continuous frames in the jitter buffer is above
    135  // `max_incomplete_time_ms`.
    136  virtual void SetNackSettings(size_t max_nack_list_size,
    137                               int max_packet_age_to_nack,
    138                               int max_incomplete_time_ms) = 0;
    139 
    140  // Runs delayed tasks. Expected to be called periodically.
    141  virtual void Process() = 0;
    142 };
    143 
    144 }  // namespace webrtc
    145 
    146 #endif  // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_