David Zhao
Committed by GitHub

Switching to using Hxxx for presets (#257)

@@ -83,22 +83,64 @@ enum class VideoPreset169( @@ -83,22 +83,64 @@ enum class VideoPreset169(
83 override val capture: VideoCaptureParameter, 83 override val capture: VideoCaptureParameter,
84 override val encoding: VideoEncoding, 84 override val encoding: VideoEncoding,
85 ) : VideoPreset { 85 ) : VideoPreset {
  86 + H90(
  87 + VideoCaptureParameter(160, 90, 15),
  88 + VideoEncoding(90_000, 15),
  89 + ),
  90 + H180(
  91 + VideoCaptureParameter(320, 180, 15),
  92 + VideoEncoding(160_000, 15),
  93 + ),
  94 + H216(
  95 + VideoCaptureParameter(384, 216, 15),
  96 + VideoEncoding(180_000, 15),
  97 + ),
  98 + H360(
  99 + VideoCaptureParameter(640, 360, 30),
  100 + VideoEncoding(450_000, 30),
  101 + ),
  102 + H540(
  103 + VideoCaptureParameter(960, 540, 30),
  104 + VideoEncoding(800_000, 30),
  105 + ),
  106 + H720(
  107 + VideoCaptureParameter(1280, 720, 30),
  108 + VideoEncoding(1_700_000, 30),
  109 + ),
  110 + H1080(
  111 + VideoCaptureParameter(1920, 1080, 30),
  112 + VideoEncoding(3_000_000, 30),
  113 + ),
  114 + H1440(
  115 + VideoCaptureParameter(2560, 1440, 30),
  116 + VideoEncoding(5_000_000, 30),
  117 + ),
  118 + H2160(
  119 + VideoCaptureParameter(3840, 2160, 30),
  120 + VideoEncoding(8_000_000, 30),
  121 + ),
  122 +
  123 + @Deprecated("QVGA is deprecated, use H180 instead")
86 QVGA( 124 QVGA(
87 VideoCaptureParameter(320, 180, 15), 125 VideoCaptureParameter(320, 180, 15),
88 VideoEncoding(125_000, 15), 126 VideoEncoding(125_000, 15),
89 ), 127 ),
  128 + @Deprecated("VGA is deprecated, use H360 instead")
90 VGA( 129 VGA(
91 VideoCaptureParameter(640, 360, 30), 130 VideoCaptureParameter(640, 360, 30),
92 VideoEncoding(400_000, 30), 131 VideoEncoding(400_000, 30),
93 ), 132 ),
  133 + @Deprecated("QHD is deprecated, use H540 instead")
94 QHD( 134 QHD(
95 VideoCaptureParameter(960, 540, 30), 135 VideoCaptureParameter(960, 540, 30),
96 VideoEncoding(800_000, 30), 136 VideoEncoding(800_000, 30),
97 ), 137 ),
  138 + @Deprecated("HD is deprecated, use H720 instead")
98 HD( 139 HD(
99 VideoCaptureParameter(1280, 720, 30), 140 VideoCaptureParameter(1280, 720, 30),
100 VideoEncoding(2_500_000, 30), 141 VideoEncoding(2_500_000, 30),
101 ), 142 ),
  143 + @Deprecated("FHD is deprecated, use H1080 instead")
102 FHD( 144 FHD(
103 VideoCaptureParameter(1920, 1080, 30), 145 VideoCaptureParameter(1920, 1080, 30),
104 VideoEncoding(4_000_000, 30), 146 VideoEncoding(4_000_000, 30),
@@ -112,22 +154,64 @@ enum class VideoPreset43( @@ -112,22 +154,64 @@ enum class VideoPreset43(
112 override val capture: VideoCaptureParameter, 154 override val capture: VideoCaptureParameter,
113 override val encoding: VideoEncoding, 155 override val encoding: VideoEncoding,
114 ) : VideoPreset { 156 ) : VideoPreset {
  157 + H120(
  158 + VideoCaptureParameter(160, 120, 15),
  159 + VideoEncoding(70_000, 15),
  160 + ),
  161 + H180(
  162 + VideoCaptureParameter(240, 180, 15),
  163 + VideoEncoding(125_000, 15),
  164 + ),
  165 + H240(
  166 + VideoCaptureParameter(320, 240, 15),
  167 + VideoEncoding(140_000, 15),
  168 + ),
  169 + H360(
  170 + VideoCaptureParameter(480, 360, 30),
  171 + VideoEncoding(330_000, 30),
  172 + ),
  173 + H480(
  174 + VideoCaptureParameter(640, 480, 30),
  175 + VideoEncoding(500_000, 30),
  176 + ),
  177 + H540(
  178 + VideoCaptureParameter(720, 540, 30),
  179 + VideoEncoding(600_000, 30),
  180 + ),
  181 + H720(
  182 + VideoCaptureParameter(960, 720, 30),
  183 + VideoEncoding(1_300_000, 30),
  184 + ),
  185 + H1080(
  186 + VideoCaptureParameter(1440, 1080, 30),
  187 + VideoEncoding(2_300_000, 30),
  188 + ),
  189 + H1440(
  190 + VideoCaptureParameter(1920, 1440, 30),
  191 + VideoEncoding(3_800_000, 30),
  192 + ),
  193 +
  194 + @Deprecated("QVGA is deprecated, use H120 instead")
115 QVGA( 195 QVGA(
116 VideoCaptureParameter(240, 180, 15), 196 VideoCaptureParameter(240, 180, 15),
117 VideoEncoding(100_000, 15), 197 VideoEncoding(100_000, 15),
118 ), 198 ),
  199 + @Deprecated("VGA is deprecated, use H360 instead")
119 VGA( 200 VGA(
120 VideoCaptureParameter(480, 360, 30), 201 VideoCaptureParameter(480, 360, 30),
121 VideoEncoding(320_000, 30), 202 VideoEncoding(320_000, 30),
122 ), 203 ),
  204 + @Deprecated("QHD is deprecated, use H540 instead")
123 QHD( 205 QHD(
124 VideoCaptureParameter(720, 540, 30), 206 VideoCaptureParameter(720, 540, 30),
125 VideoEncoding(640_000, 30), 207 VideoEncoding(640_000, 30),
126 ), 208 ),
  209 + @Deprecated("HD is deprecated, use H720 instead")
127 HD( 210 HD(
128 VideoCaptureParameter(960, 720, 30), 211 VideoCaptureParameter(960, 720, 30),
129 VideoEncoding(2_000_000, 30), 212 VideoEncoding(2_000_000, 30),
130 ), 213 ),
  214 + @Deprecated("FHD is deprecated, use H1080 instead")
131 FHD( 215 FHD(
132 VideoCaptureParameter(1440, 1080, 30), 216 VideoCaptureParameter(1440, 1080, 30),
133 VideoEncoding(3_200_000, 30), 217 VideoEncoding(3_200_000, 30),
@@ -32,20 +32,28 @@ internal object EncodingUtils { @@ -32,20 +32,28 @@ internal object EncodingUtils {
32 32
33 // Note: maintain order from smallest to biggest. 33 // Note: maintain order from smallest to biggest.
34 private val PRESETS_16_9 = listOf( 34 private val PRESETS_16_9 = listOf(
35 - VideoPreset169.QVGA,  
36 - VideoPreset169.VGA,  
37 - VideoPreset169.QHD,  
38 - VideoPreset169.HD,  
39 - VideoPreset169.FHD 35 + VideoPreset169.H90,
  36 + VideoPreset169.H180,
  37 + VideoPreset169.H216,
  38 + VideoPreset169.H360,
  39 + VideoPreset169.H540,
  40 + VideoPreset169.H720,
  41 + VideoPreset169.H1080,
  42 + VideoPreset169.H1440,
  43 + VideoPreset169.H2160
40 ) 44 )
41 45
42 // Note: maintain order from smallest to biggest. 46 // Note: maintain order from smallest to biggest.
43 private val PRESETS_4_3 = listOf( 47 private val PRESETS_4_3 = listOf(
44 - VideoPreset43.QVGA,  
45 - VideoPreset43.VGA,  
46 - VideoPreset43.QHD,  
47 - VideoPreset43.HD,  
48 - VideoPreset43.FHD 48 + VideoPreset43.H120,
  49 + VideoPreset43.H180,
  50 + VideoPreset43.H240,
  51 + VideoPreset43.H360,
  52 + VideoPreset43.H480,
  53 + VideoPreset43.H540,
  54 + VideoPreset43.H720,
  55 + VideoPreset43.H1080,
  56 + VideoPreset43.H1440,
49 ) 57 )
50 58
51 fun determineAppropriateEncoding(width: Int, height: Int): VideoEncoding { 59 fun determineAppropriateEncoding(width: Int, height: Int): VideoEncoding {