SlideShare a Scribd company logo
Gstreamer – Multimedia Stack
Dr. Selvaraj Kesavan
Contents
2
Gstreamer overview
Gstreamer building blocks
Memory management
Debug/Tracing
Clock and synchronization
Latency
Gstreamer
3
 Gstreamer is multimedia stack ,provides elements and pipeline between different elements for
creating multimedia applications such as player ,recorder ,streaming player ,video telephony, STB
rendering etc.
 End to end Multimedia stack for audio, video ,Image ,streaming ,player ,recorder ,video
telephony , Settopbox applications
 Higher level than just input / filters / output
 Networking, audio/video mixed streams, auto data handling
 Various options utilizing hardware accelerators
 Elements
 Sources, filters, sinks
 Bins and Pipelines
 Containers, pipeline is the overall bin
 Elements that contain other elements
 Allow multiple elements to be treated as one entity
 Pads
 Element source / sink connection points
 Caps
Simple pipeline
4
Create dynamically using gst-launch
Source element reads from a file
Filter element converts MP3 to PWM
Sink element passes to ALSA output
gst-launch filesrc location=a.mp3 ! mad ! alsasink
gst-launch videotestsrc ! ffmpegcolorspace ! Fbdevsink
Buffers and Events
5
Buffer:
• A pointer to the actual data being passed
• A reference to a caps structure
•Timestamp, offset, some other metadata
• Reference-counted
• Sub buffers
Events:
• Messages passed in both directions up and down the pipeline
• Used to find out about the pipeline details
• Can be in-band or out-of-band
• Examples:
– Seeking
– Flush
– Segments
– Position
– Duration
State
6
gst_element_set_state (element, state)
GST_STATE_NULL
• default state. No resources are allocated in this state, so, transitioning to it will free all resources
GST_STATE_READY
• Element has allocated all of its global resources. Resources kept within streams. In this state element
open the devices, allocating buffers but the stream is not opened in this state
GST_STATE_PAUSED
• Element has opened the stream, but is not actively processing .Element is allowed to modify a stream's
position, read and process data and such to prepare for playback. Video or audio outputs pushed into
buffer and queue to play it right after the state change. video sinks can already play the first frame
GST_STATE_PLAYING
• element does exactly the same as in the PAUSED state, except that the clock now run
Threads and Bus
7
THREADS:
•Tell an element to go to PLAYING, and something starts happening behind the scenes...
• Data flow happens in separate threads
• States change asynchronously
• GStreamer is thread-safe when using API functions.
BUS:
• Receives messages from elements such as End-Of-Stream, error, warning, tags (title, track,
etc.), state changes...
• Marshals the messages to the main thread
• Apps can, for the most part, ignore the existence of threads
Memory
8
• Most objects might deal with are refcounted.
• GstMemory is an object that manages a region of memory
• GstMemory objects are created by a GstAllocator object
• Different allocators exist for, for example, system memory, shared memory and memory
backed by a DMAbuf file descriptor
• The buffer contains one or more GstMemory objects thet represent the data in the buffer
/* allocate 100 bytes */
mem = gst_allocator_alloc (NULL, 100, NULL);
/* get access to the memory in write mode */
gst_memory_map (mem, &info, GST_MAP_WRITE);
/* fill with pattern */
for (i = 0; i < info.size; i++) info.data[i] = i;
/* release memory */
gst_memory_unmap (mem, &info);
Gstremaer – Debug options
9
• Elements are instrumented with debug output using macros.
• Debug statements are directed to a specific category, and debug level.
• The output is only produced if the category and level are enabled.
• Preferably elements also supply the GstObject outputting the message – makes the output more
useful.
• Plugins can register their own debug categories.
• See the list of available categories:– gst-inspect –gst-debug-help
• 5 levels available: ERROR, WARN, INFO, DEBUG and LOG
• To turn all categories on set the GST_DEBUG env var to the level: GST_DEBUG=5 gst-launch ....
• Turn on specific debug categories: GST_DEBUG=filesrc:5,GST_PADS:3 gst-launch ...
• Can use wildcards: GST_DEBUG=*src:5 gstlaunch...
• Works with all apps of course,(not just gst-launch)
• The overhead is fairly low for disabled categories, but the whole thing can be compiled out.
Clocks and synchronization
10
System Clock
• GStreamer uses a GstClock object, buffer timestamps and a SEGMENT event to synchronize streams in a pipeline
• running-time = absolute-time - base-time
• A GStreamer GstPipeline object maintains a GstClock object and a base-time when it goes to the PLAYING state. The pipeline gives a
handle to the selected GstClock to each element in the pipeline along with selected base-time
• all objects in the pipeline have the same clock and base-time, they can thus all calculate the running-time according to the pipeline clock.
Buffer running-time
• Buffer running-time, needs buffer timestamp and the SEGMENT event that preceded the buffer.
• First we can convert the SEGMENT event into a GstSegment object and then we can use the gst_segment_to_running_time () function to
perform the calculation of the buffer running-time
• Synchronization is now a matter of making sure that a buffer with a certain running-time is played when the clock reaches the same
running-time
• Usually this task is done by sink elements. Sink also have to take into account the latency configured in the pipeline and add this to the
buffer running-time before synchronizing to the pipeline clock
• Non-live sources timestamp buffers with a running-time starting from 0. After a flushing seek, they will produce buffers again from a
running-time of 0.
• Live sources need to timestamp buffers with a running-time matching the pipeline running-time when the first byte of the buffer was
captured
Clocks and synchronization
11
Buffer stream-time:
• The buffer stream-time, also known as the position in the stream, is calculated from the buffer timestamps
and the preceding SEGMENT event. It represents the time inside the media as a value between 0 and the
total duration of the media.
• The stream-time is never used to synchronize streams, this is only done with the running-time
• running-time of a buffer always increments monotonically along with the clock-time. Buffers are played
when their running-time is equal to the clock-time - base-time. The stream-time represents the position in
the stream and jumps backwards when repeating
Clocks and synchronization
12
Clock providers:
• A clock provider is an element in the pipeline that can provide a GstClock object.
• The clock object needs to report an absoulute-time that is monotonocally increasing when the element is in the PLAYING state..
• Clock providers exist because they play back media at some rate, and this rate is not necessarily the same as the system clock
rate.
• For example, a soundcard may playback at 44,1 kHz, but that doesn't mean that after exactly 1 second according to the system
clock, the soundcard has played back 44.100 samples. This is only true by approximation. In fact, the audio device has an
internal clock based on the number of samples played that we can expose
• If an element with an internal clock needs to synchronize, it needs to estimate when a time according to the pipeline clock will
take place according to the internal clock. To estimate this, it needs to slave its clock to the pipeline clock.
• If the pipeline clock is exactly the internal clock of an element, the element can skip the slaving step and directly use the pipeline
clock to schedule playback. This can be both faster and more accurate. Therefore, generally, elements with an internal clock like
audio input or output devices will be a clock provider for the pipeline.
Clocks and synchronization
13
• When the pipeline goes to the PLAYING state, it will go over all elements in the pipeline from sink to source and ask each
element if they can provide a clock. The last element that can provide a clock will be used as the clock provider in the pipeline.
This algorithm prefers a clock from an audio sink in a typical playback pipeline and a clock from source elements in a typical
capture pipeline.
• There exist some bus messages to let you know about the clock and clock providers in the pipeline. You can see what clock is
selected in the pipeline by looking at the NEW_CLOCK message on the bus. When a clock provider is removed from the
pipeline, a CLOCK_LOST message is posted and the application should go to PAUSED and back to PLAYING to select a new
clock.
Latency
14
• The latency is the time it takes for a sample captured at timestamp X to reach the sink. This time is measured against the clock in
the pipeline. For pipelines where the only elements that synchronize against the clock are the sinks, the latency is always 0 since
no other element is delaying the buffer
• For pipelines with live sources, a latency is introduced, mostly because of the way a live source works. Consider an audio source,
it will start capturing the first sample at time 0. If the source pushes buffers with 44100 samples at a time at 44100Hz it will have
collected the buffer at second 1. Since the timestamp of the buffer is 0 and the time of the clock is now >= 1 second, the sink will
drop this buffer because it is too late. Without any latency compensation in the sink, all buffers will be dropped.
• Before the pipeline goes to the PLAYING state, it will, in addition to selecting a clock and calculating a base-time, calculate the
latency in the pipeline. It does this by doing a LATENCY query on all the sinks in the pipeline. The pipeline then selects the
maximum latency in the pipeline and configures this with a LATENCY event.
• All sink elements will delay playback by the value in the LATENCY event. Since all sinks delay with the same amount of time, they
will be relative in sync
• Adding/removing elements to/from a pipeline or changing element properties can change the latency in a pipeline. An element
can request a latency change in the pipeline by posting a LATENCY message on the bus. The application can then decide to
query and redistribute a new latency or not. Changing the latency in a pipeline might cause visual or audible glitches and
should therefore only be done by the application when it is allowed.
Thank You
15
Ad

