4
4
const invalidConfigs = [
5
5
{
6
6
comment : 'Emtpy codec' ,
7
- config : { codec : '' } ,
7
+ config : {
8
+ codec : '' ,
9
+ width : 640 ,
10
+ height : 480 ,
11
+ } ,
8
12
} ,
9
13
{
10
14
comment : 'Unrecognized codec' ,
11
- config : { codec : 'bogus' } ,
15
+ config : {
16
+ codec : 'bogus' ,
17
+ width : 640 ,
18
+ height : 480 ,
19
+ } ,
12
20
} ,
21
+ {
22
+ comment : 'Width is too large' ,
23
+ config : {
24
+ codec : 'vp8' ,
25
+ width : 1000000 ,
26
+ height : 480 ,
27
+ } ,
28
+ } ,
29
+ {
30
+ comment : 'Height is too large' ,
31
+ config : {
32
+ codec : 'vp8' ,
33
+ width : 640 ,
34
+ height : 1000000 ,
35
+ } ,
36
+ } ,
37
+ {
38
+ comment : 'Invalid scalability mode' ,
39
+ config : {
40
+ codec : 'vp8' ,
41
+ width : 640 ,
42
+ height : 480 ,
43
+ scalabilityMode : "ABC"
44
+ }
45
+ } ,
46
+ {
47
+ comment : 'AVC not supported by VP8' ,
48
+ config : {
49
+ codec : 'vp8' ,
50
+ width : 640 ,
51
+ height : 480 ,
52
+ avc : {
53
+ format : "annexb"
54
+ }
55
+ }
56
+ }
13
57
] ;
14
58
15
59
invalidConfigs . forEach ( entry => {
16
60
promise_test ( t => {
17
61
return promise_rejects_js ( t , TypeError , VideoEncoder . isConfigSupported ( entry . config ) ) ;
18
- } , 'Test that AudioDecoder.isConfigSupported() rejects invalid config:' + entry . comment ) ;
19
- } ) ;
62
+ } , 'Test that VideoEncoder.isConfigSupported() rejects invalid config:' + entry . comment ) ;
63
+ } ) ;
64
+
65
+
66
+ const validButUnsupportedConfigs = [
67
+ {
68
+ comment : 'Too strenuous accelerated encoding parameters' ,
69
+ config : {
70
+ codec : "vp8" ,
71
+ hardwareAcceleration : "require" ,
72
+ width : 7000 ,
73
+ height : 7000 ,
74
+ bitrate : 1 ,
75
+ framerate : 240 ,
76
+ }
77
+ } ,
78
+ ] ;
79
+
80
+ validButUnsupportedConfigs . forEach ( entry => {
81
+ let config = entry . config ;
82
+ promise_test ( async t => {
83
+ let support = await VideoEncoder . isConfigSupported ( config ) ;
84
+ assert_false ( support . supported ) ;
85
+
86
+ let new_config = support . config ;
87
+ assert_equals ( new_config . codec , config . codec ) ;
88
+ assert_equals ( new_config . width , config . width ) ;
89
+ assert_equals ( new_config . height , config . height ) ;
90
+ if ( config . bitrate )
91
+ assert_equals ( new_config . bitrate , config . bitrate ) ;
92
+ if ( config . framerate )
93
+ assert_equals ( new_config . framerate , config . framerate ) ;
94
+ } , "VideoEncoder.isConfigSupported() doesn't support config:" + entry . comment ) ;
95
+ } ) ;
96
+
97
+ const validConfigs = [
98
+ {
99
+ codec : "avc1.42001E" ,
100
+ hardwareAcceleration : "allow" ,
101
+ width : 640 ,
102
+ height : 480 ,
103
+ bitrate : 5000000 ,
104
+ framerate : 24 ,
105
+ avc : {
106
+ format : "annexb"
107
+ } ,
108
+ futureConfigFeature : 'foo' ,
109
+ } ,
110
+ {
111
+ codec : "vp8" ,
112
+ hardwareAcceleration : "allow" ,
113
+ width : 800 ,
114
+ height : 600 ,
115
+ bitrate : 7000000 ,
116
+ framerate : 60 ,
117
+ scalabilityMode : "L1T2" ,
118
+ futureConfigFeature : 'foo' ,
119
+ } ,
120
+ {
121
+ codec : "vp09.00.10.08" ,
122
+ hardwareAcceleration : "allow" ,
123
+ width : 1280 ,
124
+ height : 720 ,
125
+ bitrate : 7000000 ,
126
+ framerate : 25 ,
127
+ futureConfigFeature : 'foo' ,
128
+ }
129
+ ] ;
130
+
131
+ validConfigs . forEach ( config => {
132
+ promise_test ( async t => {
133
+ let support = await VideoEncoder . isConfigSupported ( config ) ;
134
+ assert_true ( support . supported ) ;
135
+
136
+ let new_config = support . config ;
137
+ assert_false ( new_config . hasOwnProperty ( 'futureConfigFeature' ) ) ;
138
+ assert_equals ( new_config . codec , config . codec ) ;
139
+ assert_equals ( new_config . width , config . width ) ;
140
+ assert_equals ( new_config . height , config . height ) ;
141
+ if ( config . bitrate )
142
+ assert_equals ( new_config . bitrate , config . bitrate ) ;
143
+ if ( config . framerate )
144
+ assert_equals ( new_config . framerate , config . framerate ) ;
145
+ } , "VideoEncoder.isConfigSupported() supports:" + JSON . stringify ( config ) ) ;
146
+ } ) ;
147
+
148
+
0 commit comments