IStreamInformation.c revision 262059f71a68edc5e510427c63f5f1623d3672a8
1/* 2 * Copyright (C) 2011 The Android Open Source Project 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 express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17/* StreamInformation implementation */ 18 19#include "sles_allinclusive.h" 20 21static XAresult IStreamInformation_QueryMediaContainerInformation( XAStreamInformationItf self, 22 XAMediaContainerInformation * info /* [out] */) 23{ 24 XA_ENTER_INTERFACE 25 26#ifdef ANDROID 27 IStreamInformation *this = (IStreamInformation *) self; 28 interface_lock_exclusive(this); 29 info = (XAMediaContainerInformation*)&(this->mStreamInfoTable.itemAt(0).containerInfo); 30 interface_unlock_exclusive(this); 31 // even though the pointer to the media container info is returned, the values aren't set 32 // for the actual container in this version, they are simply initialized to defaults 33 // (see IStreamInformation_init) 34 result = XA_RESULT_CONTENT_UNSUPPORTED; 35#else 36 SL_LOGE("QueryMediaContainerInformation is unsupported"); 37 info = NULL; 38 result = XA_RESULT_CONTENT_UNSUPPORTED; 39#endif 40 41 XA_LEAVE_INTERFACE 42} 43 44 45static XAresult IStreamInformation_QueryStreamType( XAStreamInformationItf self, 46 XAuint32 streamIndex, /* [in] */ 47 XAuint32 *domain) /* [out] */ 48{ 49 XA_ENTER_INTERFACE 50 51 if (NULL == domain) { 52 result = XA_RESULT_PARAMETER_INVALID; 53 XA_LEAVE_INTERFACE; 54 } 55 56#ifndef ANDROID 57 *domain = XA_DOMAINTYPE_UNKNOWN; 58#else 59 if (0 == streamIndex) { 60 // stream 0 is reserved for the container 61 result = XA_RESULT_PARAMETER_INVALID; 62 } else { 63 IStreamInformation *this = (IStreamInformation *) self; 64 65 interface_lock_exclusive(this); 66 XAuint32 nbStreams = this->mStreamInfoTable.itemAt(0).containerInfo.numStreams; 67 // streams in the container are numbered 1..nbStreams 68 if (streamIndex <= nbStreams) { 69 result = XA_RESULT_SUCCESS; 70 *domain = this->mStreamInfoTable.itemAt(streamIndex).domain; 71 } else { 72 SL_LOGE("Querying stream type for stream %ld, only %ld streams available", 73 streamIndex, nbStreams); 74 result = XA_RESULT_PARAMETER_INVALID; 75 } 76 interface_unlock_exclusive(this); 77 } 78#endif 79 80 XA_LEAVE_INTERFACE 81} 82 83 84static XAresult IStreamInformation_QueryStreamInformation( XAStreamInformationItf self, 85 XAuint32 streamIndex, /* [in] */ 86 void * info) /* [out] */ 87{ 88 XA_ENTER_INTERFACE 89 90 SL_LOGE("unsupported XAStreamInformationItf function"); 91 result = XA_RESULT_CONTENT_UNSUPPORTED; 92 93 XA_LEAVE_INTERFACE 94} 95 96 97static XAresult IStreamInformation_QueryStreamName( XAStreamInformationItf self, 98 XAuint32 streamIndex, /* [in] */ 99 XAuint16 * pNameSize, /* [in/out] */ 100 XAchar * pName) /* [out] */ 101{ 102 XA_ENTER_INTERFACE 103 104 SL_LOGE("unsupported XAStreamInformationItf function"); 105 result = XA_RESULT_CONTENT_UNSUPPORTED; 106 107 XA_LEAVE_INTERFACE 108} 109 110 111static XAresult IStreamInformation_RegisterStreamChangeCallback( XAStreamInformationItf self, 112 xaStreamEventChangeCallback callback, /* [in] */ 113 void * pContext) /* [in] */ 114{ 115 XA_ENTER_INTERFACE 116 117 IStreamInformation *this = (IStreamInformation *) self; 118 119 interface_lock_exclusive(this); 120 121 this->mCallback = callback; 122 this->mContext = pContext; 123 124 switch (InterfaceToObjectID(this)) { 125 126 case XA_OBJECTID_MEDIAPLAYER: 127 SL_LOGI("IStreamInformation_RegisterStreamChangeCallback()"); 128 result = SL_RESULT_SUCCESS; 129 break; 130 default: 131 result = SL_RESULT_PARAMETER_INVALID; 132 break; 133 } 134 135 interface_unlock_exclusive(this); 136 137 XA_LEAVE_INTERFACE 138} 139 140 141static XAresult IStreamInformation_QueryActiveStreams( XAStreamInformationItf self, 142 XAuint32 *numStreams, /* [in/out] */ 143 XAboolean *activeStreams) /* [out] */ 144{ 145 XA_ENTER_INTERFACE 146 147 if (NULL == numStreams) { 148 result = XA_RESULT_PARAMETER_INVALID; 149 XA_LEAVE_INTERFACE; 150 } 151 152 SL_LOGE("unsupported XAStreamInformationItf function"); 153 result = XA_RESULT_CONTENT_UNSUPPORTED; 154 *numStreams = 0; 155 activeStreams = NULL; 156 157 XA_LEAVE_INTERFACE 158} 159 160 161static XAresult IStreamInformation_SetActiveStream( XAStreamInformationItf self, 162 XAuint32 streamNum, /* [in] */ 163 XAboolean active, /* [in] */ 164 XAboolean commitNow) /* [in] */ 165{ 166 XA_ENTER_INTERFACE 167 168 SL_LOGE("unsupported XAStreamInformationItf function"); 169 result = XA_RESULT_FEATURE_UNSUPPORTED; 170 171 XA_LEAVE_INTERFACE 172} 173 174 175static const struct XAStreamInformationItf_ IStreamInformation_Itf = { 176 IStreamInformation_QueryMediaContainerInformation, 177 IStreamInformation_QueryStreamType, 178 IStreamInformation_QueryStreamInformation, 179 IStreamInformation_QueryStreamName, 180 IStreamInformation_RegisterStreamChangeCallback, 181 IStreamInformation_QueryActiveStreams, 182 IStreamInformation_SetActiveStream 183}; 184 185void IStreamInformation_init(void *self) 186{ 187 IStreamInformation *this = (IStreamInformation *) self; 188 this->mItf = &IStreamInformation_Itf; 189 190 this->mCallback = NULL; 191 this->mContext = NULL; 192 193#ifdef ANDROID 194 // initialize container info 195 StreamInfo contInf; 196 contInf.domain = XA_DOMAINTYPE_UNKNOWN; // there should really be a domain for the container! 197 contInf.containerInfo.containerType = XA_CONTAINERTYPE_UNSPECIFIED; 198 contInf.containerInfo.mediaDuration = XA_TIME_UNKNOWN; 199 contInf.containerInfo.numStreams = 0; 200 this->mStreamInfoTable.add(contInf); 201#endif 202} 203