More Related Content

What's hot (20)

"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Nanik Tolaram
 
Init of Android
Init of AndroidInit of Android
Init of Android
Tetsuyuki Kobayashi
 
How To Build Android for ARM Chip boards
How To Build Android for ARM Chip boardsHow To Build Android for ARM Chip boards
How To Build Android for ARM Chip boards
Industrial Technology Research Institute (ITRI)(工業技術研究院, 工研院)
 
Gstreamer: an Overview
Gstreamer: an OverviewGstreamer: an Overview
Gstreamer: an Overview
Rodrigo Costa
 
NGINX High-performance Caching
NGINX High-performance CachingNGINX High-performance Caching
NGINX High-performance Caching
NGINX, Inc.
 
HTTP Security Headers
HTTP Security HeadersHTTP Security Headers
HTTP Security Headers
Ismael Goncalves
 
Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
National Cheng Kung University
 
Android 10
Android 10Android 10
Android 10
kpraveen_slideshare
 
Android's Multimedia Framework
Android's Multimedia FrameworkAndroid's Multimedia Framework
Android's Multimedia Framework
Opersys inc.
 
Metasploit for Penetration Testing: Beginner Class
Metasploit for Penetration Testing: Beginner ClassMetasploit for Penetration Testing: Beginner Class
Metasploit for Penetration Testing: Beginner Class
Georgia Weidman
 
