Changeset 68850 in vbox for trunk/src/VBox/Main
- Timestamp:
- Sep 25, 2017 10:49:29 AM (7 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleImpl.h
r68798 r68850 140 140 #ifdef VBOX_WITH_AUDIO_VIDEOREC 141 141 AudioVideoRec *i_audioVideoRecGet() const { return mAudioVideoRec; } 142 HRESULT i_audioVideoRecSendAudio(const void *pvData, size_t cbData, uint64_t u TimestampMs);142 HRESULT i_audioVideoRecSendAudio(const void *pvData, size_t cbData, uint64_t uDurationMs); 143 143 #endif 144 144 -
trunk/src/VBox/Main/include/DisplayImpl.h
r68798 r68850 212 212 bool i_videoCaptureStarted(void); 213 213 int i_videoCaptureInvalidate(void); 214 int i_videoCaptureSendAudio(const void *pvData, size_t cbData, uint64_t u TimestampMs);214 int i_videoCaptureSendAudio(const void *pvData, size_t cbData, uint64_t uDurationMs); 215 215 int i_videoCaptureStart(void); 216 216 void i_videoCaptureStop(void); -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r68828 r68850 6752 6752 * @param pvData Audio data to send. 6753 6753 * @param cbData Size (in bytes) of audio data to send. 6754 * @param u TimestampMs Time stamp(in ms) of audio data.6755 */ 6756 HRESULT Console::i_audioVideoRecSendAudio(const void *pvData, size_t cbData, uint64_t u TimestampMs)6754 * @param uDurationMs Duration (in ms) of audio data. 6755 */ 6756 HRESULT Console::i_audioVideoRecSendAudio(const void *pvData, size_t cbData, uint64_t uDurationMs) 6757 6757 { 6758 6758 if (mDisplay) 6759 6759 { 6760 int rc2 = mDisplay->i_videoCaptureSendAudio(pvData, cbData, u TimestampMs);6760 int rc2 = mDisplay->i_videoCaptureSendAudio(pvData, cbData, uDurationMs); 6761 6761 AssertRC(rc2); 6762 6762 } -
trunk/src/VBox/Main/src-client/DrvAudioVideoRec.cpp
r68797 r68850 758 758 cbDst = RT_MIN((uint32_t)cbWritten, cbDst); /* Update cbDst to actual bytes encoded (written). */ 759 759 760 Assert(cEncFrames == 1); /* At the moment we encode exactly *one* frame per frame. */ 761 762 const uint64_t uDurationMs = pSink->Codec.Opus.msFrame * cEncFrames; 763 760 764 switch (pSink->Con.Parms.enmType) 761 765 { 762 766 case AVRECCONTAINERTYPE_MAIN_CONSOLE: 763 767 { 764 HRESULT hr = pSink->Con.Main.pConsole->i_audioVideoRecSendAudio(abDst, cbDst, RTTimeMilliTS() /* Now */);768 HRESULT hr = pSink->Con.Main.pConsole->i_audioVideoRecSendAudio(abDst, cbDst, uDurationMs); 765 769 Assert(hr == S_OK); 766 770 RT_NOREF(hr); … … 771 775 case AVRECCONTAINERTYPE_WEBM: 772 776 { 773 WebMWriter::BlockData_Opus blockData = { abDst, cbDst, RTTimeMilliTS()};777 WebMWriter::BlockData_Opus blockData = { abDst, cbDst, uDurationMs }; 774 778 rc = pSink->Con.WebM.pWebM->WriteBlock(pSink->Con.WebM.uTrack, &blockData, sizeof(blockData)); 775 779 AssertRC(rc); -
trunk/src/VBox/Main/src-client/EbmlWriter.cpp
r68811 r68850 401 401 , uTrack(a_uTrack) 402 402 , offUUID(a_offID) 403 , cTotalClusters(0)404 403 , cTotalBlocks(0) 404 , tcLastWriteMs(0) 405 405 { 406 406 uUUID = RTRandU32(); … … 440 440 * Needed to write the hash sum within the footer. */ 441 441 uint64_t offUUID; 442 /** Total number of clusters. */443 uint64_t cTotalClusters;444 442 /** Total number of blocks. */ 445 443 uint64_t cTotalBlocks; 444 /** Timecode (in ms) of last write. */ 445 uint64_t tcLastWriteMs; 446 446 }; 447 447 … … 473 473 , fOpen(false) 474 474 , tcStartMs(0) 475 , tc EndMs(0)475 , tcLastWriteMs(0) 476 476 , cBlocks(0) { } 477 477 … … 485 485 /** Timecode (in ms) when starting this cluster. */ 486 486 uint64_t tcStartMs; 487 /** Timecode (in ms) when this cluster ends. */488 uint64_t tc EndMs;487 /** Timecode (in ms) of last write. */ 488 uint64_t tcLastWriteMs; 489 489 /** Number of (simple) blocks in this cluster. */ 490 490 uint64_t cBlocks; … … 499 499 { 500 500 WebMSegment(void) 501 : tcStart (0)502 , tc End(0)501 : tcStartMs(0) 502 , tcLastWriteMs(0) 503 503 , offStart(0) 504 504 , offInfo(0) … … 515 515 uint64_t uTimecodeScaleFactor; 516 516 517 /** Timecode when starting this segment. */518 uint64_t tcStart ;519 /** Timecode when this segment ended. */520 uint64_t tc End;517 /** Timecode (in ms) when starting this segment. */ 518 uint64_t tcStartMs; 519 /** Timecode (in ms) of last write. */ 520 uint64_t tcLastWriteMs; 521 521 522 522 /** Absolute offset (in bytes) of CurSeg. */ … … 532 532 /** List of cue points. Needed for seeking table. */ 533 533 std::list<WebMCuePoint> lstCues; 534 535 /** Total number of clusters. */ 536 uint64_t cClusters; 534 537 535 538 /** Map of tracks. … … 771 774 uint64_t tcPTSMs = a_pPkt->data.frame.pts * 1000 772 775 * (uint64_t) a_pCfg->g_timebase.num / a_pCfg->g_timebase.den; 776 /* Sanity. */ 777 Assert(tcPTSMs); 778 //Assert(tcPTSMs >= Cluster.tcLastWriteMs); 773 779 774 780 if ( tcPTSMs 775 && tcPTSMs <= CurSeg.CurCluster.tcEndMs)776 { 777 tcPTSMs = CurSeg.CurCluster.tcEndMs + 1;781 && tcPTSMs <= a_pTrack->tcLastWriteMs) 782 { 783 tcPTSMs = a_pTrack->tcLastWriteMs + 1; 778 784 } 779 785 … … 788 794 if (tcPTSMs > VBOX_WEBM_CLUSTER_MAX_LEN_MS) 789 795 { 790 tcPTSMs = 0; 796 LogFunc(("[T%RU8C%RU64] Exceeded max length (%RU64ms)\n", 797 a_pTrack->uTrack, Cluster.uID, VBOX_WEBM_CLUSTER_MAX_LEN_MS)); 798 799 /* Note: Do not reset the PTS here -- the new cluster starts time-wise 800 * where the old cluster left off. */ 791 801 792 802 fClusterStart = true; … … 805 815 806 816 Cluster.fOpen = true; 807 Cluster.uID = a_pTrack->cTotalClusters;817 Cluster.uID = CurSeg.cClusters; 808 818 Cluster.tcStartMs = tcPTSMs; 809 819 Cluster.offCluster = RTFileTell(m_Ebml.getFile()); 810 820 Cluster.cBlocks = 0; 821 822 if (CurSeg.cClusters) 823 AssertMsg(Cluster.tcStartMs, ("[T%RU8C%RU64] @ %RU64 start is 0 which is invalid\n", 824 a_pTrack->uTrack, Cluster.uID, Cluster.offCluster)); 811 825 812 826 LogFunc(("[T%RU8C%RU64] Start @ %RU64ms / %RU64 bytes\n", … … 823 837 } 824 838 825 a_pTrack->cTotalClusters++;826 } 827 828 Cluster.tc EndMs = tcPTSMs;839 CurSeg.cClusters++; 840 } 841 842 Cluster.tcLastWriteMs = tcPTSMs; 829 843 Cluster.cBlocks++; 830 844 831 if (CurSeg.tcEnd < Cluster.tcEndMs) 832 CurSeg.tcEnd = Cluster.tcEndMs; 845 a_pTrack->tcLastWriteMs = tcPTSMs; 846 847 if (CurSeg.tcLastWriteMs < a_pTrack->tcLastWriteMs) 848 CurSeg.tcLastWriteMs = a_pTrack->tcLastWriteMs; 833 849 834 850 /* Calculate the block's timecode, which is relative to the cluster's starting timecode. */ 835 851 uint16_t tcBlockMs = static_cast<uint16_t>(tcPTSMs - Cluster.tcStartMs); 836 852 837 Log2Func(("tcPTSMs=%RU64, tcBlockMs=%RU64\n", tcPTSMs, tcBlockMs)); 838 839 Log2Func(("[C%RU64] cBlocks=%RU64, tcStartMs=%RU64, tcEndMs=%RU64 (%zums)\n", 840 Cluster.uID, Cluster.cBlocks, Cluster.tcStartMs, Cluster.tcEndMs, Cluster.tcEndMs - Cluster.tcStartMs)); 853 Log2Func(("[T%RU8C%RU64] tcPTSMs=%RU64, (%RU64ms)\n", a_pTrack->uTrack, Cluster.uID, tcPTSMs, tcBlockMs)); 841 854 842 855 uint8_t fFlags = 0; … … 852 865 #ifdef VBOX_WITH_LIBOPUS 853 866 /* Audio blocks that have same absolute timecode as video blocks SHOULD be written before the video blocks. */ 854 int writeBlockOpus(WebMTrack *a_pTrack, const void *pvData, size_t cbData, uint64_t u TimeStampMs)867 int writeBlockOpus(WebMTrack *a_pTrack, const void *pvData, size_t cbData, uint64_t uDurationMs) 855 868 { 856 869 AssertPtrReturn(a_pTrack, VERR_INVALID_POINTER); 857 870 AssertPtrReturn(pvData, VERR_INVALID_POINTER); 858 871 AssertReturn(cbData, VERR_INVALID_PARAMETER); 859 860 RT_NOREF(uTimeStampMs);861 872 862 873 WebMCluster &Cluster = CurSeg.CurCluster; … … 867 878 * Raw Timecode = (Block timecode + Cluster timecode) * TimecodeScaleFactor 868 879 */ 869 uint64_t tcPTSMs = Cluster.tcStartMs + (Cluster.cBlocks * 20 /*ms */); 880 uint64_t tcPTSMs = CurSeg.tcLastWriteMs + uDurationMs; 881 882 /* Sanity. */ 883 Assert(tcPTSMs); 884 //Assert(tcPTSMs >= Cluster.tcLastWriteMs); 870 885 871 886 /* Whether to start a new cluster or not. */ 872 887 bool fClusterStart = false; 873 874 if (a_pTrack->cTotalBlocks == 0)875 fClusterStart = true;876 888 877 889 /* Did we reach the maximum a cluster can hold? Use a new cluster then. */ … … 888 900 889 901 Cluster.fOpen = true; 890 Cluster.uID = a_pTrack->cTotalClusters;891 Cluster.tcStartMs = Cluster.tc EndMs;902 Cluster.uID = CurSeg.cClusters; 903 Cluster.tcStartMs = Cluster.tcLastWriteMs; 892 904 Cluster.offCluster = RTFileTell(m_Ebml.getFile()); 893 905 Cluster.cBlocks = 0; 906 907 if (CurSeg.cClusters) 908 AssertMsg(Cluster.tcStartMs, ("[T%RU8C%RU64] @ %RU64 start is 0 which is invalid\n", 909 a_pTrack->uTrack, Cluster.uID, Cluster.offCluster)); 894 910 895 911 LogFunc(("[T%RU8C%RU64] Start @ %RU64ms / %RU64 bytes\n", … … 903 919 .serializeUnsignedInteger(MkvElem_Timecode, Cluster.tcStartMs); 904 920 905 a_pTrack->cTotalClusters++;906 } 907 908 Cluster.tc EndMs = tcPTSMs;921 CurSeg.cClusters++; 922 } 923 924 Cluster.tcLastWriteMs = tcPTSMs; 909 925 Cluster.cBlocks++; 910 926 911 if (CurSeg.tcEnd < Cluster.tcEndMs) 912 CurSeg.tcEnd = Cluster.tcEndMs; 927 a_pTrack->tcLastWriteMs = tcPTSMs; 928 929 if (CurSeg.tcLastWriteMs < a_pTrack->tcLastWriteMs) 930 CurSeg.tcLastWriteMs = a_pTrack->tcLastWriteMs; 913 931 914 932 /* Calculate the block's timecode, which is relative to the cluster's starting timecode. */ 915 933 uint16_t tcBlockMs = static_cast<uint16_t>(tcPTSMs - Cluster.tcStartMs); 916 934 917 Log2Func(("tcPTSMs=%RU64, tcBlockMs=%RU64\n", tcPTSMs, tcBlockMs)); 918 919 Log2Func(("[C%RU64] cBlocks=%RU64, tcStartMs=%RU64, tcEndMs=%RU64 (%zums)\n", 920 Cluster.uID, Cluster.cBlocks, Cluster.tcStartMs, Cluster.tcEndMs, Cluster.tcEndMs - Cluster.tcStartMs)); 935 Log2Func(("[T%RU8C%RU64] tcPTSMs=%RU64, (%RU64ms)\n", a_pTrack->uTrack, Cluster.uID, tcPTSMs, tcBlockMs)); 921 936 922 937 return writeSimpleBlockInternal(a_pTrack, tcBlockMs, … … 954 969 Assert(cbData == sizeof(WebMWriter::BlockData_Opus)); 955 970 WebMWriter::BlockData_Opus *pData = (WebMWriter::BlockData_Opus *)pvData; 956 rc = writeBlockOpus(pTrack, pData->pvData, pData->cbData, pData->u TimestampMs);971 rc = writeBlockOpus(pTrack, pData->pvData, pData->cbData, pData->uDurationMs); 957 972 } 958 973 else … … 1113 1128 RTStrPrintf(szApp, sizeof(szApp), VBOX_PRODUCT " %sr%u", VBOX_VERSION_STRING, RTBldCfgRevision()); 1114 1129 1115 const uint64_t tcDuration = CurSeg.tc End - CurSeg.tcStart;1130 const uint64_t tcDuration = CurSeg.tcLastWriteMs - CurSeg.tcStartMs; 1116 1131 1117 1132 if (!CurSeg.lstCues.empty()) -
trunk/src/VBox/Main/src-client/EbmlWriter.h
r68796 r68850 86 86 /** Size (in bytes) of encoded Opus audio data. */ 87 87 size_t cbData; 88 /** Timestamp (in ms). */89 uint64_t u TimestampMs;88 /** Duration (in ms) of encoded Opus audio data. */ 89 uint64_t uDurationMs; 90 90 }; 91 91 #endif /* VBOX_WITH_LIBOPUS */ -
trunk/src/VBox/Main/src-client/VideoRec.cpp
r68806 r68850 67 67 #ifdef DEBUG_andy 68 68 /** Enables dumping audio / video data for debugging reasons. */ 69 # define VBOX_VIDEOREC_DUMP69 //# define VBOX_VIDEOREC_DUMP 70 70 #endif 71 71
Note:
See TracChangeset
for help on using the changeset viewer.