I used this code:
Code: Select all
int myImemGetCallback(void *data, const char *cookie, int64_t *dts, int64_t *pts, unsigned *flags, size_t * bufferSize, void ** buffer) {
int ret = 0;
int size = globalsize;
if(!bufferinit) *buffer = malloc(size);// malloc once
memcpy(*buffer, data, size);
*dts = globaldts;
globaldts = globaldts + 33333;
*pts = globalpts;
globalpts = globalpts + 33333;
*bufferSize = size;
return ret;
}
int myImemReleaseCallback(void *data, const char *cookie, size_t bufferSize, void * buffer) {
int ret = 0;
return ret;
}
Code: Select all
vlc_args[0] = "-vvvvv";
vlc_args[1] = (char*)calloc(200, 1);
sprintf(vlc_args[1], "--imem-get=%ld", myImemGetCallback);
vlc_args[2] = (char*)calloc(200, 1);
sprintf(vlc_args[2], "--imem-release=%ld", myImemReleaseCallback);
vlc_args[3] = (char*)calloc(200, 1);
sprintf(vlc_args[3], "--imem-cat=2"); //CAT 1 == AUDIO
vlc_args[4] = (char*)calloc(200, 1);
sprintf(vlc_args[4], "--imem-data=%ld", buffertobroadcast);/** my context custom data to be passed callbacks **/
vlc_args[5] = "--imem-id=0";
vlc_args[6] = (char*)calloc(200, 1);
sprintf(vlc_args[6], "--imem-codec=RV24"); //CODEC, format of the data passed to vlc in the buffers
vlc_args[7] = (char*)calloc(200, 1);
sprintf(vlc_args[7], "--imem-width=640");
vlc_args[8] = (char*)calloc(200, 1);
sprintf(vlc_args[8], "--imem-height=360");
vlc_args[9] = (char*)calloc(200, 1);
sprintf(vlc_args[9], "--imem-channels=%d", mNumInputs); //number of channels
vlc_args[10] = (char *)calloc(200, 1);
sprintf(vlc_args[10], "--imem-samplerate=%d", mSampleFreq); //sample frequency
vlc_args[11] = (char *)calloc(200, 1);
sprintf(vlc_args[11], "--imem-fps=25.000000"); //sample frequency
Code: Select all
libvlc_vlm_add_broadcast(inst, "stream", "imem://", "#transcode{vcodec=h264,vb=3000,fps=25,scale=1,acodec=a52,ab=128,channels=2,samplerate=44100}:rtp{mux=ts,dst=127.0.0.1}", 0, NULL, 1, 0);
Also the message "late buffer for mux input" appear constantly.
imem works well and I can watch the video from camera and stream but memory leaks very fast. I don't see where it can leak in my code, maybe I miss something?