Stream MPEG-1 video with its sound, add playback controls, fix a crash on window close
Merged
GA
1mo ago+760+760+012345678901234567890123456789-210-210-012345678901234567890123456789
Hi, thanks for the nice project. I was trying to get a capable browser working under ns-3 network simulator DCE (Direct Code Execution) framework, and only one I found was Northstar. But could not get it to play a video with audio properly, so asked Claude to get it working, tested it, and here are the patches. :)
- Streaming decode.
<video>no longer decodes the whole clip into BGRA frames up front. The image keeps the downloaded bytes and one pl_mpeg decoder, and decodes the frame for the current time on each animation tick. It seeks withplm_seek_frame, or by rewind and decode for an elementary stream. This removes the 256 MB decoded-frame cap, which cut a 640x360 clip off after 11 s. Memory stays flat at one frame plus the clip, and the first frame shows without waiting for a full decode. - Sound. A program stream's MP2 track plays in the page's audio context from the same bytes, so nothing downloads twice.
play(),pause(), seeking,volume,mutedandloopdrive both. The picture waits for the sound to decode, then follows the mixer clock whenever it drifts by more than 0.1 s. - Controls.
<video controls>and<audio controls>get a working bar: play/pause, a seek track (click or drag), current time and duration, and mute. One function lays out the bar for both painting and hit testing. - Close crash. Closing a window crashed in
gtk_widget_unparenton any page, after the warning "Finalizing GtkEntry ... but it still has children left: GtkPopover". The address bar's suggestion popover was unparented from the window's destroy handler, after GTK had already finalized the entry. It is now unparented from the entry's own destroy signal.