• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2017 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 package org.webrtc;
12 
13 import androidx.annotation.Nullable;
14 
15 /** Factory for creating VideoEncoders. */
16 public interface VideoEncoderFactory {
17   public interface VideoEncoderSelector {
18     /** Called with the VideoCodecInfo of the currently used encoder. */
onCurrentEncoder(VideoCodecInfo info)19     @CalledByNative("VideoEncoderSelector") void onCurrentEncoder(VideoCodecInfo info);
20 
21     /**
22      * Called with the current available bitrate. Returns null if the encoder selector prefers to
23      * keep the current encoder or a VideoCodecInfo if a new encoder is preferred.
24      */
onAvailableBitrate(int kbps)25     @Nullable @CalledByNative("VideoEncoderSelector") VideoCodecInfo onAvailableBitrate(int kbps);
26 
27     /**
28      * Called every time the encoder input resolution change. Returns null if the encoder selector
29      * prefers to keep the current encoder or a VideoCodecInfo if a new encoder is preferred.
30      */
31     @Nullable
32     @CalledByNative("VideoEncoderSelector")
onResolutionChange(int widht, int height)33     default VideoCodecInfo onResolutionChange(int widht, int height) {
34       return null;
35     }
36 
37     /**
38      * Called when the currently used encoder signal itself as broken. Returns null if the encoder
39      * selector prefers to keep the current encoder or a VideoCodecInfo if a new encoder is
40      * preferred.
41      */
onEncoderBroken()42     @Nullable @CalledByNative("VideoEncoderSelector") VideoCodecInfo onEncoderBroken();
43   }
44 
45   /** Creates an encoder for the given video codec. */
createEncoder(VideoCodecInfo info)46   @Nullable @CalledByNative VideoEncoder createEncoder(VideoCodecInfo info);
47 
48   /**
49    * Enumerates the list of supported video codecs. This method will only be called once and the
50    * result will be cached.
51    */
getSupportedCodecs()52   @CalledByNative VideoCodecInfo[] getSupportedCodecs();
53 
54   /**
55    * Enumerates the list of supported video codecs that can also be tagged with
56    * implementation information. This method will only be called once and the
57    * result will be cached.
58    */
59   @CalledByNative
getImplementations()60   default VideoCodecInfo[] getImplementations() {
61     return getSupportedCodecs();
62   }
63 
64   /**
65    * Returns a VideoEncoderSelector if implemented by the VideoEncoderFactory,
66    * null otherwise.
67    */
68   @CalledByNative
getEncoderSelector()69   default VideoEncoderSelector getEncoderSelector() {
70     return null;
71   }
72 }
73