File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed
samples/encode-decode-worker/js Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -120,21 +120,21 @@ class pipeline {
120
120
}
121
121
} ) ;
122
122
} ,
123
- transform ( chunk , controller ) {
123
+ async transform ( chunk , controller ) {
124
124
if ( this . decoder . state != "closed" ) {
125
125
if ( chunk . type == "config" ) {
126
- let config = JSON . parse ( chunk . config ) ;
127
- VideoDecoder . isConfigSupported ( config ) . then ( ( decoderSupport ) => {
128
- if ( decoderSupport . supported ) {
129
- this . decoder . configure ( decoderSupport . config ) ;
130
- self . postMessage ( { text : 'Decoder successfully configured:\n' + JSON . stringify ( decoderSupport . config ) } ) ;
131
- } else {
132
- self . postMessage ( { severity : 'fatal' , text : 'Config not supported:\n' + JSON . stringify ( decoderSupport . config ) } ) ;
133
- }
134
- } )
135
- . catch ( ( e ) => {
136
- self . postMessage ( { severity : 'fatal' , text : `Configuration error: ${ e . message } ` } ) ;
137
- } )
126
+ let config = JSON . parse ( chunk . config ) ;
127
+ try {
128
+ const decoderSupport = await VideoDecoder . isConfigSupported ( config ) ;
129
+ if ( decoderSupport . supported ) {
130
+ this . decoder . configure ( decoderSupport . config ) ;
131
+ self . postMessage ( { text : 'Decoder successfully configured:\n' + JSON . stringify ( decoderSupport . config ) } ) ;
132
+ } else {
133
+ self . postMessage ( { severity : 'fatal' , text : 'Config not supported:\n' + JSON . stringify ( decoderSupport . config ) } ) ;
134
+ }
135
+ } catch ( e ) {
136
+ self . postMessage ( { severity : 'fatal' , text : `Configuration error: ${ e . message } ` } ) ;
137
+ }
138
138
} else {
139
139
try {
140
140
const queue = this . decoder . decodeQueueSize ;
You can’t perform that action at this time.
0 commit comments