VirtualBox

Changeset 74850 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Oct 15, 2018 4:45:58 PM (6 years ago)
Author:
vboxsync
Message:

VideoRec/Main: Use PDMAUDIOPCMPROPS for the codec's used PCM properties.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/DrvAudioVideoRec.cpp

    r74849 r74850  
    55
    66/*
    7  * Copyright (C) 2016-2017 Oracle Corporation
     7 * Copyright (C) 2016-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    171171typedef struct AVRECCODECPARMS
    172172{
    173     /** The encoding rate to use. */
    174     uint32_t                uHz;
    175     /** Number of audio channels to encode.
    176      *  Currently we only supported stereo (2) channels. */
    177     uint8_t                 cChannels;
    178     /** Bits per sample. */
    179     uint8_t                 cBits;
     173    /** The codec's used PCM properties. */
     174    PDMAUDIOPCMPROPS        PCMProps;
    180175    /** The codec's bitrate. 0 if not used / cannot be specified. */
    181176    uint32_t                uBitrate;
     
    286281static int avRecSinkInit(PDRVAUDIOVIDEOREC pThis, PAVRECSINK pSink, PAVRECCONTAINERPARMS pConParms, PAVRECCODECPARMS pCodecParms)
    287282{
    288     uint32_t uHz       = pCodecParms->uHz;
    289     uint8_t  cBits     = pCodecParms->cBits;
    290     uint8_t  cChannels = pCodecParms->cChannels;
     283    uint32_t uHz       = pCodecParms->PCMProps.uHz;
     284    uint8_t  cBytes    = pCodecParms->PCMProps.cBytes;
     285    uint8_t  cChannels = pCodecParms->PCMProps.cChannels;
    291286    uint32_t uBitrate  = pCodecParms->uBitrate;
    292287
     
    418413        pSink->Con.Parms.enmType     = pConParms->enmType;
    419414
    420         pSink->Codec.Parms.uHz       = uHz;
    421         pSink->Codec.Parms.cChannels = cChannels;
    422         pSink->Codec.Parms.cBits     = cBits;
    423         pSink->Codec.Parms.uBitrate  = uBitrate;
     415        pSink->Codec.Parms.PCMProps.uHz       = uHz;
     416        pSink->Codec.Parms.PCMProps.cChannels = cChannels;
     417        pSink->Codec.Parms.PCMProps.cBytes    = cBytes;
     418        pSink->Codec.Parms.PCMProps.cShift    = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pSink->Codec.Parms.PCMProps.cBytes,
     419                                                                                  pSink->Codec.Parms.PCMProps.cChannels);
     420        pSink->Codec.Parms.uBitrate           = uBitrate;
    424421
    425422        pSink->Codec.Opus.pEnc       = pEnc;
     
    522519    const unsigned cFrames = 2; /** @todo Use the PreRoll param for that? */
    523520
    524     const uint32_t csFrame = pSink->Codec.Parms.uHz / (1000 /* s in ms */ / pSink->Codec.Opus.msFrame);
    525     const uint32_t cbFrame = csFrame * pSink->Codec.Parms.cChannels * (pSink->Codec.Parms.cBits / 8 /* Bytes */);
     521    const uint32_t csFrame = pSink->Codec.Parms.PCMProps.uHz / (1000 /* s in ms */ / pSink->Codec.Opus.msFrame);
     522    const uint32_t cbFrame = DrvAudioHlpFramesToBytes(csFrame, &pSink->Codec.Parms.PCMProps);
    526523
    527524    rc = RTCircBufCreate(&pStreamAV->pCircBuf, cbFrame * cFrames);
     
    535532            /* Make sure to let the driver backend know that we need the audio data in
    536533             * a specific sampling rate Opus is optimized for. */
    537             pCfgAcq->Props.uHz         = pSink->Codec.Parms.uHz;
     534            pCfgAcq->Props.uHz         = pSink->Codec.Parms.PCMProps.uHz;
    538535            pCfgAcq->Props.cShift      = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfgAcq->Props.cBytes, pCfgAcq->Props.cChannels);
    539536
     
    622619
    623620    AVRECCODECPARMS CodecParms;
    624     CodecParms.uHz       = AVREC_OPUS_HZ_MAX;  /** @todo Make this configurable. */
    625     CodecParms.cChannels = 2;                  /** @todo Make this configurable. */
    626     CodecParms.cBits     = 16;                 /** @todo Make this configurable. */
    627     CodecParms.uBitrate  = 0;                  /* Let Opus decide, based on the number of channels and the input sampling rate. */
     621    CodecParms.PCMProps.uHz       = AVREC_OPUS_HZ_MAX;  /** @todo Make this configurable. */
     622    CodecParms.PCMProps.cChannels = 2;                  /** @todo Make this configurable. */
     623    CodecParms.PCMProps.cBytes    = 2;                  /** 16 bit @todo Make this configurable. */
     624
     625    CodecParms.uBitrate = 0; /* Let Opus decide, based on the number of channels and the input sampling rate. */
    628626
    629627    int rc = avRecSinkInit(pThis, &pThis->Sink, &ContainerParms, &CodecParms);
     
    720718    size_t  cbSrc;
    721719
    722     const uint32_t csFrame = pSink->Codec.Parms.uHz / (1000 /* s in ms */ / pSink->Codec.Opus.msFrame);
    723     const uint32_t cbFrame = csFrame * pSink->Codec.Parms.cChannels * (pSink->Codec.Parms.cBits / 8 /* Bytes */);
     720    const uint32_t csFrame = pSink->Codec.Parms.PCMProps.uHz / (1000 /* s in ms */ / pSink->Codec.Opus.msFrame);
     721    const uint32_t cbFrame = DrvAudioHlpFramesToBytes(csFrame, &pSink->Codec.Parms.PCMProps);
    724722
    725723    /* Only encode data if we have data for the given time period (or more). */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette