Changeset 65412 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jan 24, 2017 10:20:58 AM (8 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/DisplayImpl.cpp
r65410 r65412 2301 2301 return VINF_SUCCESS; 2302 2302 2303 return VideoRecSendAudio (mpVideoRecCtx, pvData, cbData, uTimestampMs);2303 return VideoRecSendAudioFrame(mpVideoRecCtx, pvData, cbData, uTimestampMs); 2304 2304 #else 2305 2305 RT_NOREF(pvData, cbData, uTimestampMs); … … 3241 3241 &bitmapFormat); 3242 3242 if (SUCCEEDED(hr) && pbAddress) 3243 rc = VideoRec CopyToIntBuf(pDisplay->mpVideoRecCtx, uScreenId, 0, 0,3244 BitmapFormat_BGR,3245 ulBitsPerPixel, ulBytesPerLine, ulWidth, ulHeight,3246 pbAddress, u64Now);3243 rc = VideoRecSendVideoFrame(pDisplay->mpVideoRecCtx, uScreenId, 0, 0, 3244 BitmapFormat_BGR, 3245 ulBitsPerPixel, ulBytesPerLine, ulWidth, ulHeight, 3246 pbAddress, u64Now); 3247 3247 else 3248 3248 rc = VERR_NOT_SUPPORTED; … … 3629 3629 Assert(mfCrOglVideoRecState == CRVREC_STATE_SUBMITTED); 3630 3630 # ifdef VBOX_WITH_VIDEOREC 3631 int rc = VideoRec CopyToIntBuf(mpVideoRecCtx, uScreen, x, y,3632 uPixelFormat,3633 uBitsPerPixel, uBytesPerLine,3634 uGuestWidth, uGuestHeight,3635 pu8BufferAddress, u64Timestamp);3631 int rc = VideoRecSendVideoFrame(mpVideoRecCtx, uScreen, x, y, 3632 uPixelFormat, 3633 uBitsPerPixel, uBytesPerLine, 3634 uGuestWidth, uGuestHeight, 3635 pu8BufferAddress, u64Timestamp); 3636 3636 NOREF(rc); 3637 3637 Assert(rc == VINF_SUCCESS /* || rc == VERR_TRY_AGAIN || rc == VINF_TRY_AGAIN*/); -
trunk/src/VBox/Main/src-client/VideoRec.cpp
r65410 r65412 119 119 uint16_t uScreen; 120 120 /** Target X resolution (in pixels). */ 121 uint32_t u TargetWidth;121 uint32_t uDstWidth; 122 122 /** Target Y resolution (in pixels). */ 123 uint32_t u TargetHeight;123 uint32_t uDstHeight; 124 124 /** X resolution of the last encoded frame. */ 125 uint32_t u LastSourceWidth;125 uint32_t uSrcLastWidth; 126 126 /** Y resolution of the last encoded frame. */ 127 uint32_t u LastSourceHeight;127 uint32_t uSrcLastHeight; 128 128 /** Current frame number. */ 129 129 uint64_t cFrame; … … 699 699 pCtx->uMaxSizeMB = uMaxSizeMB; 700 700 701 pStream->u TargetWidth = uWidth;702 pStream->u TargetHeight = uHeight;701 pStream->uDstWidth = uWidth; 702 pStream->uDstHeight = uHeight; 703 703 pStream->pu8RgbBuf = (uint8_t *)RTMemAllocZ(uWidth * uHeight * 4); 704 704 AssertReturn(pStream->pu8RgbBuf, VERR_NO_MEMORY); … … 1013 1013 case VIDEORECPIXELFMT_RGB32: 1014 1014 LogFlow(("32 bit\n")); 1015 if (!colorConvWriteYUV420p<ColorConvBGRA32Iter>(pStrm->u TargetWidth,1016 pStrm->u TargetHeight,1015 if (!colorConvWriteYUV420p<ColorConvBGRA32Iter>(pStrm->uDstWidth, 1016 pStrm->uDstHeight, 1017 1017 pStrm->pu8YuvBuf, 1018 1018 pStrm->pu8RgbBuf)) … … 1021 1021 case VIDEORECPIXELFMT_RGB24: 1022 1022 LogFlow(("24 bit\n")); 1023 if (!colorConvWriteYUV420p<ColorConvBGR24Iter>(pStrm->u TargetWidth,1024 pStrm->u TargetHeight,1023 if (!colorConvWriteYUV420p<ColorConvBGR24Iter>(pStrm->uDstWidth, 1024 pStrm->uDstHeight, 1025 1025 pStrm->pu8YuvBuf, 1026 1026 pStrm->pu8RgbBuf)) … … 1029 1029 case VIDEORECPIXELFMT_RGB565: 1030 1030 LogFlow(("565 bit\n")); 1031 if (!colorConvWriteYUV420p<ColorConvBGR565Iter>(pStrm->u TargetWidth,1032 pStrm->u TargetHeight,1031 if (!colorConvWriteYUV420p<ColorConvBGR565Iter>(pStrm->uDstWidth, 1032 pStrm->uDstHeight, 1033 1033 pStrm->pu8YuvBuf, 1034 1034 pStrm->pu8RgbBuf)) … … 1041 1041 } 1042 1042 1043 int VideoRecSendAudio (PVIDEORECCONTEXT pCtx, const void *pvData, size_t cbData, uint64_t uTimestampMs)1043 int VideoRecSendAudioFrame(PVIDEORECCONTEXT pCtx, const void *pvData, size_t cbData, uint64_t uTimestampMs) 1044 1044 { 1045 1045 RT_NOREF(pCtx, pvData, cbData, uTimestampMs); … … 1061 1061 * @param uBitsPerPixel Bits Per Pixel 1062 1062 * @param uBytesPerLine Bytes per source scanlineName. 1063 * @param uS ourceWidth Width of the source image (framebuffer).1064 * @param uS ourceHeight Height of the source image (framebuffer).1065 * @param pu 8BufAddr Pointer to source image(framebuffer).1063 * @param uSrcWidth Width of the source frame. 1064 * @param uSrcHeight Height of the source frame. 1065 * @param puSrcData Pointer to source frame data. 1066 1066 * @param u64TimeStampMs Time stamp (in ms). 1067 1067 */ 1068 int VideoRec CopyToIntBuf(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint32_t x, uint32_t y,1069 uint32_t uPixelFormat, uint32_t uBitsPerPixel, uint32_t uBytesPerLine,1070 uint32_t uSourceWidth, uint32_t uSourceHeight, uint8_t *pu8BufAddr,1071 uint64_t uTimeStampMs)1068 int VideoRecSendVideoFrame(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint32_t x, uint32_t y, 1069 uint32_t uPixelFormat, uint32_t uBitsPerPixel, uint32_t uBytesPerLine, 1070 uint32_t uSrcWidth, uint32_t uSrcHeight, uint8_t *puSrcData, 1071 uint64_t uTimeStampMs) 1072 1072 { 1073 1073 /* Do not execute during termination and guard against termination */ … … 1078 1078 do 1079 1079 { 1080 AssertPtrBreakStmt(pCtx, 1081 Assert PtrBreakStmt(pu8BufAddr, rc = VERR_INVALID_POINTER);1082 AssertBreakStmt(uS ourceWidth,rc = VERR_INVALID_PARAMETER);1083 Assert BreakStmt(uSourceHeight, rc = VERR_INVALID_PARAMETER);1080 AssertPtrBreakStmt(pCtx, rc = VERR_INVALID_POINTER); 1081 AssertBreakStmt(uSrcWidth, rc = VERR_INVALID_PARAMETER); 1082 AssertBreakStmt(uSrcHeight, rc = VERR_INVALID_PARAMETER); 1083 AssertPtrBreakStmt(puSrcData, rc = VERR_INVALID_POINTER); 1084 1084 1085 1085 PVIDEORECSTREAM pStream = videoRecStreamGet(pCtx, uScreen); … … 1108 1108 pStream->uLastTimeStampMs = uTimeStampMs; 1109 1109 1110 int xDiff = ((int)pStream->u TargetWidth - (int)uSourceWidth) / 2;1111 uint32_t w = uS ourceWidth;1110 int xDiff = ((int)pStream->uDstWidth - (int)uSrcWidth) / 2; 1111 uint32_t w = uSrcWidth; 1112 1112 if ((int)w + xDiff + (int)x <= 0) /* nothing visible */ 1113 1113 { … … 1126 1126 destX = x + xDiff; 1127 1127 1128 uint32_t h = uS ourceHeight;1129 int yDiff = ((int)pStream->u TargetHeight - (int)uSourceHeight) / 2;1128 uint32_t h = uSrcHeight; 1129 int yDiff = ((int)pStream->uDstHeight - (int)uSrcHeight) / 2; 1130 1130 if ((int)h + yDiff + (int)y <= 0) /* nothing visible */ 1131 1131 { … … 1144 1144 destY = y + yDiff; 1145 1145 1146 if ( destX > pStream->u TargetWidth1147 || destY > pStream->u TargetHeight)1146 if ( destX > pStream->uDstWidth 1147 || destY > pStream->uDstHeight) 1148 1148 { 1149 1149 rc = VERR_INVALID_PARAMETER; /* nothing visible */ … … 1151 1151 } 1152 1152 1153 if (destX + w > pStream->u TargetWidth)1154 w = pStream->u TargetWidth - destX;1155 1156 if (destY + h > pStream->u TargetHeight)1157 h = pStream->u TargetHeight - destY;1153 if (destX + w > pStream->uDstWidth) 1154 w = pStream->uDstWidth - destX; 1155 1156 if (destY + h > pStream->uDstHeight) 1157 h = pStream->uDstHeight - destY; 1158 1158 1159 1159 /* Calculate bytes per pixel */ … … 1185 1185 /* One of the dimensions of the current frame is smaller than before so 1186 1186 * clear the entire buffer to prevent artifacts from the previous frame */ 1187 if ( uS ourceWidth < pStream->uLastSourceWidth1188 || uS ourceHeight < pStream->uLastSourceHeight)1189 memset(pStream->pu8RgbBuf, 0, pStream->u TargetWidth * pStream->uTargetHeight * 4);1190 1191 pStream->u LastSourceWidth = uSourceWidth;1192 pStream->u LastSourceHeight = uSourceHeight;1187 if ( uSrcWidth < pStream->uSrcLastWidth 1188 || uSrcHeight < pStream->uSrcLastHeight) 1189 memset(pStream->pu8RgbBuf, 0, pStream->uDstWidth * pStream->uDstHeight * 4); 1190 1191 pStream->uSrcLastWidth = uSrcWidth; 1192 pStream->uSrcLastHeight = uSrcHeight; 1193 1193 1194 1194 /* Calculate start offset in source and destination buffers */ 1195 1195 uint32_t offSrc = y * uBytesPerLine + x * bpp; 1196 uint32_t offDst = (destY * pStream->u TargetWidth + destX) * bpp;1196 uint32_t offDst = (destY * pStream->uDstWidth + destX) * bpp; 1197 1197 /* do the copy */ 1198 1198 for (unsigned int i = 0; i < h; i++) 1199 1199 { 1200 1200 /* Overflow check */ 1201 Assert(offSrc + w * bpp <= uS ourceHeight * uBytesPerLine);1202 Assert(offDst + w * bpp <= pStream->u TargetHeight * pStream->uTargetWidth * bpp);1203 memcpy(pStream->pu8RgbBuf + offDst, pu 8BufAddr+ offSrc, w * bpp);1201 Assert(offSrc + w * bpp <= uSrcHeight * uBytesPerLine); 1202 Assert(offDst + w * bpp <= pStream->uDstHeight * pStream->uDstWidth * bpp); 1203 memcpy(pStream->pu8RgbBuf + offDst, puSrcData + offSrc, w * bpp); 1204 1204 offSrc += uBytesPerLine; 1205 offDst += pStream->u TargetWidth * bpp;1205 offDst += pStream->uDstWidth * bpp; 1206 1206 } 1207 1207 -
trunk/src/VBox/Main/src-client/VideoRec.h
r65410 r65412 33 33 34 34 bool VideoRecIsEnabled(PVIDEORECCONTEXT pCtx); 35 int VideoRecSendAudio (PVIDEORECCONTEXT pCtx, const void *pvData, size_t cbData, uint64_t uTimestampMs);36 int VideoRec CopyToIntBuf(PVIDEORECCONTEXT pCtx, uint32_t uScreen,37 uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBitsPerPixel,38 uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight,39 uint8_t *pu8BufferAddress, uint64_t u64TimeStampMs);35 int VideoRecSendAudioFrame(PVIDEORECCONTEXT pCtx, const void *pvData, size_t cbData, uint64_t uTimestampMs); 36 int VideoRecSendVideoFrame(PVIDEORECCONTEXT pCtx, uint32_t uScreen, 37 uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBitsPerPixel, 38 uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight, 39 uint8_t *pu8BufferAddress, uint64_t u64TimeStampMs); 40 40 bool VideoRecIsReady(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint64_t u64TimeStampMs); 41 41 bool VideoRecLimitReached(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint64_t u64TimeStampMs);
Note:
See TracChangeset
for help on using the changeset viewer.