gstreamer for tiny devices
play

GStreamer for Tiny Devices Olivier Crte Open First Who am I ? - PowerPoint PPT Presentation

GStreamer for Tiny Devices Olivier Crte Open First Who am I ? GStreamer at Collabora since 2007 Started with VVoIP: Telepathy & Farstream Helps our customers use GStreamer Many embedded projects 2 A Tiny Device? Flash


  1. GStreamer for Tiny Devices Olivier Crête Open First

  2. Who am I ? ● GStreamer at Collabora since 2007 ● Started with VVoIP: Telepathy & Farstream ● Helps our customers use GStreamer – Many embedded projects 2

  3. A Tiny Device? ● Flash Storage ● Slow CPU ● Little RAM 3

  4. Overview of GStreamer 4

  5. Pipelines! 5

  6. GStreamer in Applications 6

  7. Pipelines! 7

  8. GStreamer: Perfect for embedded! ● Complete Zero-Copy toolkit – Full negotiation – Buffer lifetime – Synchronization ● Loads and loads of hardware enabled plugins ● Very fast prototyping 8

  9. Example: A Security Camera ● 16 MB Flash ● 1 GB RAM ● RTSP Server ● ARMv7 9

  10. Example: A RTSP to MP4 file segments ● Captures 2s clips from RTSP server rtspsrc rtph264depay h264parse splitmuxsink 10

  11. Example: A RTSP to MP4 file segments ● Prototype on PC: g s t - l a u n c h - 1 . 0 r t s p s r c l o c a t i o n = r t s p : / / . . . ! r t p h 2 6 4 d e p a y ! h 2 6 4 p a r s e ! s p l i t m u x s i n k l o c a t i o n = f i l e _ t e m p l a t e _ % 0 5 d . m p 4 11

  12. Version 0: A shell script with gst-launch-1.0 ● Complete GStreamer build – 287 MB for total build – 82 MB of dynamic libraries 287 MB 12

  13. Version 0.1: A shell script with gst-launch-1.0 ● Strip it – 17 MB of dynamic libraries 17 MB 13

  14. Version 1: A C program # i n c l u d e < g s t / g s t . h > # i n c l u d e < u n i s t d . h > i n t m a i n ( i n t a r g c , c h a r * * a r g v ) { G s t E l e m e n t * p i p e l i n e ; G E r r o r * e r r o r = N U L L ; g s t _ i n i t ( & a r g c , & a r g v ) ; p i p e l i n e = g s t _ p a r s e _ l a u n c h ( " r t s p s r c l o c a t i o n = r t s p : / / 1 2 7 . 0 . 0 . 1 : 8 5 5 4 / t e s t ! r t p h 2 6 4 d e p a y ! h 2 6 4 p a r s e ! s p l i t m u x s i n k m a x - s i z e - t i m e = 2 l o c a t i o n = v i d e o % 0 5 d . m p 4 " , & e r r o r ) ; i f ( ! p i p e l i n e ) g _ e r r o r ( " E r r o r : % s " , e r r o r - > m e s s a g e ) ; g s t _ e l e m e n t _ s e t _ s t a t e ( p i p e l i n e , G S T _ S T A T E _ P L A Y I N G ) ; p a u s e ( ) ; g s t _ e l e m e n t _ s e t _ s t a t e ( p i p e l i n e , G S T _ S T A T E _ N U L L ) ; r e t u r n 0 ; } 14

  15. Version 1: A C program (Makefile) S Y S R O O T = / h o m e / o c r e t e / c o l l a b o r a / c e r b e r o / t o o l c h a i n / s y s r o o t - g l i b c - l i n a r o - 2 . 2 5 - 2 0 1 7 . 0 8 - a r m - l i n u x - g n u e a b i h f C C = / h o m e / o c r e t e / c o l l a b o r a / c e r b e r o / t o o l c h a i n / g c c - l i n a r o - 7 . 1 . 1 - 2 0 1 7 . 0 8 - i 6 8 6 _ a r m - l i n u x - g n u e a b i h f / b i n / a r m - l i n u x - g n u e a b i h f - g c c P K G _ C O N F I G _ P A T H = / h o m e / o c r e t e / c o l l a b o r a / c e r b e r o / b u i l d / d i s t / l i n u x _ a r m v 7 / l i b / p k g c o n f i g p r o g r a m : p r o g r a m . c M a k e f i l e l i b t o o l l i n k - - t a g = C C $ ( C C ) ` P K G _ C O N F I G _ P A T H = $ ( P K G _ C O N F I G _ P A T H ) p k g - c o n f i g - - l i b s - - c f l a g s g s t r e a m e r - 1 . 0 ` p r o g r a m . c - o p r o g r a m 15

  16. Version 1: A C program ● Binary: 13K – Stripped: 5.5K ● Plus 17 MB in libraries ● Total: 17 MB 17 MB 16

  17. Static Build? ● Using libtool – l i b t o o l - s t a t i c - l i b t o o l - l i b s – p k g - c o n f i g – - s t a t i c ● 7.5 MB binary 1.5 MB ● Stripped: 1.5 MB static binary 17

  18. Try on device ● Put on Flash, run it: * * ( p r o g r a m : 1 4 8 0 6 ) : E R R O R * * : E r r o r : n o e l e m e n t " r t s p s r c " ● Missing all the plugins! 18

  19. Copy plugins ● All ? 17MB … . ● Only relevant?! – G S T _ D E B U G = G S T _ P L U G I N _ L O A D I N G : 4 ● Total 1.7 MB in plugins once stripped 1.7 MB 19

  20. Try on device again ( p r o g r a m : 2 3 2 1 1 ) : G S t r e a m e r - W A R N I N G * * : F a i l e d t o l o a d p l u g i n ' / l i b / g s t r e a m e r - 1 . 0 / l i b g s t u d p . s o ' : l i b g s t n e t - 1 . 0 . s o . 0 : c a n n o t o p e n s h a r e d o b j e c t f i l e : N o s u c h f i l e o r d i r e c t o r y ● Plugins are not static! – Need to re-add libraries 17 MB – Back to 17 MB 20

  21. Statically build plugins ● Declare functions like G S T _ P L U G I N _ S T A T I C _ D E C L A R E ( c o r e e l e m e n t s ) ; ● Register plugins – After g s t _ i n i t ( ) – G S T _ P L U G I N _ S T A T I C _ R E G I S T E R ( c o r e e l e m e n t s ) ; 21

  22. Statically build plugins ● Link with - L / h o m e / o c r e t e / c o l l a b o r a / c e r b e r o / b u i l d / d i s t / l i n u x _ a r m v 7 / l i b / g s t r e a m e r - 1 . 0 - l g s t c o r e e l e m e n t s - l g s t i s o m p 4 - l g s t v i d e o p a r s e r s b a d - l g s t r t p - l g s t r t s p - l g s t r t p m a n a g e r - l g s t u d p 22

  23. Statically build plugins ● Real static binary is 28 MB ● Stripped to 4.7 MB ● Really working on device 4.7 MB 23

  24. Ask the compiler for HELLPPP ! ● Compile with -Os ● Disappointing, it hasn't improved! – Stripped Binary: 4.7 MB 4.7 MB 24

  25. Strip functions that are not used ● Build with: - f f u n c t i o n - s e c t i o n s - f d a t a - s e c t i o n s ● Link with: - W l , - - g c - s e c t i o n s ● Stripped Binary : 4 MB 4 MB 25

  26. Dig into! ● Find which .o files contribute to the sink ● Used – objdump – Python script ● Tool: Bloaty McBloatface – Did not work for me 26

  27. Butcher GLib ● GLib has internal plugins ● Always registered ● Not used, but bot garbage collected ● Butcher them out 27

  28. Butcher GLib ● Removed – GSettings – GDBus – AppInfo – Gapplication – Notifications https://people.collabora.com/~tester/Butcher-glib-remove-gdbus-gapplication-desktopap.patch 28

  29. Butcher GLib ● Stripped binary down to 3.8 MB 3.8 MB 29

  30. Cheating time: Compressed binary ● Using upx u p x - - b e s t p r o g r a m ● Compress down to 2 MB 2 MB 30

  31. More steps ● Remove UTF-8 tables in GLib ● Dig into exact linked code 31

  32. Thank you!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend