qtsound.m 20.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
/*****************************************************************************
* qtsound.m: qtkit (Mac OS X) based audio capture module
*****************************************************************************
* Copyright © 2011 VLC authors and VideoLAN
*
* Authors: Pierre d'Herbemont <pdherbemont@videolan.org>
*          Gustaf Neumann <neumann@wu.ac.at>
*          Michael S. Feurstein <michael.feurstein@wu.ac.at>
*
*****************************************************************************
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*
*****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_aout.h>

#include <vlc_demux.h>
#include <vlc_dialog.h>

42 43 44
//#define QTKIT_VERSION_MIN_REQUIRED 70603
#define QTKIT_VERSION_MAX_ALLOWED 70700

45 46 47 48 49
#import <QTKit/QTKit.h>

/*****************************************************************************
 * Local prototypes.
 *****************************************************************************/
50 51 52 53
static int Open(vlc_object_t *p_this);
static void Close(vlc_object_t *p_this);
static int Demux(demux_t *p_demux);
static int Control(demux_t *, int, va_list);
54 55 56 57 58 59

/*****************************************************************************
 * Module descriptor
 *****************************************************************************/

vlc_module_begin()
60 61 62 63 64 65 66
set_shortname(N_("QTSound"))
set_description(N_("QuickTime Sound Capture"))
set_category(CAT_INPUT)
set_subcategory(SUBCAT_INPUT_ACCESS)
add_shortcut("qtsound")
set_capability("access_demux", 0)
set_callbacks(Open, Close)
67 68 69 70 71 72 73 74 75 76
vlc_module_end ()


/*****************************************************************************
 * QTKit Bridge
 *****************************************************************************/
@interface VLCDecompressedAudioOutput : QTCaptureDecompressedAudioOutput
{
    demux_t *p_qtsound;
    AudioBuffer *currentAudioBuffer;
Michael Feurstein's avatar
Michael Feurstein committed
77
    block_t *rawAudioData;
78 79 80 81 82 83 84 85
    UInt32 numberOfSamples;
    date_t date;
    mtime_t currentPts;
    mtime_t previousPts;
}
- (id)initWithDemux:(demux_t *)p_demux;
- (void)outputAudioSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection;
- (BOOL)checkCurrentAudioBuffer;
Michael Feurstein's avatar
Michael Feurstein committed
86
- (void)freeAudioMem;
87 88 89 90 91 92 93 94 95 96
- (mtime_t)getCurrentPts;
- (void *)getCurrentAudioBufferData;
- (UInt32)getCurrentTotalDataSize;
- (UInt32)getNumberOfSamples;

@end

@implementation VLCDecompressedAudioOutput : QTCaptureDecompressedAudioOutput
- (id)initWithDemux:(demux_t *)p_demux
{
97
    if (self = [super init]) {
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
        p_qtsound = p_demux;
        currentAudioBuffer = nil;
        date_Init(&date, 44100, 1);
        date_Set(&date,0);
        currentPts = 0;
        previousPts = 0;
    }
    return self;
}
- (void)dealloc
{
    [super dealloc];
}

- (void)outputAudioSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection
{
    AudioBufferList *tempAudioBufferList;
    UInt32 totalDataSize = 0;
    UInt32 count = 0;

118
    @synchronized (self) {
119 120 121 122 123
        numberOfSamples = [sampleBuffer numberOfSamples];
        date_Increment(&date,numberOfSamples);
        currentPts = date_Get(&date);

        tempAudioBufferList = [sampleBuffer audioBufferListWithOptions:0];
124
        if (tempAudioBufferList->mNumberBuffers == 2) {
125 126 127 128
            /*
             * Compute totalDataSize as sum of all data blocks in the
             * audio buffer list:
             */
129
            for (count = 0; count < tempAudioBufferList->mNumberBuffers; count++)
130
                totalDataSize += tempAudioBufferList->mBuffers[count].mDataByteSize;
131

132 133 134 135
            /*
             * Allocate storage for the interleaved audio data
             */
            rawAudioData = block_Alloc(totalDataSize * sizeof(float));
136 137
            if (NULL == rawAudioData) {
                msg_Err(p_qtsound, "Raw audiodata could not be allocated");
138 139
                return;
            }
140
        } else {
141 142
            msg_Err(p_qtsound, "Too many or only one channel found: %i.",
                               tempAudioBufferList->mNumberBuffers);
143 144 145 146 147 148 149
            return;
        }

        /*
         * Interleave raw data (provided in two separate channels as
         * F32L) with 2 samples per frame
         */
150
        if (totalDataSize) {
151 152 153 154 155 156 157 158
            unsigned short i;
            const float *b1Ptr, *b2Ptr;
            float *uPtr;

            for (i = 0,
                 uPtr = (float *)rawAudioData,
                 b1Ptr = (const float *) tempAudioBufferList->mBuffers[0].mData,
                 b2Ptr = (const float *) tempAudioBufferList->mBuffers[1].mData;
159
                 i < numberOfSamples; i++) {
160 161
                *uPtr++ = *b1Ptr++;
                *uPtr++ = *b2Ptr++;
162 163
            }

164
            if (currentAudioBuffer == nil) {
165
                currentAudioBuffer = (AudioBuffer *)malloc(sizeof(AudioBuffer));
166 167
                if (NULL == currentAudioBuffer) {
                    msg_Err(p_qtsound, "AudioBuffer could not be allocated.");
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
                    return;
                }
            }
            currentAudioBuffer->mNumberChannels = 2;
            currentAudioBuffer->mDataByteSize = totalDataSize;
            currentAudioBuffer->mData = rawAudioData;
        }
    }
}

- (BOOL)checkCurrentAudioBuffer
{
    return (currentAudioBuffer) ? 1 : 0;
}

Michael Feurstein's avatar
Michael Feurstein committed
183 184
- (void)freeAudioMem
{
185 186
    @synchronized (self) {
        if (rawAudioData)
Michael Feurstein's avatar
Michael Feurstein committed
187 188 189 190
            free(rawAudioData);
    }
}

191 192 193 194 195
- (mtime_t)getCurrentPts
{
    /* FIXME: can this getter be minimized? */
    mtime_t pts;

196
    if(!currentAudioBuffer || currentPts == previousPts)
197 198
        return 0;

199
    @synchronized (self) {
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
        pts = previousPts = currentPts;
    }

    return (currentAudioBuffer->mData) ? currentPts : 0;
}

- (void *)getCurrentAudioBufferData
{
    return currentAudioBuffer->mData;
}

- (UInt32)getCurrentTotalDataSize
{
    return currentAudioBuffer->mDataByteSize;
}

- (UInt32)getNumberOfSamples
{
    return numberOfSamples;
}

@end

/*****************************************************************************
 * Struct
 *****************************************************************************/

struct demux_sys_t {
    QTCaptureSession * session;
    QTCaptureDevice * audiodevice;
    VLCDecompressedAudioOutput * audiooutput;
    es_out_id_t *p_es_audio;
    int i_audio_max_buffer_size;
};

/*****************************************************************************
 * Open: initialize interface
 *****************************************************************************/
