1 /** 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License") { 5 } 6 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #include <VideoConfig.h> 20 21 namespace android 22 { 23 24 namespace telephony 25 { 26 27 namespace imsmedia 28 { 29 VideoConfig()30VideoConfig::VideoConfig() : 31 RtpConfig(RtpConfig::TYPE_VIDEO) 32 { 33 videoMode = CODEC_PROFILE_NONE; 34 codecType = CODEC_AVC; 35 framerate = DEFAULT_FRAMERATE; 36 bitrate = DEFAULT_BITRATE; 37 maxMtuBytes = 1500; 38 codecProfile = CODEC_PROFILE_NONE; 39 codecLevel = CODEC_LEVEL_NONE; 40 intraFrameIntervalSec = 1; 41 packetizationMode = 1; 42 cameraId = 0; 43 cameraZoom = 0; 44 resolutionWidth = DEFAULT_RESOLUTION_WIDTH; 45 resolutionHeight = DEFAULT_RESOLUTION_HEIGHT; 46 pauseImagePath = String8(""); 47 deviceOrientationDegree = 0; 48 cvoValue = CVO_DEFINE_NONE; 49 rtcpFbTypes = RTP_FB_NONE; 50 } 51 VideoConfig(VideoConfig * config)52VideoConfig::VideoConfig(VideoConfig* config) : 53 RtpConfig(config) 54 { 55 if (config == nullptr) 56 return; 57 videoMode = config->videoMode; 58 codecType = config->codecType; 59 framerate = config->framerate; 60 bitrate = config->bitrate; 61 maxMtuBytes = config->maxMtuBytes; 62 codecProfile = config->codecProfile; 63 codecLevel = config->codecLevel; 64 intraFrameIntervalSec = config->intraFrameIntervalSec; 65 packetizationMode = config->packetizationMode; 66 cameraId = config->cameraId; 67 cameraZoom = config->cameraZoom; 68 resolutionWidth = config->resolutionWidth; 69 resolutionHeight = config->resolutionHeight; 70 pauseImagePath = config->pauseImagePath; 71 deviceOrientationDegree = config->deviceOrientationDegree; 72 cvoValue = config->cvoValue; 73 rtcpFbTypes = config->rtcpFbTypes; 74 } 75 VideoConfig(const VideoConfig & config)76VideoConfig::VideoConfig(const VideoConfig& config) : 77 RtpConfig(config) 78 { 79 videoMode = config.videoMode; 80 codecType = config.codecType; 81 framerate = config.framerate; 82 bitrate = config.bitrate; 83 maxMtuBytes = config.maxMtuBytes; 84 codecProfile = config.codecProfile; 85 codecLevel = config.codecLevel; 86 intraFrameIntervalSec = config.intraFrameIntervalSec; 87 packetizationMode = config.packetizationMode; 88 cameraId = config.cameraId; 89 cameraZoom = config.cameraZoom; 90 resolutionWidth = config.resolutionWidth; 91 resolutionHeight = config.resolutionHeight; 92 pauseImagePath = config.pauseImagePath; 93 deviceOrientationDegree = config.deviceOrientationDegree; 94 cvoValue = config.cvoValue; 95 rtcpFbTypes = config.rtcpFbTypes; 96 } 97 ~VideoConfig()98VideoConfig::~VideoConfig() {} 99 operator =(const VideoConfig & config)100VideoConfig& VideoConfig::operator=(const VideoConfig& config) 101 { 102 if (this != &config) 103 { 104 RtpConfig::operator=(config); 105 videoMode = config.videoMode; 106 codecType = config.codecType; 107 framerate = config.framerate; 108 bitrate = config.bitrate; 109 maxMtuBytes = config.maxMtuBytes; 110 codecProfile = config.codecProfile; 111 codecLevel = config.codecLevel; 112 intraFrameIntervalSec = config.intraFrameIntervalSec; 113 packetizationMode = config.packetizationMode; 114 cameraId = config.cameraId; 115 cameraZoom = config.cameraZoom; 116 resolutionWidth = config.resolutionWidth; 117 resolutionHeight = config.resolutionHeight; 118 pauseImagePath = config.pauseImagePath; 119 deviceOrientationDegree = config.deviceOrientationDegree; 120 cvoValue = config.cvoValue; 121 rtcpFbTypes = config.rtcpFbTypes; 122 } 123 return *this; 124 } 125 operator ==(const VideoConfig & config) const126bool VideoConfig::operator==(const VideoConfig& config) const 127 { 128 return (RtpConfig::operator==(config) && this->videoMode == config.videoMode && 129 this->codecType == config.codecType && this->framerate == config.framerate && 130 this->bitrate == config.bitrate && this->maxMtuBytes == config.maxMtuBytes && 131 this->codecProfile == config.codecProfile && this->codecLevel == config.codecLevel && 132 this->intraFrameIntervalSec == config.intraFrameIntervalSec && 133 this->packetizationMode == config.packetizationMode && 134 this->cameraId == config.cameraId && this->cameraZoom == config.cameraZoom && 135 this->resolutionWidth == config.resolutionWidth && 136 this->resolutionHeight == config.resolutionHeight && 137 this->pauseImagePath == config.pauseImagePath && 138 this->deviceOrientationDegree == config.deviceOrientationDegree && 139 this->cvoValue == config.cvoValue && this->rtcpFbTypes == config.rtcpFbTypes); 140 } 141 operator !=(const VideoConfig & config) const142bool VideoConfig::operator!=(const VideoConfig& config) const 143 { 144 return (RtpConfig::operator!=(config) || this->videoMode != config.videoMode || 145 this->codecType != config.codecType || this->framerate != config.framerate || 146 this->bitrate != config.bitrate || this->maxMtuBytes != config.maxMtuBytes || 147 this->codecProfile != config.codecProfile || this->codecLevel != config.codecLevel || 148 this->intraFrameIntervalSec != config.intraFrameIntervalSec || 149 this->packetizationMode != config.packetizationMode || 150 this->cameraId != config.cameraId || this->cameraZoom != config.cameraZoom || 151 this->resolutionWidth != config.resolutionWidth || 152 this->resolutionHeight != config.resolutionHeight || 153 this->pauseImagePath != config.pauseImagePath || 154 this->deviceOrientationDegree != config.deviceOrientationDegree || 155 this->cvoValue != config.cvoValue || this->rtcpFbTypes != config.rtcpFbTypes); 156 } 157 writeToParcel(Parcel * out) const158status_t VideoConfig::writeToParcel(Parcel* out) const 159 { 160 status_t err; 161 if (out == nullptr) 162 { 163 return BAD_VALUE; 164 } 165 166 err = RtpConfig::writeToParcel(out); 167 if (err != NO_ERROR) 168 { 169 return err; 170 } 171 172 err = out->writeInt32(videoMode); 173 if (err != NO_ERROR) 174 { 175 return err; 176 } 177 178 err = out->writeInt32(codecType); 179 if (err != NO_ERROR) 180 { 181 return err; 182 } 183 184 err = out->writeInt32(framerate); 185 if (err != NO_ERROR) 186 { 187 return err; 188 } 189 190 err = out->writeInt32(bitrate); 191 if (err != NO_ERROR) 192 { 193 return err; 194 } 195 196 err = out->writeInt32(maxMtuBytes); 197 if (err != NO_ERROR) 198 { 199 return err; 200 } 201 err = out->writeInt32(codecProfile); 202 if (err != NO_ERROR) 203 { 204 return err; 205 } 206 207 err = out->writeInt32(codecLevel); 208 if (err != NO_ERROR) 209 { 210 return err; 211 } 212 213 err = out->writeInt32(intraFrameIntervalSec); 214 if (err != NO_ERROR) 215 { 216 return err; 217 } 218 219 err = out->writeInt32(packetizationMode); 220 if (err != NO_ERROR) 221 { 222 return err; 223 } 224 225 err = out->writeInt32(cameraId); 226 if (err != NO_ERROR) 227 { 228 return err; 229 } 230 231 err = out->writeInt32(cameraZoom); 232 if (err != NO_ERROR) 233 { 234 return err; 235 } 236 237 err = out->writeInt32(resolutionWidth); 238 if (err != NO_ERROR) 239 { 240 return err; 241 } 242 243 err = out->writeInt32(resolutionHeight); 244 if (err != NO_ERROR) 245 { 246 return err; 247 } 248 249 String16 name(pauseImagePath); 250 err = out->writeString16(name); 251 if (err != NO_ERROR) 252 { 253 return err; 254 } 255 256 err = out->writeInt32(deviceOrientationDegree); 257 if (err != NO_ERROR) 258 { 259 return err; 260 } 261 262 err = out->writeInt32(cvoValue); 263 if (err != NO_ERROR) 264 { 265 return err; 266 } 267 268 err = out->writeInt32(rtcpFbTypes); 269 if (err != NO_ERROR) 270 { 271 return err; 272 } 273 274 return NO_ERROR; 275 } 276 readFromParcel(const Parcel * in)277status_t VideoConfig::readFromParcel(const Parcel* in) 278 { 279 status_t err; 280 if (in == nullptr) 281 { 282 return BAD_VALUE; 283 } 284 285 err = RtpConfig::readFromParcel(in); 286 if (err != NO_ERROR) 287 { 288 return err; 289 } 290 291 err = in->readInt32(&videoMode); 292 if (err != NO_ERROR) 293 { 294 return err; 295 } 296 297 err = in->readInt32(&codecType); 298 if (err != NO_ERROR) 299 { 300 return err; 301 } 302 303 err = in->readInt32(&framerate); 304 if (err != NO_ERROR) 305 { 306 return err; 307 } 308 309 err = in->readInt32(&bitrate); 310 if (err != NO_ERROR) 311 { 312 return err; 313 } 314 315 err = in->readInt32(&maxMtuBytes); 316 if (err != NO_ERROR) 317 { 318 return err; 319 } 320 321 err = in->readInt32(&codecProfile); 322 if (err != NO_ERROR) 323 { 324 return err; 325 } 326 327 err = in->readInt32(&codecLevel); 328 if (err != NO_ERROR) 329 { 330 return err; 331 } 332 333 err = in->readInt32(&intraFrameIntervalSec); 334 if (err != NO_ERROR) 335 { 336 return err; 337 } 338 339 err = in->readInt32(&packetizationMode); 340 if (err != NO_ERROR) 341 { 342 return err; 343 } 344 345 err = in->readInt32(&cameraId); 346 if (err != NO_ERROR) 347 { 348 return err; 349 } 350 351 err = in->readInt32(&cameraZoom); 352 if (err != NO_ERROR) 353 { 354 return err; 355 } 356 357 err = in->readInt32(&resolutionWidth); 358 if (err != NO_ERROR) 359 { 360 return err; 361 } 362 363 err = in->readInt32(&resolutionHeight); 364 if (err != NO_ERROR) 365 { 366 return err; 367 } 368 369 String16 path; 370 err = in->readString16(&path); 371 if (err != NO_ERROR) 372 { 373 return err; 374 } 375 376 pauseImagePath = String8(path.c_str()); 377 378 err = in->readInt32(&deviceOrientationDegree); 379 if (err != NO_ERROR) 380 { 381 return err; 382 } 383 384 err = in->readInt32(&cvoValue); 385 if (err != NO_ERROR) 386 { 387 return err; 388 } 389 390 err = in->readInt32(&rtcpFbTypes); 391 if (err != NO_ERROR) 392 { 393 return err; 394 } 395 396 return NO_ERROR; 397 } 398 setVideoMode(const int32_t mode)399void VideoConfig::setVideoMode(const int32_t mode) 400 { 401 videoMode = mode; 402 } 403 getVideoMode()404int32_t VideoConfig::getVideoMode() 405 { 406 return videoMode; 407 } 408 setCodecType(const int32_t type)409void VideoConfig::setCodecType(const int32_t type) 410 { 411 codecType = type; 412 } 413 getCodecType()414int32_t VideoConfig::getCodecType() 415 { 416 return codecType; 417 } 418 setFramerate(const int32_t framerate)419void VideoConfig::setFramerate(const int32_t framerate) 420 { 421 this->framerate = framerate; 422 } 423 getFramerate()424int32_t VideoConfig::getFramerate() 425 { 426 return framerate; 427 } 428 setBitrate(const int32_t bitrate)429void VideoConfig::setBitrate(const int32_t bitrate) 430 { 431 this->bitrate = bitrate; 432 } 433 getBitrate()434int32_t VideoConfig::getBitrate() 435 { 436 return bitrate; 437 } 438 setMaxMtuBytes(const int32_t mtuBytes)439void VideoConfig::setMaxMtuBytes(const int32_t mtuBytes) 440 { 441 maxMtuBytes = mtuBytes; 442 } 443 getMaxMtuBytes()444int32_t VideoConfig::getMaxMtuBytes() 445 { 446 return maxMtuBytes; 447 } 448 setCodecProfile(const int32_t profile)449void VideoConfig::setCodecProfile(const int32_t profile) 450 { 451 codecProfile = profile; 452 } 453 getCodecProfile()454int32_t VideoConfig::getCodecProfile() 455 { 456 return codecProfile; 457 } 458 setCodecLevel(const int32_t level)459void VideoConfig::setCodecLevel(const int32_t level) 460 { 461 codecLevel = level; 462 } 463 getCodecLevel()464int32_t VideoConfig::getCodecLevel() 465 { 466 return codecLevel; 467 } 468 setIntraFrameInterval(const int32_t interval)469void VideoConfig::setIntraFrameInterval(const int32_t interval) 470 { 471 intraFrameIntervalSec = interval; 472 } 473 getIntraFrameInterval()474int32_t VideoConfig::getIntraFrameInterval() 475 { 476 return intraFrameIntervalSec; 477 } 478 setPacketizationMode(const int32_t mode)479void VideoConfig::setPacketizationMode(const int32_t mode) 480 { 481 packetizationMode = mode; 482 } 483 getPacketizationMode()484int32_t VideoConfig::getPacketizationMode() 485 { 486 return packetizationMode; 487 } 488 setCameraId(const int32_t id)489void VideoConfig::setCameraId(const int32_t id) 490 { 491 cameraId = id; 492 } 493 getCameraId()494int32_t VideoConfig::getCameraId() 495 { 496 return cameraId; 497 } 498 setCameraZoom(const int32_t zoom)499void VideoConfig::setCameraZoom(const int32_t zoom) 500 { 501 cameraZoom = zoom; 502 } 503 getCameraZoom()504int32_t VideoConfig::getCameraZoom() 505 { 506 return cameraZoom; 507 } 508 setResolutionWidth(const int32_t width)509void VideoConfig::setResolutionWidth(const int32_t width) 510 { 511 resolutionWidth = width; 512 } 513 getResolutionWidth()514int32_t VideoConfig::getResolutionWidth() 515 { 516 return resolutionWidth; 517 } 518 setResolutionHeight(const int32_t height)519void VideoConfig::setResolutionHeight(const int32_t height) 520 { 521 resolutionHeight = height; 522 } 523 getResolutionHeight()524int32_t VideoConfig::getResolutionHeight() 525 { 526 return resolutionHeight; 527 } 528 setPauseImagePath(const android::String8 & path)529void VideoConfig::setPauseImagePath(const android::String8& path) 530 { 531 pauseImagePath = path; 532 } 533 getPauseImagePath()534android::String8 VideoConfig::getPauseImagePath() 535 { 536 return pauseImagePath; 537 } 538 setDeviceOrientationDegree(const int32_t degree)539void VideoConfig::setDeviceOrientationDegree(const int32_t degree) 540 { 541 deviceOrientationDegree = degree; 542 } 543 getDeviceOrientationDegree()544int32_t VideoConfig::getDeviceOrientationDegree() 545 { 546 return deviceOrientationDegree; 547 } 548 setCvoValue(const int32_t value)549void VideoConfig::setCvoValue(const int32_t value) 550 { 551 cvoValue = value; 552 } 553 getCvoValue()554int32_t VideoConfig::getCvoValue() 555 { 556 return cvoValue; 557 } 558 setRtcpFbType(const int32_t types)559void VideoConfig::setRtcpFbType(const int32_t types) 560 { 561 rtcpFbTypes = types; 562 } 563 getRtcpFbType()564int32_t VideoConfig::getRtcpFbType() 565 { 566 return rtcpFbTypes; 567 } 568 569 } // namespace imsmedia 570 571 } // namespace telephony 572 573 } // namespace android 574