Android Audio System
Android Audio SystemAndroid Audio System
Android Audio System
Yi-Hsiang Huang
 
Android media framework overview
Android media framework overviewAndroid media framework overview
Android media framework overview
Jerrin George
 
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
CODE BLUE
 
Unit Testing Using Mockito in Android (1).pdf
Unit Testing Using Mockito in Android (1).pdfUnit Testing Using Mockito in Android (1).pdf
Unit Testing Using Mockito in Android (1).pdf
Katy Slemon
 
Running Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Running Android on the Raspberry Pi: Android Pie meets Raspberry PiRunning Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Running Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Chris Simmonds
 
syzkaller: the next gen kernel fuzzer
syzkaller: the next gen kernel fuzzersyzkaller: the next gen kernel fuzzer
syzkaller: the next gen kernel fuzzer
Dmitry Vyukov
 
Recon for Bug Bounty by Agnibha Dutta.pdf
Recon for Bug Bounty by Agnibha  Dutta.pdfRecon for Bug Bounty by Agnibha  Dutta.pdf
Recon for Bug Bounty by Agnibha Dutta.pdf
null - The Open Security Community
 
Android audio system(audioflinger)
Android audio system(audioflinger)Android audio system(audioflinger)
Android audio system(audioflinger)
fefe7270
 
Software update for embedded systems - elce2014
Software update for embedded systems - elce2014Software update for embedded systems - elce2014
Software update for embedded systems - elce2014
Stefano Babic
 
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Pierre-jean Texier
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Nanik Tolaram
 
Gstreamer: an Overview
Gstreamer: an OverviewGstreamer: an Overview
Gstreamer: an Overview
Rodrigo Costa
 
NGINX High-performance Caching
NGINX High-performance CachingNGINX High-performance Caching
NGINX High-performance Caching
NGINX, Inc.
 
Android's Multimedia Framework
Android's Multimedia FrameworkAndroid's Multimedia Framework
Android's Multimedia Framework
Opersys inc.
 
Metasploit for Penetration Testing: Beginner Class
Metasploit for Penetration Testing: Beginner ClassMetasploit for Penetration Testing: Beginner Class
Metasploit for Penetration Testing: Beginner Class
Georgia Weidman
 
Android media framework overview
Android media framework overviewAndroid media framework overview
Android media framework overview
Jerrin George
 
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
CODE BLUE
 
Unit Testing Using Mockito in Android (1).pdf
Unit Testing Using Mockito in Android (1).pdfUnit Testing Using Mockito in Android (1).pdf
Unit Testing Using Mockito in Android (1).pdf
Katy Slemon
 
Running Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Running Android on the Raspberry Pi: Android Pie meets Raspberry PiRunning Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Running Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Chris Simmonds
 