238
static int Open(vlc_object_t *p_this)
239 240 241 242 243 244 245 246 247 248 249 250 251 252
{
    demux_t *p_demux = (demux_t*)p_this;
    demux_sys_t *p_sys;
    es_format_t audiofmt;
    char *psz_uid = NULL;
    int audiocodec;
    bool success;
    NSString *qtk_curraudiodevice_uid;
    NSAutoreleasePool *pool;
    NSArray *myAudioDevices, *audioformat_array;
    QTFormatDescription *audio_format;
    QTCaptureDeviceInput *audioInput;
    NSError *o_returnedAudioError;

253
    if(p_demux->psz_location && *p_demux->psz_location)
254
        psz_uid = p_demux->psz_location;
255 256

    msg_Dbg(p_demux, "qtsound uid = %s", psz_uid);
257 258 259 260
    qtk_curraudiodevice_uid = [[NSString alloc] initWithFormat:@"%s", psz_uid];

    pool = [[NSAutoreleasePool alloc] init];

261 262
    p_demux->p_sys = p_sys = calloc(1, sizeof(demux_sys_t));
    if(!p_sys)
263 264
        return VLC_ENOMEM;

265
    msg_Dbg(p_demux, "qtsound : uid = %s", [qtk_curraudiodevice_uid UTF8String]);
266
    myAudioDevices = [[[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeSound] arrayByAddingObjectsFromArray:[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed]] retain];
267 268
    if([myAudioDevices count] == 0) {
        dialog_FatalWait(p_demux, _("No Audio Input device found"),
269
                         _("Your Mac does not seem to be equipped with a suitable audio input device."
270 271
                     "Please check your connectors and drivers."));
        msg_Err(p_demux, "Can't find any Audio device");
272 273 274

        goto error;
    }
275
    unsigned iaudio;
276
    for (iaudio = 0; iaudio < [myAudioDevices count]; iaudio++) {
277
        QTCaptureDevice *qtk_audioDevice;
278
        qtk_audioDevice = myAudioDevices[iaudio];
279 280 281
        msg_Dbg(p_demux, "qtsound audio %u/%lu localizedDisplayName: %s uniqueID: %s", iaudio, [myAudioDevices count], [[qtk_audioDevice localizedDisplayName] UTF8String], [[qtk_audioDevice uniqueID] UTF8String]);
        if ([[[qtk_audioDevice uniqueID]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtk_curraudiodevice_uid]) {
            msg_Dbg(p_demux, "Device found");
282 283 284 285 286
            break;
        }
    }

    audioInput = nil;
287
    if(iaudio < [myAudioDevices count])
288
        p_sys->audiodevice = myAudioDevices[iaudio];
289
    else {
290 291 292 293
        /* cannot find designated audio device, fall back to open default audio device */
        msg_Dbg(p_demux, "Cannot find designated uid audio device as %s. Fall back to open default audio device.", [qtk_curraudiodevice_uid UTF8String]);
        p_sys->audiodevice = [QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeSound];
    }
294 295
    if(!p_sys->audiodevice) {
        dialog_FatalWait(p_demux, _("No audio input device found"),
296
                         _("Your Mac does not seem to be equipped with a suitable audio input device."
297 298
                     "Please check your connectors and drivers."));
        msg_Err(p_demux, "Can't find any Audio device");
299 300 301 302

        goto error;
    }

303 304
    if(![p_sys->audiodevice open: &o_returnedAudioError]) {
        msg_Err(p_demux, "Unable to open the audio capture device (%ld)", [o_returnedAudioError code]);
305 306 307
        goto error;
    }

308 309
    if([p_sys->audiodevice isInUseByAnotherApplication] == YES) {
        msg_Err(p_demux, "default audio capture device is exclusively in use by another application");
310 311 312
        goto error;
    }
    audioInput = [[QTCaptureDeviceInput alloc] initWithDevice: p_sys->audiodevice];
313 314
    if(!audioInput) {
        msg_Err(p_demux, "can't create a valid audio capture input facility");
315
        goto error;
316 317
    } else
        msg_Dbg(p_demux, "created valid audio capture input facility");
318 319

    p_sys->audiooutput = [[VLCDecompressedAudioOutput alloc] initWithDemux:p_demux];
320
    msg_Dbg (p_demux, "initialized audio output");
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358

    /* Get the formats */
    /*
     FIXME: the format description gathered here does not seem to be the same
     in comparison to the format description collected from the actual sampleBuffer.
     This information needs to be updated some other place. For the time being this shall suffice.

     The following verbose output is an example of what is read from the input device during the below block
     [0x3042138] qtsound demux debug: Audio localized format summary: Linear PCM, 24 bit little-endian signed integer, 2 channels, 44100 Hz
     [0x3042138] qtsound demux debug: Sample Rate: 44100; Format ID: lpcm; Format Flags: 00000004; Bytes per Packet: 8; Frames per Packet: 1; Bytes per Frame: 8; Channels per Frame: 2; Bits per Channel: 24
     [0x3042138] qtsound demux debug: Flag float 0 bigEndian 0 signedInt 1 packed 0 alignedHigh 0 non interleaved 0 non mixable 0
     canonical 0 nativeFloatPacked 0 nativeEndian 0

     However when reading this information from the sampleBuffer during the delegate call from
     - (void)outputAudioSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection;
     the following data shows up
     2011-09-23 22:06:03.077 VLC[23070:f103] Audio localized format summary: Linear PCM, 32 bit little-endian floating point, 2 channels, 44100 Hz
     2011-09-23 22:06:03.078 VLC[23070:f103] Sample Rate: 44100; Format ID: lpcm; Format Flags: 00000029; Bytes per Packet: 4; Frames per Packet: 1; Bytes per Frame: 4; Channels per Frame: 2; Bits per Channel: 32
     2011-09-23 22:06:03.078 VLC[23070:f103] Flag float 1 bigEndian 0 signedInt 0 packed 1 alignedHigh 0 non interleaved 1 non mixable 0
     canonical 1 nativeFloatPacked 1 nativeEndian 0

     Note the differences
     24bit vs. 32bit
     little-endian signed integer vs. little-endian floating point
     format flag 00000004 vs. 00000029
     bytes per packet 8 vs. 4
     packed 0 vs. 1
     non interleaved 0 vs. 1 -> this makes a major difference when filling our own buffer
     canonical 0 vs. 1
     nativeFloatPacked 0 vs. 1

     One would assume we'd need to feed the (es_format_t)audiofmt with the data collected here.
     This is not the case. Audio will be transmitted in artefacts, due to wrong information.

     At the moment this data is set manually, however one should consider trying to set this data dynamically
     */
    audioformat_array = [p_sys->audiodevice formatDescriptions];
    audio_format = NULL;
359
    for(int k = 0; k < [audioformat_array count]; k++) {
360
        audio_format = (QTFormatDescription *)audioformat_array[k];
361

362 363
        msg_Dbg(p_demux, "Audio localized format summary: %s", [[audio_format localizedFormatSummary] UTF8String]);
        msg_Dbg(p_demux, "Audio format description attributes: %s",[[[audio_format formatDescriptionAttributes] description] UTF8String]);
364 365 366 367 368 369 370 371 372 373 374 375

        AudioStreamBasicDescription asbd = {0};
        NSValue *asbdValue =  [audio_format attributeForKey:QTFormatDescriptionAudioStreamBasicDescriptionAttribute];
        [asbdValue getValue:&asbd];

        char formatIDString[5];
        UInt32 formatID = CFSwapInt32HostToBig (asbd.mFormatID);
        bcopy (&formatID, formatIDString, 4);
        formatIDString[4] = '\0';

        /* kept for development purposes */
#if 0
376
        msg_Dbg(p_demux, "Sample Rate: %.0lf; Format ID: %s; Format Flags: %.8x; Bytes per Packet: %d; Frames per Packet: %d; Bytes per Frame: %d; Channels per Frame: %d; Bits per Channel: %d",
377 378 379 380 381 382 383 384 385
                asbd.mSampleRate,
                formatIDString,
                asbd.mFormatFlags,
                asbd.mBytesPerPacket,
                asbd.mFramesPerPacket,
                asbd.mBytesPerFrame,
                asbd.mChannelsPerFrame,
                asbd.mBitsPerChannel);

386
        msg_Dbg(p_demux, "Flag float %d bigEndian %d signedInt %d packed %d alignedHigh %d non interleaved %d non mixable %d\ncanonical %d nativeFloatPacked %d nativeEndian %d",
387 388 389 390 391 392 393 394 395 396 397
                (asbd.mFormatFlags & kAudioFormatFlagIsFloat) != 0,
                (asbd.mFormatFlags & kAudioFormatFlagIsBigEndian) != 0,
                (asbd.mFormatFlags & kAudioFormatFlagIsSignedInteger) != 0,
                (asbd.mFormatFlags & kAudioFormatFlagIsPacked) != 0,
                (asbd.mFormatFlags & kAudioFormatFlagIsAlignedHigh) != 0,
                (asbd.mFormatFlags & kAudioFormatFlagIsNonInterleaved) != 0,
                (asbd.mFormatFlags & kAudioFormatFlagIsNonMixable) != 0,

                (asbd.mFormatFlags & kAudioFormatFlagsCanonical) != 0,
                (asbd.mFormatFlags & kAudioFormatFlagsNativeFloatPacked) != 0,
                (asbd.mFormatFlags & kAudioFormatFlagsNativeEndian) != 0
398
               );
399 400 401
#endif
    }

402
    if([audioformat_array count])
403
        audio_format = audioformat_array[0];
404 405
    else
        goto error;
406 407 408

    /* Now we can init */
    audiocodec = VLC_CODEC_FL32;
409
    es_format_Init(&audiofmt, AUDIO_ES, audiocodec);
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431

    audiofmt.audio.i_format = audiocodec;
    audiofmt.audio.i_rate = 44100;
    /*
     * i_physical_channels Describes the channels configuration of the
     * samples (ie. number of channels which are available in the
     * buffer, and positions).
     */
    audiofmt.audio.i_physical_channels = AOUT_CHAN_RIGHT | AOUT_CHAN_LEFT;
    /*
     * i_original_channels Describes from which original channels,
     * before downmixing, the buffer is derived.
     */
    audiofmt.audio.i_original_channels = AOUT_CHAN_RIGHT | AOUT_CHAN_LEFT;
    /*
     * Please note that it may be completely arbitrary - buffers are not
     * obliged to contain a integral number of so-called "frames". It's
     * just here for the division:
     * buffer_size = i_nb_samples * i_bytes_per_frame / i_frame_length
     */
    audiofmt.audio.i_bitspersample = 32;
    audiofmt.audio.i_channels = 2;
432
    audiofmt.audio.i_blockalign = audiofmt.audio.i_channels * (audiofmt.audio.i_bitspersample / 8);
433
    audiofmt.i_bitrate = audiofmt.audio.i_channels * audiofmt.audio.i_rate * audiofmt.audio.i_bitspersample;
434
    p_sys->i_audio_max_buffer_size = audiofmt.i_bitrate;
435 436 437 438

    p_sys->session = [[QTCaptureSession alloc] init];

    success = [p_sys->session addInput:audioInput error: &o_returnedAudioError];
439 440
    if(!success) {
        msg_Err(p_demux, "the audio capture device could not be added to capture session (%ld)", [o_returnedAudioError code]);
441 442 443 444
        goto error;
    }

    success = [p_sys->session addOutput:p_sys->audiooutput error: &o_returnedAudioError];
445 446
    if(!success) {
        msg_Err(p_demux, "audio output could not be added to capture session (%ld)", [o_returnedAudioError code]);
447 448 449 450 451 452 453 454 455 456 457 458
        goto error;
    }

    [p_sys->session startRunning];

    /* Set up p_demux */
    p_demux->pf_demux = Demux;
    p_demux->pf_control = Control;
    p_demux->info.i_update = 0;
    p_demux->info.i_title = 0;
    p_demux->info.i_seekpoint = 0;

459 460
    msg_Dbg(p_demux, "New audio es %d channels %dHz",
            audiofmt.audio.i_channels, audiofmt.audio.i_rate);
461

462
    p_sys->p_es_audio = es_out_Add(p_demux->out, &audiofmt);
463 464 465 466

    [audioInput release];
    [pool release];

467
    msg_Dbg(p_demux, "QTSound: We have an audio device ready!");
468 469 470 471 472 473

    return VLC_SUCCESS;
error:
    [audioInput release];
    [pool release];

474
    free(p_sys);
475 476 477 478 479 480 481

    return VLC_EGENERIC;
}

/*****************************************************************************
 * Close: destroy interface
 *****************************************************************************/
482
static void Close(vlc_object_t *p_this)
483 484 485 486 487 488 489 490 491
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    demux_t *p_demux = (demux_t*)p_this;
    demux_sys_t *p_sys = p_demux->p_sys;

    [p_sys->session performSelectorOnMainThread:@selector(stopRunning) withObject:nil waitUntilDone:NO];
    [p_sys->audiooutput performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];
    [p_sys->session performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO];

492
    free(p_sys);
493 494 495 496 497 498 499

    [pool release];
}

