<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.videolan.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Berthe</id>
	<title>VideoLAN Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.videolan.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Berthe"/>
	<link rel="alternate" type="text/html" href="https://wiki.videolan.org/Special:Contributions/Berthe/"/>
	<updated>2026-11-04T17:14:00Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Stream_to_memory_(smem)_tutorial&amp;diff=17459</id>
		<title>Stream to memory (smem) tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Stream_to_memory_(smem)_tutorial&amp;diff=17459"/>
		<updated>2010-11-02T08:24:31Z</updated>

		<summary type="html">&lt;p&gt;Berthe: mistakes…&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here is a small tutorial intended to make a quick tour of the &#039;&#039;stream to memory&#039;&#039; module (smem) , included in VLC 1.1.0.&lt;br /&gt;
This module allows you to write a code which handles the video and audio data read by VLC.&lt;br /&gt;
This page shows a basic code written in C which uses this module.&lt;br /&gt;
&lt;br /&gt;
== Including VLC library ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vlc/vlc.h&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Defining callbacks ==&lt;br /&gt;
&lt;br /&gt;
VLC sends you the data you need via two functions that you define yourself. They will be run before and after the data is rendered. There are two functions for the audio data, and two for the video one. In this example I will just show how to deal with audio data, the process is the same for video handling.&lt;br /&gt;
&amp;lt;pre&amp;gt;void prepareRender(void* p_audio_data, uint8_t** pp_pcm_buffer , unsigned int size); // Audio prerender callback&lt;br /&gt;
void handleStream(void* p_audio_data, uint8_t* p_pcm_buffer, unsigned int channels, unsigned int rate, unsigned int nb_samples, unsigned int bits_per_sample, unsigned int size, int64_t pts); // Audio postrender callback&lt;br /&gt;
// Video prerender and postrender callbacks not implemented.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a VLC instance ==&lt;br /&gt;
&lt;br /&gt;
As with every application you build with libvlc, you have to initialize the library. But you also have to tell VLC the address of each callback you wrote. This is made by writing the address in the parameters used to launch VLC.&lt;br /&gt;
&amp;lt;pre&amp;gt;int main(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
        // VLC pointers&lt;br /&gt;
        libvlc_instance_t *vlcInstance;&lt;br /&gt;
        libvlc_media_player_t *mp;&lt;br /&gt;
        libvlc_media_t *media;&lt;br /&gt;
&lt;br /&gt;
        // VLC options&lt;br /&gt;
        char smem_options[256];&lt;br /&gt;
&lt;br /&gt;
        sprintf(smem_options, &amp;quot;#transcode{acodec=s16l}:smem{audio-postrender-callback=%lld,audio-prerender-callback=%lld}&amp;quot;,&lt;br /&gt;
                // We are using transcode because smem only support raw audio and video formats&lt;br /&gt;
&lt;br /&gt;
                 (long long int)(intptr_t)(void*)&amp;amp;handleStream, (long long int)(intptr_t)(void*)&amp;amp;prepareRender);&lt;br /&gt;
                // We print (as a decimal value) the addresses. Note that you can also define smem-audio-data : this pointer&lt;br /&gt;
                // will be passed to your callbacks (it may be useful to retrive some extra informations) but isn&#039;t required at all.&lt;br /&gt;
&lt;br /&gt;
        const char * const vlc_args[] = {&lt;br /&gt;
              &amp;quot;-I&amp;quot;, &amp;quot;dummy&amp;quot;, // Don&#039;t use any interface&lt;br /&gt;
              &amp;quot;--ignore-config&amp;quot;, // Don&#039;t use VLC&#039;s config&lt;br /&gt;
              &amp;quot;--extraintf=logger&amp;quot;, // Log anything&lt;br /&gt;
              &amp;quot;--verbose=2&amp;quot;, // Be much more verbose then normal for debugging purpose&lt;br /&gt;
              &amp;quot;--sout&amp;quot;, smem_options // Stream to memory&lt;br /&gt;
               };&lt;br /&gt;
&lt;br /&gt;
        // We launch VLC&lt;br /&gt;
        vlcInstance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);&lt;br /&gt;
&lt;br /&gt;
        mp = libvlc_media_player_new(vlcInstance);&lt;br /&gt;
&lt;br /&gt;
        // To be continued.&lt;br /&gt;
