- Timestamp:
- Nov 5, 2018 6:35:21 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 126356
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/DrvAudioVideoRec.h
r75251 r75254 45 45 public: 46 46 47 int applyConfiguration(const settings::CaptureSettings & a_Settings);47 int applyConfiguration(const settings::CaptureSettings &Settings); 48 48 49 49 public: -
trunk/src/VBox/Main/include/VideoRecStream.h
r75251 r75254 32 32 33 33 class WebMWriter; 34 35 struct CaptureContext; 36 typedef struct CaptureContext *PVIDEORECCONTEXT; 37 34 class CaptureContext; 38 35 39 36 /** Structure for queuing all blocks bound to a single timecode. … … 114 111 CaptureStream(void); 115 112 116 CaptureStream(uint32_t a_uScreen, const settings::CaptureScreenSettings &a_Settings);113 CaptureStream(uint32_t uScreen, const settings::CaptureScreenSettings &Settings); 117 114 118 115 virtual ~CaptureStream(void); … … 120 117 public: 121 118 122 int Init(uint32_t a_uScreen, const settings::CaptureScreenSettings &a_Settings);119 int Init(uint32_t uScreen, const settings::CaptureScreenSettings &Settings); 123 120 int Uninit(void); 124 121 … … 136 133 int close(void); 137 134 138 int initInternal(uint32_t a_uScreen, const settings::CaptureScreenSettings &a_Settings);135 int initInternal(uint32_t uScreen, const settings::CaptureScreenSettings &Settings); 139 136 int uninitInternal(void); 140 137 … … 158 155 /** Recording context this stream is associated to. */ 159 156 CaptureContext *pCtx; 160 union 161 { 162 struct 163 { 164 /** File handle to use for writing. */ 165 RTFILE hFile; 166 /** File name being used for this stream. */ 167 Utf8Str strName; 168 /** Pointer to WebM writer instance being used. */ 169 WebMWriter *pWEBM; 170 } File; 171 }; 157 struct 158 { 159 /** File handle to use for writing. */ 160 RTFILE hFile; 161 /** File name being used for this stream. */ 162 Utf8Str strName; 163 /** Pointer to WebM writer instance being used. */ 164 WebMWriter *pWEBM; 165 } File; 172 166 bool fEnabled; 173 167 #ifdef VBOX_WITH_AUDIO_VIDEOREC … … 196 190 } Video; 197 191 198 settings::CaptureScreenSettings S ettings;192 settings::CaptureScreenSettings ScreenSettings; 199 193 /** Common set of video recording (data) blocks, needed for 200 194 * multiplexing to all recording streams. */ -
trunk/src/VBox/Main/src-client/DrvAudioVideoRec.cpp
r75251 r75254 1088 1088 * @param Settings Capturing configuration to apply. 1089 1089 */ 1090 int AudioVideoRec::applyConfiguration(const settings::CaptureSettings & a_Settings)1090 int AudioVideoRec::applyConfiguration(const settings::CaptureSettings &Settings) 1091 1091 { 1092 1092 /** @todo Do some validation here. */ 1093 mVideoRecCfg = a_Settings; /* Note: Does have an own copy operator. */1093 mVideoRecCfg = Settings; /* Note: Does have an own copy operator. */ 1094 1094 return VINF_SUCCESS; 1095 1095 } -
trunk/src/VBox/Main/src-client/VideoRec.cpp
r75251 r75254 187 187 * 188 188 * @returns IPRT status code. 189 * @param cScreens Number of screens to create context for. 190 * @param pVideoRecCfg Pointer to video recording configuration to use. 189 * @param a_Settings Capture settings to use for context creation. 191 190 */ 192 191 int CaptureContext::createInternal(const settings::CaptureSettings &a_Settings) -
trunk/src/VBox/Main/src-client/VideoRecStream.cpp
r75251 r75254 47 47 } 48 48 49 CaptureStream::CaptureStream(uint32_t a_uScreen, const settings::CaptureScreenSettings &a_Settings)49 CaptureStream::CaptureStream(uint32_t uScreen, const settings::CaptureScreenSettings &Settings) 50 50 : tsStartMs(0) 51 51 { 52 int rc2 = initInternal( a_uScreen, a_Settings);52 int rc2 = initInternal(uScreen, Settings); 53 53 if (RT_FAILURE(rc2)) 54 54 throw rc2; … … 68 68 int CaptureStream::open(void) 69 69 { 70 Assert(S ettings.enmDest == CaptureDestination_None);70 Assert(ScreenSettings.enmDest == CaptureDestination_None); 71 71 72 72 int rc; 73 73 74 switch (S ettings.enmDest)74 switch (ScreenSettings.enmDest) 75 75 { 76 76 case CaptureDestination_File: 77 77 { 78 Assert(S ettings.File.strName.isNotEmpty());79 80 char *pszAbsPath = RTPathAbsDup(S ettings.File.strName.c_str());78 Assert(ScreenSettings.File.strName.isNotEmpty()); 79 80 char *pszAbsPath = RTPathAbsDup(ScreenSettings.File.strName.c_str()); 81 81 AssertPtrReturn(pszAbsPath, VERR_NO_MEMORY); 82 82 … … 172 172 { 173 173 #ifdef VBOX_WITH_LIBVPX 174 Assert(this->S ettings.Video.ulFPS);174 Assert(this->ScreenSettings.Video.ulFPS); 175 175 if (value.compare("realtime", Utf8Str::CaseInsensitive) == 0) 176 176 this->Video.Codec.VPX.uEncoderDeadline = VPX_DL_REALTIME; 177 177 else if (value.compare("good", Utf8Str::CaseInsensitive) == 0) 178 this->Video.Codec.VPX.uEncoderDeadline = 1000000 / this->S ettings.Video.ulFPS;178 this->Video.Codec.VPX.uEncoderDeadline = 1000000 / this->ScreenSettings.Video.ulFPS; 179 179 else if (value.compare("best", Utf8Str::CaseInsensitive) == 0) 180 180 this->Video.Codec.VPX.uEncoderDeadline = VPX_DL_BEST_QUALITY; … … 190 190 if (value.compare("false", Utf8Str::CaseInsensitive) == 0) 191 191 { 192 this->S ettings.featureMap[CaptureFeature_Video] = false;192 this->ScreenSettings.featureMap[CaptureFeature_Video] = false; 193 193 #ifdef VBOX_WITH_AUDIO_VIDEOREC 194 194 LogRel(("VideoRec: Only audio will be recorded\n")); … … 201 201 if (value.compare("true", Utf8Str::CaseInsensitive) == 0) 202 202 { 203 this->S ettings.featureMap[CaptureFeature_Audio] = true;203 this->ScreenSettings.featureMap[CaptureFeature_Audio] = true; 204 204 } 205 205 else … … 212 212 if (value.compare("low", Utf8Str::CaseInsensitive) == 0) 213 213 { 214 this->S ettings.Audio.uHz = 8000;215 this->S ettings.Audio.cBits = 16;216 this->S ettings.Audio.cChannels = 1;214 this->ScreenSettings.Audio.uHz = 8000; 215 this->ScreenSettings.Audio.cBits = 16; 216 this->ScreenSettings.Audio.cChannels = 1; 217 217 } 218 218 else if (value.startsWith("med" /* "med[ium]" */, Utf8Str::CaseInsensitive) == 0) … … 222 222 else if (value.compare("high", Utf8Str::CaseInsensitive) == 0) 223 223 { 224 this->S ettings.Audio.uHz = 48000;225 this->S ettings.Audio.cBits = 16;226 this->S ettings.Audio.cChannels = 2;224 this->ScreenSettings.Audio.uHz = 48000; 225 this->ScreenSettings.Audio.cBits = 16; 226 this->ScreenSettings.Audio.cChannels = 2; 227 227 } 228 228 #endif … … 238 238 const settings::CaptureScreenSettings &CaptureStream::GetConfig(void) const 239 239 { 240 return this->S ettings;240 return this->ScreenSettings; 241 241 } 242 242 … … 252 252 return true; 253 253 254 if ( Settings.ulMaxTimeS255 && tsNowMs >= this->tsStartMs + ( Settings.ulMaxTimeS * RT_MS_1SEC))254 if ( this->ScreenSettings.ulMaxTimeS 255 && tsNowMs >= this->tsStartMs + (this->ScreenSettings.ulMaxTimeS * RT_MS_1SEC)) 256 256 { 257 257 return true; 258 258 } 259 259 260 if ( Settings.enmDest == CaptureDestination_File)261 { 262 263 if ( Settings.File.ulMaxSizeMB)260 if (this->ScreenSettings.enmDest == CaptureDestination_File) 261 { 262 263 if (this->ScreenSettings.File.ulMaxSizeMB) 264 264 { 265 265 uint64_t sizeInMB = this->File.pWEBM->GetFileSize() / _1M; 266 if(sizeInMB >= Settings.File.ulMaxSizeMB)266 if(sizeInMB >= this->ScreenSettings.File.ulMaxSizeMB) 267 267 return true; 268 268 } … … 297 297 lock(); 298 298 299 if (! Settings.fEnabled)299 if (!this->ScreenSettings.fEnabled) 300 300 { 301 301 unlock(); … … 327 327 this->Video.Codec.VPX.pu8YuvBuf, pVideoFrame->uWidth, pVideoFrame->uHeight, 328 328 /* Source */ 329 pVideoFrame->pu8RGBBuf, this->S ettings.Video.ulWidth, this->Settings.Video.ulHeight);329 pVideoFrame->pu8RGBBuf, this->ScreenSettings.Video.ulWidth, this->ScreenSettings.Video.ulHeight); 330 330 if (RT_SUCCESS(rc)) 331 331 { … … 440 440 this->Video.uLastTimeStampMs = uTimeStampMs; 441 441 442 int xDiff = ((int)this->S ettings.Video.ulWidth - (int)uSrcWidth) / 2;442 int xDiff = ((int)this->ScreenSettings.Video.ulWidth - (int)uSrcWidth) / 2; 443 443 uint32_t w = uSrcWidth; 444 444 if ((int)w + xDiff + (int)x <= 0) /* Nothing visible. */ … … 459 459 460 460 uint32_t h = uSrcHeight; 461 int yDiff = ((int)this->S ettings.Video.ulHeight - (int)uSrcHeight) / 2;461 int yDiff = ((int)this->ScreenSettings.Video.ulHeight - (int)uSrcHeight) / 2; 462 462 if ((int)h + yDiff + (int)y <= 0) /* Nothing visible. */ 463 463 { … … 476 476 destY = y + yDiff; 477 477 478 if ( destX > this->S ettings.Video.ulWidth479 || destY > this->S ettings.Video.ulHeight)478 if ( destX > this->ScreenSettings.Video.ulWidth 479 || destY > this->ScreenSettings.Video.ulHeight) 480 480 { 481 481 rc = VERR_INVALID_PARAMETER; /* Nothing visible. */ … … 483 483 } 484 484 485 if (destX + w > this->S ettings.Video.ulWidth)486 w = this->S ettings.Video.ulWidth - destX;487 488 if (destY + h > this->S ettings.Video.ulHeight)489 h = this->S ettings.Video.ulHeight - destY;485 if (destX + w > this->ScreenSettings.Video.ulWidth) 486 w = this->ScreenSettings.Video.ulWidth - destX; 487 488 if (destY + h > this->ScreenSettings.Video.ulHeight) 489 h = this->ScreenSettings.Video.ulHeight - destY; 490 490 491 491 pFrame = (PVIDEORECVIDEOFRAME)RTMemAllocZ(sizeof(VIDEORECVIDEOFRAME)); … … 515 515 AssertMsgFailedBreakStmt(("Unknown pixel format (%RU32)\n", uPixelFormat), rc = VERR_NOT_SUPPORTED); 516 516 517 const size_t cbRGBBuf = this->S ettings.Video.ulWidth518 * this->S ettings.Video.ulHeight517 const size_t cbRGBBuf = this->ScreenSettings.Video.ulWidth 518 * this->ScreenSettings.Video.ulHeight 519 519 * uBytesPerPixel; 520 520 AssertBreakStmt(cbRGBBuf, rc = VERR_INVALID_PARAMETER); … … 528 528 /* If the current video frame is smaller than video resolution we're going to encode, 529 529 * clear the frame beforehand to prevent artifacts. */ 530 if ( uSrcWidth < this->S ettings.Video.ulWidth531 || uSrcHeight < this->S ettings.Video.ulHeight)530 if ( uSrcWidth < this->ScreenSettings.Video.ulWidth 531 || uSrcHeight < this->ScreenSettings.Video.ulHeight) 532 532 { 533 533 RT_BZERO(pFrame->pu8RGBBuf, pFrame->cbRGBBuf); … … 536 536 /* Calculate start offset in source and destination buffers. */ 537 537 uint32_t offSrc = y * uBytesPerLine + x * uBytesPerPixel; 538 uint32_t offDst = (destY * this->S ettings.Video.ulWidth + destX) * uBytesPerPixel;538 uint32_t offDst = (destY * this->ScreenSettings.Video.ulWidth + destX) * uBytesPerPixel; 539 539 540 540 #ifdef VBOX_VIDEOREC_DUMP … … 576 576 /* Overflow check. */ 577 577 Assert(offSrc + w * uBytesPerPixel <= uSrcHeight * uBytesPerLine); 578 Assert(offDst + w * uBytesPerPixel <= this->S ettings.Video.ulHeight * this->Settings.Video.ulWidth * uBytesPerPixel);578 Assert(offDst + w * uBytesPerPixel <= this->ScreenSettings.Video.ulHeight * this->ScreenSettings.Video.ulWidth * uBytesPerPixel); 579 579 580 580 memcpy(pFrame->pu8RGBBuf + offDst, puSrcData + offSrc, w * uBytesPerPixel); … … 585 585 #endif 586 586 offSrc += uBytesPerLine; 587 offDst += this->S ettings.Video.ulWidth * uBytesPerPixel;587 offDst += this->ScreenSettings.Video.ulWidth * uBytesPerPixel; 588 588 } 589 589 … … 634 634 } 635 635 636 int CaptureStream::Init(uint32_t a_uScreen, const settings::CaptureScreenSettings &a_Settings)637 { 638 return initInternal( a_uScreen, a_Settings);636 int CaptureStream::Init(uint32_t uScreen, const settings::CaptureScreenSettings &Settings) 637 { 638 return initInternal(uScreen, Settings); 639 639 } 640 640 … … 644 644 * @returns IPRT status code. 645 645 * @param uScreen Screen number to use for this recording stream. 646 * @param Cfg Recording screenconfiguration to use for initialization.647 */ 648 int CaptureStream::initInternal(uint32_t a_uScreen, const settings::CaptureScreenSettings &a_Settings)649 { 650 int rc = parseOptionsString( a_Settings.strOptions);646 * @param Settings Capturing configuration to use for initialization. 647 */ 648 int CaptureStream::initInternal(uint32_t uScreen, const settings::CaptureScreenSettings &Settings) 649 { 650 int rc = parseOptionsString(Settings.strOptions); 651 651 if (RT_FAILURE(rc)) 652 652 return rc; … … 660 660 return rc; 661 661 662 const bool fVideoEnabled = a_Settings.isFeatureEnabled(CaptureFeature_Video);663 const bool fAudioEnabled = a_Settings.isFeatureEnabled(CaptureFeature_Audio);662 const bool fVideoEnabled = Settings.isFeatureEnabled(CaptureFeature_Video); 663 const bool fAudioEnabled = Settings.isFeatureEnabled(CaptureFeature_Audio); 664 664 665 665 if (fVideoEnabled) … … 669 669 rc = initAudio(); 670 670 671 switch (this->S ettings.enmDest)671 switch (this->ScreenSettings.enmDest) 672 672 { 673 673 case CaptureDestination_File: 674 674 { 675 const char *pszFile = this->S ettings.File.strName.c_str();675 const char *pszFile = this->ScreenSettings.File.strName.c_str(); 676 676 677 677 rc = File.pWEBM->OpenEx(pszFile, &this->File.hFile, 678 678 #ifdef VBOX_WITH_AUDIO_VIDEOREC 679 a_Settings.isFeatureEnabled(CaptureFeature_Audio)679 Settings.isFeatureEnabled(CaptureFeature_Audio) 680 680 ? WebMWriter::AudioCodec_Opus : WebMWriter::AudioCodec_None, 681 681 #else 682 682 WebMWriter::AudioCodec_None, 683 683 #endif 684 a_Settings.isFeatureEnabled(CaptureFeature_Video)684 Settings.isFeatureEnabled(CaptureFeature_Video) 685 685 ? WebMWriter::VideoCodec_VP8 : WebMWriter::VideoCodec_None); 686 686 if (RT_FAILURE(rc)) … … 692 692 if (fVideoEnabled) 693 693 { 694 rc = this->File.pWEBM->AddVideoTrack( a_Settings.Video.ulWidth, a_Settings.Video.ulHeight,695 a_Settings.Video.ulFPS, &this->uTrackVideo);694 rc = this->File.pWEBM->AddVideoTrack(Settings.Video.ulWidth, Settings.Video.ulHeight, 695 Settings.Video.ulFPS, &this->uTrackVideo); 696 696 if (RT_FAILURE(rc)) 697 697 { … … 701 701 702 702 LogRel(("VideoRec: Recording video of screen #%u with %RU32x%RU32 @ %RU32 kbps, %RU32 FPS (track #%RU8)\n", 703 this->uScreenID, a_Settings.Video.ulWidth, a_Settings.Video.ulHeight, a_Settings.Video.ulRate,704 a_Settings.Video.ulFPS, this->uTrackVideo));703 this->uScreenID, Settings.Video.ulWidth, Settings.Video.ulHeight, Settings.Video.ulRate, 704 Settings.Video.ulFPS, this->uTrackVideo)); 705 705 } 706 706 … … 708 708 if (fAudioEnabled) 709 709 { 710 rc = this->File.pWEBM->AddAudioTrack( a_Settings.Audio.uHz, a_Settings.Audio.cChannels, a_Settings.Audio.cBits,710 rc = this->File.pWEBM->AddAudioTrack(Settings.Audio.uHz, Settings.Audio.cChannels, Settings.Audio.cBits, 711 711 &this->uTrackAudio); 712 712 if (RT_FAILURE(rc)) … … 717 717 718 718 LogRel(("VideoRec: Recording audio in %RU16Hz, %RU8 bit, %RU8 %s (track #%RU8)\n", 719 a_Settings.Audio.uHz, a_Settings.Audio.cBits, a_Settings.Audio.cChannels,720 a_Settings.Audio.cChannels ? "channels" : "channel", this->uTrackAudio));719 Settings.Audio.uHz, Settings.Audio.cBits, Settings.Audio.cChannels, 720 Settings.Audio.cChannels ? "channels" : "channel", this->uTrackAudio)); 721 721 } 722 722 #endif … … 755 755 this->pCtx = pCtx; 756 756 this->fEnabled = true; 757 this->uScreenID = a_uScreen;757 this->uScreenID = uScreen; 758 758 this->tsStartMs = RTTimeMilliTS(); 759 this->S ettings = a_Settings;759 this->ScreenSettings = Settings; 760 760 } 761 761 else … … 782 782 if (this->fEnabled) 783 783 { 784 switch (this->S ettings.enmDest)784 switch (this->ScreenSettings.enmDest) 785 785 { 786 786 case CaptureDestination_File: … … 807 807 } 808 808 809 switch (this->S ettings.enmDest)809 switch (this->ScreenSettings.enmDest) 810 810 { 811 811 case CaptureDestination_File: … … 816 816 if (RT_SUCCESS(rc)) 817 817 { 818 LogRel(("VideoRec: Closed file '%s'\n", this->S ettings.File.strName.c_str()));818 LogRel(("VideoRec: Closed file '%s'\n", this->ScreenSettings.File.strName.c_str())); 819 819 } 820 820 else 821 821 { 822 LogRel(("VideoRec: Error closing file '%s', rc=%Rrc\n", this->S ettings.File.strName.c_str(), rc));822 LogRel(("VideoRec: Error closing file '%s', rc=%Rrc\n", this->ScreenSettings.File.strName.c_str(), rc)); 823 823 break; 824 824 } … … 858 858 return rc; 859 859 860 if (this->S ettings.isFeatureEnabled(CaptureFeature_Video))860 if (this->ScreenSettings.isFeatureEnabled(CaptureFeature_Video)) 861 861 { 862 862 int rc2 = unitVideo(); … … 911 911 { 912 912 /* Sanity. */ 913 AssertReturn(this->S ettings.Video.ulRate, VERR_INVALID_PARAMETER);914 AssertReturn(this->S ettings.Video.ulWidth, VERR_INVALID_PARAMETER);915 AssertReturn(this->S ettings.Video.ulHeight, VERR_INVALID_PARAMETER);916 AssertReturn(this->S ettings.Video.ulFPS, VERR_INVALID_PARAMETER);913 AssertReturn(this->ScreenSettings.Video.ulRate, VERR_INVALID_PARAMETER); 914 AssertReturn(this->ScreenSettings.Video.ulWidth, VERR_INVALID_PARAMETER); 915 AssertReturn(this->ScreenSettings.Video.ulHeight, VERR_INVALID_PARAMETER); 916 AssertReturn(this->ScreenSettings.Video.ulFPS, VERR_INVALID_PARAMETER); 917 917 918 918 this->Video.cFailedEncodingFrames = 0; 919 this->Video.uDelayMs = RT_MS_1SEC / this->S ettings.Video.ulFPS;919 this->Video.uDelayMs = RT_MS_1SEC / this->ScreenSettings.Video.ulFPS; 920 920 921 921 #ifdef VBOX_WITH_LIBVPX … … 951 951 952 952 /* Target bitrate in kilobits per second. */ 953 pCodec->VPX.Cfg.rc_target_bitrate = this->S ettings.Video.ulRate;953 pCodec->VPX.Cfg.rc_target_bitrate = this->ScreenSettings.Video.ulRate; 954 954 /* Frame width. */ 955 pCodec->VPX.Cfg.g_w = this->S ettings.Video.ulWidth;955 pCodec->VPX.Cfg.g_w = this->ScreenSettings.Video.ulWidth; 956 956 /* Frame height. */ 957 pCodec->VPX.Cfg.g_h = this->S ettings.Video.ulHeight;957 pCodec->VPX.Cfg.g_h = this->ScreenSettings.Video.ulHeight; 958 958 /* 1ms per frame. */ 959 959 pCodec->VPX.Cfg.g_timebase.num = 1; … … 971 971 972 972 if (!vpx_img_alloc(&pCodec->VPX.RawImage, VPX_IMG_FMT_I420, 973 this->S ettings.Video.ulWidth, this->Settings.Video.ulHeight, 1))973 this->ScreenSettings.Video.ulWidth, this->ScreenSettings.Video.ulHeight, 1)) 974 974 { 975 975 LogRel(("VideoRec: Failed to allocate image %RU32x%RU32\n", 976 this->S ettings.Video.ulWidth, this->Settings.Video.ulHeight));976 this->ScreenSettings.Video.ulWidth, this->ScreenSettings.Video.ulHeight)); 977 977 return VERR_NO_MEMORY; 978 978 } … … 988 988 { 989 989 #ifdef VBOX_WITH_AUDIO_VIDEOREC 990 if (this->S ettings.isFeatureEnabled(CaptureFeature_Audio))990 if (this->ScreenSettings.isFeatureEnabled(CaptureFeature_Audio)) 991 991 { 992 992 /* Sanity. */ 993 AssertReturn(this->S ettings.Audio.uHz, VERR_INVALID_PARAMETER);994 AssertReturn(this->S ettings.Audio.cBits, VERR_INVALID_PARAMETER);995 AssertReturn(this->S ettings.Audio.cChannels, VERR_INVALID_PARAMETER);993 AssertReturn(this->ScreenSettings.Audio.uHz, VERR_INVALID_PARAMETER); 994 AssertReturn(this->ScreenSettings.Audio.cBits, VERR_INVALID_PARAMETER); 995 AssertReturn(this->ScreenSettings.Audio.cChannels, VERR_INVALID_PARAMETER); 996 996 } 997 997 #endif
Note:
See TracChangeset
for help on using the changeset viewer.