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 #ifndef PVMF_STREAMING_MANAGER_INTERNAL_H_INCLUDED 19 #include "pvmf_streaming_manager_internal.h" 20 #endif 21 #ifndef PVMF_STREAMING_MANAGER_NODE_H_INCLUDED 22 #include "pvmf_streaming_manager_node.h" 23 #endif 24 #ifndef PV_LOGGGER_H_INCLUDED 25 #include "pvlogger.h" 26 #endif 27 #ifndef PVMF_SOCKET_NODE_H_INCLUDED 28 #include "pvmf_socket_node.h" 29 #endif 30 #ifndef PVRTSP_ENGINE_NODE_EXTENSION_INTERFACE_H_INCLUDED 31 #include "pvrtspenginenodeextensioninterface.h" 32 #endif 33 #ifndef PVMF_JITTER_BUFFER_NODE_H_INCLUDED 34 #include "pvmf_jitter_buffer_node.h" 35 #endif 36 #ifndef PVMF_MEDIALAYER_NODE_H_INCLUDED 37 #include "pvmf_medialayer_node.h" 38 #endif 39 40 /** 41 * Macros for calling PVLogger 42 */ 43 #define LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m); 44 #define LOGINFOHI(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG,iLogger,PVLOGMSG_INFO,m); 45 #define LOGINFOMED(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iLogger,PVLOGMSG_INFO,m); 46 #define LOGINFOLOW(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_INFO,m); 47 #define LOGINFO(m) LOGINFOMED(m) 48 49 50 PVMFStreamingManagerExtensionInterfaceImpl::PVMFStreamingManagerExtensionInterfaceImpl(PVMFStreamingManagerNode*c, 51 PVMFSessionId sid) 52 : PVInterfaceImpl<PVMFStreamingManagerNodeAllocator>(PVUuid(PVMF_STREAMINGMANAGERNODE_EXTENSIONINTERFACE_UUID)) 53 , iSessionId(sid) 54 , iContainer(c) 55 56 {} 57 58 PVMFStreamingManagerExtensionInterfaceImpl::~PVMFStreamingManagerExtensionInterfaceImpl() 59 {} 60 61 OSCL_EXPORT_REF 62 PVMFStatus PVMFStreamingManagerExtensionInterfaceImpl::setClientParameters(PVMFSMClientParams* clientParams) 63 { 64 PVMFSMNodeContainer* iSessionControllerNodeContainer = 65 iContainer->getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE); 66 67 if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle); 68 69 PVRTSPEngineNodeExtensionInterface* rtspExtIntf = 70 (PVRTSPEngineNodeExtensionInterface*) 71 (iSessionControllerNodeContainer->iExtensions[0]); 72 73 return (rtspExtIntf->SetClientParameters(clientParams->_deviceInfo, 74 clientParams->_userAgent, 75 clientParams->_userNetwork)); 76 77 }; 78 79 OSCL_EXPORT_REF 80 PVMFStatus PVMFStreamingManagerExtensionInterfaceImpl::setTimeParams(PVMFSMTimeParams* timeParams) 81 { 82 OSCL_UNUSED_ARG(timeParams); 83 return PVMFFailure; 84 }; 85 86 OSCL_EXPORT_REF 87 PVMFStatus PVMFStreamingManagerExtensionInterfaceImpl::setAuthenticationParameters(PVMFSMAuthenticationParmas* authenticationParams) 88 { 89 PVMFSMNodeContainer* iSessionControllerNodeContainer = 90 iContainer->getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE); 91 92 if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle); 93 94 PVRTSPEngineNodeExtensionInterface* rtspExtIntf = 95 (PVRTSPEngineNodeExtensionInterface*) 96 (iSessionControllerNodeContainer->iExtensions[0]); 97 98 return (rtspExtIntf->SetAuthenticationParameters(authenticationParams->_userID, 99 authenticationParams->_authenticationInfo, 100 authenticationParams->_expirationInfo, 101 authenticationParams->_applicationSpecificString, 102 authenticationParams->_verificationInfo, 103 authenticationParams->_signatureInfo)); 104 }; 105 106 OSCL_EXPORT_REF 107 PVMFStatus PVMFStreamingManagerExtensionInterfaceImpl::setJitterBufferParams(PVMFSMJitterBufferParmas* jitterBufferParams) 108 { 109 PVMFSMNodeContainer* iJitterBufferNodeContainer = 110 iContainer->getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE); 111 112 if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle); 113 114 PVMFJitterBufferExtensionInterface* jbExtIntf = 115 (PVMFJitterBufferExtensionInterface*) 116 (iJitterBufferNodeContainer->iExtensions[0]); 117 118 jbExtIntf->setJitterBufferDurationInMilliSeconds(jitterBufferParams->_bufferDurationInMilliSeconds); 119 jbExtIntf->setPlayBackThresholdInMilliSeconds(jitterBufferParams->_playBackThresholdInMilliSeconds); 120 121 iContainer->setJitterBufferDurationInMilliSeconds(jitterBufferParams->_bufferDurationInMilliSeconds); 122 123 return PVMFSuccess; 124 } 125 126 OSCL_EXPORT_REF 127 PVMFStatus PVMFStreamingManagerExtensionInterfaceImpl::resetJitterBuffer() 128 { 129 return PVMFFailure; 130 } 131 132 OSCL_EXPORT_REF PVMFStatus 133 PVMFStreamingManagerExtensionInterfaceImpl::setPayloadParserRegistry(PayloadParserRegistry* registry) 134 { 135 PVMFSMNodeContainer* iMediaLayerNodeContainer = 136 iContainer->getNodeContainer(PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE); 137 138 if (iMediaLayerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle); 139 140 PVMFMediaLayerNodeExtensionInterface* mlExtIntf = 141 (PVMFMediaLayerNodeExtensionInterface*) 142 (iMediaLayerNodeContainer->iExtensions[0]); 143 144 return (mlExtIntf->setPayloadParserRegistry(registry)); 145 } 146 147 OSCL_EXPORT_REF PVMFStatus 148 PVMFStreamingManagerExtensionInterfaceImpl::setPacketSourceInterface(PVMFPacketSource* aPacketSource) 149 { 150 iPacketSource = aPacketSource; 151 return PVMFSuccess; 152 } 153 154 OSCL_EXPORT_REF PVMFStatus 155 PVMFStreamingManagerExtensionInterfaceImpl::setDataPortLogging(bool logEnable, 156 OSCL_String* logPath) 157 { 158 PVMFSMNodeContainer* iMediaLayerNodeContainer = 159 iContainer->getNodeContainer(PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE); 160 161 if (iMediaLayerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle); 162 163 PVMFMediaLayerNodeExtensionInterface* mlExtIntf = 164 (PVMFMediaLayerNodeExtensionInterface*) 165 (iMediaLayerNodeContainer->iExtensions[0]); 166 167 return (mlExtIntf->setPortDataLogging(logEnable, logPath)); 168 } 169 170 OSCL_EXPORT_REF PVMFStatus 171 PVMFStreamingManagerExtensionInterfaceImpl::switchStreams(uint32 aSrcStreamID, uint32 aDestStreamID) 172 { 173 return (iContainer->switchStreams(aSrcStreamID, aDestStreamID)); 174 } 175 176 OSCL_EXPORT_REF PVMFStatus 177 PVMFStreamingManagerExtensionInterfaceImpl::SetSourceInitializationData(OSCL_wString& aSourceURL, 178 PVMFFormatType& aSourceFormat, 179 OsclAny* aSourceData) 180 { 181 return (iContainer->setSessionSourceInfo(aSourceURL, 182 aSourceFormat, 183 aSourceData)); 184 } 185 186 OSCL_EXPORT_REF PVMFStatus 187 PVMFStreamingManagerExtensionInterfaceImpl::SetClientPlayBackClock(PVMFMediaClock* clientClock) 188 { 189 PVMFSMNodeContainer* iJitterBufferNodeContainer = 190 iContainer->getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE); 191 192 if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle); 193 194 PVMFJitterBufferExtensionInterface* jbExtIntf = 195 (PVMFJitterBufferExtensionInterface*) 196 (iJitterBufferNodeContainer->iExtensions[0]); 197 198 jbExtIntf->setClientPlayBackClock(clientClock); 199 200 PVMFSMNodeContainer* iMediaLayerNodeContainer = 201 iContainer->getNodeContainer(PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE); 202 203 if (iMediaLayerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle); 204 205 PVMFMediaLayerNodeExtensionInterface* mlExtIntf = 206 (PVMFMediaLayerNodeExtensionInterface*) 207 (iMediaLayerNodeContainer->iExtensions[0]); 208 209 mlExtIntf->setClientPlayBackClock(clientClock); 210 211 return PVMFSuccess; 212 } 213 214 OSCL_EXPORT_REF PVMFStatus 215 PVMFStreamingManagerExtensionInterfaceImpl::SetEstimatedServerClock(PVMFMediaClock* aClientClock) 216 { 217 OSCL_UNUSED_ARG(aClientClock); 218 return PVMFErrNotSupported; 219 } 220 221 OSCL_EXPORT_REF PVMFStatus 222 PVMFStreamingManagerExtensionInterfaceImpl::GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo) 223 { 224 return (iContainer->GetMediaPresentationInfo(aInfo)); 225 } 226 227 OSCL_EXPORT_REF PVMFStatus 228 PVMFStreamingManagerExtensionInterfaceImpl::SelectTracks(PVMFMediaPresentationInfo& aInfo) 229 { 230 return (iContainer->SelectTracks(aInfo, iSessionId)); 231 } 232 233 OSCL_EXPORT_REF void PVMFStreamingManagerExtensionInterfaceImpl::addRef() 234 { 235 PVInterfaceImpl<PVMFStreamingManagerNodeAllocator>::addRef(); 236 } 237 238 OSCL_EXPORT_REF void PVMFStreamingManagerExtensionInterfaceImpl::removeRef() 239 { 240 PVInterfaceImpl<PVMFStreamingManagerNodeAllocator>::removeRef(); 241 } 242 243 OSCL_EXPORT_REF bool 244 PVMFStreamingManagerExtensionInterfaceImpl::queryInterface(const PVUuid& uuid, PVInterface*& iface) 245 { 246 if (uuid == PVMF_STREAMINGMANAGERNODE_EXTENSIONINTERFACE_UUID) 247 { 248 PVMFStreamingManagerExtensionInterface* interimPtr = 249 OSCL_STATIC_CAST(PVMFStreamingManagerExtensionInterface*, this); 250 iface = OSCL_STATIC_CAST(PVInterface*, interimPtr); 251 return true; 252 } 253 else if (uuid == PVMF_TRACK_SELECTION_INTERFACE_UUID) 254 { 255 PVMFTrackSelectionExtensionInterface* interimPtr = 256 OSCL_STATIC_CAST(PVMFTrackSelectionExtensionInterface*, this); 257 iface = OSCL_STATIC_CAST(PVInterface*, interimPtr); 258 return true; 259 } 260 else if (uuid == PVMF_DATA_SOURCE_INIT_INTERFACE_UUID) 261 { 262 PVMFDataSourceInitializationExtensionInterface* interimPtr = 263 OSCL_STATIC_CAST(PVMFDataSourceInitializationExtensionInterface*, this); 264 iface = OSCL_STATIC_CAST(PVInterface*, interimPtr); 265 return true; 266 } 267 else if (uuid == PvmfDataSourcePlaybackControlUuid) 268 { 269 PvmfDataSourcePlaybackControlInterface* interimPtr = 270 OSCL_STATIC_CAST(PvmfDataSourcePlaybackControlInterface*, this); 271 iface = OSCL_STATIC_CAST(PVInterface*, interimPtr); 272 return true; 273 } 274 else if (uuid == KPVMFMetadataExtensionUuid) 275 { 276 PVMFMetadataExtensionInterface* interimPtr = 277 OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*, this); 278 iface = OSCL_STATIC_CAST(PVInterface*, interimPtr); 279 return true; 280 } 281 else if (uuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID) 282 { 283 PvmiCapabilityAndConfig* interimPtr = 284 OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, this); 285 iface = OSCL_STATIC_CAST(PVInterface*, interimPtr); 286 return true; 287 } 288 else if (uuid == PVMFCPMPluginLicenseInterfaceUuid) 289 { 290 PVMFCPMPluginLicenseInterface* interimPtr = 291 OSCL_STATIC_CAST(PVMFCPMPluginLicenseInterface*, this); 292 iface = OSCL_STATIC_CAST(PVInterface*, interimPtr); 293 return true; 294 } 295 else 296 { 297 iface = NULL; 298 return false; 299 } 300 } 301 302 OSCL_EXPORT_REF PVMFCommandId 303 PVMFStreamingManagerExtensionInterfaceImpl::SetDataSourcePosition(PVMFSessionId aSessionId, 304 PVMFTimestamp aTargetNPT, 305 PVMFTimestamp& aActualNPT, 306 PVMFTimestamp& aActualMediaDataTS, 307 bool aSeekToSyncPoint, 308 uint32 aStreamID, 309 OsclAny* aContext) 310 { 311 return (iContainer->SetDataSourcePosition(aSessionId, 312 aTargetNPT, 313 aActualNPT, 314 aActualMediaDataTS, 315 aSeekToSyncPoint, 316 aStreamID, 317 aContext)); 318 } 319 320 OSCL_EXPORT_REF PVMFCommandId 321 PVMFStreamingManagerExtensionInterfaceImpl::SetDataSourcePosition(PVMFSessionId aSessionId, 322 PVMFDataSourcePositionParams& aPVMFDataSourcePositionParams, 323 OsclAny* aContext) 324 { 325 return (iContainer->SetDataSourcePosition(aSessionId, 326 aPVMFDataSourcePositionParams, 327 aContext)); 328 } 329 330 OSCL_EXPORT_REF PVMFCommandId 331 PVMFStreamingManagerExtensionInterfaceImpl::QueryDataSourcePosition(PVMFSessionId aSessionId, 332 PVMFTimestamp aTargetNPT, 333 PVMFTimestamp& aActualNPT, 334 bool aSeekToSyncPoint, 335 OsclAny* aContext) 336 { 337 return (iContainer->QueryDataSourcePosition(aSessionId, 338 aTargetNPT, 339 aActualNPT, 340 aSeekToSyncPoint, 341 aContext)); 342 } 343 344 OSCL_EXPORT_REF PVMFCommandId 345 PVMFStreamingManagerExtensionInterfaceImpl::QueryDataSourcePosition(PVMFSessionId aSessionId, 346 PVMFTimestamp aTargetNPT, 347 PVMFTimestamp& aSeekPointBeforeTargetNPT, 348 PVMFTimestamp& aSeekPointAfterTargetNPT, 349 OsclAny* aContext, 350 bool aSeekToSyncPoint) 351 { 352 OSCL_UNUSED_ARG(aSeekPointAfterTargetNPT); 353 return (iContainer->QueryDataSourcePosition(aSessionId, 354 aTargetNPT, 355 aSeekPointBeforeTargetNPT, 356 aSeekToSyncPoint, 357 aContext)); 358 } 359 360 OSCL_EXPORT_REF PVMFCommandId 361 PVMFStreamingManagerExtensionInterfaceImpl::SetDataSourceRate(PVMFSessionId aSessionId, 362 int32 aRate, 363 PVMFTimebase* aTimebase, 364 OsclAny* aContext) 365 { 366 367 return (iContainer->SetDataSourceRate(aSessionId, 368 aRate, 369 aTimebase, 370 aContext)); 371 } 372 373 OSCL_EXPORT_REF PVMFStatus 374 PVMFStreamingManagerExtensionInterfaceImpl::ComputeSkipTimeStamp(PVMFTimestamp aTargetNPT, 375 PVMFTimestamp aActualNPT, 376 PVMFTimestamp aActualMediaDataTS, 377 PVMFTimestamp& aSkipTimeStamp, 378 PVMFTimestamp& aStartNPT) 379 { 380 return (iContainer->ComputeSkipTimeStamp(aTargetNPT, 381 aActualNPT, 382 aActualMediaDataTS, 383 aSkipTimeStamp, 384 aStartNPT)); 385 } 386 387 OSCL_EXPORT_REF uint32 388 PVMFStreamingManagerExtensionInterfaceImpl::GetNumMetadataKeys(char* query_key) 389 { 390 return (iContainer->GetNumMetadataKeys(query_key)); 391 } 392 393 OSCL_EXPORT_REF uint32 394 PVMFStreamingManagerExtensionInterfaceImpl::GetNumMetadataValues(PVMFMetadataList& aKeyList) 395 { 396 return (iContainer->GetNumMetadataValues(aKeyList)); 397 } 398 399 OSCL_EXPORT_REF PVMFCommandId 400 PVMFStreamingManagerExtensionInterfaceImpl::GetNodeMetadataKeys(PVMFSessionId aSessionId, 401 PVMFMetadataList& aKeyList, 402 uint32 starting_index, 403 int32 max_entries, 404 char* query_key, 405 const OsclAny* aContextData) 406 { 407 return (iContainer->GetNodeMetadataKeys(aSessionId, 408 aKeyList, 409 starting_index, 410 max_entries, 411 query_key, 412 aContextData)); 413 } 414 415 OSCL_EXPORT_REF PVMFCommandId 416 PVMFStreamingManagerExtensionInterfaceImpl::GetNodeMetadataValues(PVMFSessionId aSessionId, 417 PVMFMetadataList& aKeyList, 418 Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, 419 uint32 starting_index, 420 int32 max_entries, 421 const OsclAny* aContextData) 422 { 423 return (iContainer->GetNodeMetadataValues(aSessionId, 424 aKeyList, 425 aValueList, 426 starting_index, 427 max_entries, 428 aContextData)); 429 } 430 431 // From PVMFMetadataExtensionInterface 432 OSCL_EXPORT_REF PVMFStatus 433 PVMFStreamingManagerExtensionInterfaceImpl::ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList, 434 uint32 aStart, 435 uint32 aEnd) 436 { 437 return iContainer->ReleaseNodeMetadataKeys(aKeyList, aStart, aEnd); 438 } 439 440 // From PVMFMetadataExtensionInterface 441 OSCL_EXPORT_REF PVMFStatus 442 PVMFStreamingManagerExtensionInterfaceImpl::ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, 443 uint32 start, 444 uint32 end) 445 { 446 return iContainer->ReleaseNodeMetadataValues(aValueList, start, end); 447 } 448 449 450 // From PVMFCPMPluginLicenseInterface 451 OSCL_EXPORT_REF PVMFCommandId 452 PVMFStreamingManagerExtensionInterfaceImpl::GetLicense(PVMFSessionId aSessionId, 453 OSCL_wString& aContentName, 454 OsclAny* aData, 455 uint32 aDataSize, 456 int32 aTimeoutMsec, 457 OsclAny* aContextData) 458 { 459 return iContainer->GetLicense(aSessionId, 460 aContentName, 461 aData, 462 aDataSize, 463 aTimeoutMsec, 464 aContextData); 465 } 466 467 OSCL_EXPORT_REF PVMFCommandId 468 PVMFStreamingManagerExtensionInterfaceImpl::GetLicense(PVMFSessionId aSessionId, 469 OSCL_String& aContentName, 470 OsclAny* aData, 471 uint32 aDataSize, 472 int32 aTimeoutMsec, 473 OsclAny* aContextData) 474 { 475 return iContainer->GetLicense(aSessionId, 476 aContentName, 477 aData, 478 aDataSize, 479 aTimeoutMsec, 480 aContextData); 481 } 482 483 OSCL_EXPORT_REF PVMFCommandId 484 PVMFStreamingManagerExtensionInterfaceImpl::CancelGetLicense(PVMFSessionId aSessionId, PVMFCommandId aCmdId, OsclAny* aContextData) 485 { 486 return iContainer->CancelGetLicense(aSessionId, aCmdId, aContextData); 487 } 488 489 PVMFStatus PVMFStreamingManagerExtensionInterfaceImpl::GetLicenseStatus( 490 PVMFCPMLicenseStatus& aStatus) 491 { 492 return iContainer->GetLicenseStatus(aStatus); 493 } 494