&lt;br /&gt;
        return 0;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementing callbacks ==&lt;br /&gt;
{{mmwiki|PCM format|PCM}}&lt;br /&gt;
The smem module sends us the data in PCM format.&lt;br /&gt;
&lt;br /&gt;
The first callback, called &#039;&#039;prepareRender&#039;&#039; in this example, locks the mutex and sets the data pointer (i.e. where the data will be written). All you have to do here is to ensure that &#039;&#039;*pp_pcm_buffer&#039;&#039; points now to a valid array where &#039;&#039;size&#039;&#039; bytes can be written.&lt;br /&gt;
&lt;br /&gt;
The second callback, here &#039;&#039;handleStream&#039;&#039;, is the place where you can do everything you want with the data you got !&lt;br /&gt;
&lt;br /&gt;
The&#039;&#039; p_audio_data&#039;&#039; pointer is linked to the object you set in the command line parameters. It can be useful in order to communicate with the rest of the program.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void prepareRender (void* p_audio_data, uint8_t** pp_pcm_buffer , unsigned int size)&lt;br /&gt;
{&lt;br /&gt;
        // TODO: Lock the mutex&lt;br /&gt;
&lt;br /&gt;
        *pp_pcm_buffer = // TODO&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void handleStream(void* p_audio_data, uint8_t* p_pcm_buffer, unsigned int channels, unsigned int rate, unsigned int nb_samples, unsigned int bits_per_sample, unsigned int size, int64_t pts )&lt;br /&gt;
{&lt;br /&gt;
        // TODO: explain how data should be handled&lt;br /&gt;
        // TODO: Unlock the mutex&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling the data ==&lt;br /&gt;
The PCM format is very raw, but you may still have to do some small transformations in order to be able to get the exact waveform of the audio stream.&lt;br /&gt;
&lt;br /&gt;
First, the audio data is sent as an array of bytes, but each sample may be coded on more bytes : if you use the unchanged array, the values won&#039;t mean anything. The parameter &#039;&#039;bits_per_sample&#039;&#039; helps you to know how to tackle this problem.&lt;br /&gt;
&lt;br /&gt;
Then, the data is still in an unsigned format : the negative values have an offset which makes the data look wierd.&lt;/div&gt;</summary>
		<author><name>Berthe</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Stream_to_memory_(smem)_tutorial&amp;diff=17226</id>
		<title>Stream to memory (smem) tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Stream_to_memory_(smem)_tutorial&amp;diff=17226"/>
		<updated>2010-10-28T22:44:07Z</updated>

		<summary type="html">&lt;p&gt;Berthe: Added some info about callbacks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here is a small tutorial intended to make a quick tour of the &#039;&#039;stream to memory&#039;&#039; module (smem) , included in VLC 1.1.0.&lt;br /&gt;
This module allows you to write a code which handles the video and audio data read by VLC.&lt;br /&gt;
This page shows a basic code written in C which uses this module.&lt;br /&gt;
&lt;br /&gt;
== Including VLC library ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vlc/vlc.h&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Defining callbacks ==&lt;br /&gt;
&lt;br /&gt;
VLC sends you the data you need via two functions that you define yourself. They will be run before and after the data is rendered. There are two functions for the audio data, and two for the video one. In this example I will just show how to deal with audio data, the process is the same for video handling.&lt;br /&gt;
&amp;lt;pre&amp;gt;void prepareRender(void* p_audio_data, uint8_t** pp_pcm_buffer , unsigned int size); // Audio prerender callback&lt;br /&gt;
void handleStream(void* p_audio_data, uint8_t* p_pcm_buffer, unsigned int channels, unsigned int rate, unsigned int nb_samples, unsigned int bits_per_sample, unsigned int size, int64_t pts); // Audio postrender callback&lt;br /&gt;
// Video prerender and postrender callbacks not implemented.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a VLC instance ==&lt;br /&gt;
&lt;br /&gt;
As with every application you build with libvlc, you have to initialize the library. But you also have to tell VLC the address of each callback you wrote. This is made by writing the address in the parameters used to launch VLC.&lt;br /&gt;
&amp;lt;pre&amp;gt;int main(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
        // VLC pointers&lt;br /&gt;
        libvlc_instance_t *vlcInstance;&lt;br /&gt;
        libvlc_media_player_t *mp;&lt;br /&gt;
        libvlc_media_t *media;&lt;br /&gt;
&lt;br /&gt;
        // VLC options&lt;br /&gt;
        char smem_options[256];&lt;br /&gt;
&lt;br /&gt;
        sprintf(smem_options, &amp;quot;#transcode{acodec=s16l}:smem{audio-postrender-callback=%lld,audio-prerender-callback=%lld}&amp;quot;,&lt;br /&gt;
                // We are using transcode because smem only support raw audio and video formats&lt;br /&gt;
&lt;br /&gt;
                 (long long int)(intptr_t)(void*)&amp;amp;handleStream, (long long int)(intptr_t)(void*)&amp;amp;prepareRender);&lt;br /&gt;
                // We print (as a decimal value) the addresses. Note that you can also define smem-audio-data : this pointer&lt;br /&gt;
                // will be passed to your callbacks (it may be useful to retrive some extra informations) but isn&#039;t required at all.&lt;br /&gt;
&lt;br /&gt;
        const char * const vlc_args[] = {&lt;br /&gt;
              &amp;quot;-I&amp;quot;, &amp;quot;dummy&amp;quot;, // Don&#039;t use any interface&lt;br /&gt;
              &amp;quot;--ignore-config&amp;quot;, // Don&#039;t use VLC&#039;s config&lt;br /&gt;
              &amp;quot;--extraintf=logger&amp;quot;, // Log anything&lt;br /&gt;
              &amp;quot;--verbose=2&amp;quot;, // Be much more verbose then normal for debugging purpose&lt;br /&gt;
              &amp;quot;--sout&amp;quot;, smem_options // Stream to memory&lt;br /&gt;
               };&lt;br /&gt;
&lt;br /&gt;
        // We launch VLC&lt;br /&gt;
        vlcInstance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);&lt;br /&gt;
&lt;br /&gt;
        mp = libvlc_media_player_new(vlcInstance);&lt;br /&gt;
&lt;br /&gt;
        // To be continued.&lt;br /&gt;
&lt;br /&gt;
        return 0;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementing callbacks ==&lt;br /&gt;
{{mmwiki|PCM format|PCM}}&lt;br /&gt;
The smem module sends us the data in PCM format.&lt;br /&gt;
&lt;br /&gt;
The first callback, called &#039;&#039;prepareRender&#039;&#039; in this example, locks the mutex and sets the data pointer (i.e. where the data will be written). All you have to do here is to ensure that &#039;&#039;*pp_pcm_buffer&#039;&#039; points now to a valid array where &#039;&#039;size&#039;&#039; bytes can be written.&lt;br /&gt;
&lt;br /&gt;
The second callback, here &#039;&#039;handleStream&#039;&#039;, is the place where you can do everything you want with the data you got !&lt;br /&gt;
&lt;br /&gt;
The pointer &#039;&#039;p_audio_data&#039;&#039; points to the object you set in the command line parameters. It can be useful to communicate with the rest of the application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void prepareRender (void* p_audio_data, uint8_t** pp_pcm_buffer , unsigned int size)&lt;br /&gt;
{&lt;br /&gt;
        // TODO: Lock the mutex&lt;br /&gt;
&lt;br /&gt;
        *pp_pcm_buffer = // TODO&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void handleStream(void* p_audio_data, uint8_t* p_pcm_buffer, unsigned int channels, unsigned int rate, unsigned int nb_samples, unsigned int bits_per_sample, unsigned int size, int64_t pts )&lt;br /&gt;
{&lt;br /&gt;
        // TODO: explain how data should be handled&lt;br /&gt;
        // TODO: Unlock the mutex&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Handling the data ==&lt;br /&gt;
The PCM format is very raw, but you may still have to do some small transformations in order to be able to get the exact waveform of the audio stream.&lt;br /&gt;
&lt;br /&gt;
First, the audio data is sent as an array of bytes, but each sample may be coded on more bytes : if you use the unchanged array, the values won&#039;t mean anything. The parameter &#039;&#039;bits_per_sample&#039;&#039; helps you to know how to tackle this problem.&lt;br /&gt;
&lt;br /&gt;
Then, the data is still in an unsigned format : the negative values have an offset which makes the data look wierd.&lt;/div&gt;</summary>
		<author><name>Berthe</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Stream_to_memory_(smem)_tutorial&amp;diff=16364</id>
		<title>Stream to memory (smem) tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Stream_to_memory_(smem)_tutorial&amp;diff=16364"/>
		<updated>2010-06-19T12:30:43Z</updated>

		<summary type="html">&lt;p&gt;Berthe: /* Implementing callbacks */  Added some info about PCM (TBC)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here is a small tutorial intended to make a quick tour of the &#039;&#039;stream to memory&#039;&#039; module (smem) , included in VLC 1.1.0.&lt;br /&gt;
This module allows you to write a code which handles the video and audio data read by VLC.&lt;br /&gt;
This page shows a basic code written in C which uses this module.&lt;br /&gt;
&lt;br /&gt;
== Including VLC library ==&lt;br /&gt;
&lt;br /&gt;
An easy part : we just have to include one header. Don&#039;t forget to have the linker add the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vlc/vlc.h&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Defining callbacks ==&lt;br /&gt;
&lt;br /&gt;
VLC sends you the data you need via two functions that you define yourself. They will be run before and after the data is rendered. There are two functions for the audio data, and two for the video one. In this example I will just show how to deal with audio data, the process is the same for video handling.&lt;br /&gt;
&amp;lt;pre&amp;gt;void prepareRender(void* p_audio_data, uint8_t** pp_pcm_buffer , unsigned int size); // Audio prerender callback&lt;br /&gt;
void handleStream(void* p_audio_data, uint8_t* p_pcm_buffer, unsigned int channels, unsigned int rate, unsigned int nb_samples, unsigned int bits_per_sample, unsigned int size, int64_t pts); // Audio postrender callback&lt;br /&gt;
// Video prerender and postrender callbacks not implemented.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a VLC instance ==&lt;br /&gt;
&lt;br /&gt;
As with every application you build with libvlc, you have to initialize the library. But you also have to tell VLC the address of each callback you wrote. This is made by writing the address in the parameters used to launch VLC.&lt;br /&gt;
&amp;lt;pre&amp;gt;int main(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
        // VLC pointers&lt;br /&gt;
        libvlc_instance_t *vlcInstance;&lt;br /&gt;
        libvlc_media_player_t *mp;&lt;br /&gt;
        libvlc_media_t *media;&lt;br /&gt;
&lt;br /&gt;
        // VLC options&lt;br /&gt;
        char smem_options[256];&lt;br /&gt;
&lt;br /&gt;
        sprintf(smem_options, &amp;quot;#transcode{acodec=s16l}:smem{audio-postrender-callback=%lld,audio-prerender-callback=%lld}&amp;quot;,&lt;br /&gt;
                // We are using transcode because smem only support raw audio and video formats&lt;br /&gt;
&lt;br /&gt;
                 (long long int)(intptr_t)(void*)&amp;amp;handleStream, (long long int)(intptr_t)(void*)&amp;amp;prepareRender);&lt;br /&gt;
                // We print (as a decimal value) the addresses. Note that you can also define smem-audio-data : this pointer&lt;br /&gt;
                // will be passed to your callbacks (it may be useful to retrive some extra informations) but isn&#039;t required at all.&lt;br /&gt;
&lt;br /&gt;
        const char * const vlc_args[] = {&lt;br /&gt;
              &amp;quot;-I&amp;quot;, &amp;quot;dummy&amp;quot;, // Don&#039;t use any interface&lt;br /&gt;
              &amp;quot;--ignore-config&amp;quot;, // Don&#039;t use VLC&#039;s config&lt;br /&gt;
              &amp;quot;--extraintf=logger&amp;quot;, // Log anything&lt;br /&gt;
              &amp;quot;--verbose=2&amp;quot;, // Be much more verbose then normal for debugging purpose&lt;br /&gt;
              &amp;quot;--sout&amp;quot;, smem_options // Stream to memory&lt;br /&gt;
               };&lt;br /&gt;
&lt;br /&gt;
        // We launch VLC&lt;br /&gt;
        vlcInstance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);&lt;br /&gt;
&lt;br /&gt;
        mp = libvlc_media_player_new(vlcInstance);&lt;br /&gt;
&lt;br /&gt;
        // To be continued.&lt;br /&gt;
&lt;br /&gt;
        return 0;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementing callbacks ==&lt;br /&gt;
{{mmwiki|PCM format|PCM}}&lt;br /&gt;
The smem module sends us the data in PCM format.&lt;br /&gt;
&lt;br /&gt;
TODO: Here some text describing the behaviour of callbacks&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void prepareRender (void* p_audio_data, uint8_t** pp_pcm_buffer , unsigned int size)&lt;br /&gt;
{&lt;br /&gt;
        // TODO: Lock the mutex&lt;br /&gt;
&lt;br /&gt;
        *pp_pcm_buffer = // TODO&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void handleStream(void* p_audio_data, uint8_t* p_pcm_buffer, unsigned int channels, unsigned int rate, unsigned int nb_samples, unsigned int bits_per_sample, unsigned int size, int64_t pts )&lt;br /&gt;
{&lt;br /&gt;
        // TODO: explain how data should be handled&lt;br /&gt;
        // TODO: Unlock the mutex&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Berthe</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Talk:Quality&amp;diff=16356</id>
		<title>Talk:Quality</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Talk:Quality&amp;diff=16356"/>
		<updated>2010-06-18T11:29:20Z</updated>

		<summary type="html">&lt;p&gt;Berthe: outdated ?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I would suggest listing the testfiles up on the Wiki-page and numbering them. Maybe include advance features like videofilters, special outputs, the used acess-module and/or even the whole vlcrc configuration file.&lt;br /&gt;
When someone encounters a problem in QA he/she could refer to &#039;Test 1&#039; or &#039;Test A&#039; or something that describes the setup and settings.&lt;br /&gt;
&lt;br /&gt;
== Outdated ? ==&lt;br /&gt;
I think this page is outdated, it should be removed or updated, but I don&#039;t really know what to put here... [[User:Berthe|berthe]] 11:29, 18 June 2010 (UTC)&lt;/div&gt;</summary>
		<author><name>Berthe</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Talk:LibVLC&amp;diff=16350</id>
		<title>Talk:LibVLC</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Talk:LibVLC&amp;diff=16350"/>
		<updated>2010-06-16T16:44:40Z</updated>

		<summary type="html">&lt;p&gt;Berthe: /* Add article */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Add article ==&lt;br /&gt;
&lt;br /&gt;
I created аrticle-translation in Russian &amp;quot;How use libvlc&amp;quot;(http://unick-soft.ru/Articles.cgi?id=15) Can you add link to it in topic? 	you are interesting articles in English only.&lt;br /&gt;
&lt;br /&gt;
[[User:Unick|Unick]] 23:25, 10 November 2009 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Smem tutorial ==&lt;br /&gt;
I started to write a tutorial for smem. Can I add it here ? [http://wiki.videolan.org/Stream_to_memory_%28smem%29_tutorial|link to the tutorial]. &lt;br /&gt;
[[User:Berthe|berthe]] 16:44, 16 June 2010 (UTC)&lt;/div&gt;</summary>
		<author><name>Berthe</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Stream_to_memory_(smem)_tutorial&amp;diff=16349</id>
		<title>Stream to memory (smem) tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Stream_to_memory_(smem)_tutorial&amp;diff=16349"/>
		<updated>2010-06-16T16:31:32Z</updated>

		<summary type="html">&lt;p&gt;Berthe: first sentence was not correct, I hope that&amp;#039;s better now&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here is a small tutorial intended to make a quick tour of the &#039;&#039;stream to memory&#039;&#039; module (smem) , included in VLC 1.1.0.&lt;br /&gt;
This module allows you to write a code which handles the video and audio data read by VLC.&lt;br /&gt;
This page shows a basic code written in C which uses this module.&lt;br /&gt;
&lt;br /&gt;
== Including VLC library ==&lt;br /&gt;
&lt;br /&gt;
An easy part : we just have to include one header. Don&#039;t forget to have the linker add the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vlc/vlc.h&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Defining callbacks ==&lt;br /&gt;
&lt;br /&gt;
VLC sends you the data you need via two functions that you define yourself. They will be run before and after the data is rendered. There are two functions for the audio data, and two for the video one. In this example I will just show how to deal with audio data, the process is the same for video handling.&lt;br /&gt;
&amp;lt;pre&amp;gt;void prepareRender(void* p_audio_data, uint8_t** pp_pcm_buffer , unsigned int size); // Audio prerender callback&lt;br /&gt;
void handleStream(void* p_audio_data, uint8_t* p_pcm_buffer, unsigned int channels, unsigned int rate, unsigned int nb_samples, unsigned int bits_per_sample, unsigned int size, int64_t pts); // Audio postrender callback&lt;br /&gt;
// Video prerender and postrender callbacks not implemented.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a VLC instance ==&lt;br /&gt;
&lt;br /&gt;
As with every application you build with libvlc, you have to initialize the library. But you also have to tell VLC the address of each callback you wrote. This is made by writing the address in the parameters used to launch VLC.&lt;br /&gt;
&amp;lt;pre&amp;gt;int main(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
        // VLC pointers&lt;br /&gt;
        libvlc_instance_t *vlcInstance;&lt;br /&gt;
        libvlc_media_player_t *mp;&lt;br /&gt;
        libvlc_media_t *media;&lt;br /&gt;
&lt;br /&gt;
        // VLC options&lt;br /&gt;
        char smem_options[256];&lt;br /&gt;
&lt;br /&gt;
        sprintf(smem_options, &amp;quot;#transcode{acodec=s16l}:smem{audio-postrender-callback=%lld,audio-prerender-callback=%lld}&amp;quot;,&lt;br /&gt;
                // We are using transcode because smem only support raw audio and video formats&lt;br /&gt;
&lt;br /&gt;
                 (long long int)(intptr_t)(void*)&amp;amp;handleStream, (long long int)(intptr_t)(void*)&amp;amp;prepareRender);&lt;br /&gt;
                // We print (as a decimal value) the addresses. Note that you can also define smem-audio-data : this pointer&lt;br /&gt;
                // will be passed to your callbacks (it may be useful to retrive some extra informations) but isn&#039;t required at all.&lt;br /&gt;
&lt;br /&gt;
        const char * const vlc_args[] = {&lt;br /&gt;
              &amp;quot;-I&amp;quot;, &amp;quot;dummy&amp;quot;, // Don&#039;t use any interface&lt;br /&gt;
              &amp;quot;--ignore-config&amp;quot;, // Don&#039;t use VLC&#039;s config&lt;br /&gt;
              &amp;quot;--extraintf=logger&amp;quot;, // Log anything&lt;br /&gt;
              &amp;quot;--verbose=2&amp;quot;, // Be much more verbose then normal for debugging purpose&lt;br /&gt;
              &amp;quot;--sout&amp;quot;, smem_options // Stream to memory&lt;br /&gt;
               };&lt;br /&gt;
&lt;br /&gt;
        // We launch VLC&lt;br /&gt;
        vlcInstance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);&lt;br /&gt;
&lt;br /&gt;
        mp = libvlc_media_player_new(vlcInstance);&lt;br /&gt;
&lt;br /&gt;
        // To be continued.&lt;br /&gt;
&lt;br /&gt;
        return 0;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementing callbacks ==&lt;br /&gt;
&lt;br /&gt;
TODO: Here some text describing the behaviour of callbacks&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void prepareRender (void* p_audio_data, uint8_t** pp_pcm_buffer , unsigned int size)&lt;br /&gt;
{&lt;br /&gt;
        // TODO: Lock the mutex&lt;br /&gt;
&lt;br /&gt;
        *pp_pcm_buffer = // TODO&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void handleStream(void* p_audio_data, uint8_t* p_pcm_buffer, unsigned int channels, unsigned int rate, unsigned int nb_samples, unsigned int bits_per_sample, unsigned int size, int64_t pts )&lt;br /&gt;
{&lt;br /&gt;
        // TODO: explain how data should be handled&lt;br /&gt;
        // TODO: Unlock the mutex&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Berthe</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Stream_to_memory_(smem)_tutorial&amp;diff=16348</id>
		<title>Stream to memory (smem) tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Stream_to_memory_(smem)_tutorial&amp;diff=16348"/>
		<updated>2010-06-16T16:28:02Z</updated>

		<summary type="html">&lt;p&gt;Berthe: Created page with &amp;#039;Here is a small tutorial intended to purpose a quick tour of the &amp;#039;&amp;#039;stream to memory (smem)&amp;#039;&amp;#039; module, included in VLC 1.1.0. This module allows you to write a code which handles t…&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here is a small tutorial intended to purpose a quick tour of the &#039;&#039;stream to memory (smem)&#039;&#039; module, included in VLC 1.1.0.&lt;br /&gt;
This module allows you to write a code which handles the video and audio data read by VLC.&lt;br /&gt;
This page shows a basic code written in C which uses this module.&lt;br /&gt;
&lt;br /&gt;
== Including VLC library ==&lt;br /&gt;
&lt;br /&gt;
An easy part : we just have to include one header. Don&#039;t forget to have the linker add the library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdint.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;vlc/vlc.h&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Defining callbacks ==&lt;br /&gt;
&lt;br /&gt;
VLC sends you the data you need via two functions that you define yourself. They will be run before and after the data is rendered. There are two functions for the audio data, and two for the video one. In this example I will just show how to deal with audio data, the process is the same for video handling.&lt;br /&gt;
&amp;lt;pre&amp;gt;void prepareRender(void* p_audio_data, uint8_t** pp_pcm_buffer , unsigned int size); // Audio prerender callback&lt;br /&gt;
void handleStream(void* p_audio_data, uint8_t* p_pcm_buffer, unsigned int channels, unsigned int rate, unsigned int nb_samples, unsigned int bits_per_sample, unsigned int size, int64_t pts); // Audio postrender callback&lt;br /&gt;
// Video prerender and postrender callbacks not implemented.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a VLC instance ==&lt;br /&gt;
&lt;br /&gt;
As with every application you build with libvlc, you have to initialize the library. But you also have to tell VLC the address of each callback you wrote. This is made by writing the address in the parameters used to launch VLC.&lt;br /&gt;
&amp;lt;pre&amp;gt;int main(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
        // VLC pointers&lt;br /&gt;
        libvlc_instance_t *vlcInstance;&lt;br /&gt;
        libvlc_media_player_t *mp;&lt;br /&gt;
        libvlc_media_t *media;&lt;br /&gt;
&lt;br /&gt;
        // VLC options&lt;br /&gt;
        char smem_options[256];&lt;br /&gt;
&lt;br /&gt;
        sprintf(smem_options, &amp;quot;#transcode{acodec=s16l}:smem{audio-postrender-callback=%lld,audio-prerender-callback=%lld}&amp;quot;,&lt;br /&gt;
                // We are using transcode because smem only support raw audio and video formats&lt;br /&gt;
&lt;br /&gt;
                 (long long int)(intptr_t)(void*)&amp;amp;handleStream, (long long int)(intptr_t)(void*)&amp;amp;prepareRender);&lt;br /&gt;
                // We print (as a decimal value) the addresses. Note that you can also define smem-audio-data : this pointer&lt;br /&gt;
                // will be passed to your callbacks (it may be useful to retrive some extra informations) but isn&#039;t required at all.&lt;br /&gt;
&lt;br /&gt;
        const char * const vlc_args[] = {&lt;br /&gt;
              &amp;quot;-I&amp;quot;, &amp;quot;dummy&amp;quot;, // Don&#039;t use any interface&lt;br /&gt;
              &amp;quot;--ignore-config&amp;quot;, // Don&#039;t use VLC&#039;s config&lt;br /&gt;
              &amp;quot;--extraintf=logger&amp;quot;, // Log anything&lt;br /&gt;
              &amp;quot;--verbose=2&amp;quot;, // Be much more verbose then normal for debugging purpose&lt;br /&gt;
              &amp;quot;--sout&amp;quot;, smem_options // Stream to memory&lt;br /&gt;
               };&lt;br /&gt;
&lt;br /&gt;
        // We launch VLC&lt;br /&gt;
        vlcInstance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);&lt;br /&gt;
&lt;br /&gt;
        mp = libvlc_media_player_new(vlcInstance);&lt;br /&gt;
&lt;br /&gt;
        // To be continued.&lt;br /&gt;
&lt;br /&gt;
        return 0;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Implementing callbacks ==&lt;br /&gt;
&lt;br /&gt;
TODO: Here some text describing the behaviour of callbacks&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;void prepareRender (void* p_audio_data, uint8_t** pp_pcm_buffer , unsigned int size)&lt;br /&gt;
{&lt;br /&gt;
        // TODO: Lock the mutex&lt;br /&gt;
&lt;br /&gt;
        *pp_pcm_buffer = // TODO&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void handleStream(void* p_audio_data, uint8_t* p_pcm_buffer, unsigned int channels, unsigned int rate, unsigned int nb_samples, unsigned int bits_per_sample, unsigned int size, int64_t pts )&lt;br /&gt;
{&lt;br /&gt;
        // TODO: explain how data should be handled&lt;br /&gt;
        // TODO: Unlock the mutex&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Berthe</name></author>
	</entry>
</feed>