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 {
120120 }
121121 } ) ;
122122 } ,
123- transform ( chunk , controller ) {
123+ async transform ( chunk , controller ) {
124124 if ( this . decoder . state != "closed" ) {
125125 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+ }
138138 } else {
139139 try {
140140 const queue = this . decoder . decodeQueueSize ;
You can’t perform that action at this time.
0 commit comments