syzkaller: the next gen kernel fuzzer
syzkaller: the next gen kernel fuzzersyzkaller: the next gen kernel fuzzer
syzkaller: the next gen kernel fuzzer
Dmitry Vyukov
 
Android audio system(audioflinger)
Android audio system(audioflinger)Android audio system(audioflinger)
Android audio system(audioflinger)
fefe7270
 
Software update for embedded systems - elce2014
Software update for embedded systems - elce2014Software update for embedded systems - elce2014
Software update for embedded systems - elce2014
Stefano Babic
 
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Diving into SWUpdate: adding new platform support in 30minutes with Yocto/OE !
Pierre-jean Texier
 

Similar to Gstreamer internals (20)

B.Tech. Computer Science Engineering OS Notes Unit 2
B.Tech. Computer Science Engineering OS Notes Unit 2B.Tech. Computer Science Engineering OS Notes Unit 2
B.Tech. Computer Science Engineering OS Notes Unit 2
likatif784
 
I/O Organization
I/O OrganizationI/O Organization
I/O Organization
Dhaval Bagal
 
Fluentd v0.14 Plugin API Details
Fluentd v0.14 Plugin API DetailsFluentd v0.14 Plugin API Details
Fluentd v0.14 Plugin API Details
SATOSHI TAGOMORI
 
Monitoring and tuning your chef server - chef conf talk
Monitoring and tuning your chef server - chef conf talk Monitoring and tuning your chef server - chef conf talk
Monitoring and tuning your chef server - chef conf talk
Andrew DuFour
 
Process scheduling &amp; time
Process scheduling &amp; timeProcess scheduling &amp; time
Process scheduling &amp; time
Yojana Nanaware
 
Backing Up and Recovery
Backing Up and RecoveryBacking Up and Recovery
Backing Up and Recovery
Maham Huda
 
AMC Minor Technical Issues
AMC Minor Technical IssuesAMC Minor Technical Issues
AMC Minor Technical Issues
Apache Traffic Server
 
Comprehensive Monitoring for Docker
Comprehensive Monitoring for DockerComprehensive Monitoring for Docker
Comprehensive Monitoring for Docker
Christian Beedgen
 
ch2.pptx
ch2.pptxch2.pptx
ch2.pptx
Halogens
 
Deploy secure, scalable, and highly available web apps with Azure Front Door ...
Deploy secure, scalable, and highly available web apps with Azure Front Door ...Deploy secure, scalable, and highly available web apps with Azure Front Door ...
Deploy secure, scalable, and highly available web apps with Azure Front Door ...
Stamo Petkov
 
UNIT 2.pptx
UNIT 2.pptxUNIT 2.pptx
UNIT 2.pptx
BLACKSPAROW
 
C++ scalable network_io
C++ scalable network_ioC++ scalable network_io
C++ scalable network_io
Arindam Mukherjee
 
DMA It can give more time to an intersection approach that is experiencing h...
DMA  It can give more time to an intersection approach that is experiencing h...DMA  It can give more time to an intersection approach that is experiencing h...
DMA It can give more time to an intersection approach that is experiencing h...
vaishnavipanditengg
 
Pipelining of Processors
Pipelining of ProcessorsPipelining of Processors
Pipelining of Processors
Gaditek
 
Reactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactorReactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactor
OrenEzer1
 
On the benchmark of Chainer
On the benchmark of ChainerOn the benchmark of Chainer
On the benchmark of Chainer
Kenta Oono
 
IoT Aquarium
IoT AquariumIoT Aquarium
IoT Aquarium
Benjamin Chodroff
 
IoT Aquarium 2
IoT Aquarium 2IoT Aquarium 2
IoT Aquarium 2
Benjamin Chodroff
 
UNIT -5 EMBEDDED DRIVERS AND APPLICATION PORTING.pptx
UNIT -5 EMBEDDED DRIVERS AND APPLICATION PORTING.pptxUNIT -5 EMBEDDED DRIVERS AND APPLICATION PORTING.pptx
UNIT -5 EMBEDDED DRIVERS AND APPLICATION PORTING.pptx
KesavanT10
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptx
DivyaKS18
 
B.Tech. Computer Science Engineering OS Notes Unit 2
B.Tech. Computer Science Engineering OS Notes Unit 2B.Tech. Computer Science Engineering OS Notes Unit 2
B.Tech. Computer Science Engineering OS Notes Unit 2
likatif784
 
