| 335 | } |
| 336 | |
| 337 | virtual void InitEncode (const GMPVideoCodec& codecSettings, |
| 338 | const uint8_t* aCodecSpecific, |
| 339 | uint32_t aCodecSpecificSize, |
| 340 | GMPVideoEncoderCallback* callback, |
| 341 | int32_t numberOfCores, |
| 342 | uint32_t maxPayloadSize) { |
| 343 | gmp_api_version_ = codecSettings.mGMPApiVersion; |
| 344 | callback_ = callback; |
| 345 | |
| 346 | GMPErr err = g_platform_api->createthread (&worker_thread_); |
| 347 | if (err != GMPNoErr) { |
| 348 | GMPLOG (GL_ERROR, "Couldn't create new thread"); |
| 349 | Error (GMPGenericErr); |
| 350 | return; |
| 351 | } |
| 352 | |
| 353 | int rv = WelsCreateSVCEncoder (&encoder_); |
| 354 | if (rv) { |
| 355 | Error (GMPGenericErr); |
| 356 | return; |
| 357 | } |
| 358 | |
| 359 | if (gmp_api_version_ >= kGMPVersion34) { |
| 360 | uint32_t logLevel = GMPLogLevelToWelsLogLevel(codecSettings.mLogLevel); |
| 361 | long rv = encoder_->SetOption(ENCODER_OPTION_TRACE_LEVEL, &logLevel); |
| 362 | if (rv != cmResultSuccess) { |
| 363 | GMPLOG (GL_ERROR, "Encoder SetOption OPTION_TRACE_LEVEL failed " << rv); |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | SEncParamExt param; |
| 368 | memset (¶m, 0, sizeof (param)); |
| 369 | encoder_->GetDefaultParams (¶m); |
| 370 | |
| 371 | GMPLOG (GL_INFO, "Initializing encoder at " |
| 372 | << codecSettings.mWidth |
| 373 | << "x" |
| 374 | << codecSettings.mHeight |
| 375 | << "@" |
| 376 | << static_cast<int> (codecSettings.mMaxFramerate)); |
| 377 | |
| 378 | // Translate parameters. |
| 379 | if (gmp_api_version_ >= kGMPVersion35) { |
| 380 | param.iUsageType = GMPVideoCodecModeToWelsUsageType(codecSettings.mMode); |
| 381 | } else if (codecSettings.mMode == kGMPScreensharing) { |
| 382 | param.iUsageType = SCREEN_CONTENT_REAL_TIME; |
| 383 | } else { |
| 384 | param.iUsageType = CAMERA_VIDEO_REAL_TIME; |
| 385 | } |
| 386 | param.iPicWidth = codecSettings.mWidth; |
| 387 | param.iPicHeight = codecSettings.mHeight; |
| 388 | if (gmp_api_version_ >= kGMPVersion35) { |
| 389 | param.iRCMode = GMPRateControlModeToWelsRcModes(codecSettings.mRateControlMode); |
| 390 | } else { |
| 391 | param.iRCMode = RC_BITRATE_MODE; |
| 392 | } |
| 393 | param.iTargetBitrate = codecSettings.mStartBitrate * 1000; |
| 394 | param.iMaxBitrate = codecSettings.mMaxBitrate * 1000; |
nothing calls this directly
no test coverage detected