| 601 | } |
| 602 | |
| 603 | void Encode_w (GMPVideoi420Frame* inputImage, |
| 604 | GMPVideoFrameType frame_type) { |
| 605 | SFrameBSInfo encoded; |
| 606 | |
| 607 | if (frame_type == kGMPKeyFrame) { |
| 608 | encoder_->ForceIntraFrame (true); |
| 609 | if (!inputImage) |
| 610 | return; |
| 611 | } |
| 612 | if (!inputImage) { |
| 613 | GMPLOG (GL_ERROR, "no input image"); |
| 614 | return; |
| 615 | } |
| 616 | SSourcePicture src; |
| 617 | |
| 618 | src.iColorFormat = videoFormatI420; |
| 619 | src.iStride[0] = inputImage->Stride (kGMPYPlane); |
| 620 | src.pData[0] = reinterpret_cast<unsigned char*> ( |
| 621 | const_cast<uint8_t*> (inputImage->Buffer (kGMPYPlane))); |
| 622 | src.iStride[1] = inputImage->Stride (kGMPUPlane); |
| 623 | src.pData[1] = reinterpret_cast<unsigned char*> ( |
| 624 | const_cast<uint8_t*> (inputImage->Buffer (kGMPUPlane))); |
| 625 | src.iStride[2] = inputImage->Stride (kGMPVPlane); |
| 626 | src.pData[2] = reinterpret_cast<unsigned char*> ( |
| 627 | const_cast<uint8_t*> (inputImage->Buffer (kGMPVPlane))); |
| 628 | src.iStride[3] = 0; |
| 629 | src.pData[3] = nullptr; |
| 630 | src.iPicWidth = inputImage->Width(); |
| 631 | src.iPicHeight = inputImage->Height(); |
| 632 | src.uiTimeStamp = inputImage->Timestamp() / 1000; //encoder needs millisecond |
| 633 | const SSourcePicture* pics = &src; |
| 634 | |
| 635 | int result = encoder_->EncodeFrame (pics, &encoded); |
| 636 | if (result != cmResultSuccess) { |
| 637 | GMPLOG (GL_ERROR, "Couldn't encode frame. Error = " << result); |
| 638 | } |
| 639 | |
| 640 | |
| 641 | // Translate int to enum |
| 642 | GMPVideoFrameType encoded_type; |
| 643 | bool has_frame = false; |
| 644 | |
| 645 | switch (encoded.eFrameType) { |
| 646 | case videoFrameTypeIDR: |
| 647 | encoded_type = kGMPKeyFrame; |
| 648 | has_frame = true; |
| 649 | break; |
| 650 | case videoFrameTypeI: |
| 651 | encoded_type = kGMPKeyFrame; |
| 652 | has_frame = true; |
| 653 | break; |
| 654 | case videoFrameTypeP: |
| 655 | encoded_type = kGMPDeltaFrame; |
| 656 | has_frame = true; |
| 657 | break; |
| 658 | case videoFrameTypeSkip: |
| 659 | // Can skip the call back since no actual bitstream will be generated |
| 660 | break; |
nothing calls this directly
no test coverage detected