/*****************************************************************************
 * Demux:
 *****************************************************************************/
500
static int Demux(demux_t *p_demux)
501 502 503 504 505
{
    demux_sys_t *p_sys = p_demux->p_sys;
    block_t *p_blocka;
    NSAutoreleasePool *pool;

506
    p_blocka = block_Alloc(p_sys->i_audio_max_buffer_size);
507

508 509
    if(!p_blocka) {
        msg_Err(p_demux, "cannot get audio block");
510 511 512
        return 0;
    }

513 514
    @synchronized (p_sys->audiooutput) {
        if ([p_sys->audiooutput checkCurrentAudioBuffer]) {
515 516
            p_blocka->i_buffer = p_blocka->i_size = [p_sys->audiooutput getCurrentTotalDataSize];
            p_blocka->p_buffer = p_blocka->p_start = [p_sys->audiooutput getCurrentAudioBufferData];
517
            p_blocka->i_nb_samples = [p_sys->audiooutput getNumberOfSamples];
518
            p_blocka->i_pts = [p_sys->audiooutput getCurrentPts];
519 520 521
        }
    }

522
    if(!p_blocka->i_pts) {
523
        // Nothing to transfer yet, just forget
524 525
        block_Release(p_blocka);
        msleep(10000);
526 527 528
        return 1;
    }

529 530 531
    if(p_blocka) {
        es_out_Control(p_demux->out, ES_OUT_SET_PCR, p_blocka->i_pts);
        es_out_Send(p_demux->out, p_sys->p_es_audio, p_blocka);
532 533
    }

534
    @synchronized (p_sys->audiooutput) {
Michael Feurstein's avatar
Michael Feurstein committed
535 536 537
        [p_sys->audiooutput freeAudioMem];
    }

538 539 540 541 542 543
    return 1;
}

/*****************************************************************************
 * Control:
 *****************************************************************************/
544
static int Control(demux_t *p_demux, int i_query, va_list args)
545 546 547 548
{
    bool *pb;
    int64_t *pi64;

549
    switch(i_query) {
550 551 552 553 554
            /* Special for access_demux */
        case DEMUX_CAN_PAUSE:
        case DEMUX_CAN_SEEK:
        case DEMUX_SET_PAUSE_STATE:
        case DEMUX_CAN_CONTROL_PACE:
555
            pb = (bool*)va_arg(args, bool *);
556 557 558 559
            *pb = false;
            return VLC_SUCCESS;

        case DEMUX_GET_PTS_DELAY:
560 561
            pi64 = (int64_t*)va_arg(args, int64_t *);
            *pi64 = INT64_C(1000) * var_InheritInteger(p_demux, "live-caching");
562 563 564 565 566 567 568
            return VLC_SUCCESS;

        default:
            return VLC_EGENERIC;
    }
    return VLC_EGENERIC;
}