Fluentd v0.14 Plugin API Details
Fluentd v0.14 Plugin API DetailsFluentd v0.14 Plugin API Details
Fluentd v0.14 Plugin API Details
SATOSHI TAGOMORI
 
Monitoring and tuning your chef server - chef conf talk
Monitoring and tuning your chef server - chef conf talk Monitoring and tuning your chef server - chef conf talk
Monitoring and tuning your chef server - chef conf talk
Andrew DuFour
 
Process scheduling &amp; time
Process scheduling &amp; timeProcess scheduling &amp; time
Process scheduling &amp; time
Yojana Nanaware
 
Backing Up and Recovery
Backing Up and RecoveryBacking Up and Recovery
Backing Up and Recovery
Maham Huda
 
Comprehensive Monitoring for Docker
Comprehensive Monitoring for DockerComprehensive Monitoring for Docker
Comprehensive Monitoring for Docker
Christian Beedgen
 
Deploy secure, scalable, and highly available web apps with Azure Front Door ...
Deploy secure, scalable, and highly available web apps with Azure Front Door ...Deploy secure, scalable, and highly available web apps with Azure Front Door ...
Deploy secure, scalable, and highly available web apps with Azure Front Door ...
Stamo Petkov
 
DMA It can give more time to an intersection approach that is experiencing h...
DMA  It can give more time to an intersection approach that is experiencing h...DMA  It can give more time to an intersection approach that is experiencing h...
DMA It can give more time to an intersection approach that is experiencing h...
vaishnavipanditengg
 
Pipelining of Processors
Pipelining of ProcessorsPipelining of Processors
Pipelining of Processors
Gaditek
 
Reactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactorReactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactor
OrenEzer1
 
On the benchmark of Chainer
On the benchmark of ChainerOn the benchmark of Chainer
On the benchmark of Chainer
Kenta Oono
 
UNIT -5 EMBEDDED DRIVERS AND APPLICATION PORTING.pptx
UNIT -5 EMBEDDED DRIVERS AND APPLICATION PORTING.pptxUNIT -5 EMBEDDED DRIVERS AND APPLICATION PORTING.pptx
UNIT -5 EMBEDDED DRIVERS AND APPLICATION PORTING.pptx
KesavanT10
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptx
DivyaKS18
 
Ad

More from Selvaraj Kesavan (8)

Analytics&IoT
Analytics&IoTAnalytics&IoT
Analytics&IoT
Selvaraj Kesavan
 
Role of cloud and analytics in IoT
Role of cloud and analytics in IoTRole of cloud and analytics in IoT
Role of cloud and analytics in IoT
Selvaraj Kesavan
 
Cloud computing aws -key services
Cloud computing  aws -key servicesCloud computing  aws -key services
Cloud computing aws -key services
Selvaraj Kesavan
 
Cloud Computing Virtualization and containers
Cloud Computing Virtualization and containersCloud Computing Virtualization and containers
Cloud Computing Virtualization and containers
Selvaraj Kesavan
 
Cloud computing
Cloud computingCloud computing
Cloud computing
Selvaraj Kesavan
 
Internet of things
Internet of thingsInternet of things
Internet of things
Selvaraj Kesavan
 
Emergence of cloud computing and internet of things an overview
Emergence of cloud computing and internet of things   an overviewEmergence of cloud computing and internet of things   an overview
Emergence of cloud computing and internet of things an overview
Selvaraj Kesavan
 
Multimedia streaming
Multimedia streamingMultimedia streaming
Multimedia streaming
Selvaraj Kesavan
 
Role of cloud and analytics in IoT
Role of cloud and analytics in IoTRole of cloud and analytics in IoT
Role of cloud and analytics in IoT
Selvaraj Kesavan
 
Cloud computing aws -key services
Cloud computing  aws -key servicesCloud computing  aws -key services
Cloud computing aws -key services
Selvaraj Kesavan
 
Cloud Computing Virtualization and containers
Cloud Computing Virtualization and containersCloud Computing Virtualization and containers
Cloud Computing Virtualization and containers
Selvaraj Kesavan
 
Emergence of cloud computing and internet of things an overview
Emergence of cloud computing and internet of things   an overviewEmergence of cloud computing and internet of things   an overview
Emergence of cloud computing and internet of things an overview
Selvaraj Kesavan
 
Ad

Recently uploaded (20)

Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 

