Changeset 96324 in vbox
- Timestamp:
- Aug 19, 2022 8:15:55 AM (2 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/Recording.h
r96322 r96324 48 48 size_t GetStreamCount(void) const; 49 49 #ifdef VBOX_WITH_AUDIO_RECORDING 50 PRECORDINGCODEC GetCodecAudio(void) { return &this-> CodecAudio; }50 PRECORDINGCODEC GetCodecAudio(void) { return &this->m_CodecAudio; } 51 51 #endif 52 52 … … 118 118 119 119 /** Pointer to the console object. */ 120 Console * pConsole;120 Console *m_pConsole; 121 121 /** Used recording configuration. */ 122 122 settings::RecordingSettings m_Settings; 123 123 /** The current state. */ 124 RECORDINGSTS enmState;124 RECORDINGSTS m_enmState; 125 125 /** Critical section to serialize access. */ 126 RTCRITSECT CritSect;126 RTCRITSECT m_CritSect; 127 127 /** Semaphore to signal the encoding worker thread. */ 128 RTSEMEVENT WaitEvent;128 RTSEMEVENT m_WaitEvent; 129 129 /** Shutdown indicator. */ 130 bool fShutdown;130 bool m_fShutdown; 131 131 /** Encoding worker thread. */ 132 RTTHREAD Thread;132 RTTHREAD m_Thread; 133 133 /** Vector of current recording streams. 134 134 * Per VM screen (display) one recording stream is being used. */ 135 RecordingStreams vecStreams;135 RecordingStreams m_vecStreams; 136 136 /** Number of streams in vecStreams which currently are enabled for recording. */ 137 uint16_t cStreamsEnabled;137 uint16_t m_cStreamsEnabled; 138 138 /** Timestamp (in ms) of when recording has been started. */ 139 uint64_t tsStartMs;139 uint64_t m_tsStartMs; 140 140 #ifdef VBOX_WITH_AUDIO_RECORDING 141 141 /** Audio codec to use. … … 145 145 * all audio data of a VM will be the same for each stream at a given 146 146 * point in time. */ 147 RECORDINGCODEC CodecAudio;147 RECORDINGCODEC m_CodecAudio; 148 148 #endif /* VBOX_WITH_AUDIO_RECORDING */ 149 149 /** Block map of raw common data blocks which need to get encoded first. */ 150 RecordingBlockMap m apBlocksRaw;150 RecordingBlockMap m_mapBlocksRaw; 151 151 /** Block map of encoded common blocks. 152 152 * … … 159 159 * For now this only affects audio, e.g. all recording streams 160 160 * need to have the same audio data at a specific point in time. */ 161 RecordingBlockMap m apBlocksEncoded;161 RecordingBlockMap m_mapBlocksEncoded; 162 162 }; 163 163 #endif /* !MAIN_INCLUDED_Recording_h */ -
trunk/src/VBox/Main/include/RecordingStream.h
r96322 r96324 125 125 126 126 const settings::RecordingScreenSettings &GetConfig(void) const; 127 uint16_t GetID(void) const { return this-> uScreenID; };127 uint16_t GetID(void) const { return this->m_uScreenID; }; 128 128 #ifdef VBOX_WITH_AUDIO_RECORDING 129 PRECORDINGCODEC GetAudioCodec(void) { return this-> pCodecAudio; };129 PRECORDINGCODEC GetAudioCodec(void) { return this->m_pCodecAudio; }; 130 130 #endif 131 PRECORDINGCODEC GetVideoCodec(void) { return &this-> CodecVideo; };131 PRECORDINGCODEC GetVideoCodec(void) { return &this->m_CodecVideo; }; 132 132 133 133 bool IsLimitReached(uint64_t msTimestamp) const; … … 176 176 RecordingContext *m_pCtx; 177 177 /** The current state. */ 178 RECORDINGSTREAMSTATE enmState;178 RECORDINGSTREAMSTATE m_enmState; 179 179 struct 180 180 { 181 181 /** File handle to use for writing. */ 182 RTFILE hFile;182 RTFILE m_hFile; 183 183 /** Pointer to WebM writer instance being used. */ 184 WebMWriter * pWEBM;184 WebMWriter *m_pWEBM; 185 185 } File; 186 bool fEnabled;186 bool m_fEnabled; 187 187 /** Track number of audio stream. 188 188 * Set to UINT8_MAX if not being used. */ 189 uint8_t uTrackAudio;189 uint8_t m_uTrackAudio; 190 190 /** Track number of video stream. 191 191 * Set to UINT8_MAX if not being used. */ 192 uint8_t uTrackVideo;192 uint8_t m_uTrackVideo; 193 193 /** Screen ID. */ 194 uint16_t uScreenID;194 uint16_t m_uScreenID; 195 195 /** Critical section to serialize access. */ 196 RTCRITSECT CritSect;196 RTCRITSECT m_CritSect; 197 197 /** Timestamp (in ms) of when recording has been started. */ 198 uint64_t tsStartMs;198 uint64_t m_tsStartMs; 199 199 #ifdef VBOX_WITH_AUDIO_RECORDING 200 200 /** Pointer to audio codec instance data to use. … … 206 206 * 207 207 * Might be NULL if not being used. */ 208 PRECORDINGCODEC pCodecAudio;208 PRECORDINGCODEC m_pCodecAudio; 209 209 #endif /* VBOX_WITH_AUDIO_RECORDING */ 210 210 /** Video codec instance data to use. */ 211 RECORDINGCODEC CodecVideo;211 RECORDINGCODEC m_CodecVideo; 212 212 /** Screen settings to use. */ 213 213 settings::RecordingScreenSettings 214 ScreenSettings;214 m_ScreenSettings; 215 215 /** Common set of recording (data) blocks, needed for 216 216 * multiplexing to all recording streams. */ 217 RecordingBlockSet Blocks;217 RecordingBlockSet m_Blocks; 218 218 }; 219 219 -
trunk/src/VBox/Main/include/WebMWriter.h
r96285 r96324 373 373 { 374 374 WebMSegment(void) 375 : tcAbsStartMs(0)376 , tcAbsLastWrittenMs(0)377 , offStart(0)378 , offInfo(0)379 , offSeekInfo(0)380 , offTracks(0)381 , offCues(0)382 , cClusters(0)383 { 384 uTimecodeScaleFactor = VBOX_WEBM_TIMECODESCALE_FACTOR_MS;385 386 LogFunc(("Default timecode scale is: %RU64ns\n", uTimecodeScaleFactor));375 : m_tcAbsStartMs(0) 376 , m_tcAbsLastWrittenMs(0) 377 , m_offStart(0) 378 , m_offInfo(0) 379 , m_offSeekInfo(0) 380 , m_offTracks(0) 381 , m_offCues(0) 382 , m_cClusters(0) 383 { 384 m_uTimecodeScaleFactor = VBOX_WEBM_TIMECODESCALE_FACTOR_MS; 385 386 LogFunc(("Default timecode scale is: %RU64ns\n", m_uTimecodeScaleFactor)); 387 387 } 388 388 … … 399 399 int init(void) 400 400 { 401 return RTCritSectInit(& CritSect);401 return RTCritSectInit(&m_CritSect); 402 402 } 403 403 … … 409 409 clear(); 410 410 411 RTCritSectDelete(& CritSect);411 RTCritSectDelete(&m_CritSect); 412 412 } 413 413 … … 417 417 void clear(void) 418 418 { 419 WebMCuePointList::iterator itCuePoint = lstCuePoints.begin();420 while (itCuePoint != lstCuePoints.end())419 WebMCuePointList::iterator itCuePoint = m_lstCuePoints.begin(); 420 while (itCuePoint != m_lstCuePoints.end()) 421 421 { 422 422 WebMCuePoint *pCuePoint = (*itCuePoint); … … 424 424 delete pCuePoint; 425 425 426 lstCuePoints.erase(itCuePoint);427 itCuePoint = lstCuePoints.begin();426 m_lstCuePoints.erase(itCuePoint); 427 itCuePoint = m_lstCuePoints.begin(); 428 428 } 429 429 430 Assert( lstCuePoints.empty());430 Assert(m_lstCuePoints.empty()); 431 431 } 432 432 433 433 /** Critical section for serializing access to this segment. */ 434 RTCRITSECT CritSect;434 RTCRITSECT m_CritSect; 435 435 436 436 /** The timecode scale factor of this segment. */ 437 uint64_t uTimecodeScaleFactor;437 uint64_t m_uTimecodeScaleFactor; 438 438 439 439 /** Absolute timecode (in ms) when starting this segment. */ 440 WebMTimecodeAbs tcAbsStartMs;440 WebMTimecodeAbs m_tcAbsStartMs; 441 441 /** Absolute timecode (in ms) of last write. */ 442 WebMTimecodeAbs tcAbsLastWrittenMs;442 WebMTimecodeAbs m_tcAbsLastWrittenMs; 443 443 444 444 /** Absolute offset (in bytes) of CurSeg. */ 445 uint64_t offStart;445 uint64_t m_offStart; 446 446 /** Absolute offset (in bytes) of general info. */ 447 uint64_t offInfo;447 uint64_t m_offInfo; 448 448 /** Absolute offset (in bytes) of seeking info. */ 449 uint64_t offSeekInfo;449 uint64_t m_offSeekInfo; 450 450 /** Absolute offset (in bytes) of tracks. */ 451 uint64_t offTracks;451 uint64_t m_offTracks; 452 452 /** Absolute offset (in bytes) of cues table. */ 453 uint64_t offCues;453 uint64_t m_offCues; 454 454 /** List of cue points. Needed for seeking table. */ 455 WebMCuePointList lstCuePoints;455 WebMCuePointList m_lstCuePoints; 456 456 457 457 /** Total number of clusters. */ 458 uint64_t cClusters;458 uint64_t m_cClusters; 459 459 460 460 /** Map of tracks. 461 461 * The key marks the track number (*not* the UUID!). */ 462 std::map <uint8_t, WebMTrack *> m apTracks;462 std::map <uint8_t, WebMTrack *> m_mapTracks; 463 463 464 464 /** Current cluster which is being handled. … … 466 466 * Note that we don't need (and shouldn't need, as this can be a *lot* of data!) a 467 467 * list of all clusters. */ 468 WebMCluster CurCluster;469 470 WebMQueue queueBlocks;471 472 } CurSeg;468 WebMCluster m_CurCluster; 469 470 WebMQueue m_queueBlocks; 471 472 } m_CurSeg; 473 473 474 474 /** Audio codec to use. */ … … 542 542 * @returns Number of written WebM clusters; 0 when no clusters written (empty file). 543 543 */ 544 uint64_t GetClusters(void) const { return CurSeg.cClusters; }544 uint64_t GetClusters(void) const { return m_CurSeg.m_cClusters; } 545 545 546 546 protected: -
trunk/src/VBox/Main/src-client/Recording.cpp
r96323 r96324 64 64 */ 65 65 RecordingContext::RecordingContext(void) 66 : pConsole(NULL)67 , enmState(RECORDINGSTS_UNINITIALIZED)68 , cStreamsEnabled(0)69 { 70 int vrc = RTCritSectInit(& this->CritSect);66 : m_pConsole(NULL) 67 , m_enmState(RECORDINGSTS_UNINITIALIZED) 68 , m_cStreamsEnabled(0) 69 { 70 int vrc = RTCritSectInit(&m_CritSect); 71 71 if (RT_FAILURE(vrc)) 72 72 throw vrc; … … 82 82 */ 83 83 RecordingContext::RecordingContext(Console *ptrConsole, const settings::RecordingSettings &Settings) 84 : pConsole(NULL)85 , enmState(RECORDINGSTS_UNINITIALIZED)86 , cStreamsEnabled(0)87 { 88 int vrc = RTCritSectInit(& this->CritSect);84 : m_pConsole(NULL) 85 , m_enmState(RECORDINGSTS_UNINITIALIZED) 86 , m_cStreamsEnabled(0) 87 { 88 int vrc = RTCritSectInit(&m_CritSect); 89 89 if (RT_FAILURE(vrc)) 90 90 throw vrc; … … 99 99 destroyInternal(); 100 100 101 if (RTCritSectIsInitialized(& this->CritSect))102 RTCritSectDelete(& this->CritSect);101 if (RTCritSectIsInitialized(&m_CritSect)) 102 RTCritSectDelete(&m_CritSect); 103 103 } 104 104 … … 119 119 for (;;) 120 120 { 121 int vrc = RTSemEventWait(pThis-> WaitEvent, RT_INDEFINITE_WAIT);121 int vrc = RTSemEventWait(pThis->m_WaitEvent, RT_INDEFINITE_WAIT); 122 122 AssertRCBreak(vrc); 123 123 124 Log2Func(("Processing %zu streams\n", pThis-> vecStreams.size()));124 Log2Func(("Processing %zu streams\n", pThis->m_vecStreams.size())); 125 125 126 126 /* Process common raw blocks (data which not has been encoded yet). */ 127 vrc = pThis->processCommonData(pThis->m apBlocksRaw, 100 /* ms timeout */);127 vrc = pThis->processCommonData(pThis->m_mapBlocksRaw, 100 /* ms timeout */); 128 128 129 129 /** @todo r=andy This is inefficient -- as we already wake up this thread 130 130 * for every screen from Main, we here go again (on every wake up) through 131 131 * all screens. */ 132 RecordingStreams::iterator itStream = pThis-> vecStreams.begin();133 while (itStream != pThis-> vecStreams.end())132 RecordingStreams::iterator itStream = pThis->m_vecStreams.begin(); 133 while (itStream != pThis->m_vecStreams.end()) 134 134 { 135 135 RecordingStream *pStream = (*itStream); 136 136 137 137 /* Hand-in common encoded blocks. */ 138 vrc = pStream->Process(pThis->m apBlocksEncoded);138 vrc = pStream->Process(pThis->m_mapBlocksEncoded); 139 139 if (RT_FAILURE(vrc)) 140 140 { … … 151 151 /* Keep going in case of errors. */ 152 152 153 if (ASMAtomicReadBool(&pThis-> fShutdown))153 if (ASMAtomicReadBool(&pThis->m_fShutdown)) 154 154 { 155 155 LogFunc(("Thread is shutting down ...\n")); … … 170 170 int RecordingContext::threadNotify(void) 171 171 { 172 return RTSemEventSignal( this->WaitEvent);172 return RTSemEventSignal(m_WaitEvent); 173 173 } 174 174 … … 209 209 Frame.Audio.cbBuf = pAudioFrame->cbBuf; 210 210 211 vrc = recordingCodecEncode(& this->CodecAudio, &Frame, NULL, NULL);211 vrc = recordingCodecEncode(&m_CodecAudio, &Frame, NULL, NULL); 212 212 break; 213 213 } … … 293 293 pBlock->pvData = pFrame; 294 294 pBlock->cbData = sizeof(RECORDINGAUDIOFRAME) + cbData; 295 pBlock->cRefs = this->cStreamsEnabled;295 pBlock->cRefs = m_cStreamsEnabled; 296 296 pBlock->msTimestamp = msTimestamp; 297 297 pBlock->uFlags = uFlags; … … 351 351 { 352 352 RecordingContext *pThis = (RecordingContext *)pvUser; 353 return pThis->writeCommonData(pThis->m apBlocksEncoded, pCodec, pvData, cbData, msAbsPTS, uFlags);353 return pThis->writeCommonData(pThis->m_mapBlocksEncoded, pCodec, pvData, cbData, msAbsPTS, uFlags); 354 354 } 355 355 … … 374 374 Callbacks.pfnWriteData = RecordingContext::audioCodecWriteDataCallback; 375 375 376 int vrc = recordingCodecCreateAudio(& this->CodecAudio, enmCodec);376 int vrc = recordingCodecCreateAudio(&m_CodecAudio, enmCodec); 377 377 if (RT_SUCCESS(vrc)) 378 vrc = recordingCodecInit(& this->CodecAudio, &Callbacks, screenSettings);378 vrc = recordingCodecInit(&m_CodecAudio, &Callbacks, screenSettings); 379 379 380 380 return vrc; … … 408 408 #endif 409 409 410 this->pConsole = ptrConsole;410 m_pConsole = ptrConsole; 411 411 412 412 settings::RecordingScreenSettingsMap::const_iterator itScreen = m_Settings.mapScreens.begin(); … … 417 417 { 418 418 pStream = new RecordingStream(this, itScreen->first /* Screen ID */, itScreen->second); 419 this->vecStreams.push_back(pStream);419 m_vecStreams.push_back(pStream); 420 420 if (itScreen->second.fEnabled) 421 this->cStreamsEnabled++;421 m_cStreamsEnabled++; 422 422 LogFlowFunc(("pStream=%p\n", pStream)); 423 423 } … … 438 438 if (RT_SUCCESS(vrc)) 439 439 { 440 this->tsStartMs = RTTimeMilliTS();441 this->enmState = RECORDINGSTS_CREATED;442 this->fShutdown = false;443 444 vrc = RTSemEventCreate(& this->WaitEvent);440 m_tsStartMs = RTTimeMilliTS(); 441 m_enmState = RECORDINGSTS_CREATED; 442 m_fShutdown = false; 443 444 vrc = RTSemEventCreate(&m_WaitEvent); 445 445 AssertRCReturn(vrc, vrc); 446 446 } … … 459 459 int RecordingContext::startInternal(void) 460 460 { 461 if ( this->enmState == RECORDINGSTS_STARTED)461 if (m_enmState == RECORDINGSTS_STARTED) 462 462 return VINF_SUCCESS; 463 463 464 Assert( this->enmState == RECORDINGSTS_CREATED);465 466 int vrc = RTThreadCreate(& this->Thread, RecordingContext::threadMain, (void *)this, 0,464 Assert(m_enmState == RECORDINGSTS_CREATED); 465 466 int vrc = RTThreadCreate(&m_Thread, RecordingContext::threadMain, (void *)this, 0, 467 467 RTTHREADTYPE_MAIN_WORKER, RTTHREADFLAGS_WAITABLE, "Record"); 468 468 469 469 if (RT_SUCCESS(vrc)) /* Wait for the thread to start. */ 470 vrc = RTThreadUserWait( this->Thread, RT_MS_30SEC /* 30s timeout */);470 vrc = RTThreadUserWait(m_Thread, RT_MS_30SEC /* 30s timeout */); 471 471 472 472 if (RT_SUCCESS(vrc)) 473 473 { 474 474 LogRel(("Recording: Started\n")); 475 this->enmState = RECORDINGSTS_STARTED;475 m_enmState = RECORDINGSTS_STARTED; 476 476 } 477 477 else … … 488 488 int RecordingContext::stopInternal(void) 489 489 { 490 if ( this->enmState != RECORDINGSTS_STARTED)490 if (m_enmState != RECORDINGSTS_STARTED) 491 491 return VINF_SUCCESS; 492 492 … … 494 494 495 495 /* Set shutdown indicator. */ 496 ASMAtomicWriteBool(& this->fShutdown, true);496 ASMAtomicWriteBool(&m_fShutdown, true); 497 497 498 498 /* Signal the thread and wait for it to shut down. */ 499 499 int vrc = threadNotify(); 500 500 if (RT_SUCCESS(vrc)) 501 vrc = RTThreadWait( this->Thread, RT_MS_30SEC /* 30s timeout */, NULL);501 vrc = RTThreadWait(m_Thread, RT_MS_30SEC /* 30s timeout */, NULL); 502 502 503 503 lock(); … … 506 506 { 507 507 LogRel(("Recording: Stopped\n")); 508 this->enmState = RECORDINGSTS_CREATED;508 m_enmState = RECORDINGSTS_CREATED; 509 509 } 510 510 else … … 524 524 lock(); 525 525 526 if ( this->enmState == RECORDINGSTS_UNINITIALIZED)526 if (m_enmState == RECORDINGSTS_UNINITIALIZED) 527 527 { 528 528 unlock(); … … 533 533 AssertRCReturnVoid(vrc); 534 534 535 vrc = RTSemEventDestroy( this->WaitEvent);535 vrc = RTSemEventDestroy(m_WaitEvent); 536 536 AssertRCReturnVoid(vrc); 537 537 538 this->WaitEvent = NIL_RTSEMEVENT;539 540 RecordingStreams::iterator it = this->vecStreams.begin();541 while (it != this->vecStreams.end())538 m_WaitEvent = NIL_RTSEMEVENT; 539 540 RecordingStreams::iterator it = m_vecStreams.begin(); 541 while (it != m_vecStreams.end()) 542 542 { 543 543 RecordingStream *pStream = (*it); … … 549 549 pStream = NULL; 550 550 551 this->vecStreams.erase(it);552 it = this->vecStreams.begin();551 m_vecStreams.erase(it); 552 it = m_vecStreams.begin(); 553 553 } 554 554 555 555 /* Sanity. */ 556 Assert( this->vecStreams.empty());557 Assert( this->mapBlocksRaw.size() == 0);558 Assert( this->mapBlocksEncoded.size() == 0);559 560 this->enmState = RECORDINGSTS_UNINITIALIZED;556 Assert(m_vecStreams.empty()); 557 Assert(m_mapBlocksRaw.size() == 0); 558 Assert(m_mapBlocksEncoded.size() == 0); 559 560 m_enmState = RECORDINGSTS_UNINITIALIZED; 561 561 562 562 unlock(); … … 570 570 const settings::RecordingSettings &RecordingContext::GetConfig(void) const 571 571 { 572 return this->m_Settings;572 return m_Settings; 573 573 } 574 574 … … 585 585 try 586 586 { 587 pStream = this->vecStreams.at(uScreen);587 pStream = m_vecStreams.at(uScreen); 588 588 } 589 589 catch (std::out_of_range &) … … 602 602 int RecordingContext::lock(void) 603 603 { 604 int vrc = RTCritSectEnter(& this->CritSect);604 int vrc = RTCritSectEnter(&m_CritSect); 605 605 AssertRC(vrc); 606 606 return vrc; … … 614 614 int RecordingContext::unlock(void) 615 615 { 616 int vrc = RTCritSectLeave(& this->CritSect);616 int vrc = RTCritSectLeave(&m_CritSect); 617 617 AssertRC(vrc); 618 618 return vrc; … … 637 637 size_t RecordingContext::GetStreamCount(void) const 638 638 { 639 return this->vecStreams.size();639 return m_vecStreams.size(); 640 640 } 641 641 … … 690 690 lock(); 691 691 692 RecordingStreams::const_iterator itStream = this->vecStreams.begin();693 while (itStream != this->vecStreams.end())692 RecordingStreams::const_iterator itStream = m_vecStreams.begin(); 693 while (itStream != m_vecStreams.end()) 694 694 { 695 695 if ((*itStream)->GetConfig().isFeatureEnabled(enmFeature)) … … 715 715 lock(); 716 716 717 const bool fIsReady = this->enmState >= RECORDINGSTS_CREATED;717 const bool fIsReady = m_enmState >= RECORDINGSTS_CREATED; 718 718 719 719 unlock(); … … 737 737 bool fIsReady = false; 738 738 739 if ( this->enmState != RECORDINGSTS_STARTED)739 if (m_enmState != RECORDINGSTS_STARTED) 740 740 { 741 741 const RecordingStream *pStream = getStreamInternal(uScreen); … … 762 762 lock(); 763 763 764 const bool fIsStarted = this->enmState == RECORDINGSTS_STARTED;764 const bool fIsStarted = m_enmState == RECORDINGSTS_STARTED; 765 765 766 766 unlock(); … … 778 778 lock(); 779 779 780 LogFlowThisFunc(("cStreamsEnabled=%RU16\n", this->cStreamsEnabled));781 782 const bool fLimitReached = this->cStreamsEnabled == 0;780 LogFlowThisFunc(("cStreamsEnabled=%RU16\n", m_cStreamsEnabled)); 781 782 const bool fLimitReached = m_cStreamsEnabled == 0; 783 783 784 784 unlock(); … … 825 825 bool fNeedsUpdate = false; 826 826 827 if ( this->enmState == RECORDINGSTS_STARTED)828 { 829 if ( recordingCodecIsInitialized(& CodecAudio)830 && recordingCodecGetWritable(& CodecAudio, msTimestamp) > 0)827 if (m_enmState == RECORDINGSTS_STARTED) 828 { 829 if ( recordingCodecIsInitialized(&m_CodecAudio) 830 && recordingCodecGetWritable(&m_CodecAudio, msTimestamp) > 0) 831 831 { 832 832 fNeedsUpdate = true; … … 853 853 lock(); 854 854 855 Assert( this->cStreamsEnabled);856 this->cStreamsEnabled--;857 858 LogFlowThisFunc(("cStreamsEnabled=%RU16\n", cStreamsEnabled));855 Assert(m_cStreamsEnabled); 856 m_cStreamsEnabled--; 857 858 LogFlowThisFunc(("cStreamsEnabled=%RU16\n", m_cStreamsEnabled)); 859 859 860 860 unlock(); … … 874 874 { 875 875 #ifdef VBOX_WITH_AUDIO_RECORDING 876 return writeCommonData( this->mapBlocksRaw, &this->CodecAudio,876 return writeCommonData(m_mapBlocksRaw, &m_CodecAudio, 877 877 pvData, cbData, msTimestamp, RECORDINGCODEC_ENC_F_BLOCK_IS_KEY); 878 878 #else -
trunk/src/VBox/Main/src-client/RecordingStream.cpp
r96323 r96324 38 38 39 39 RecordingStream::RecordingStream(RecordingContext *a_pCtx, uint32_t uScreen, const settings::RecordingScreenSettings &Settings) 40 : enmState(RECORDINGSTREAMSTATE_UNINITIALIZED)40 : m_enmState(RECORDINGSTREAMSTATE_UNINITIALIZED) 41 41 { 42 42 int vrc2 = initInternal(a_pCtx, uScreen, Settings); … … 85 85 char *pszFile = NULL; 86 86 87 vrc = RTStrAPrintf(&pszFile, "%s-%u%s", pszAbsPath, this->uScreenID, pszSuff);87 vrc = RTStrAPrintf(&pszFile, "%s-%u%s", pszAbsPath, m_uScreenID, pszSuff); 88 88 if (RT_SUCCESS(vrc)) 89 89 { … … 113 113 pszAbsPath, time.i32Year, time.u8Month, time.u8MonthDay, 114 114 time.u8Hour, time.u8Minute, time.u8Second, time.u32Nanosecond, 115 this->uScreenID, pszSuff);115 m_uScreenID, pszSuff); 116 116 if (RT_SUCCESS(vrc)) 117 117 vrc = RTFileOpen(&hFile, pszFile, fOpen); … … 125 125 try 126 126 { 127 Assert(File. pWEBM == NULL);128 File. pWEBM = new WebMWriter();127 Assert(File.m_pWEBM == NULL); 128 File.m_pWEBM = new WebMWriter(); 129 129 } 130 130 catch (std::bad_alloc &) … … 135 135 if (RT_SUCCESS(vrc)) 136 136 { 137 this->File. hFile = hFile;138 this->ScreenSettings.File.strName = pszFile;137 this->File.m_hFile = hFile; 138 m_ScreenSettings.File.strName = pszFile; 139 139 } 140 140 } … … 146 146 { 147 147 LogRel(("Recording: Failed to open file '%s' for screen %RU32, vrc=%Rrc\n", 148 pszFile ? pszFile : "<Unnamed>", this->uScreenID, vrc));148 pszFile ? pszFile : "<Unnamed>", m_uScreenID, vrc)); 149 149 } 150 150 … … 169 169 const settings::RecordingScreenSettings &RecordingStream::GetConfig(void) const 170 170 { 171 return this->ScreenSettings;171 return m_ScreenSettings; 172 172 } 173 173 … … 181 181 { 182 182 LogFlowThisFunc(("msTimestamp=%RU64, ulMaxTimeS=%RU32, tsStartMs=%RU64\n", 183 msTimestamp, this->ScreenSettings.ulMaxTimeS, this->tsStartMs));184 185 if ( this->ScreenSettings.ulMaxTimeS186 && msTimestamp >= this->tsStartMs + (this->ScreenSettings.ulMaxTimeS * RT_MS_1SEC))183 msTimestamp, m_ScreenSettings.ulMaxTimeS, m_tsStartMs)); 184 185 if ( m_ScreenSettings.ulMaxTimeS 186 && msTimestamp >= m_tsStartMs + (m_ScreenSettings.ulMaxTimeS * RT_MS_1SEC)) 187 187 { 188 188 LogRel(("Recording: Time limit for stream #%RU16 has been reached (%RU32s)\n", 189 this->uScreenID, this->ScreenSettings.ulMaxTimeS));189 m_uScreenID, m_ScreenSettings.ulMaxTimeS)); 190 190 return true; 191 191 } 192 192 193 if ( this->ScreenSettings.enmDest == RecordingDestination_File)194 { 195 if ( this->ScreenSettings.File.ulMaxSizeMB)196 { 197 uint64_t sizeInMB = this->File. pWEBM->GetFileSize() / _1M;198 if(sizeInMB >= this->ScreenSettings.File.ulMaxSizeMB)193 if (m_ScreenSettings.enmDest == RecordingDestination_File) 194 { 195 if (m_ScreenSettings.File.ulMaxSizeMB) 196 { 197 uint64_t sizeInMB = this->File.m_pWEBM->GetFileSize() / _1M; 198 if(sizeInMB >= m_ScreenSettings.File.ulMaxSizeMB) 199 199 { 200 200 LogRel(("Recording: File size limit for stream #%RU16 has been reached (%RU64MB)\n", 201 this->uScreenID, this->ScreenSettings.File.ulMaxSizeMB));201 m_uScreenID, m_ScreenSettings.File.ulMaxSizeMB)); 202 202 return true; 203 203 } … … 205 205 206 206 /* Check for available free disk space */ 207 if ( this->File. pWEBM208 && this->File. pWEBM->GetAvailableSpace() < 0x100000) /** @todo r=andy WTF? Fix this. */207 if ( this->File.m_pWEBM 208 && this->File.m_pWEBM->GetAvailableSpace() < 0x100000) /** @todo r=andy WTF? Fix this. */ 209 209 { 210 210 LogRel(("Recording: Not enough free storage space available, stopping recording\n")); … … 225 225 int RecordingStream::iterateInternal(uint64_t msTimestamp) 226 226 { 227 if (! this->fEnabled)227 if (!m_fEnabled) 228 228 return VINF_SUCCESS; 229 229 … … 237 237 vrc = VINF_SUCCESS; 238 238 239 AssertPtr( this->m_pCtx);239 AssertPtr(m_pCtx); 240 240 241 241 switch (vrc) … … 243 243 case VINF_RECORDING_LIMIT_REACHED: 244 244 { 245 this->fEnabled = false;246 247 int vrc2 = this->m_pCtx->OnLimitReached(this->uScreenID, VINF_SUCCESS /* rc */);245 m_fEnabled = false; 246 247 int vrc2 = m_pCtx->OnLimitReached(m_uScreenID, VINF_SUCCESS /* rc */); 248 248 AssertRC(vrc2); 249 249 break; … … 279 279 bool RecordingStream::IsReady(void) const 280 280 { 281 return this->fEnabled;281 return m_fEnabled; 282 282 } 283 283 … … 290 290 bool RecordingStream::NeedsUpdate(uint64_t msTimestamp) const 291 291 { 292 return recordingCodecGetWritable((const PRECORDINGCODEC)& CodecVideo, msTimestamp) > 0;292 return recordingCodecGetWritable((const PRECORDINGCODEC)&m_CodecVideo, msTimestamp) > 0; 293 293 } 294 294 … … 309 309 lock(); 310 310 311 if (! this->ScreenSettings.fEnabled)311 if (!m_ScreenSettings.fEnabled) 312 312 { 313 313 unlock(); … … 317 317 int vrc = VINF_SUCCESS; 318 318 319 RecordingBlockMap::iterator itStreamBlocks = Blocks.Map.begin();320 while (itStreamBlocks != Blocks.Map.end())319 RecordingBlockMap::iterator itStreamBlocks = m_Blocks.Map.begin(); 320 while (itStreamBlocks != m_Blocks.Map.end()) 321 321 { 322 322 uint64_t const msTimestamp = itStreamBlocks->first; … … 338 338 Frame.msTimestamp = msTimestamp; 339 339 340 int vrc2 = recordingCodecEncode(& this->CodecVideo, &Frame, NULL, NULL);340 int vrc2 = recordingCodecEncode(&m_CodecVideo, &Frame, NULL, NULL); 341 341 AssertRC(vrc2); 342 342 if (RT_SUCCESS(vrc)) … … 358 358 delete pBlocks; 359 359 360 Blocks.Map.erase(itStreamBlocks);361 itStreamBlocks = Blocks.Map.begin();360 m_Blocks.Map.erase(itStreamBlocks); 361 itStreamBlocks = m_Blocks.Map.begin(); 362 362 } 363 363 364 364 #ifdef VBOX_WITH_AUDIO_RECORDING 365 365 /* Do we need to multiplex the common audio data to this stream? */ 366 if ( this->ScreenSettings.isFeatureEnabled(RecordingFeature_Audio))366 if (m_ScreenSettings.isFeatureEnabled(RecordingFeature_Audio)) 367 367 { 368 368 /* As each (enabled) screen has to get the same audio data, look for common (audio) data which needs to be … … 384 384 Assert(pAudioFrame->cbBuf); 385 385 386 AssertPtr(this->File. pWEBM);387 int vrc2 = this->File. pWEBM->WriteBlock(this->uTrackAudio, pAudioFrame->pvBuf, pAudioFrame->cbBuf, pBlockCommon->msTimestamp, pBlockCommon->uFlags);386 AssertPtr(this->File.m_pWEBM); 387 int vrc2 = this->File.m_pWEBM->WriteBlock(m_uTrackAudio, pAudioFrame->pvBuf, pAudioFrame->cbBuf, pBlockCommon->msTimestamp, pBlockCommon->uFlags); 388 388 AssertRC(vrc2); 389 389 if (RT_SUCCESS(vrc)) … … 489 489 do 490 490 { 491 int xDiff = ((int) this->ScreenSettings.Video.ulWidth - (int)uSrcWidth) / 2;491 int xDiff = ((int)m_ScreenSettings.Video.ulWidth - (int)uSrcWidth) / 2; 492 492 uint32_t w = uSrcWidth; 493 493 if ((int)w + xDiff + (int)x <= 0) /* Nothing visible. */ … … 508 508 509 509 uint32_t h = uSrcHeight; 510 int yDiff = ((int) this->ScreenSettings.Video.ulHeight - (int)uSrcHeight) / 2;510 int yDiff = ((int)m_ScreenSettings.Video.ulHeight - (int)uSrcHeight) / 2; 511 511 if ((int)h + yDiff + (int)y <= 0) /* Nothing visible. */ 512 512 { … … 525 525 destY = y + yDiff; 526 526 527 if ( destX > this->ScreenSettings.Video.ulWidth528 || destY > this->ScreenSettings.Video.ulHeight)527 if ( destX > m_ScreenSettings.Video.ulWidth 528 || destY > m_ScreenSettings.Video.ulHeight) 529 529 { 530 530 vrc = VERR_INVALID_PARAMETER; /* Nothing visible. */ … … 532 532 } 533 533 534 if (destX + w > this->ScreenSettings.Video.ulWidth)535 w = this->ScreenSettings.Video.ulWidth - destX;536 537 if (destY + h > this->ScreenSettings.Video.ulHeight)538 h = this->ScreenSettings.Video.ulHeight - destY;534 if (destX + w > m_ScreenSettings.Video.ulWidth) 535 w = m_ScreenSettings.Video.ulWidth - destX; 536 537 if (destY + h > m_ScreenSettings.Video.ulHeight) 538 h = m_ScreenSettings.Video.ulHeight - destY; 539 539 540 540 pFrame = (PRECORDINGVIDEOFRAME)RTMemAllocZ(sizeof(RECORDINGVIDEOFRAME)); … … 564 564 AssertMsgFailedBreakStmt(("Unknown pixel format (%RU32)\n", uPixelFormat), vrc = VERR_NOT_SUPPORTED); 565 565 566 const size_t cbRGBBuf = this->ScreenSettings.Video.ulWidth567 * this->ScreenSettings.Video.ulHeight566 const size_t cbRGBBuf = m_ScreenSettings.Video.ulWidth 567 * m_ScreenSettings.Video.ulHeight 568 568 * uBytesPerPixel; 569 569 AssertBreakStmt(cbRGBBuf, vrc = VERR_INVALID_PARAMETER); … … 577 577 /* If the current video frame is smaller than video resolution we're going to encode, 578 578 * clear the frame beforehand to prevent artifacts. */ 579 if ( uSrcWidth < this->ScreenSettings.Video.ulWidth580 || uSrcHeight < this->ScreenSettings.Video.ulHeight)579 if ( uSrcWidth < m_ScreenSettings.Video.ulWidth 580 || uSrcHeight < m_ScreenSettings.Video.ulHeight) 581 581 { 582 582 RT_BZERO(pFrame->pu8RGBBuf, pFrame->cbRGBBuf); … … 585 585 /* Calculate start offset in source and destination buffers. */ 586 586 uint32_t offSrc = y * uBytesPerLine + x * uBytesPerPixel; 587 uint32_t offDst = (destY * this->ScreenSettings.Video.ulWidth + destX) * uBytesPerPixel;587 uint32_t offDst = (destY * m_ScreenSettings.Video.ulWidth + destX) * uBytesPerPixel; 588 588 589 589 #ifdef VBOX_RECORDING_DUMP … … 607 607 608 608 char szFileName[RTPATH_MAX]; 609 RTStrPrintf2(szFileName, sizeof(szFileName), "/tmp/VideoRecFrame-%RU32.bmp", this->uScreenID);609 RTStrPrintf2(szFileName, sizeof(szFileName), "/tmp/VideoRecFrame-%RU32.bmp", m_uScreenID); 610 610 611 611 RTFILE fh; … … 625 625 /* Overflow check. */ 626 626 Assert(offSrc + w * uBytesPerPixel <= uSrcHeight * uBytesPerLine); 627 Assert(offDst + w * uBytesPerPixel <= this->ScreenSettings.Video.ulHeight * this->ScreenSettings.Video.ulWidth * uBytesPerPixel);627 Assert(offDst + w * uBytesPerPixel <= m_ScreenSettings.Video.ulHeight * m_ScreenSettings.Video.ulWidth * uBytesPerPixel); 628 628 629 629 memcpy(pFrame->pu8RGBBuf + offDst, puSrcData + offSrc, w * uBytesPerPixel); … … 634 634 #endif 635 635 offSrc += uBytesPerLine; 636 offDst += this->ScreenSettings.Video.ulWidth * uBytesPerPixel;636 offDst += m_ScreenSettings.Video.ulWidth * uBytesPerPixel; 637 637 } 638 638 … … 660 660 pRecordingBlocks->List.push_back(pBlock); 661 661 662 Assert( this->Blocks.Map.find(msTimestamp) == this->Blocks.Map.end());663 this->Blocks.Map.insert(std::make_pair(msTimestamp, pRecordingBlocks));662 Assert(m_Blocks.Map.find(msTimestamp) == m_Blocks.Map.end()); 663 m_Blocks.Map.insert(std::make_pair(msTimestamp, pRecordingBlocks)); 664 664 } 665 665 catch (const std::exception &ex) … … 708 708 const settings::RecordingScreenSettings &screenSettings) 709 709 { 710 AssertReturn( enmState == RECORDINGSTREAMSTATE_UNINITIALIZED, VERR_WRONG_ORDER);711 712 this->m_pCtx = pCtx;713 this->uTrackAudio = UINT8_MAX;714 this->uTrackVideo = UINT8_MAX;715 this->tsStartMs = 0;716 this->uScreenID = uScreen;710 AssertReturn(m_enmState == RECORDINGSTREAMSTATE_UNINITIALIZED, VERR_WRONG_ORDER); 711 712 m_pCtx = pCtx; 713 m_uTrackAudio = UINT8_MAX; 714 m_uTrackVideo = UINT8_MAX; 715 m_tsStartMs = 0; 716 m_uScreenID = uScreen; 717 717 #ifdef VBOX_WITH_AUDIO_RECORDING 718 718 /* We use the codec from the recording context, as this stream only receives multiplexed data (same audio for all streams). */ 719 this->pCodecAudio = m_pCtx->GetCodecAudio();720 #endif 721 this->ScreenSettings = screenSettings;722 723 settings::RecordingScreenSettings *pSettings = & this->ScreenSettings;724 725 int vrc = RTCritSectInit(& this->CritSect);719 m_pCodecAudio = m_pCtx->GetCodecAudio(); 720 #endif 721 m_ScreenSettings = screenSettings; 722 723 settings::RecordingScreenSettings *pSettings = &m_ScreenSettings; 724 725 int vrc = RTCritSectInit(&m_CritSect); 726 726 if (RT_FAILURE(vrc)) 727 727 return vrc; 728 728 729 this->File. pWEBM = NULL;730 this->File. hFile = NIL_RTFILE;729 this->File.m_pWEBM = NULL; 730 this->File.m_hFile = NIL_RTFILE; 731 731 732 732 vrc = open(*pSettings); … … 751 751 const char *pszFile = pSettings->File.strName.c_str(); 752 752 753 AssertPtr(File. pWEBM);754 vrc = File. pWEBM->OpenEx(pszFile, &this->File.hFile,753 AssertPtr(File.m_pWEBM); 754 vrc = File.m_pWEBM->OpenEx(pszFile, &this->File.m_hFile, 755 755 fAudioEnabled ? pSettings->Audio.enmCodec : RecordingAudioCodec_None, 756 756 fVideoEnabled ? pSettings->Video.enmCodec : RecordingVideoCodec_None); … … 763 763 if (fVideoEnabled) 764 764 { 765 vrc = this->File. pWEBM->AddVideoTrack(&this->CodecVideo,765 vrc = this->File.m_pWEBM->AddVideoTrack(&m_CodecVideo, 766 766 pSettings->Video.ulWidth, pSettings->Video.ulHeight, pSettings->Video.ulFPS, 767 & this->uTrackVideo);767 &m_uTrackVideo); 768 768 if (RT_FAILURE(vrc)) 769 769 { … … 773 773 774 774 LogRel(("Recording: Recording video of screen #%u with %RU32x%RU32 @ %RU32 kbps, %RU32 FPS (track #%RU8)\n", 775 this->uScreenID, pSettings->Video.ulWidth, pSettings->Video.ulHeight,776 pSettings->Video.ulRate, pSettings->Video.ulFPS, this->uTrackVideo));775 m_uScreenID, pSettings->Video.ulWidth, pSettings->Video.ulHeight, 776 pSettings->Video.ulRate, pSettings->Video.ulFPS, m_uTrackVideo)); 777 777 } 778 778 … … 780 780 if (fAudioEnabled) 781 781 { 782 AssertPtr( this->pCodecAudio);783 vrc = this->File. pWEBM->AddAudioTrack(this->pCodecAudio,782 AssertPtr(m_pCodecAudio); 783 vrc = this->File.m_pWEBM->AddAudioTrack(m_pCodecAudio, 784 784 pSettings->Audio.uHz, pSettings->Audio.cChannels, pSettings->Audio.cBits, 785 & this->uTrackAudio);785 &m_uTrackAudio); 786 786 if (RT_FAILURE(vrc)) 787 787 { … … 791 791 792 792 LogRel(("Recording: Recording audio of screen #%u in %RU16Hz, %RU8 bit, %RU8 %s (track #%RU8)\n", 793 this->uScreenID, pSettings->Audio.uHz, pSettings->Audio.cBits, pSettings->Audio.cChannels,794 pSettings->Audio.cChannels ? "channels" : "channel", this->uTrackAudio));793 m_uScreenID, pSettings->Audio.uHz, pSettings->Audio.cBits, pSettings->Audio.cChannels, 794 pSettings->Audio.cChannels ? "channels" : "channel", m_uTrackAudio)); 795 795 } 796 796 #endif … … 813 813 } 814 814 #endif 815 LogRel(("Recording: Recording %s of screen #%u to '%s'\n", szWhat, this->uScreenID, pszFile));815 LogRel(("Recording: Recording %s of screen #%u to '%s'\n", szWhat, m_uScreenID, pszFile)); 816 816 } 817 817 … … 827 827 if (RT_SUCCESS(vrc)) 828 828 { 829 this->enmState = RECORDINGSTREAMSTATE_INITIALIZED;830 this->fEnabled = true;831 this->tsStartMs = RTTimeProgramMilliTS();829 m_enmState = RECORDINGSTREAMSTATE_INITIALIZED; 830 m_fEnabled = true; 831 m_tsStartMs = RTTimeProgramMilliTS(); 832 832 833 833 return VINF_SUCCESS; … … 852 852 int vrc = VINF_SUCCESS; 853 853 854 switch ( this->ScreenSettings.enmDest)854 switch (m_ScreenSettings.enmDest) 855 855 { 856 856 case RecordingDestination_File: 857 857 { 858 if (this->File. pWEBM)859 vrc = this->File. pWEBM->Close();858 if (this->File.m_pWEBM) 859 vrc = this->File.m_pWEBM->Close(); 860 860 break; 861 861 } … … 866 866 } 867 867 868 this->Blocks.Clear();869 870 LogRel(("Recording: Recording screen #%u stopped\n", this->uScreenID));868 m_Blocks.Clear(); 869 870 LogRel(("Recording: Recording screen #%u stopped\n", m_uScreenID)); 871 871 872 872 if (RT_FAILURE(vrc)) 873 873 { 874 LogRel(("Recording: Error stopping recording screen #%u, vrc=%Rrc\n", this->uScreenID, vrc));874 LogRel(("Recording: Error stopping recording screen #%u, vrc=%Rrc\n", m_uScreenID, vrc)); 875 875 return vrc; 876 876 } 877 877 878 switch ( this->ScreenSettings.enmDest)878 switch (m_ScreenSettings.enmDest) 879 879 { 880 880 case RecordingDestination_File: 881 881 { 882 if (RTFileIsValid(this->File. hFile))883 { 884 vrc = RTFileClose(this->File. hFile);882 if (RTFileIsValid(this->File.m_hFile)) 883 { 884 vrc = RTFileClose(this->File.m_hFile); 885 885 if (RT_SUCCESS(vrc)) 886 886 { 887 LogRel(("Recording: Closed file '%s'\n", this->ScreenSettings.File.strName.c_str()));887 LogRel(("Recording: Closed file '%s'\n", m_ScreenSettings.File.strName.c_str())); 888 888 } 889 889 else 890 890 { 891 LogRel(("Recording: Error closing file '%s', rc=%Rrc\n", this->ScreenSettings.File.strName.c_str(), vrc));891 LogRel(("Recording: Error closing file '%s', rc=%Rrc\n", m_ScreenSettings.File.strName.c_str(), vrc)); 892 892 break; 893 893 } 894 894 } 895 895 896 WebMWriter *pWebMWriter = this->File. pWEBM;896 WebMWriter *pWebMWriter = this->File.m_pWEBM; 897 897 AssertPtr(pWebMWriter); 898 898 … … 902 902 if (pWebMWriter->GetClusters() == 0) 903 903 { 904 int vrc2 = RTFileDelete( this->ScreenSettings.File.strName.c_str());904 int vrc2 = RTFileDelete(m_ScreenSettings.File.strName.c_str()); 905 905 AssertRC(vrc2); /* Ignore rc on non-debug builds. */ 906 906 } … … 909 909 pWebMWriter = NULL; 910 910 911 this->File. pWEBM = NULL;911 this->File.m_pWEBM = NULL; 912 912 } 913 913 break; … … 940 940 int RecordingStream::uninitInternal(void) 941 941 { 942 if ( this->enmState != RECORDINGSTREAMSTATE_INITIALIZED)942 if (m_enmState != RECORDINGSTREAMSTATE_INITIALIZED) 943 943 return VINF_SUCCESS; 944 944 … … 948 948 949 949 #ifdef VBOX_WITH_AUDIO_RECORDING 950 this->pCodecAudio = NULL;951 #endif 952 953 if ( this->ScreenSettings.isFeatureEnabled(RecordingFeature_Video))954 { 955 vrc = recordingCodecFinalize(& this->CodecVideo);950 m_pCodecAudio = NULL; 951 #endif 952 953 if (m_ScreenSettings.isFeatureEnabled(RecordingFeature_Video)) 954 { 955 vrc = recordingCodecFinalize(&m_CodecVideo); 956 956 if (RT_SUCCESS(vrc)) 957 vrc = recordingCodecDestroy(& this->CodecVideo);957 vrc = recordingCodecDestroy(&m_CodecVideo); 958 958 } 959 959 960 960 if (RT_SUCCESS(vrc)) 961 961 { 962 RTCritSectDelete(& this->CritSect);963 964 this->enmState = RECORDINGSTREAMSTATE_UNINITIALIZED;965 this->fEnabled = false;962 RTCritSectDelete(&m_CritSect); 963 964 m_enmState = RECORDINGSTREAMSTATE_UNINITIALIZED; 965 m_fEnabled = false; 966 966 } 967 967 … … 982 982 uint64_t msAbsPTS, uint32_t uFlags) 983 983 { 984 AssertPtr(this->File. pWEBM);984 AssertPtr(this->File.m_pWEBM); 985 985 AssertPtr(pvData); 986 986 Assert (cbData); … … 999 999 } 1000 1000 1001 return this->File. pWEBM->WriteBlock( pCodec->Parms.enmType == RECORDINGCODECTYPE_AUDIO1002 ? this->uTrackAudio : this->uTrackVideo,1001 return this->File.m_pWEBM->WriteBlock( pCodec->Parms.enmType == RECORDINGCODECTYPE_AUDIO 1002 ? m_uTrackAudio : m_uTrackVideo, 1003 1003 pvData, cbData, msAbsPTS, blockFlags); 1004 1004 } … … 1040 1040 AssertReturn(screenSettings.Video.ulFPS, VERR_INVALID_PARAMETER); 1041 1041 1042 PRECORDINGCODEC pCodec = & this->CodecVideo;1042 PRECORDINGCODEC pCodec = &m_CodecVideo; 1043 1043 1044 1044 RECORDINGCODECCALLBACKS Callbacks; … … 1061 1061 void RecordingStream::lock(void) 1062 1062 { 1063 int vrc = RTCritSectEnter(& CritSect);1063 int vrc = RTCritSectEnter(&m_CritSect); 1064 1064 AssertRC(vrc); 1065 1065 } … … 1070 1070 void RecordingStream::unlock(void) 1071 1071 { 1072 int vrc = RTCritSectLeave(& CritSect);1072 int vrc = RTCritSectLeave(&m_CritSect); 1073 1073 AssertRC(vrc); 1074 1074 } -
trunk/src/VBox/Main/src-client/WebMWriter.cpp
r96285 r96324 123 123 124 124 /* Make sure to drain all queues. */ 125 processQueue(& CurSeg.queueBlocks, true /* fForce */);125 processQueue(&m_CurSeg.m_queueBlocks, true /* fForce */); 126 126 127 127 writeFooter(); 128 128 129 WebMTracks::iterator itTrack = CurSeg.mapTracks.begin();130 while (itTrack != CurSeg.mapTracks.end())129 WebMTracks::iterator itTrack = m_CurSeg.m_mapTracks.begin(); 130 while (itTrack != m_CurSeg.m_mapTracks.end()) 131 131 { 132 132 WebMTrack *pTrack = itTrack->second; … … 134 134 delete pTrack; 135 135 136 CurSeg.mapTracks.erase(itTrack);137 138 itTrack = CurSeg.mapTracks.begin();139 } 140 141 Assert( CurSeg.queueBlocks.Map.size() == 0);142 Assert( CurSeg.mapTracks.size() == 0);136 m_CurSeg.m_mapTracks.erase(itTrack); 137 138 itTrack = m_CurSeg.m_mapTracks.begin(); 139 } 140 141 Assert(m_CurSeg.m_queueBlocks.Map.size() == 0); 142 Assert(m_CurSeg.m_mapTracks.size() == 0); 143 143 144 144 com::Utf8Str strFileName = getFileName().c_str(); … … 169 169 /* Some players (e.g. Firefox with Nestegg) rely on track numbers starting at 1. 170 170 * Using a track number 0 will show those files as being corrupted. */ 171 const uint8_t uTrack = (uint8_t) CurSeg.mapTracks.size() + 1;171 const uint8_t uTrack = (uint8_t)m_CurSeg.m_mapTracks.size() + 1; 172 172 173 173 subStart(MkvElem_TrackEntry); … … 287 287 pTrack->uTrack, pTrack->Audio.uHz, pTrack->Audio.msPerBlock, pTrack->Audio.framesPerBlock)); 288 288 289 CurSeg.mapTracks[uTrack] = pTrack;289 m_CurSeg.m_mapTracks[uTrack] = pTrack; 290 290 291 291 if (puTrack) … … 319 319 /* Some players (e.g. Firefox with Nestegg) rely on track numbers starting at 1. 320 320 * Using a track number 0 will show those files as being corrupted. */ 321 const uint8_t uTrack = (uint8_t) CurSeg.mapTracks.size() + 1;321 const uint8_t uTrack = (uint8_t)m_CurSeg.m_mapTracks.size() + 1; 322 322 323 323 subStart(MkvElem_TrackEntry); … … 345 345 LogRel2(("Recording: WebM track #%RU8: Video\n", pTrack->uTrack)); 346 346 347 CurSeg.mapTracks[uTrack] = pTrack;347 m_CurSeg.m_mapTracks[uTrack] = pTrack; 348 348 349 349 if (puTrack) … … 406 406 m_enmVideoCodec = enmVideoCodec; 407 407 408 return CurSeg.init();408 return m_CurSeg.init(); 409 409 } 410 410 … … 414 414 void WebMWriter::destroy(void) 415 415 { 416 CurSeg.uninit();416 m_CurSeg.uninit(); 417 417 } 418 418 … … 439 439 440 440 /* Save offset of current segment. */ 441 CurSeg.offStart = RTFileTell(getFile());441 m_CurSeg.m_offStart = RTFileTell(getFile()); 442 442 443 443 writeSeekHeader(); 444 444 445 445 /* Save offset of upcoming tracks segment. */ 446 CurSeg.offTracks = RTFileTell(getFile());446 m_CurSeg.m_offTracks = RTFileTell(getFile()); 447 447 448 448 /* The tracks segment starts right after this header. */ … … 463 463 { 464 464 #ifdef LOG_ENABLED 465 WebMCluster &Cluster = CurSeg.CurCluster;465 WebMCluster &Cluster = m_CurSeg.m_CurCluster; 466 466 467 467 Log3Func(("[T%RU8C%RU64] Off=%RU64, AbsPTSMs=%RU64, RelToClusterMs=%RU16, %zu bytes\n", … … 508 508 509 509 /* See if we already have an entry for the specified timecode in our queue. */ 510 WebMBlockMap::iterator itQueue = CurSeg.queueBlocks.Map.find(tcAbsPTS);511 if (itQueue != CurSeg.queueBlocks.Map.end()) /* Use existing queue. */510 WebMBlockMap::iterator itQueue = m_CurSeg.m_queueBlocks.Map.find(tcAbsPTS); 511 if (itQueue != m_CurSeg.m_queueBlocks.Map.end()) /* Use existing queue. */ 512 512 { 513 513 WebMTimecodeBlocks &Blocks = itQueue->second; … … 519 519 Blocks.Enqueue(a_pBlock); 520 520 521 CurSeg.queueBlocks.Map[tcAbsPTS] = Blocks;521 m_CurSeg.m_queueBlocks.Map[tcAbsPTS] = Blocks; 522 522 } 523 523 524 vrc = processQueue(& CurSeg.queueBlocks, false /* fForce */);524 vrc = processQueue(&m_CurSeg.m_queueBlocks, false /* fForce */); 525 525 } 526 526 catch(...) … … 547 547 int WebMWriter::WriteBlock(uint8_t uTrack, const void *pvData, size_t cbData, WebMTimecodeAbs tcAbsPTSMs, WebMBlockFlags uFlags) 548 548 { 549 int vrc = RTCritSectEnter(& CurSeg.CritSect);549 int vrc = RTCritSectEnter(&m_CurSeg.m_CritSect); 550 550 AssertRC(vrc); 551 551 552 WebMTracks::iterator itTrack = CurSeg.mapTracks.find(uTrack);553 if (itTrack == CurSeg.mapTracks.end())554 { 555 RTCritSectLeave(& CurSeg.CritSect);552 WebMTracks::iterator itTrack = m_CurSeg.m_mapTracks.find(uTrack); 553 if (itTrack == m_CurSeg.m_mapTracks.end()) 554 { 555 RTCritSectLeave(&m_CurSeg.m_CritSect); 556 556 return VERR_NOT_FOUND; 557 557 } … … 577 577 } 578 578 579 int vrc2 = RTCritSectLeave(& CurSeg.CritSect);579 int vrc2 = RTCritSectLeave(&m_CurSeg.m_CritSect); 580 580 AssertRC(vrc2); 581 581 … … 603 603 } 604 604 605 WebMCluster &Cluster = CurSeg.CurCluster;605 WebMCluster &Cluster = m_CurSeg.m_CurCluster; 606 606 607 607 /* Iterate through the block map. */ 608 608 WebMBlockMap::iterator it = pQueue->Map.begin(); 609 while (it != CurSeg.queueBlocks.Map.end())609 while (it != m_CurSeg.m_queueBlocks.Map.end()) 610 610 { 611 611 WebMTimecodeAbs mapAbsPTSMs = it->first; … … 617 617 /* If the current segment does not have any clusters (yet), 618 618 * take the first absolute PTS as the starting point for that segment. */ 619 if ( CurSeg.cClusters == 0)619 if (m_CurSeg.m_cClusters == 0) 620 620 { 621 CurSeg.tcAbsStartMs = mapAbsPTSMs;621 m_CurSeg.m_tcAbsStartMs = mapAbsPTSMs; 622 622 fClusterStart = true; 623 623 } … … 656 656 } 657 657 else /* First cluster ever? Use the segment's starting timecode. */ 658 tcAbsClusterLastWrittenMs = CurSeg.tcAbsStartMs;658 tcAbsClusterLastWrittenMs = m_CurSeg.m_tcAbsStartMs; 659 659 660 660 Cluster.fOpen = true; 661 Cluster.uID = CurSeg.cClusters;661 Cluster.uID = m_CurSeg.m_cClusters; 662 662 /* Use the block map's currently processed TC as the cluster's starting TC. */ 663 663 Cluster.tcAbsStartMs = mapAbsPTSMs; … … 676 676 WebMCuePoint *pCuePoint = new WebMCuePoint(Cluster.tcAbsStartMs); 677 677 678 WebMTracks::iterator itTrack = CurSeg.mapTracks.begin();679 while (itTrack != CurSeg.mapTracks.end())678 WebMTracks::iterator itTrack = m_CurSeg.m_mapTracks.begin(); 679 while (itTrack != m_CurSeg.m_mapTracks.end()) 680 680 { 681 681 pCuePoint->Pos[itTrack->first] = new WebMCueTrackPosEntry(Cluster.offStart); … … 683 683 } 684 684 685 CurSeg.lstCuePoints.push_back(pCuePoint);685 m_CurSeg.m_lstCuePoints.push_back(pCuePoint); 686 686 687 687 subStart(MkvElem_Cluster) 688 .serializeUnsignedInteger(MkvElem_Timecode, Cluster.tcAbsStartMs - CurSeg.tcAbsStartMs);689 690 CurSeg.cClusters++;688 .serializeUnsignedInteger(MkvElem_Timecode, Cluster.tcAbsStartMs - m_CurSeg.m_tcAbsStartMs); 689 690 m_CurSeg.m_cClusters++; 691 691 692 692 mapBlocks.fClusterStarted = true; … … 694 694 695 695 Log2Func(("[C%RU64] SegTcAbsStartMs=%RU64, ClusterTcAbsStartMs=%RU64, ClusterTcAbsLastWrittenMs=%RU64, mapAbsPTSMs=%RU64\n", 696 Cluster.uID, CurSeg.tcAbsStartMs, Cluster.tcAbsStartMs, Cluster.tcAbsLastWrittenMs, mapAbsPTSMs));696 Cluster.uID, m_CurSeg.m_tcAbsStartMs, Cluster.tcAbsStartMs, Cluster.tcAbsLastWrittenMs, mapAbsPTSMs)); 697 697 698 698 /* Iterate through all blocks related to the current timecode. */ … … 718 718 pTrack->tcAbsLastWrittenMs = Cluster.tcAbsLastWrittenMs; 719 719 720 if ( CurSeg.tcAbsLastWrittenMs < pTrack->tcAbsLastWrittenMs)721 CurSeg.tcAbsLastWrittenMs = pTrack->tcAbsLastWrittenMs;720 if (m_CurSeg.m_tcAbsLastWrittenMs < pTrack->tcAbsLastWrittenMs) 721 m_CurSeg.m_tcAbsLastWrittenMs = pTrack->tcAbsLastWrittenMs; 722 722 723 723 /* Save a cue point if this is a keyframe (if no new cluster has been started, … … 729 729 WebMCuePoint *pCuePoint = new WebMCuePoint(Cluster.tcAbsLastWrittenMs); 730 730 731 WebMTracks::iterator itTrack = CurSeg.mapTracks.begin();732 while (itTrack != CurSeg.mapTracks.end())731 WebMTracks::iterator itTrack = m_CurSeg.m_mapTracks.begin(); 732 while (itTrack != m_CurSeg.m_mapTracks.end()) 733 733 { 734 734 pCuePoint->Pos[itTrack->first] = new WebMCueTrackPosEntry(Cluster.offStart); … … 736 736 } 737 737 738 CurSeg.lstCuePoints.push_back(pCuePoint);738 m_CurSeg.m_lstCuePoints.push_back(pCuePoint); 739 739 } 740 740 … … 747 747 Assert(mapBlocks.Queue.empty()); 748 748 749 CurSeg.queueBlocks.Map.erase(it);750 751 it = CurSeg.queueBlocks.Map.begin();752 } 753 754 Assert( CurSeg.queueBlocks.Map.empty());749 m_CurSeg.m_queueBlocks.Map.erase(it); 750 751 it = m_CurSeg.m_queueBlocks.Map.begin(); 752 } 753 754 Assert(m_CurSeg.m_queueBlocks.Map.empty()); 755 755 756 756 pQueue->tsLastProcessedMs = RTTimeMilliTS(); … … 774 774 } 775 775 776 if ( CurSeg.CurCluster.fOpen)776 if (m_CurSeg.m_CurCluster.fOpen) 777 777 { 778 778 subEnd(MkvElem_Cluster); 779 CurSeg.CurCluster.fOpen = false;779 m_CurSeg.m_CurCluster.fOpen = false; 780 780 } 781 781 … … 783 783 * Write Cues element. 784 784 */ 785 CurSeg.offCues = RTFileTell(getFile());786 LogFunc(("Cues @ %RU64\n", CurSeg.offCues));785 m_CurSeg.m_offCues = RTFileTell(getFile()); 786 LogFunc(("Cues @ %RU64\n", m_CurSeg.m_offCues)); 787 787 788 788 subStart(MkvElem_Cues); 789 789 790 WebMCuePointList::iterator itCuePoint = CurSeg.lstCuePoints.begin();791 while (itCuePoint != CurSeg.lstCuePoints.end())790 WebMCuePointList::iterator itCuePoint = m_CurSeg.m_lstCuePoints.begin(); 791 while (itCuePoint != m_CurSeg.m_lstCuePoints.end()) 792 792 { 793 793 WebMCuePoint *pCuePoint = (*itCuePoint); … … 811 811 subStart(MkvElem_CueTrackPositions) 812 812 .serializeUnsignedInteger(MkvElem_CueTrack, itTrackPos->first) 813 .serializeUnsignedInteger(MkvElem_CueClusterPosition, pTrackPos->offCluster - CurSeg.offStart, 8)813 .serializeUnsignedInteger(MkvElem_CueClusterPosition, pTrackPos->offCluster - m_CurSeg.m_offStart, 8) 814 814 .subEnd(MkvElem_CueTrackPositions); 815 815 … … 839 839 void WebMWriter::writeSeekHeader(void) 840 840 { 841 if ( CurSeg.offSeekInfo)842 RTFileSeek(getFile(), CurSeg.offSeekInfo, RTFILE_SEEK_BEGIN, NULL);841 if (m_CurSeg.m_offSeekInfo) 842 RTFileSeek(getFile(), m_CurSeg.m_offSeekInfo, RTFILE_SEEK_BEGIN, NULL); 843 843 else 844 CurSeg.offSeekInfo = RTFileTell(getFile());845 846 LogFunc(("Seek Header @ %RU64\n", CurSeg.offSeekInfo));844 m_CurSeg.m_offSeekInfo = RTFileTell(getFile()); 845 846 LogFunc(("Seek Header @ %RU64\n", m_CurSeg.m_offSeekInfo)); 847 847 848 848 subStart(MkvElem_SeekHead); … … 850 850 subStart(MkvElem_Seek) 851 851 .serializeUnsignedInteger(MkvElem_SeekID, MkvElem_Tracks) 852 .serializeUnsignedInteger(MkvElem_SeekPosition, CurSeg.offTracks - CurSeg.offStart, 8)852 .serializeUnsignedInteger(MkvElem_SeekPosition, m_CurSeg.m_offTracks - m_CurSeg.m_offStart, 8) 853 853 .subEnd(MkvElem_Seek); 854 854 855 if ( CurSeg.offCues)856 LogFunc(("Updating Cues @ %RU64\n", CurSeg.offCues));855 if (m_CurSeg.m_offCues) 856 LogFunc(("Updating Cues @ %RU64\n", m_CurSeg.m_offCues)); 857 857 858 858 subStart(MkvElem_Seek) 859 859 .serializeUnsignedInteger(MkvElem_SeekID, MkvElem_Cues) 860 .serializeUnsignedInteger(MkvElem_SeekPosition, CurSeg.offCues - CurSeg.offStart, 8)860 .serializeUnsignedInteger(MkvElem_SeekPosition, m_CurSeg.m_offCues - m_CurSeg.m_offStart, 8) 861 861 .subEnd(MkvElem_Seek); 862 862 863 863 subStart(MkvElem_Seek) 864 864 .serializeUnsignedInteger(MkvElem_SeekID, MkvElem_Info) 865 .serializeUnsignedInteger(MkvElem_SeekPosition, CurSeg.offInfo - CurSeg.offStart, 8)865 .serializeUnsignedInteger(MkvElem_SeekPosition, m_CurSeg.m_offInfo - m_CurSeg.m_offStart, 8) 866 866 .subEnd(MkvElem_Seek); 867 867 … … 873 873 874 874 /* Save offset of the segment's info element. */ 875 CurSeg.offInfo = RTFileTell(getFile());876 877 LogFunc(("Info @ %RU64\n", CurSeg.offInfo));875 m_CurSeg.m_offInfo = RTFileTell(getFile()); 876 877 LogFunc(("Info @ %RU64\n", m_CurSeg.m_offInfo)); 878 878 879 879 char szMux[64]; … … 888 888 RTStrPrintf(szApp, sizeof(szApp), VBOX_PRODUCT " %sr%u", VBOX_VERSION_STRING, RTBldCfgRevision()); 889 889 890 const WebMTimecodeAbs tcAbsDurationMs = CurSeg.tcAbsLastWrittenMs - CurSeg.tcAbsStartMs;891 892 if (! CurSeg.lstCuePoints.empty())890 const WebMTimecodeAbs tcAbsDurationMs = m_CurSeg.m_tcAbsLastWrittenMs - m_CurSeg.m_tcAbsStartMs; 891 892 if (!m_CurSeg.m_lstCuePoints.empty()) 893 893 { 894 894 LogFunc(("tcAbsDurationMs=%RU64\n", tcAbsDurationMs)); … … 897 897 898 898 subStart(MkvElem_Info) 899 .serializeUnsignedInteger(MkvElem_TimecodeScale, CurSeg.uTimecodeScaleFactor)899 .serializeUnsignedInteger(MkvElem_TimecodeScale, m_CurSeg.m_uTimecodeScaleFactor) 900 900 .serializeFloat(MkvElem_Segment_Duration, tcAbsDurationMs) 901 901 .serializeString(MkvElem_MuxingApp, szMux)
Note:
See TracChangeset
for help on using the changeset viewer.