File tree Expand file tree Collapse file tree
samples/encode-decode-worker/js Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ class pipeline {
152152
153153 EncodeVideoStream ( self , config ) {
154154 return new TransformStream ( {
155- start ( controller ) {
155+ async start ( controller ) {
156156 this . frameCounter = 0 ;
157157 this . seqNo = 0 ;
158158 this . keyframeIndex = 0 ;
@@ -196,17 +196,17 @@ class pipeline {
196196 self . postMessage ( { severity : 'fatal' , text : `Encoder error: ${ e . message } ` } ) ;
197197 }
198198 } ) ;
199- VideoEncoder . isConfigSupported ( config ) . then ( ( encoderSupport ) => {
200- if ( encoderSupport . supported ) {
199+ try {
200+ const encoderSupport = await VideoEncoder . isConfigSupported ( config ) ;
201+ if ( encoderSupport . supported ) {
201202 this . encoder . configure ( encoderSupport . config ) ;
202203 self . postMessage ( { text : 'Encoder successfully configured:\n' + JSON . stringify ( encoderSupport . config ) } ) ;
203204 } else {
204205 self . postMessage ( { severity : 'fatal' , text : 'Config not supported:\n' + JSON . stringify ( encoderSupport . config ) } ) ;
205206 }
206- } )
207- . catch ( ( e ) => {
208- self . postMessage ( { severity : 'fatal' , text : `Configuration error: ${ e . message } ` } ) ;
209- } )
207+ } catch ( e ) {
208+ self . postMessage ( { severity : 'fatal' , text : `Configuration error: ${ e . message } ` } ) ;
209+ }
210210 } ,
211211 transform ( frame , controller ) {
212212 if ( this . pending_outputs <= 30 ) {
You can’t perform that action at this time.
0 commit comments