1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 #include "tsc_capability.h" 19 20 #include "tsc_statemanager.h" 21 #include "tsc_component.h" 22 23 void TSC_capability::InitVarsSession() 24 { 25 iTcsIn_H263_sqcifMPI = 0; // Units 1/30 second 26 iTcsIn_H263_qcifMPI = 2; // Units 1/30 second 27 iTcsIn_H263_cifMPI = 0; // Units 1/30 second 28 iTcsIn_H263_4cifMPI = 0; // Units 1/30 second 29 iTcsIn_H263_16cifMPI = 0; // Units 1/30 second 30 } 31 32 void TSC_capability::InitVarsLocal() 33 { 34 /* Initialize video resolutions */ 35 PVMFVideoResolutionRange qcif_range(PVMF_RESOLUTION_QCIF, PVMF_RESOLUTION_QCIF); 36 iResolutionsRx.push_back(qcif_range); 37 iResolutionsTx.push_back(qcif_range); 38 } 39 void TSC_capability::ResetCapability() 40 { 41 if (iRemoteCapability) 42 { 43 delete iRemoteCapability; 44 iRemoteCapability = NULL; 45 } 46 } 47 48 TSC_capability::~TSC_capability() 49 { 50 ResetCapability(); 51 } 52 53 Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator> 54 TSC_capability::GetResolutions(TPVDirection dir) 55 { 56 if (dir == OUTGOING) 57 { 58 return iResolutionsTx; 59 } 60 return iResolutionsRx; 61 } 62 63 void TSC_capability::SetVideoResolutions(TPVDirection dir, 64 Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator>& resolutions) 65 { 66 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 67 (0, "TSC_capability::SetVideoResolutions dir(%d), size(%d)", dir, resolutions.size())); 68 if (dir == OUTGOING) 69 { 70 iResolutionsTx = resolutions; 71 } 72 else if (dir == INCOMING) 73 { 74 iResolutionsRx = resolutions; 75 } 76 } 77 78 79 uint32 TSC_capability::GetRemoteBitrate(PVCodecType_t codec_type) 80 { 81 /* lookup the bitrate from remote capabilities */ 82 for (uint16 i = 0; i < iRemoteCapability->GetNumCapabilityItems(); i++) 83 { 84 if (iRemoteCapability->GetCapabilityItem(i)->GetFormatType() == PVCodecTypeToPVMFFormatType(codec_type)) 85 { 86 uint32 br = iRemoteCapability->GetCapabilityItem(i)->GetBitrate(); 87 return br; 88 } 89 } 90 return 0; 91 } 92 93 void TSC_capability::ExtractTcsParameters(PS_VideoCapability pVideo, CPvtH263Capability *aMedia_capability) 94 { 95 int frame_rate = GetMaxFrameRate_H263(pVideo->h263VideoCapability); 96 if (pVideo->h263VideoCapability->option_of_sqcifMPI) 97 { 98 iTcsIn_H263_sqcifMPI = pVideo->h263VideoCapability->sqcifMPI; 99 aMedia_capability->SetMaxResolution(128, 96, frame_rate); 100 101 } 102 if (pVideo->h263VideoCapability->option_of_qcifMPI) 103 { 104 iTcsIn_H263_qcifMPI = pVideo->h263VideoCapability->qcifMPI; 105 aMedia_capability->SetMaxResolution(176, 144, frame_rate); 106 } 107 if (pVideo->h263VideoCapability->option_of_cifMPI) 108 { 109 iTcsIn_H263_cifMPI = pVideo->h263VideoCapability->cifMPI; 110 aMedia_capability->SetMaxResolution(352, 288, frame_rate); 111 } 112 if (pVideo->h263VideoCapability->option_of_cif4MPI) 113 { 114 iTcsIn_H263_4cifMPI = pVideo->h263VideoCapability->cif4MPI; 115 aMedia_capability->SetMaxResolution(704, 576, frame_rate); 116 } 117 if (pVideo->h263VideoCapability->option_of_cif16MPI) 118 { 119 iTcsIn_H263_16cifMPI = pVideo->h263VideoCapability->cif16MPI; 120 aMedia_capability->SetMaxResolution(1408, 1192, frame_rate); 121 } 122 } 123 124 void TSC_capability::ExtractTcsParameters(PS_VideoCapability pVideo, CPvtMpeg4Capability *aMedia_capability) 125 { 126 int frame_rate = GetMaxFrameRate_M4V(pVideo->genericVideoCapability); 127 aMedia_capability->SetMaxResolution(176, 144, frame_rate); 128 } 129 130 //////////////////////////////////////////////////////////////////////////// 131 // ParseTcsCapabilities() 132 // 133 // This routine takes the incoming TerminalCapability 134 // and parsed all capabilities - Audio, Video, UserInput. 135 // 136 //////////////////////////////////////////////////////////////////////////// 137 138 void TSC_capability::ParseTcsCapabilities(S_Capability &aCapability, Oscl_Vector<CPvtMediaCapability*, OsclMemAllocator> &aMedia_capability, uint32 aUserInputCapabilities, S_UserInputCapability *aUserInputCapability) 139 { 140 CodecCapabilityInfo codec_info; 141 PS_VideoCapability pVideo = NULL; 142 PS_AudioCapability pAudio = NULL; 143 PVMFFormatType format_type = PVMF_MIME_FORMAT_UNKNOWN; 144 145 pVideo = NULL; 146 pAudio = NULL; 147 switch (aCapability.index) 148 { 149 case 1: // ReceiveVideo 150 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 151 (0, "TSC_capability: Remote video caps ReceiveVideo\n")); 152 pVideo = aCapability.receiveVideoCapability; 153 break; 154 case 3: // ReceiveAndTransmitVideo 155 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 156 (0, "TSC_capability: Remote video caps ReceiveAndTransmitVideo\n")); 157 pVideo = aCapability.receiveAndTransmitVideoCapability; 158 break; 159 case 4: 160 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 161 (0, "TSC_capability: Remote video caps ReceiveAudio\n")); 162 pAudio = aCapability.receiveAudioCapability; 163 break; 164 case 6: 165 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 166 (0, "TSC_capability: Remote video caps ReceiveAndTransmitAudio\n")); 167 pAudio = aCapability.receiveAndTransmitAudioCapability; 168 break; 169 case 15: 170 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 171 (0, "TSC_capability: Remote caps receiveUserInputCapability")); 172 aUserInputCapability = aCapability.receiveUserInputCapability; 173 break; 174 case 17: 175 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 176 (0, "TSC_capability: Remote caps receiveAndTransmitUserInputCapability")); 177 aUserInputCapability = aCapability.receiveAndTransmitUserInputCapability; 178 break; 179 default: 180 return; 181 } 182 GetCodecInfo(&aCapability, codec_info); 183 if (codec_info.codec == PV_CODEC_TYPE_NONE) 184 return; 185 format_type = PVCodecTypeToPVMFFormatType(codec_info.codec); 186 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 187 (0, "TSC_capability::ParseTcsCapabilities CapabilityTable codec=%d,format=%s", 188 codec_info.codec, format_type.getMIMEStrPtr())); 189 CPvtMediaCapability* media_capability = NULL; 190 191 if (pVideo) 192 { 193 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 194 (0, "TSC_capability::ParseTcsCapabilities Remote video caps Video index(%d)\n", 195 pVideo->index)); 196 if (format_type == PVMF_MIME_H2632000) // H263VideoCapability 197 { 198 pVideo->index = 3; 199 media_capability = new CPvtH263Capability(); 200 201 media_capability->iBitrate = pVideo->h263VideoCapability->maxBitRate; 202 // Extract H263 Parameters 203 ExtractTcsParameters(pVideo, (CPvtH263Capability*)media_capability); 204 ((CPvtH263Capability *)media_capability)->iH263VideoCapability = pVideo->h263VideoCapability; 205 aMedia_capability.push_back(media_capability); 206 207 } 208 else if (format_type == PVMF_MIME_M4V) 209 { 210 211 media_capability = new CPvtMpeg4Capability(); 212 media_capability->iBitrate = pVideo->genericVideoCapability->maxBitRate; 213 ExtractTcsParameters(pVideo, (CPvtMpeg4Capability*)media_capability); 214 ((CPvtMpeg4Capability*)media_capability)->iGenericCapability = pVideo->genericVideoCapability; 215 aMedia_capability.push_back(media_capability); 216 } 217 } 218 else if (pAudio) 219 { 220 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 221 (0, "TSC_capability: Remote caps Audio index(%d)\n", pAudio->index)); 222 if (pAudio->index == 8) 223 { 224 media_capability = new CPvtAudioCapability(format_type); 225 aMedia_capability.push_back(media_capability); 226 media_capability->iBitrate = 64; 227 } 228 else if (pAudio->index == 20) 229 { 230 media_capability = new CPvtAudioCapability(format_type); 231 aMedia_capability.push_back(media_capability); 232 media_capability->iBitrate = pAudio->genericAudioCapability->maxBitRate; 233 } 234 } 235 else if (aUserInputCapability) 236 { 237 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 238 (0, "TSC_capability: Remote caps UI index(%d)\n", 239 aUserInputCapability->index)); 240 aUserInputCapabilities |= (1 << aUserInputCapability->index); 241 } 242 243 244 } 245 246 PS_DataType TSC_capability::GetOutgoingDataType(PVCodecType_t codecType, 247 uint32 bitrate, 248 uint16 csi_len, 249 uint8* csi) 250 { 251 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 252 (0, "TSC_capability::GetOutgoingDataType - codecType(%d), bitrate(%d)", codecType, bitrate)); 253 254 PS_DataType pDataType = (PS_DataType) OSCL_DEFAULT_MALLOC(sizeof(S_DataType)); 255 oscl_memset(pDataType, 0, sizeof(S_DataType)); 256 PS_GenericCapability genericCap = NULL; 257 uint16 index = 0; 258 259 /* lookup the bitrate from remote capabilities */ 260 for (index = 0; index < iRemoteCapability->GetNumCapabilityItems(); index++) 261 { 262 if (iRemoteCapability->GetCapabilityItem(index)->GetFormatType() == 263 PVCodecTypeToPVMFFormatType(codecType)) 264 { 265 bitrate = iRemoteCapability->GetCapabilityItem(index)->GetBitrate(); 266 break; 267 268 } 269 } 270 switch (codecType) 271 { 272 case PV_AUD_TYPE_G723: /* WWURM: change H324_AUDIO_RECV to H324_AUDIO_SEND */ 273 /* (LCN=2): G723 Audio */ 274 PS_G7231 g723Cap; 275 pDataType->index = 3; 276 /* NEW245: allocate memory for audioData*/ 277 pDataType->audioData = (PS_AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability)); 278 pDataType->audioData->index = 8; 279 /* NEW245: allocate memory for g7231 */ 280 pDataType->audioData->g7231 = 281 g723Cap = 282 (PS_G7231) OSCL_DEFAULT_MALLOC(sizeof(S_G7231)); 283 g723Cap->maxAl_sduAudioFrames = 1; 284 g723Cap->silenceSuppression = false; 285 break; 286 case PV_AUD_TYPE_GSM: 287 /* (LCN=2): Amr Audio */ 288 pDataType->index = 3; 289 /* NEW245: allocate memory for audioData */ 290 pDataType->audioData = (PS_AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability)); 291 pDataType->audioData->index = 20; 292 /* NEW245: allocate memory for genericAudioCapability */ 293 pDataType->audioData->genericAudioCapability = 294 genericCap = 295 (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability)); 296 genericCap->capabilityIdentifier.index = 0; 297 /* NEW245: allocate memory for standard */ 298 genericCap->capabilityIdentifier.standard = (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT)); 299 genericCap->capabilityIdentifier.standard->size = 7; 300 genericCap->capabilityIdentifier.standard->data = (uint8*) OSCL_DEFAULT_MALLOC(7 * sizeof(uint8)); 301 genericCap->capabilityIdentifier.standard->data[0] = 0x00; 302 genericCap->capabilityIdentifier.standard->data[1] = 0x08; 303 genericCap->capabilityIdentifier.standard->data[2] = 0x81; 304 genericCap->capabilityIdentifier.standard->data[3] = 0x75; 305 genericCap->capabilityIdentifier.standard->data[4] = 0x01; 306 genericCap->capabilityIdentifier.standard->data[5] = 0x01; 307 genericCap->capabilityIdentifier.standard->data[6] = 0x01; 308 genericCap->option_of_maxBitRate = true; 309 genericCap->maxBitRate = bitrate; 310 genericCap->option_of_collapsing = true; 311 genericCap->size_of_collapsing = 1; 312 genericCap->collapsing = (PS_GenericParameter) OSCL_DEFAULT_MALLOC(1 * sizeof(S_GenericParameter)); 313 genericCap->collapsing[0].parameterIdentifier.index = 0; 314 genericCap->collapsing[0].parameterIdentifier.standard = 0; 315 genericCap->collapsing[0].parameterValue.index = 2; 316 genericCap->collapsing[0].parameterValue.unsignedMin = 1; 317 genericCap->collapsing[0].option_of_supersedes = false; 318 319 genericCap->option_of_nonCollapsing = false; 320 genericCap->option_of_nonCollapsingRaw = false; 321 genericCap->option_of_transport = false; 322 break; 323 case PV_VID_TYPE_H263: 324 /* (LCN=3): H263 Video */ 325 PS_H263VideoCapability h263VideoCap; 326 pDataType->index = 2; 327 /* NEW245: allocate memory for videoData */ 328 pDataType->videoData = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability)); 329 oscl_memset(pDataType->videoData, 0, sizeof(S_VideoCapability)); 330 pDataType->videoData->index = 3; 331 /* NEW245: allocate memory for h263VideoCapability */ 332 pDataType->videoData->h263VideoCapability = 333 h263VideoCap = 334 (PS_H263VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_H263VideoCapability)); 335 oscl_memset(pDataType->videoData->h263VideoCapability, 0, sizeof(S_H263VideoCapability)); 336 337 if (iTcsIn_H263_sqcifMPI && IsResolutionSupported(PVMF_RESOLUTION_SQCIF, iResolutionsTx)) 338 { 339 h263VideoCap->option_of_sqcifMPI = true; 340 h263VideoCap->sqcifMPI = (uint8)iTcsIn_H263_sqcifMPI; 341 } 342 343 if (iTcsIn_H263_qcifMPI && IsResolutionSupported(PVMF_RESOLUTION_QCIF, iResolutionsTx)) 344 { 345 h263VideoCap->option_of_qcifMPI = true; 346 h263VideoCap->qcifMPI = 2; 347 } 348 349 if (iTcsIn_H263_cifMPI && IsResolutionSupported(PVMF_RESOLUTION_CIF, iResolutionsTx)) 350 { 351 h263VideoCap->option_of_cifMPI = true; 352 h263VideoCap->cifMPI = (uint8)iTcsIn_H263_cifMPI; 353 } 354 355 if (iTcsIn_H263_4cifMPI && IsResolutionSupported(PVMF_RESOLUTION_4CIF, iResolutionsTx)) 356 { 357 h263VideoCap->option_of_cif4MPI = true; 358 h263VideoCap->cif4MPI = (uint8)iTcsIn_H263_4cifMPI; 359 } 360 361 if (iTcsIn_H263_16cifMPI && IsResolutionSupported(PVMF_RESOLUTION_16CIF, iResolutionsTx)) 362 { 363 h263VideoCap->option_of_cif16MPI = true; 364 h263VideoCap->cif16MPI = (uint8)iTcsIn_H263_16cifMPI; 365 } 366 367 h263VideoCap->option_of_cifMPI = false; 368 h263VideoCap->option_of_cif4MPI = false; 369 h263VideoCap->option_of_cif16MPI = false; 370 h263VideoCap->maxBitRate = bitrate; 371 h263VideoCap->unrestrictedVector = false; 372 h263VideoCap->arithmeticCoding = false; 373 h263VideoCap->advancedPrediction = false; 374 h263VideoCap->pbFrames = false; 375 h263VideoCap->temporalSpatialTradeOffCapability = ON; 376 h263VideoCap->option_of_hrd_B = false; 377 h263VideoCap->option_of_bppMaxKb = false; 378 h263VideoCap->option_of_slowSqcifMPI = false; 379 h263VideoCap->option_of_slowQcifMPI = false; 380 h263VideoCap->option_of_slowCifMPI = false; 381 h263VideoCap->option_of_slowCif4MPI = false; 382 h263VideoCap->option_of_slowCif16MPI = false; 383 h263VideoCap->errorCompensation = false; 384 h263VideoCap->option_of_enhancementLayerInfo = false; 385 h263VideoCap->option_of_h263Options = false; 386 break; 387 case PV_VID_TYPE_MPEG4: 388 { 389 /* (LCN=3): MPEG4 Video */ 390 pDataType->index = 2; 391 /* NEW245: allocate memory for videoData */ 392 pDataType->videoData = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability)); 393 pDataType->videoData->index = 5; 394 /* NEW245: allocate memory for genericVideoCapability */ 395 pDataType->videoData->genericVideoCapability = 396 genericCap = 397 (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability)); 398 genericCap->capabilityIdentifier.index = 0; 399 /* NEW245: allocate memory for standard */ 400 genericCap->capabilityIdentifier.standard = (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT)); 401 genericCap->capabilityIdentifier.standard->size = 7; 402 genericCap->capabilityIdentifier.standard->data = (uint8*) OSCL_DEFAULT_MALLOC(7 * sizeof(uint8)); 403 genericCap->capabilityIdentifier.standard->data[0] = 0x00; 404 genericCap->capabilityIdentifier.standard->data[1] = 0x08; 405 genericCap->capabilityIdentifier.standard->data[2] = 0x81; 406 genericCap->capabilityIdentifier.standard->data[3] = 0x75; 407 genericCap->capabilityIdentifier.standard->data[4] = 0x01; 408 genericCap->capabilityIdentifier.standard->data[5] = 0x00; 409 genericCap->capabilityIdentifier.standard->data[6] = 0x00; 410 genericCap->option_of_maxBitRate = true; 411 genericCap->maxBitRate = bitrate; 412 genericCap->option_of_collapsing = false; 413 genericCap->option_of_nonCollapsing = true; 414 genericCap->size_of_nonCollapsing = 3; 415 genericCap->nonCollapsing = (PS_GenericParameter) OSCL_DEFAULT_MALLOC(3 * sizeof(S_GenericParameter)); 416 genericCap->nonCollapsing[0].parameterIdentifier.index = 0; 417 genericCap->nonCollapsing[0].parameterIdentifier.standard = 0; 418 genericCap->nonCollapsing[0].parameterValue.index = 3; 419 // Value on next line changed to 8 (RAN - PandL) 420 genericCap->nonCollapsing[0].parameterValue.unsignedMax = 8; /* simple profile level 0 */ 421 genericCap->nonCollapsing[0].option_of_supersedes = false; 422 423 genericCap->nonCollapsing[1].parameterIdentifier.index = 0; 424 genericCap->nonCollapsing[1].parameterIdentifier.standard = 1; 425 genericCap->nonCollapsing[1].parameterValue.index = 3; 426 genericCap->nonCollapsing[1].parameterValue.unsignedMax = 1; /* simple profile object */ 427 genericCap->nonCollapsing[1].option_of_supersedes = false; 428 429 /* WWU_VOAL2: BLCMP4 temporally off */ 430 genericCap->nonCollapsing[2].parameterIdentifier.index = 0; 431 genericCap->nonCollapsing[2].parameterIdentifier.standard = 2; 432 genericCap->nonCollapsing[2].parameterValue.index = 6; 433 /* NEW245: allocate memory for octetString */ 434 genericCap->nonCollapsing[2].parameterValue.octetString = 435 (PS_OCTETSTRING) OSCL_DEFAULT_MALLOC(sizeof(S_OCTETSTRING)); 436 if (csi && csi_len) 437 { 438 genericCap->nonCollapsing[2].parameterValue.octetString->data = (uint8*)OSCL_DEFAULT_MALLOC(csi_len); 439 oscl_memcpy(genericCap->nonCollapsing[2].parameterValue.octetString->data, 440 csi, 441 csi_len); 442 genericCap->nonCollapsing[2].parameterValue.octetString->size = csi_len; 443 } 444 else // need to set it to FILLER FSI otherwise PER copy/delete routines will Leave 445 { 446 genericCap->nonCollapsing[2].parameterValue.octetString->data = (uint8*)OSCL_DEFAULT_MALLOC(PV2WAY_FILLER_FSI_LEN); 447 SetFillerFsi(genericCap->nonCollapsing[2].parameterValue.octetString->data, PV2WAY_FILLER_FSI_LEN); 448 genericCap->nonCollapsing[2].parameterValue.octetString->size = PV2WAY_FILLER_FSI_LEN; 449 } 450 genericCap->nonCollapsing[2].option_of_supersedes = false; 451 452 genericCap->option_of_nonCollapsingRaw = false; 453 genericCap->option_of_transport = false; 454 } 455 break; 456 default: 457 /* NULL data type */ 458 pDataType->index = 1; 459 } 460 return pDataType; 461 } 462 463 /* The following routine verifies if an incoming datatype is syntactically valid and supported */ 464 PVMFStatus TSC_capability::ValidateIncomingDataType(bool forRev, PS_DataType pDataType) 465 { 466 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 467 (0, "TSC_capability::ValidateIncomingDataType(%d,%x)", forRev, pDataType)); 468 if (!pDataType) 469 return PVMFFailure; 470 471 if (pDataType->index == 1) // null data 472 { 473 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 474 (0, "TSC_capability::ValidateIncomingDataType - null data type received")); 475 if (forRev) 476 { 477 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 478 (0, "TSC_capability::ValidateIncomingDataType Error - null data not acceptable for forward parameters")); 479 return PVMFFailure; 480 } 481 return PVMFSuccess; 482 } 483 else if (pDataType->index == 2) // videoData 484 { 485 PS_VideoCapability video_cap = pDataType->videoData; 486 if (video_cap->index == 3) /* H263 */ 487 { 488 PS_H263VideoCapability h263Cap = video_cap->h263VideoCapability; 489 // checks only valid on forward parameters 490 if (forRev) 491 { 492 // check if any unsupported resolution is indicated 493 if ((h263Cap->option_of_sqcifMPI && !IsResolutionSupported(PVMF_RESOLUTION_SQCIF, iResolutionsRx)) || 494 (h263Cap->option_of_qcifMPI && !IsResolutionSupported(PVMF_RESOLUTION_QCIF, iResolutionsRx)) || 495 (h263Cap->option_of_cifMPI && !IsResolutionSupported(PVMF_RESOLUTION_CIF, iResolutionsRx)) || 496 (h263Cap->option_of_cif4MPI && !IsResolutionSupported(PVMF_RESOLUTION_4CIF, iResolutionsRx)) || 497 (h263Cap->option_of_cif16MPI && !IsResolutionSupported(PVMF_RESOLUTION_16CIF, iResolutionsRx))) 498 { 499 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 500 (0, "TSC_capability::ValidateIncomingDataType ERROR - Unsuported resolution")); 501 return PVMFErrNotSupported; 502 } 503 // check if atleast one resolution is enabled 504 if (!(h263Cap->option_of_sqcifMPI || 505 h263Cap->option_of_qcifMPI || 506 h263Cap->option_of_cifMPI || 507 h263Cap->option_of_cif4MPI || 508 h263Cap->option_of_cif16MPI)) 509 { 510 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 511 (0, "TSC_capability::ValidateIncomingDataType ERROR - Invalid datatype for H.263. No resolutions indicated.")); 512 return PVMFFailure; 513 } 514 } 515 else // checks only valid on reverse parameters 516 { 517 unsigned num_ok_resolutions = 0; 518 if (h263Cap->option_of_sqcifMPI && 519 IsResolutionSupported(PVMF_RESOLUTION_SQCIF, iResolutionsTx)) 520 { 521 if (h263Cap->sqcifMPI < 1 || h263Cap->sqcifMPI > 30) 522 { 523 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 524 (0, "TSC_capability::ValidateIncomingDataType ERROR - Invalid H263 SQCIF mpi")); 525 } 526 else 527 num_ok_resolutions++; 528 } 529 if (h263Cap->option_of_qcifMPI && 530 IsResolutionSupported(PVMF_RESOLUTION_QCIF, iResolutionsTx)) 531 { 532 if (h263Cap->qcifMPI < 1 || h263Cap->qcifMPI > 30) 533 { 534 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 535 (0, "TSC_capability::ValidateIncomingDataType ERROR - Invalid H263 QCIF mpi")); 536 } 537 else 538 num_ok_resolutions++; 539 } 540 if (h263Cap->option_of_cifMPI && 541 IsResolutionSupported(PVMF_RESOLUTION_CIF, iResolutionsTx)) 542 { 543 if (h263Cap->cifMPI < 1 || h263Cap->cifMPI > 30) 544 { 545 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 546 (0, "TSC_capability::ValidateIncomingDataType ERROR - Invalid H263 QCIF mpi")); 547 } 548 else 549 num_ok_resolutions++; 550 } 551 if (h263Cap->option_of_cif4MPI && 552 IsResolutionSupported(PVMF_RESOLUTION_4CIF, iResolutionsTx)) 553 { 554 if (h263Cap->cif4MPI < 1 || h263Cap->cif4MPI > 30) 555 { 556 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 557 (0, "TSC_capability::ValidateIncomingDataType ERROR - Invalid H263 QCIF mpi")); 558 } 559 else 560 num_ok_resolutions++; 561 } 562 if (h263Cap->option_of_cif16MPI && 563 IsResolutionSupported(PVMF_RESOLUTION_16CIF, iResolutionsTx)) 564 { 565 if (h263Cap->cif16MPI < 1 || h263Cap->cif16MPI > 30) 566 { 567 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 568 (0, "TSC_capability::ValidateIncomingDataType ERROR - Invalid H263 QCIF mpi")); 569 } 570 else 571 num_ok_resolutions++; 572 } 573 if (num_ok_resolutions == 0) 574 { 575 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 576 (0, "TSC_capability::ValidateIncomingDataType ERROR - Cannot transmit using this codec")); 577 return PVMFFailure; 578 } 579 } 580 if (h263Cap->maxBitRate > 640) 581 { 582 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 583 (0, "TSC_capability::ValidateIncomingDataType ERROR - Invalid bitrate(%d)", h263Cap->maxBitRate)); 584 return PVMFFailure; 585 } 586 } 587 else if (video_cap->index == 5) /* MPEG 4 */ 588 { 589 //PS_GenericCapability m4vCap=video_cap->genericVideoCapability; 590 uint8* fsi = NULL; 591 unsigned fsisz =::GetFormatSpecificInfo(pDataType, fsi); 592 if (fsi != NULL && fsisz != 0) 593 { 594 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 595 (0, "TSC_capability::ValidateIncomingDataType VOL header dump")); 596 printBuffer(iLogger, fsi, (uint16)fsisz); 597 } 598 else 599 { 600 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 601 (0, "TSC_capability::ValidateIncomingDataType VOL header not given")); 602 } 603 } 604 else 605 { 606 return PVMFErrNotSupported; 607 } 608 } 609 else if (pDataType->index == 3) // audioData 610 { 611 PS_AudioCapability audio_cap = pDataType->audioData; 612 if (audio_cap->index == 8) /* G.723 */ 613 { 614 //PS_G7231 g723Cap = audio_cap->g7231; 615 616 } 617 else if (audio_cap->index == 20) /* AMR */ 618 { 619 //PS_GenericCapability amrCap=audio_cap->genericAudioCapability; 620 } 621 else 622 { 623 624 return PVMFErrNotSupported; 625 } 626 } 627 else 628 { 629 return PVMFErrNotSupported; 630 } 631 return PVMFSuccess; 632 } 633 634 /* The following routines return our preferences for DataType and H223LogicalChannelParameters */ 635 bool TSC_capability::IsSegmentable(TPVDirection direction, PV2WayMediaType media_type) 636 { 637 OSCL_UNUSED_ARG(direction); 638 switch (media_type) 639 { 640 case PV_AUDIO: 641 return false; 642 case PV_VIDEO: 643 return true; 644 default: 645 return true; 646 } 647 } 648 649 PS_H223LogicalChannelParameters 650 TSC_capability::GetOutgoingLcnParams(PV2WayMediaType media_type, PS_AdaptationLayerType adaptation_layer) 651 { 652 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 653 (0, "TSC_capability:GetLcnParams - media_type(%d), layer(%x)", media_type, adaptation_layer)); 654 OSCL_ASSERT(media_type == PV_AUDIO || media_type == PV_VIDEO); 655 PS_H223LogicalChannelParameters pParameter = (PS_H223LogicalChannelParameters)OSCL_DEFAULT_MALLOC(sizeof(S_H223LogicalChannelParameters)); 656 oscl_memset(pParameter , 0, sizeof(S_H223LogicalChannelParameters)); 657 658 pParameter->segmentableFlag = IsSegmentable(OUTGOING, media_type); 659 pParameter->adaptationLayerType.index = adaptation_layer->index; 660 661 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 662 (0, "TSC_capability: GetLcnParams al index(%d) \n", pParameter->adaptationLayerType.index)); 663 664 if (pParameter->adaptationLayerType.index == 5) 665 { 666 /* AL3(Video) */ 667 pParameter->adaptationLayerType.al3 = (PS_Al3) OSCL_DEFAULT_MALLOC(sizeof(S_Al3)); 668 oscl_memcpy(pParameter->adaptationLayerType.al3, adaptation_layer->al3, sizeof(S_Al3)); 669 pParameter->adaptationLayerType.al3->sendBufferSize = 0; 670 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 671 (0, "TSC_capability: GetLcnParams controlFieldOctets(%d), sendBufferSize(%d)\n", 672 pParameter->adaptationLayerType.al3->controlFieldOctets, 673 pParameter->adaptationLayerType.al3->sendBufferSize)); 674 } 675 return pParameter; 676 } 677 678 PVMFStatus TSC_capability::ValidateIncomingH223LcnParams(PS_H223LogicalChannelParameters h223params, 679 TPVDirection dir) 680 { 681 OSCL_UNUSED_ARG(dir); 682 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 683 (0, "TSC_capability::ValidateIncomingH223LcnParams(%x),dir(%d)", 684 h223params, dir)); 685 686 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 687 (0, "TSC_capability::ValidateIncomingH223LcnParams AL index(%d)", 688 h223params->adaptationLayerType.index)); 689 if (h223params->adaptationLayerType.index == 0 || 690 h223params->adaptationLayerType.index > 5) 691 { 692 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 693 (0, "TSC_capability::ValidateIncomingH223LcnParams invalid index(%d)", 694 h223params->adaptationLayerType.index)); 695 return PVMFErrNotSupported; 696 } 697 698 if (h223params->adaptationLayerType.index == 5) 699 { 700 PS_Al3 al3 = h223params->adaptationLayerType.al3; 701 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 702 (0, "TSC_capability::ValidateIncomingH223LcnParams al3->controlFieldOctets(%d),al3->sendBufferSize(%d)", al3->controlFieldOctets, al3->sendBufferSize)); 703 if (al3->controlFieldOctets > 2) 704 { 705 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 706 (0, "TSC_capability::ValidateIncomingH223LcnParams ERROR - Invalid al3->controlFieldOctets(%d)", al3->controlFieldOctets)); 707 return PVMFFailure; 708 } 709 } 710 return PVMFSuccess; 711 } 712 713 PVMFStatus TSC_capability::ValidateForwardReverseParams(PS_ForwardReverseParam forRevParams, 714 TPVDirection dir) 715 { 716 if (forRevParams == NULL || dir == PV_DIRECTION_NONE) 717 { 718 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 719 (0, "TSC_capability::ValidateForwardReverseParams forRevParams==NULL || dir==PV_DIRECTION_NONE")); 720 return PVMFFailure; 721 } 722 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 723 (0, "TSC_capability::ValidateForwardReverseParams params(%x), option_of_reverse(%d)", 724 forRevParams, 725 forRevParams->option_of_reverseLogicalChannelParameters)); 726 if (dir&INCOMING) 727 { 728 PS_ForwardLogicalChannelParameters forwardParams = &forRevParams->forwardLogicalChannelParameters; 729 /* validate datatype */ 730 PVMFStatus datatypeCheck = ValidateIncomingDataType(true, &forwardParams->dataType); 731 if (datatypeCheck != PVMFSuccess) 732 { 733 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 734 (0, "TSC_capability::ValidateForwardReverseParams ERROR - forward datatype not supported.")); 735 return datatypeCheck; 736 } 737 /* Validate lcp */ 738 if (forwardParams->multiplexParameters.index != 1) 739 { 740 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 741 (0, "TSC_capability::ValidateForwardReverseParams Invalid index for forward multipleParameters(%d)", forwardParams->multiplexParameters.index)); 742 return PVMFFailure; 743 } 744 if (forwardParams->multiplexParameters.h223LogicalChannelParameters == NULL) 745 { 746 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 747 (0, "TSC_capability::ValidateForwardReverseParams forward multipleParameters==NULL")); 748 return PVMFFailure; 749 } 750 PVMFStatus h223paramsCheck = ValidateIncomingH223LcnParams(forwardParams->multiplexParameters.h223LogicalChannelParameters, INCOMING); 751 if (h223paramsCheck != PVMFSuccess) 752 { 753 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 754 (0, "TSC_capability::ValidateForwardReverseParams ERROR - forward h223params not supported.")); 755 return h223paramsCheck; 756 } 757 } 758 759 if (dir&OUTGOING) 760 { 761 if (!forRevParams->option_of_reverseLogicalChannelParameters) 762 return PVMFSuccess; 763 PS_ReverseLogicalChannelParameters reverseParams = &forRevParams->reverseLogicalChannelParameters; 764 /* validate datatype */ 765 PVMFStatus datatypeCheck = ValidateIncomingDataType(false, &reverseParams->dataType); 766 if (datatypeCheck != PVMFSuccess) 767 { 768 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 769 (0, "TSC_capability::ValidateForwardReverseParams ERROR - reverse datatype not supported.")); 770 return datatypeCheck; 771 } 772 if (!reverseParams->option_of_rlcMultiplexParameters) 773 { 774 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 775 (0, "TSC_capability::ValidateForwardReverseParams no option for reverse multipleParameters")); 776 return PVMFFailure; 777 } 778 /* Validate lcp */ 779 if (reverseParams->rlcMultiplexParameters.index != 0) 780 { 781 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 782 (0, "TSC_capability::ValidateForwardReverseParams Invalid index for reverse multipleParameters(%d)", reverseParams->rlcMultiplexParameters.index)); 783 return PVMFFailure; 784 } 785 if (reverseParams->rlcMultiplexParameters.h223LogicalChannelParameters == NULL) 786 { 787 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 788 (0, "TSC_capability::ValidateForwardReverseParams reverse multipleParameters==NULL")); 789 return PVMFFailure; 790 } 791 PVMFStatus h223paramsCheck = ValidateIncomingH223LcnParams(reverseParams->rlcMultiplexParameters.h223LogicalChannelParameters, OUTGOING); 792 if (h223paramsCheck != PVMFSuccess) 793 { 794 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG, 795 (0, "TSC_capability::ValidateForwardReverseParams ERROR - reverse h223params not supported.")); 796 return h223paramsCheck; 797 } 798 } 799 return PVMFSuccess; 800 } 801 802 bool TSC_capability::VerifyReverseParameters(PS_ForwardReverseParam forRevParams, 803 TSCObserver* aObserver, 804 PVMFStatus& status) 805 { 806 OSCL_UNUSED_ARG(aObserver); 807 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 808 (0, "TSC_capability::VerifyReverseParameters")); 809 status = PVMFSuccess; 810 status = ValidateForwardReverseParams(forRevParams, OUTGOING); 811 if (status != PVMFSuccess) 812 { 813 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 814 (0, "TSC_capability:VerifyReverseParameters - Reverse params invalid")); 815 return true; 816 } 817 818 PVCodecType_t codec = GetCodecType(&forRevParams->reverseLogicalChannelParameters.dataType); 819 GetMediaType(codec); 820 if (!CodecRequiresFsi(codec)) 821 { 822 status = PVMFSuccess; 823 return true; 824 } 825 status = PVMFFailure; 826 return false; 827 } 828 829 CPvtTerminalCapability* TSC_capability::GetRemoteCapability() 830 { 831 return iRemoteCapability; 832 } 833 834 uint32 TSC_capability::GetMaxBitrateForOutgoingChannel(PVCodecType_t codecType) 835 { 836 uint32 bitrate = 0; 837 /* lookup the bitrate from remote capabilities */ 838 for (uint16 i = 0; i < iRemoteCapability->GetNumCapabilityItems(); i++) 839 { 840 if (iRemoteCapability->GetCapabilityItem(i)->GetFormatType() == PVCodecTypeToPVMFFormatType(codecType)) 841 bitrate = iRemoteCapability->GetCapabilityItem(i)->GetBitrate(); 842 } 843 return bitrate; 844 } 845 846 PS_DataType 847 TSC_capability::GetDataType(PVCodecType_t codecType, 848 uint32 bitrate, 849 const uint8* dci, 850 uint16 dci_len) 851 { 852 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 853 (0, "TSC_capability::GetDataType - codecType(%d),bitrate(%d),dci(%x),dci_len(%d)", 854 codecType, bitrate, dci, dci_len)); 855 bitrate /= 100; 856 PS_DataType pDataType = (PS_DataType) OSCL_DEFAULT_MALLOC(sizeof(S_DataType)); 857 oscl_memset(pDataType , 0, sizeof(S_DataType)); 858 PS_GenericCapability genericCap = NULL; 859 860 switch (codecType) 861 { 862 case PV_AUD_TYPE_G723: /* WWURM: change H324_AUDIO_RECV to H324_AUDIO_SEND */ 863 /* (LCN=2): G723 Audio */ 864 PS_G7231 g723Cap; 865 pDataType->index = 3; 866 /* NEW245: allocate memory for audioData*/ 867 pDataType->audioData = (PS_AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability)); 868 pDataType->audioData->index = 8; 869 /* NEW245: allocate memory for g7231 */ 870 pDataType->audioData->g7231 = 871 g723Cap = 872 (PS_G7231) OSCL_DEFAULT_MALLOC(sizeof(S_G7231)); 873 g723Cap->maxAl_sduAudioFrames = 1; 874 g723Cap->silenceSuppression = false; 875 break; 876 case PV_AUD_TYPE_GSM: 877 /* (LCN=2): Amr Audio */ 878 pDataType->index = 3; 879 /* NEW245: allocate memory for audioData */ 880 pDataType->audioData = (PS_AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability)); 881 pDataType->audioData->index = 20; 882 /* NEW245: allocate memory for genericAudioCapability */ 883 pDataType->audioData->genericAudioCapability = 884 genericCap = 885 (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability)); 886 genericCap->capabilityIdentifier.index = 0; 887 /* NEW245: allocate memory for standard */ 888 genericCap->capabilityIdentifier.standard = (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT)); 889 genericCap->capabilityIdentifier.standard->size = 7; 890 genericCap->capabilityIdentifier.standard->data = (uint8*) OSCL_DEFAULT_MALLOC(7 * sizeof(uint8)); 891 genericCap->capabilityIdentifier.standard->data[0] = 0x00; 892 genericCap->capabilityIdentifier.standard->data[1] = 0x08; 893 genericCap->capabilityIdentifier.standard->data[2] = 0x81; 894 genericCap->capabilityIdentifier.standard->data[3] = 0x75; 895 genericCap->capabilityIdentifier.standard->data[4] = 0x01; 896 genericCap->capabilityIdentifier.standard->data[5] = 0x01; 897 genericCap->capabilityIdentifier.standard->data[6] = 0x01; 898 genericCap->option_of_maxBitRate = true; 899 genericCap->maxBitRate = bitrate; 900 genericCap->option_of_collapsing = true; 901 genericCap->size_of_collapsing = 1; 902 genericCap->collapsing = (PS_GenericParameter) OSCL_DEFAULT_MALLOC(1 * sizeof(S_GenericParameter)); 903 genericCap->collapsing[0].parameterIdentifier.index = 0; 904 genericCap->collapsing[0].parameterIdentifier.standard = 0; 905 genericCap->collapsing[0].parameterValue.index = 2; 906 genericCap->collapsing[0].parameterValue.unsignedMin = 1; 907 genericCap->collapsing[0].option_of_supersedes = false; 908 909 genericCap->option_of_nonCollapsing = false; 910 genericCap->option_of_nonCollapsingRaw = false; 911 genericCap->option_of_transport = false; 912 break; 913 case PV_VID_TYPE_H263: 914 /* (LCN=3): H263 Video */ 915 PS_H263VideoCapability h263VideoCap; 916 pDataType->index = 2; 917 /* NEW245: allocate memory for videoData */ 918 pDataType->videoData = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability)); 919 oscl_memset(pDataType->videoData, 0, sizeof(S_VideoCapability)); 920 pDataType->videoData->index = 3; 921 /* NEW245: allocate memory for h263VideoCapability */ 922 pDataType->videoData->h263VideoCapability = 923 h263VideoCap = 924 (PS_H263VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_H263VideoCapability)); 925 oscl_memset(pDataType->videoData->h263VideoCapability, 0, sizeof(S_H263VideoCapability)); 926 927 if (iTcsIn_H263_sqcifMPI && IsResolutionSupported(PVMF_RESOLUTION_SQCIF, iResolutionsTx)) 928 { 929 h263VideoCap->option_of_sqcifMPI = true; 930 h263VideoCap->sqcifMPI = (uint8)iTcsIn_H263_sqcifMPI; 931 } 932 933 if (iTcsIn_H263_qcifMPI && IsResolutionSupported(PVMF_RESOLUTION_QCIF, iResolutionsTx)) 934 { 935 h263VideoCap->option_of_qcifMPI = true; 936 h263VideoCap->qcifMPI = 2; 937 } 938 939 if (iTcsIn_H263_cifMPI && IsResolutionSupported(PVMF_RESOLUTION_CIF, iResolutionsTx)) 940 { 941 h263VideoCap->option_of_cifMPI = true; 942 h263VideoCap->cifMPI = (uint8)iTcsIn_H263_cifMPI; 943 } 944 945 if (iTcsIn_H263_4cifMPI && IsResolutionSupported(PVMF_RESOLUTION_4CIF, iResolutionsTx)) 946 { 947 h263VideoCap->option_of_cif4MPI = true; 948 h263VideoCap->cif4MPI = (uint8)iTcsIn_H263_4cifMPI; 949 } 950 951 if (iTcsIn_H263_16cifMPI && IsResolutionSupported(PVMF_RESOLUTION_16CIF, iResolutionsTx)) 952 { 953 h263VideoCap->option_of_cif16MPI = true; 954 h263VideoCap->cif16MPI = (uint8)iTcsIn_H263_16cifMPI; 955 } 956 957 h263VideoCap->option_of_cifMPI = false; 958 h263VideoCap->option_of_cif4MPI = false; 959 h263VideoCap->option_of_cif16MPI = false; 960 h263VideoCap->maxBitRate = bitrate; 961 h263VideoCap->unrestrictedVector = false; 962 h263VideoCap->arithmeticCoding = false; 963 h263VideoCap->advancedPrediction = false; 964 h263VideoCap->pbFrames = false; 965 h263VideoCap->temporalSpatialTradeOffCapability = ON; 966 h263VideoCap->option_of_hrd_B = false; 967 h263VideoCap->option_of_bppMaxKb = false; 968 h263VideoCap->option_of_slowSqcifMPI = false; 969 h263VideoCap->option_of_slowQcifMPI = false; 970 h263VideoCap->option_of_slowCifMPI = false; 971 h263VideoCap->option_of_slowCif4MPI = false; 972 h263VideoCap->option_of_slowCif16MPI = false; 973 h263VideoCap->errorCompensation = false; 974 h263VideoCap->option_of_enhancementLayerInfo = false; 975 h263VideoCap->option_of_h263Options = false; 976 break; 977 case PV_VID_TYPE_MPEG4: 978 { 979 /* (LCN=3): MPEG4 Video */ 980 pDataType->index = 2; 981 /* NEW245: allocate memory for videoData */ 982 pDataType->videoData = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability)); 983 pDataType->videoData->index = 5; 984 /* NEW245: allocate memory for genericVideoCapability */ 985 pDataType->videoData->genericVideoCapability = 986 genericCap = 987 (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability)); 988 genericCap->capabilityIdentifier.index = 0; 989 /* NEW245: allocate memory for standard */ 990 genericCap->capabilityIdentifier.standard = (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT)); 991 genericCap->capabilityIdentifier.standard->size = 7; 992 genericCap->capabilityIdentifier.standard->data = (uint8*) OSCL_DEFAULT_MALLOC(7 * sizeof(uint8)); 993 genericCap->capabilityIdentifier.standard->data[0] = 0x00; 994 genericCap->capabilityIdentifier.standard->data[1] = 0x08; 995 genericCap->capabilityIdentifier.standard->data[2] = 0x81; 996 genericCap->capabilityIdentifier.standard->data[3] = 0x75; 997 genericCap->capabilityIdentifier.standard->data[4] = 0x01; 998 genericCap->capabilityIdentifier.standard->data[5] = 0x00; 999 genericCap->capabilityIdentifier.standard->data[6] = 0x00; 1000 genericCap->option_of_maxBitRate = true; 1001 genericCap->maxBitRate = bitrate; 1002 genericCap->option_of_collapsing = false; 1003 genericCap->option_of_nonCollapsing = true; 1004 genericCap->size_of_nonCollapsing = (uint16)((dci && dci_len) ? 3 : 2); 1005 genericCap->nonCollapsing = (PS_GenericParameter) OSCL_DEFAULT_MALLOC(3 * sizeof(S_GenericParameter)); 1006 genericCap->nonCollapsing[0].parameterIdentifier.index = 0; 1007 genericCap->nonCollapsing[0].parameterIdentifier.standard = 0; 1008 genericCap->nonCollapsing[0].parameterValue.index = 3; 1009 // Value on next line changed to 8 (RAN - PandL) 1010 genericCap->nonCollapsing[0].parameterValue.unsignedMax = 8; /* simple profile level 0 */ 1011 genericCap->nonCollapsing[0].option_of_supersedes = false; 1012 1013 genericCap->nonCollapsing[1].parameterIdentifier.index = 0; 1014 genericCap->nonCollapsing[1].parameterIdentifier.standard = 1; 1015 genericCap->nonCollapsing[1].parameterValue.index = 3; 1016 genericCap->nonCollapsing[1].parameterValue.unsignedMax = 1; /* simple profile object */ 1017 genericCap->nonCollapsing[1].option_of_supersedes = false; 1018 1019 if (dci && dci_len) 1020 { 1021 /* WWU_VOAL2: BLCMP4 temporally off */ 1022 genericCap->nonCollapsing[2].parameterIdentifier.index = 0; 1023 genericCap->nonCollapsing[2].parameterIdentifier.standard = 2; 1024 genericCap->nonCollapsing[2].parameterValue.index = 6; 1025 /* NEW245: allocate memory for octetString */ 1026 genericCap->nonCollapsing[2].parameterValue.octetString = 1027 (PS_OCTETSTRING) OSCL_DEFAULT_MALLOC(sizeof(S_OCTETSTRING)); 1028 genericCap->nonCollapsing[2].parameterValue.octetString->data = 1029 (uint8*)OSCL_DEFAULT_MALLOC(dci_len); 1030 oscl_memcpy(genericCap->nonCollapsing[2].parameterValue.octetString->data, 1031 dci, dci_len); 1032 genericCap->nonCollapsing[2].parameterValue.octetString->size = dci_len; 1033 genericCap->nonCollapsing[2].option_of_supersedes = false; 1034 } 1035 1036 genericCap->option_of_nonCollapsingRaw = false; 1037 genericCap->option_of_transport = false; 1038 } 1039 break; 1040 1041 default: 1042 /* NULL data type */ 1043 pDataType->index = 1; 1044 } 1045 return pDataType; 1046 } 1047 1048 uint16 1049 TSC_capability::GetSupportedCodecCapabilityInfo(TPVDirection dir, 1050 PV2WayMediaType mediaType, 1051 Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& codec_info_list) 1052 { 1053 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, 1054 (0, "TSC_capability::GetSupportedCodecCapabilityInfo dir=%d, mediaType=%d", 1055 dir, mediaType)); 1056 Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>* channel_config = 1057 iTSCcomponent->GetChannelConfig(dir); 1058 if (channel_config == NULL) 1059 { 1060 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, 1061 (0, "TSC_capability::GetSupportedCodecCapabilityInfo channel config for this direction == NULL")); 1062 return 0; 1063 } 1064 for (unsigned n = 0; n < channel_config->size(); n++) 1065 { 1066 PV2WayMediaType channelMediaType = (*channel_config)[n].GetMediaType(); 1067 if (channelMediaType != mediaType) 1068 { 1069 continue; 1070 } 1071 Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>* formats = (*channel_config)[n].GetCodecs(); 1072 if (!formats) 1073 { 1074 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, 1075 (0, "TSC_capability::GetSupportedCodecCapabilityInfo No formats specified for format type(%d)", channelMediaType)); 1076 continue; 1077 } 1078 for (unsigned m = 0; m < formats->size(); m++) 1079 { 1080 CodecCapabilityInfo* info = NULL; 1081 PVCodecType_t codec_type = PVMFFormatTypeToPVCodecType((*formats)[m].format); 1082 TPVDirection dir = (*formats)[m].dir; 1083 if (GetMediaType(codec_type) == PV_VIDEO) 1084 { 1085 info = new VideoCodecCapabilityInfo; 1086 ((VideoCodecCapabilityInfo*)info)->resolutions = (dir == OUTGOING) ? iResolutionsTx : iResolutionsRx; 1087 } 1088 else 1089 { 1090 info = new CodecCapabilityInfo; 1091 } 1092 info->codec = codec_type; 1093 info->dir = dir; 1094 codec_info_list.push_back(info); 1095 } 1096 } 1097 return (uint16)codec_info_list.size(); 1098 } 1099 1100 bool 1101 TSC_capability::HasSymmetryConstraint(Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& codec_list) 1102 { 1103 for (unsigned i = 0; i < codec_list.size(); i++) 1104 { 1105 if (codec_list[i]->dir == PV_DIRECTION_BOTH) 1106 return true; 1107 } 1108 return false; 1109 } 1110 1111 CodecCapabilityInfo* 1112 TSC_capability::SelectOutgoingCodec(Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>* remote_list, 1113 Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>* local_list) 1114 { 1115 Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>* list1 = remote_list; 1116 Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>* list2 = local_list; 1117 if (iTSCstatemanager.ReadState(TSC_MSD_DECISION) == MASTER) 1118 { 1119 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 1120 (0, "TSC_capability::SelectOutgoingCodec Selecting our preferred codec for mediaType since we are master")); 1121 list1 = local_list; 1122 list2 = remote_list; 1123 } 1124 for (unsigned i = 0; i < (*list1).size(); i++) 1125 { 1126 CodecCapabilityInfo* supported_codec_info =::IsSupported((*list1)[i], *list2); 1127 if (supported_codec_info == NULL) 1128 continue; 1129 // check if we support transmitting this codec 1130 FormatCapabilityInfo capability_info; 1131 if (iTSCcomponent->IsSupported(OUTGOING, 1132 supported_codec_info->codec, capability_info)) 1133 { 1134 return (list1 == remote_list) ? (*list1)[i] : supported_codec_info; 1135 } 1136 else 1137 { 1138 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, 1139 (0, "TSC_capability::SelectOutgoingCodec Codec=%d not supported in outgoing direction", 1140 supported_codec_info->codec)); 1141 } 1142 } 1143 return NULL; 1144 } 1145 1146 CodecCapabilityInfo* 1147 TSC_capability::SelectOutgoingCodec(Oscl_Vector < CodecCapabilityInfo*, 1148 OsclMemAllocator > * remote_list) 1149 { 1150 for (unsigned i = 0; i < (*remote_list).size(); i++) 1151 { 1152 // check if this includes receive capability 1153 if ((*remote_list)[i]->dir == OUTGOING) 1154 { 1155 continue; 1156 } 1157 // check if we support transmitting this codec 1158 FormatCapabilityInfo capability_info; 1159 if (iTSCcomponent->IsSupported(OUTGOING, 1160 (*remote_list)[i]->codec, capability_info)) 1161 { 1162 return (*remote_list)[i]; 1163 } 1164 } 1165 return NULL; 1166 } 1167 1168 1169