PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/protocols/rtsp_client_engine/src/pvrtsp_client_engine_port.cpp

https://gitlab.com/Codeaurora/platform_external_opencore
C++ | 177 lines | 134 code | 14 blank | 29 comment | 14 complexity | 54e42b100e490152beb7f0ba65f5b9b7 MD5 | raw file
  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 "pvrtsp_client_engine_port.h"
  19. #ifndef OSCL_MIME_STRING_UTILS_H
  20. #include "pv_mime_string_utils.h"
  21. #endif
  22. PVMFRTSPPort::PVMFRTSPPort(int32 aSdpTrackID, bool aIsMedia, int32 aTag, PVMFNodeInterface* aNode)
  23. : PvmfPortBaseImpl(aTag, aNode)
  24. {
  25. iSdpTrackID = aSdpTrackID;
  26. iRdtStreamId = -1;
  27. bIsMedia = aIsMedia,
  28. bIsChannelIDSet = false;;
  29. Construct();
  30. }
  31. ////////////////////////////////////////////////////////////////////////////
  32. PVMFRTSPPort::PVMFRTSPPort(int32 aSdpTrackID, bool aIsMedia, int32 aTag, PVMFNodeInterface* aNode
  33. , uint32 aInCapacity
  34. , uint32 aInReserve
  35. , uint32 aInThreshold
  36. , uint32 aOutCapacity
  37. , uint32 aOutReserve
  38. , uint32 aOutThreshold)
  39. : PvmfPortBaseImpl(aTag, aNode, aInCapacity, aInReserve, aInThreshold, aOutCapacity, aOutReserve, aOutThreshold)
  40. {
  41. iSdpTrackID = aSdpTrackID;
  42. bIsMedia = aIsMedia,
  43. bIsChannelIDSet = false;;
  44. iRdtStreamId = -1;
  45. Construct();
  46. }
  47. ////////////////////////////////////////////////////////////////////////////
  48. void PVMFRTSPPort::Construct()
  49. {
  50. iLogger = PVLogger::GetLoggerObject("PVMFRTSPPort");
  51. oscl_memset(&iStats, 0, sizeof(PvmfPortBaseImplStats));
  52. // iNumFramesGenerated=0;
  53. iNumFramesConsumed = 0;
  54. PvmiCapabilityAndConfigPortFormatImpl::Construct(
  55. PVMF_RTSP_PORT_IO_FORMATS
  56. , PVMF_RTSP_PORT_IO_FORMATS_VALTYPE);
  57. }
  58. ////////////////////////////////////////////////////////////////////////////
  59. PVMFRTSPPort::~PVMFRTSPPort()
  60. {
  61. Disconnect();
  62. }
  63. ////////////////////////////////////////////////////////////////////////////
  64. bool PVMFRTSPPort::IsFormatSupported(PVMFFormatType aFmt)
  65. {
  66. // return (aFmt==PVMF_INET_UDP)||(aFmt==PVMF_INET_TCP);
  67. if (aFmt == PVMF_MIME_INET_TCP)
  68. {
  69. return true;
  70. }
  71. return false;
  72. }
  73. ////////////////////////////////////////////////////////////////////////////
  74. void PVMFRTSPPort::FormatUpdated()
  75. {
  76. PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
  77. , (0, "PVMFRTSPPort::FormatUpdated %s", iFormat.getMIMEStrPtr()));
  78. }
  79. void PVMFRTSPPort::setParametersSync(PvmiMIOSession aSession,
  80. PvmiKvp* aParameters,
  81. int num_elements,
  82. PvmiKvp * & aRet_kvp)
  83. {
  84. OSCL_UNUSED_ARG(aSession);
  85. PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFRTSPPort::getParametersSync: aSession=0x%x, aParameters=0x%x, num_elements=%d, aRet_kvp=0x%x",
  86. aSession, aParameters, num_elements, aRet_kvp));
  87. if (!aParameters || (num_elements != 1) ||
  88. (pv_mime_strcmp(aParameters->key, PVMF_RTSP_PORT_IO_FORMATS_VALTYPE) != 0))
  89. {
  90. aRet_kvp = aParameters;
  91. OSCL_LEAVE(OsclErrArgument);
  92. }
  93. if (aParameters->value.key_specific_value == NULL)
  94. {
  95. aRet_kvp = aParameters;
  96. OSCL_LEAVE(OsclErrArgument);
  97. }
  98. else
  99. {
  100. aRet_kvp = NULL;
  101. //iAllocSharedPtr = *((OsclSharedPtr<PVMFSharedSocketDataBufferAlloc>*)(aParameters->value.key_specific_value));
  102. }
  103. }
  104. PVMFStatus PVMFRTSPPort::getParametersSync(PvmiMIOSession aSession,
  105. PvmiKeyType aIdentifier,
  106. PvmiKvp*& aParameters,
  107. int& num_parameter_elements,
  108. PvmiCapabilityContext aContext)
  109. {
  110. OSCL_UNUSED_ARG(aSession);
  111. OSCL_UNUSED_ARG(aIdentifier);
  112. OSCL_UNUSED_ARG(aContext);
  113. PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFRTSPPort::getParametersSync: aSession=0x%x, aIdentifier=%s, aParameters=0x%x, num_parameters_elements=%d, aContext=0x%x",
  114. aSession, aIdentifier, aParameters, num_parameter_elements, aContext));
  115. num_parameter_elements = 0;
  116. if (!pvmiGetPortInPlaceDataProcessingInfoSync(PVMI_PORT_CONFIG_INPLACE_DATA_PROCESSING_KEY, aParameters))
  117. {
  118. return PVMFFailure;
  119. }
  120. num_parameter_elements = 1;
  121. return PVMFSuccess;
  122. }
  123. PVMFStatus PVMFRTSPPort::releaseParameters(PvmiMIOSession aSession,
  124. PvmiKvp* aParameters,
  125. int num_elements)
  126. {
  127. OSCL_UNUSED_ARG(aSession);
  128. PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFRTSPPort::releaseParameters: aSession=0x%x, aParameters=0x%x, num_elements=%d",
  129. aSession, aParameters, num_elements));
  130. if ((num_elements != 1) ||
  131. (pv_mime_strcmp(aParameters->key, PVMI_PORT_CONFIG_INPLACE_DATA_PROCESSING_KEY) != 0))
  132. {
  133. PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFRTSPPort::releaseParameters: Error - Not a PvmiKvp created by this port"));
  134. return PVMFFailure;
  135. }
  136. OsclMemAllocator alloc;
  137. //alloc.deallocate((OsclAny*)(aParameters->key));
  138. alloc.deallocate((OsclAny*)(aParameters));
  139. return PVMFSuccess;
  140. }
  141. bool
  142. PVMFRTSPPort::pvmiGetPortInPlaceDataProcessingInfoSync(const char* aFormatValType,
  143. PvmiKvp*& aKvp)
  144. {
  145. /*
  146. * Create PvmiKvp for capability settings
  147. */
  148. aKvp = NULL;
  149. OsclMemAllocator alloc;
  150. uint32 strLen = oscl_strlen(aFormatValType) + 1;
  151. uint8* ptr = (uint8*)alloc.ALLOCATE(sizeof(PvmiKvp) + strLen);
  152. if (ptr == NULL)
  153. {
  154. return false;
  155. }
  156. aKvp = new(ptr) PvmiKvp;
  157. ptr += sizeof(PvmiKvp);
  158. aKvp->key = (PvmiKeyType)ptr;
  159. oscl_strncpy(aKvp->key, aFormatValType, strLen);
  160. aKvp->length = aKvp->capacity = strLen;
  161. aKvp->value.bool_value = false;
  162. return true;
  163. }