public MediaFrame readFrame ( ) throws JavaAVException { MediaFrame mediaFrame = new MediaFrame ( ) ; while ( mediaFrame != null && ! mediaFrame . hasFrame ( ) ) { if ( av_read_frame ( formatContext , avPacket ) < 0 ) { if ( videoDecoders . get ( avPacket . stream_index ( ) ) != null ) { // video codec may have buffered some frames avPacket . data ( null ) ; avPacket . size ( 0 ) ; } else { return null ; } } MediaPacket mediaPacket = new MediaPacket ( avPacket ) ; Decoder decoder ; if ( ( decoder = videoDecoders . get ( avPacket . stream_index ( ) ) ) != null ) { mediaFrame = decoder . decodeVideo ( mediaPacket ) ; } else if ( ( decoder = audioDecoders . get ( avPacket . stream_index ( ) ) ) != null ) { mediaFrame = decoder . decodeAudio ( mediaPacket ) ; } av_free_packet ( avPacket ) ; mediaPacket . clear ( ) ; } return mediaFrame ; }
Consecutively retrieves media frames from previously specified input source . The media type of the returned frame may alter between consecutive calls . One call may return an audio frame and the next call may return a video frame .