Gstreamer internals

  • 1. Gstreamer – Multimedia Stack Dr. Selvaraj Kesavan
  • 2. Contents 2 Gstreamer overview Gstreamer building blocks Memory management Debug/Tracing Clock and synchronization Latency
  • 3. Gstreamer 3  Gstreamer is multimedia stack ,provides elements and pipeline between different elements for creating multimedia applications such as player ,recorder ,streaming player ,video telephony, STB rendering etc.  End to end Multimedia stack for audio, video ,Image ,streaming ,player ,recorder ,video telephony , Settopbox applications  Higher level than just input / filters / output  Networking, audio/video mixed streams, auto data handling  Various options utilizing hardware accelerators  Elements  Sources, filters, sinks  Bins and Pipelines  Containers, pipeline is the overall bin  Elements that contain other elements  Allow multiple elements to be treated as one entity  Pads  Element source / sink connection points  Caps
  • 4. Simple pipeline 4 Create dynamically using gst-launch Source element reads from a file Filter element converts MP3 to PWM Sink element passes to ALSA output gst-launch filesrc location=a.mp3 ! mad ! alsasink gst-launch videotestsrc ! ffmpegcolorspace ! Fbdevsink
  • 5. Buffers and Events 5 Buffer: • A pointer to the actual data being passed • A reference to a caps structure •Timestamp, offset, some other metadata • Reference-counted • Sub buffers Events: • Messages passed in both directions up and down the pipeline • Used to find out about the pipeline details • Can be in-band or out-of-band • Examples: – Seeking – Flush – Segments – Position – Duration
  • 6. State 6 gst_element_set_state (element, state) GST_STATE_NULL • default state. No resources are allocated in this state, so, transitioning to it will free all resources GST_STATE_READY • Element has allocated all of its global resources. Resources kept within streams. In this state element open the devices, allocating buffers but the stream is not opened in this state GST_STATE_PAUSED • Element has opened the stream, but is not actively processing .Element is allowed to modify a stream's position, read and process data and such to prepare for playback. Video or audio outputs pushed into buffer and queue to play it right after the state change. video sinks can already play the first frame GST_STATE_PLAYING • element does exactly the same as in the PAUSED state, except that the clock now run
  • 7. Threads and Bus 7 THREADS: •Tell an element to go to PLAYING, and something starts happening behind the scenes... • Data flow happens in separate threads • States change asynchronously • GStreamer is thread-safe when using API functions. BUS: • Receives messages from elements such as End-Of-Stream, error, warning, tags (title, track, etc.), state changes... • Marshals the messages to the main thread • Apps can, for the most part, ignore the existence of threads
  • 8. Memory 8 • Most objects might deal with are refcounted. • GstMemory is an object that manages a region of memory • GstMemory objects are created by a GstAllocator object • Different allocators exist for, for example, system memory, shared memory and memory backed by a DMAbuf file descriptor • The buffer contains one or more GstMemory objects thet represent the data in the buffer /* allocate 100 bytes */ mem = gst_allocator_alloc (NULL, 100, NULL); /* get access to the memory in write mode */ gst_memory_map (mem, &info, GST_MAP_WRITE); /* fill with pattern */ for (i = 0; i < info.size; i++) info.data[i] = i; /* release memory */ gst_memory_unmap (mem, &info);
  • 9. Gstremaer – Debug options 9 • Elements are instrumented with debug output using macros. • Debug statements are directed to a specific category, and debug level. • The output is only produced if the category and level are enabled. • Preferably elements also supply the GstObject outputting the message – makes the output more useful. • Plugins can register their own debug categories. • See the list of available categories:– gst-inspect –gst-debug-help • 5 levels available: ERROR, WARN, INFO, DEBUG and LOG • To turn all categories on set the GST_DEBUG env var to the level: GST_DEBUG=5 gst-launch .... • Turn on specific debug categories: GST_DEBUG=filesrc:5,GST_PADS:3 gst-launch ... • Can use wildcards: GST_DEBUG=*src:5 gstlaunch... • Works with all apps of course,(not just gst-launch) • The overhead is fairly low for disabled categories, but the whole thing can be compiled out.
  • 10. Clocks and synchronization 10 System Clock • GStreamer uses a GstClock object, buffer timestamps and a SEGMENT event to synchronize streams in a pipeline • running-time = absolute-time - base-time • A GStreamer GstPipeline object maintains a GstClock object and a base-time when it goes to the PLAYING state. The pipeline gives a handle to the selected GstClock to each element in the pipeline along with selected base-time • all objects in the pipeline have the same clock and base-time, they can thus all calculate the running-time according to the pipeline clock. Buffer running-time • Buffer running-time, needs buffer timestamp and the SEGMENT event that preceded the buffer. • First we can convert the SEGMENT event into a GstSegment object and then we can use the gst_segment_to_running_time () function to perform the calculation of the buffer running-time • Synchronization is now a matter of making sure that a buffer with a certain running-time is played when the clock reaches the same running-time • Usually this task is done by sink elements. Sink also have to take into account the latency configured in the pipeline and add this to the buffer running-time before synchronizing to the pipeline clock • Non-live sources timestamp buffers with a running-time starting from 0. After a flushing seek, they will produce buffers again from a running-time of 0. • Live sources need to timestamp buffers with a running-time matching the pipeline running-time when the first byte of the buffer was captured
  • 11. Clocks and synchronization 11 Buffer stream-time: • The buffer stream-time, also known as the position in the stream, is calculated from the buffer timestamps and the preceding SEGMENT event. It represents the time inside the media as a value between 0 and the total duration of the media. • The stream-time is never used to synchronize streams, this is only done with the running-time • running-time of a buffer always increments monotonically along with the clock-time. Buffers are played when their running-time is equal to the clock-time - base-time. The stream-time represents the position in the stream and jumps backwards when repeating
  • 12. Clocks and synchronization 12 Clock providers: • A clock provider is an element in the pipeline that can provide a GstClock object. • The clock object needs to report an absoulute-time that is monotonocally increasing when the element is in the PLAYING state.. • Clock providers exist because they play back media at some rate, and this rate is not necessarily the same as the system clock rate. • For example, a soundcard may playback at 44,1 kHz, but that doesn't mean that after exactly 1 second according to the system clock, the soundcard has played back 44.100 samples. This is only true by approximation. In fact, the audio device has an internal clock based on the number of samples played that we can expose • If an element with an internal clock needs to synchronize, it needs to estimate when a time according to the pipeline clock will take place according to the internal clock. To estimate this, it needs to slave its clock to the pipeline clock. • If the pipeline clock is exactly the internal clock of an element, the element can skip the slaving step and directly use the pipeline clock to schedule playback. This can be both faster and more accurate. Therefore, generally, elements with an internal clock like audio input or output devices will be a clock provider for the pipeline.
  • 13. Clocks and synchronization 13 • When the pipeline goes to the PLAYING state, it will go over all elements in the pipeline from sink to source and ask each element if they can provide a clock. The last element that can provide a clock will be used as the clock provider in the pipeline. This algorithm prefers a clock from an audio sink in a typical playback pipeline and a clock from source elements in a typical capture pipeline. • There exist some bus messages to let you know about the clock and clock providers in the pipeline. You can see what clock is selected in the pipeline by looking at the NEW_CLOCK message on the bus. When a clock provider is removed from the pipeline, a CLOCK_LOST message is posted and the application should go to PAUSED and back to PLAYING to select a new clock.
  • 14. Latency 14 • The latency is the time it takes for a sample captured at timestamp X to reach the sink. This time is measured against the clock in the pipeline. For pipelines where the only elements that synchronize against the clock are the sinks, the latency is always 0 since no other element is delaying the buffer • For pipelines with live sources, a latency is introduced, mostly because of the way a live source works. Consider an audio source, it will start capturing the first sample at time 0. If the source pushes buffers with 44100 samples at a time at 44100Hz it will have collected the buffer at second 1. Since the timestamp of the buffer is 0 and the time of the clock is now >= 1 second, the sink will drop this buffer because it is too late. Without any latency compensation in the sink, all buffers will be dropped. • Before the pipeline goes to the PLAYING state, it will, in addition to selecting a clock and calculating a base-time, calculate the latency in the pipeline. It does this by doing a LATENCY query on all the sinks in the pipeline. The pipeline then selects the maximum latency in the pipeline and configures this with a LATENCY event. • All sink elements will delay playback by the value in the LATENCY event. Since all sinks delay with the same amount of time, they will be relative in sync • Adding/removing elements to/from a pipeline or changing element properties can change the latency in a pipeline. An element can request a latency change in the pipeline by posting a LATENCY message on the bus. The application can then decide to query and redistribute a new latency or not. Changing the latency in a pipeline might cause visual or audible glitches and should therefore only be done by the application when it is allowed.

Editor's Notes