- Timestamp:
- Oct 25, 2018 12:58:49 PM (6 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/VideoRecStream.h
r75040 r75066 166 166 typedef std::vector <PVIDEORECSTREAM> VideoRecStreams; 167 167 168 int videoRecStreamClose(PVIDEORECSTREAM pStream); 169 PVIDEORECSTREAM videoRecStreamGet(PVIDEORECCONTEXT pCtx, uint32_t uScreen); 170 int videoRecStreamOpen(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg); 168 int VideoRecStreamClose(PVIDEORECSTREAM pStream); 169 int VideoRecStreamOpen(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg); 171 170 int VideoRecStreamProcess(PVIDEORECSTREAM pStream); 172 int videoRecStreamUninit(PVIDEORECSTREAM pStream);173 int videoRecStreamUnitVideo(PVIDEORECSTREAM pStream);174 int videoRecStreamInitVideo(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg);171 int VideoRecStreamUninit(PVIDEORECSTREAM pStream); 172 int VideoRecStreamUnitVideo(PVIDEORECSTREAM pStream); 173 int VideoRecStreamInitVideo(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg); 175 174 #ifdef VBOX_WITH_LIBVPX 176 int videoRecStreamInitVideoVPX(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg);177 int videoRecStreamUninitVideoVPX(PVIDEORECSTREAM pStream);178 int videoRecStreamWriteVideoVPX(PVIDEORECSTREAM pStream, uint64_t uTimeStampMs, PVIDEORECVIDEOFRAME pFrame);175 int VideoRecStreamInitVideoVPX(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg); 176 int VideoRecStreamUninitVideoVPX(PVIDEORECSTREAM pStream); 177 int VideoRecStreamWriteVideoVPX(PVIDEORECSTREAM pStream, uint64_t uTimeStampMs, PVIDEORECVIDEOFRAME pFrame); 179 178 #endif 180 void videoRecStreamLock(PVIDEORECSTREAM pStream);181 void videoRecStreamUnlock(PVIDEORECSTREAM pStream);179 void VideoRecStreamLock(PVIDEORECSTREAM pStream); 180 void VideoRecStreamUnlock(PVIDEORECSTREAM pStream); 182 181 183 182 #endif /* ____H_VIDEOREC_STREAM */ -
trunk/src/VBox/Main/src-client/VideoRec.cpp
r75040 r75066 320 320 PVIDEORECSTREAM pStream = (*it); 321 321 322 videoRecStreamLock(pStream);323 324 int rc2 = videoRecStreamClose(pStream);322 VideoRecStreamLock(pStream); 323 324 int rc2 = VideoRecStreamClose(pStream); 325 325 if (RT_SUCCESS(rc)) 326 326 rc = rc2; 327 327 328 rc2 = videoRecStreamUninit(pStream);328 rc2 = VideoRecStreamUninit(pStream); 329 329 if (RT_SUCCESS(rc)) 330 330 rc = rc2; … … 333 333 it = pCtx->vecStreams.begin(); 334 334 335 videoRecStreamUnlock(pStream);335 VideoRecStreamUnlock(pStream); 336 336 337 337 RTCritSectDelete(&pStream->CritSect); … … 382 382 383 383 /** 384 * Retrieves a specific recording stream of a recording context. 385 * 386 * @returns Pointer to recording stream if found, or NULL if not found. 387 * @param pCtx Recording context to look up stream for. 388 * @param uScreen Screen number of recording stream to look up. 389 */ 390 PVIDEORECSTREAM videoRecGetStream(PVIDEORECCONTEXT pCtx, uint32_t uScreen) 391 { 392 AssertPtrReturn(pCtx, NULL); 393 394 PVIDEORECSTREAM pStream; 395 396 try 397 { 398 pStream = pCtx->vecStreams.at(uScreen); 399 } 400 catch (std::out_of_range &) 401 { 402 pStream = NULL; 403 } 404 405 return pStream; 406 } 407 408 /** 384 409 * Checks if recording engine is ready to accept new recording data for a given screen. 385 410 * … … 399 424 bool fIsReady = false; 400 425 401 PVIDEORECSTREAM pStream = videoRec StreamGet(pCtx, uScreen);426 PVIDEORECSTREAM pStream = videoRecGetStream(pCtx, uScreen); 402 427 if (pStream) 403 428 { 404 videoRecStreamLock(pStream);429 VideoRecStreamLock(pStream); 405 430 fIsReady = pStream->fEnabled; 406 videoRecStreamUnlock(pStream);431 VideoRecStreamUnlock(pStream); 407 432 } 408 433 … … 438 463 bool VideoRecIsLimitReached(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint64_t tsNowMs) 439 464 { 440 PVIDEORECSTREAM pStream = videoRec StreamGet(pCtx, uScreen);465 PVIDEORECSTREAM pStream = videoRecGetStream(pCtx, uScreen); 441 466 if ( !pStream 442 467 || !pStream->fEnabled) … … 583 608 AssertRC(rc); 584 609 585 PVIDEORECSTREAM pStream = videoRec StreamGet(pCtx, uScreen);610 PVIDEORECSTREAM pStream = videoRecGetStream(pCtx, uScreen); 586 611 if (!pStream) 587 612 { … … 592 617 } 593 618 594 videoRecStreamLock(pStream);619 VideoRecStreamLock(pStream); 595 620 596 621 PVIDEORECVIDEOFRAME pFrame = NULL; … … 801 826 VideoRecVideoFrameFree(pFrame); 802 827 803 videoRecStreamUnlock(pStream);828 VideoRecStreamUnlock(pStream); 804 829 805 830 int rc2 = RTCritSectLeave(&pCtx->CritSect); -
trunk/src/VBox/Main/src-client/VideoRecStream.cpp
r75040 r75066 43 43 44 44 /** 45 * Retrieves a specific recording stream of a recording context.46 *47 * @returns Pointer to recording stream if found, or NULL if not found.48 * @param pCtx Recording context to look up stream for.49 * @param uScreen Screen number of recording stream to look up.50 */51 PVIDEORECSTREAM videoRecStreamGet(PVIDEORECCONTEXT pCtx, uint32_t uScreen)52 {53 AssertPtrReturn(pCtx, NULL);54 55 PVIDEORECSTREAM pStream;56 57 try58 {59 pStream = pCtx->vecStreams.at(uScreen);60 }61 catch (std::out_of_range &)62 {63 pStream = NULL;64 }65 66 return pStream;67 }68 69 /**70 45 * Locks a recording stream. 71 46 * 72 47 * @param pStream Recording stream to lock. 73 48 */ 74 void videoRecStreamLock(PVIDEORECSTREAM pStream)49 void VideoRecStreamLock(PVIDEORECSTREAM pStream) 75 50 { 76 51 int rc = RTCritSectEnter(&pStream->CritSect); … … 83 58 * @param pStream Recording stream to unlock. 84 59 */ 85 void videoRecStreamUnlock(PVIDEORECSTREAM pStream)60 void VideoRecStreamUnlock(PVIDEORECSTREAM pStream) 86 61 { 87 62 int rc = RTCritSectLeave(&pStream->CritSect); … … 96 71 * @param pCfg Recording configuration to use. 97 72 */ 98 int videoRecStreamOpen(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg)73 int VideoRecStreamOpen(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg) 99 74 { 100 75 AssertPtrReturn(pStream, VERR_INVALID_POINTER); … … 209 184 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 210 185 211 videoRecStreamLock(pStream);186 VideoRecStreamLock(pStream); 212 187 213 188 if (!pStream->fEnabled) 214 189 { 215 videoRecStreamUnlock(pStream);190 VideoRecStreamUnlock(pStream); 216 191 return VINF_SUCCESS; 217 192 } … … 247 222 if (RT_SUCCESS(rc)) 248 223 { 249 rc = videoRecStreamWriteVideoVPX(pStream, uTimeStampMs, pVideoFrame);224 rc = VideoRecStreamWriteVideoVPX(pStream, uTimeStampMs, pVideoFrame); 250 225 } 251 226 else … … 325 300 #endif 326 301 327 videoRecStreamUnlock(pStream);302 VideoRecStreamUnlock(pStream); 328 303 329 304 return rc; … … 331 306 332 307 /** 333 * VideoRec utility function to initialize video recording context. 334 * 335 * @returns IPRT status code. 336 * @param pCtx Pointer to video recording context. 308 * Initializes a recording stream. 309 * 310 * @returns IPRT status code. 311 * @param pStream Recording stream to initialize. 312 * @param pCtx Recording context to use for initialization. 337 313 * @param uScreen Screen number to record. 338 314 */ 339 int VideoRecStreamInit(PVIDEORECCONTEXT pCtx, uint32_t uScreen) 340 { 341 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 315 int VideoRecStreamInit(PVIDEORECSTREAM pStream, PVIDEORECCONTEXT pCtx, uint32_t uScreen) 316 { 317 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 318 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 342 319 343 320 PVIDEORECCFG pCfg = &pCtx->Cfg; … … 353 330 #endif 354 331 355 PVIDEORECSTREAM pStream = videoRecStreamGet(pCtx, uScreen); 356 if (!pStream) 357 return VERR_NOT_FOUND; 358 359 int rc = videoRecStreamOpen(pStream, pCfg); 332 int rc = VideoRecStreamOpen(pStream, pCfg); 360 333 if (RT_FAILURE(rc)) 361 334 return rc; 362 335 363 pStream->pCtx = pCtx;364 365 336 if (pCfg->Video.fEnabled) 366 rc = videoRecStreamInitVideo(pStream, pCfg);337 rc = VideoRecStreamInitVideo(pStream, pCfg); 367 338 368 339 switch (pStream->enmDst) … … 448 419 if (RT_FAILURE(rc)) 449 420 { 450 int rc2 = videoRecStreamClose(pStream);421 int rc2 = VideoRecStreamClose(pStream); 451 422 AssertRC(rc2); 452 423 return rc; … … 467 438 * 468 439 */ 469 int videoRecStreamClose(PVIDEORECSTREAM pStream)440 int VideoRecStreamClose(PVIDEORECSTREAM pStream) 470 441 { 471 442 int rc = VINF_SUCCESS; … … 548 519 * @param pStream Recording stream to uninitialize. 549 520 */ 550 int videoRecStreamUninit(PVIDEORECSTREAM pStream)521 int VideoRecStreamUninit(PVIDEORECSTREAM pStream) 551 522 { 552 523 int rc = VINF_SUCCESS; … … 554 525 if (pStream->pCtx->Cfg.Video.fEnabled) 555 526 { 556 int rc2 = videoRecStreamUnitVideo(pStream);527 int rc2 = VideoRecStreamUnitVideo(pStream); 557 528 if (RT_SUCCESS(rc)) 558 529 rc = rc2; … … 568 539 * @param pStream Recording stream to uninitialize video recording for. 569 540 */ 570 int videoRecStreamUnitVideo(PVIDEORECSTREAM pStream)541 int VideoRecStreamUnitVideo(PVIDEORECSTREAM pStream) 571 542 { 572 543 #ifdef VBOX_WITH_LIBVPX 573 544 /* At the moment we only have VPX. */ 574 return videoRecStreamUninitVideoVPX(pStream);545 return VideoRecStreamUninitVideoVPX(pStream); 575 546 #else 576 547 return VERR_NOT_SUPPORTED; … … 585 556 * @param pStream Recording stream to uninitialize VPX codec for. 586 557 */ 587 int videoRecStreamUninitVideoVPX(PVIDEORECSTREAM pStream)558 int VideoRecStreamUninitVideoVPX(PVIDEORECSTREAM pStream) 588 559 { 589 560 vpx_img_free(&pStream->Video.Codec.VPX.RawImage); … … 602 573 * @param pCfg Video recording configuration to use for initialization. 603 574 */ 604 int videoRecStreamInitVideo(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg)575 int VideoRecStreamInitVideo(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg) 605 576 { 606 577 #ifdef VBOX_WITH_LIBVPX 607 578 /* At the moment we only have VPX. */ 608 return videoRecStreamInitVideoVPX(pStream, pCfg);579 return VideoRecStreamInitVideoVPX(pStream, pCfg); 609 580 #else 610 581 return VERR_NOT_SUPPORTED; … … 620 591 * @param pCfg Video recording configuration to use for initialization. 621 592 */ 622 int videoRecStreamInitVideoVPX(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg)593 int VideoRecStreamInitVideoVPX(PVIDEORECSTREAM pStream, PVIDEORECCFG pCfg) 623 594 { 624 595 pStream->Video.uWidth = pCfg->Video.uWidth; … … 687 658 * @param pFrame Frame to encode and submit. 688 659 */ 689 int videoRecStreamWriteVideoVPX(PVIDEORECSTREAM pStream, uint64_t uTimeStampMs, PVIDEORECVIDEOFRAME pFrame)660 int VideoRecStreamWriteVideoVPX(PVIDEORECSTREAM pStream, uint64_t uTimeStampMs, PVIDEORECVIDEOFRAME pFrame) 690 661 { 691 662 AssertPtrReturn(pStream, VERR_INVALID_POINTER);
Note:
See TracChangeset
for help on using the changeset viewer.