VirtualBox

Changeset 69188 in vbox for trunk/src


Ignore:
Timestamp:
Oct 24, 2017 8:59:02 AM (7 years ago)
Author:
vboxsync
Message:

VideoRec/DrvAudioVideoRec: Use a PTS for encoding.

File:
1 edited

Legend:

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

    r68895 r69188  
    232232    /** Codec data this sink uses for encoding. */
    233233    AVRECCODEC           Codec;
     234    /** Timestamp (in ms) of when the sink was created. */
     235    uint64_t             tsStartMs;
    234236} AVRECSINK, *PAVRECSINK;
    235237
     
    245247    /** Pointer to sink to use for writing. */
    246248    PAVRECSINK           pSink;
     249    /** Last encoded PTS (in ms). */
     250    uint64_t             uLastPTSMs;
    247251} AVRECSTREAM, *PAVRECSTREAM;
    248252
     
    410414        pSink->Codec.STAM.msEncTotal = 0;
    411415#endif
     416
     417        pSink->tsStartMs             = RTTimeMilliTS();
    412418    }
    413419    else
     
    509515    if (RT_SUCCESS(rc))
    510516    {
    511         pStreamAV->pSink = pSink; /* Assign sink to stream. */
     517        pStreamAV->pSink      = pSink; /* Assign sink to stream. */
     518        pStreamAV->uLastPTSMs = 0;
    512519
    513520        if (pCfgAcq)
     
    760767            Assert(cEncFrames == 1); /* At the moment we encode exactly *one* frame per frame. */
    761768
     769            if (pStreamAV->uLastPTSMs == 0)
     770                pStreamAV->uLastPTSMs = RTTimeMilliTS() - pSink->tsStartMs;
     771
    762772            const uint64_t uDurationMs = pSink->Codec.Opus.msFrame * cEncFrames;
     773            const uint64_t uPTSMs      = pStreamAV->uLastPTSMs + uDurationMs;
     774
     775            pStreamAV->uLastPTSMs += uDurationMs;
    763776
    764777            switch (pSink->Con.Parms.enmType)
     
    766779                case AVRECCONTAINERTYPE_MAIN_CONSOLE:
    767780                {
    768                     HRESULT hr = pSink->Con.Main.pConsole->i_audioVideoRecSendAudio(abDst, cbDst, uDurationMs);
     781                    HRESULT hr = pSink->Con.Main.pConsole->i_audioVideoRecSendAudio(abDst, cbDst, uPTSMs);
    769782                    Assert(hr == S_OK);
    770783                    RT_NOREF(hr);
     
    775788                case AVRECCONTAINERTYPE_WEBM:
    776789                {
    777                     WebMWriter::BlockData_Opus blockData = { abDst, cbDst, uDurationMs };
     790                    WebMWriter::BlockData_Opus blockData = { abDst, cbDst, uPTSMs };
    778791                    rc = pSink->Con.WebM.pWebM->WriteBlock(pSink->Con.WebM.uTrack, &blockData, sizeof(blockData));
    779792                    AssertRC(rc);
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