MCPcopy Create free account
hub / github.com/cisco/openh264 / SetRates

Method SetRates

module/gmp-openh264.cpp:492–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490 }
491
492 virtual void SetRates (uint32_t aNewBitRate, uint32_t aFrameRate) {
493 GMPLOG (GL_INFO, "[SetRates] Begin with: "
494 << aNewBitRate << " , " << aFrameRate);
495 //update bitrate if needed
496 const int32_t newBitRate = aNewBitRate * 1000; //kbps->bps
497 SBitrateInfo existEncoderBitRate;
498 existEncoderBitRate.iLayer = SPATIAL_LAYER_ALL;
499 int rv = encoder_->GetOption (ENCODER_OPTION_BITRATE, &existEncoderBitRate);
500 if (rv != cmResultSuccess) {
501 GMPLOG (GL_ERROR, "[SetRates] Error in Getting Bit Rate at Layer:"
502 << rv
503 << " ; Layer = "
504 << existEncoderBitRate.iLayer
505 << " ; BR = "
506 << existEncoderBitRate.iBitrate);
507 Error (GMPGenericErr);
508 return;
509 }
510 if (rv == cmResultSuccess && existEncoderBitRate.iBitrate != newBitRate) {
511 SBitrateInfo newEncoderBitRate;
512 newEncoderBitRate.iLayer = SPATIAL_LAYER_ALL;
513 newEncoderBitRate.iBitrate = newBitRate;
514 rv = encoder_->SetOption (ENCODER_OPTION_BITRATE, &newEncoderBitRate);
515 if (rv == cmResultSuccess) {
516 GMPLOG (GL_INFO, "[SetRates] Update Encoder Bandwidth (AllLayers): ReturnValue: "
517 << rv
518 << "BitRate(kbps): "
519 << aNewBitRate);
520 } else {
521 GMPLOG (GL_ERROR, "[SetRates] Error in Setting Bit Rate at Layer:"
522 << rv
523 << " ; Layer = "
524 << newEncoderBitRate.iLayer
525 << " ; BR = "
526 << newEncoderBitRate.iBitrate);
527 Error (GMPGenericErr);
528 return;
529 }
530 }
531 //update framerate if needed
532 float existFrameRate = 0;
533 rv = encoder_->GetOption (ENCODER_OPTION_FRAME_RATE, &existFrameRate);
534 if (rv != cmResultSuccess) {
535 GMPLOG (GL_ERROR, "[SetRates] Error in Getting Frame Rate:"
536 << rv << " FrameRate: " << existFrameRate);
537 Error (GMPGenericErr);
538 return;
539 }
540 if (rv == cmResultSuccess &&
541 (aFrameRate - existFrameRate > 0.001f ||
542 existFrameRate - aFrameRate > 0.001f)) {
543 float newFrameRate = static_cast<float> (aFrameRate);
544 rv = encoder_->SetOption (ENCODER_OPTION_FRAME_RATE, &newFrameRate);
545 if (rv == cmResultSuccess) {
546 GMPLOG (GL_INFO, "[SetRates] Update Encoder Frame Rate: ReturnValue: "
547 << rv << " FrameRate: " << aFrameRate);
548 } else {
549 GMPLOG (GL_ERROR, "[SetRates] Error in Setting Frame Rate: ReturnValue: "

Callers

nothing calls this directly

Calls 2

GetOptionMethod · 0.45
SetOptionMethod · 0.45

Tested by

no test coverage detected