IStreamInformation.c revision 887b8d1551370e592f527dcba3e76cf6916cf677
19066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/* 23d40df335e4c0df972720271a84277077f168f65Dan Egnor * Copyright (C) 2011 The Android Open Source Project 33d40df335e4c0df972720271a84277077f168f65Dan Egnor * 43d40df335e4c0df972720271a84277077f168f65Dan Egnor * Licensed under the Apache License, Version 2.0 (the "License"); 53d40df335e4c0df972720271a84277077f168f65Dan Egnor * you may not use this file except in compliance with the License. 63d40df335e4c0df972720271a84277077f168f65Dan Egnor * You may obtain a copy of the License at 73d40df335e4c0df972720271a84277077f168f65Dan Egnor * 83d40df335e4c0df972720271a84277077f168f65Dan Egnor * http://www.apache.org/licenses/LICENSE-2.0 93d40df335e4c0df972720271a84277077f168f65Dan Egnor * 103d40df335e4c0df972720271a84277077f168f65Dan Egnor * Unless required by applicable law or agreed to in writing, software 113d40df335e4c0df972720271a84277077f168f65Dan Egnor * distributed under the License is distributed on an "AS IS" BASIS, 123d40df335e4c0df972720271a84277077f168f65Dan Egnor * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133d40df335e4c0df972720271a84277077f168f65Dan Egnor * See the License for the specific language governing permissions and 143d40df335e4c0df972720271a84277077f168f65Dan Egnor * limitations under the License. 153d40df335e4c0df972720271a84277077f168f65Dan Egnor */ 169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/* StreamInformation implementation */ 189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 193d40df335e4c0df972720271a84277077f168f65Dan Egnor#include "sles_allinclusive.h" 209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectstatic XAresult IStreamInformation_QueryMediaContainerInformation( XAStreamInformationItf self, 22492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor XAMediaContainerInformation * info /* [out] */) 2313579ed3305bf89b41a9fa88e1347f0e0769d279Dianne Hackborn{ 243d40df335e4c0df972720271a84277077f168f65Dan Egnor XA_ENTER_INTERFACE 253d40df335e4c0df972720271a84277077f168f65Dan Egnor 26492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor if (NULL == info) { 273d40df335e4c0df972720271a84277077f168f65Dan Egnor result = XA_RESULT_PARAMETER_INVALID; 281af33d0ddc2f50ade146e4d48e2feb6f1d553427Doug Zongker XA_LEAVE_INTERFACE 2913579ed3305bf89b41a9fa88e1347f0e0769d279Dianne Hackborn } 3013579ed3305bf89b41a9fa88e1347f0e0769d279Dianne Hackborn 313d40df335e4c0df972720271a84277077f168f65Dan Egnor#ifdef ANDROID 32948eef82546c15086d0b78ce18ee874aa5c634f7Jeff Sharkey IStreamInformation *thiz = (IStreamInformation *) self; 338a9b22056b13477f59df934928c00c58b5871c95Joe Onorato interface_lock_shared(thiz); 343d40df335e4c0df972720271a84277077f168f65Dan Egnor // always storing container info at index 0, as per spec 353d40df335e4c0df972720271a84277077f168f65Dan Egnor *info = thiz->mStreamInfoTable.itemAt(0).containerInfo; 363d40df335e4c0df972720271a84277077f168f65Dan Egnor interface_unlock_shared(thiz); 373d40df335e4c0df972720271a84277077f168f65Dan Egnor // even though the pointer to the media container info is returned, the values aren't set 383d40df335e4c0df972720271a84277077f168f65Dan Egnor // for the actual container in this version, they are simply initialized to defaults 393d40df335e4c0df972720271a84277077f168f65Dan Egnor // (see IStreamInformation_init) 403d40df335e4c0df972720271a84277077f168f65Dan Egnor result = XA_RESULT_SUCCESS; 413d40df335e4c0df972720271a84277077f168f65Dan Egnor#else 423d40df335e4c0df972720271a84277077f168f65Dan Egnor SL_LOGE("QueryMediaContainerInformation is unsupported"); 433d40df335e4c0df972720271a84277077f168f65Dan Egnor memset(info, 0, sizeof(XAMediaContainerInformation)); 449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project result = XA_RESULT_FEATURE_UNSUPPORTED; 450132a952f75a88582f4437b2c97039b71456f828Dave Burke#endif 460132a952f75a88582f4437b2c97039b71456f828Dave Burke 470132a952f75a88582f4437b2c97039b71456f828Dave Burke XA_LEAVE_INTERFACE 480132a952f75a88582f4437b2c97039b71456f828Dave Burke} 4942471dd5552a346dd82a58a663159875ccc4fb79Dan Egnor 50492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor 51492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnorstatic XAresult IStreamInformation_QueryStreamType( XAStreamInformationItf self, 52944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker XAuint32 streamIndex, /* [in] */ 53944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker XAuint32 *domain) /* [out] */ 54944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker{ 55944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker XA_ENTER_INTERFACE 56944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker 57944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker if (NULL == domain) { 58944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker result = XA_RESULT_PARAMETER_INVALID; 59944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker XA_LEAVE_INTERFACE; 60492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor } 61492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor 62492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor#ifndef ANDROID 639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *domain = XA_DOMAINTYPE_UNKNOWN; 64c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor#else 65c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor if (0 == streamIndex) { 66c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor // stream 0 is reserved for the container 67c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor result = XA_RESULT_PARAMETER_INVALID; 68c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor *domain = XA_DOMAINTYPE_UNKNOWN; 69c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor } else { 70c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor IStreamInformation *thiz = (IStreamInformation *) self; 71c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor 72c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor interface_lock_shared(thiz); 73c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor 74944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker XAuint32 nbStreams = thiz->mStreamInfoTable.itemAt(0).containerInfo.numStreams; 7513579ed3305bf89b41a9fa88e1347f0e0769d279Dianne Hackborn // streams in the container are numbered 1..nbStreams 7613579ed3305bf89b41a9fa88e1347f0e0769d279Dianne Hackborn if (streamIndex <= nbStreams) { 7713579ed3305bf89b41a9fa88e1347f0e0769d279Dianne Hackborn result = XA_RESULT_SUCCESS; 7813579ed3305bf89b41a9fa88e1347f0e0769d279Dianne Hackborn *domain = thiz->mStreamInfoTable.itemAt(streamIndex).domain; 7913579ed3305bf89b41a9fa88e1347f0e0769d279Dianne Hackborn } else { 8013579ed3305bf89b41a9fa88e1347f0e0769d279Dianne Hackborn SL_LOGE("Querying stream type for stream %d, only %d streams available", 8113579ed3305bf89b41a9fa88e1347f0e0769d279Dianne Hackborn streamIndex, nbStreams); 8213579ed3305bf89b41a9fa88e1347f0e0769d279Dianne Hackborn result = XA_RESULT_PARAMETER_INVALID; 8313579ed3305bf89b41a9fa88e1347f0e0769d279Dianne Hackborn } 84944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker 85944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker interface_unlock_shared(thiz); 86944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker } 87944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker#endif 88c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor 89c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor XA_LEAVE_INTERFACE 909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project} 919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 92948eef82546c15086d0b78ce18ee874aa5c634f7Jeff Sharkey 93948eef82546c15086d0b78ce18ee874aa5c634f7Jeff Sharkeystatic XAresult IStreamInformation_QueryStreamInformation( XAStreamInformationItf self, 94944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker XAuint32 streamIndex, /* [in] */ 95944ff0b788bf1702bad38d21cc2b83a9985dd112Doug Zongker void * info) /* [out] */ 96492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor{ 97492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor XA_ENTER_INTERFACE 98492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor 99c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor if (NULL == info) { 100492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor result = XA_RESULT_PARAMETER_INVALID; 101492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor } else { 1028b2c916a8dc2370ce700a577d999f1a0fd848735Colin Cross 1038b2c916a8dc2370ce700a577d999f1a0fd848735Colin Cross#ifndef ANDROID 104492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor result = XA_RESULT_FEATURE_UNSUPPORTED; 105492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor#else 106492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor 107492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor IStreamInformation *thiz = (IStreamInformation *) self; 108c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor 109431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross interface_lock_shared(thiz); 1103d40df335e4c0df972720271a84277077f168f65Dan Egnor 111c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor XAuint32 nbStreams = thiz->mStreamInfoTable.itemAt(0).containerInfo.numStreams; 112c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor // stream 0 is the container, and other streams in the container are numbered 1..nbStreams 113c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor if (streamIndex <= nbStreams) { 114c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor result = XA_RESULT_SUCCESS; 1153d40df335e4c0df972720271a84277077f168f65Dan Egnor const StreamInfo& streamInfo = thiz->mStreamInfoTable.itemAt((size_t)streamIndex); 116431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross 117431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross switch (streamInfo.domain) { 118431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross case XA_DOMAINTYPE_CONTAINER: 119431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross *(XAMediaContainerInformation *)info = streamInfo.containerInfo; 120431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross break; 121431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross case XA_DOMAINTYPE_AUDIO: 122431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross *(XAAudioStreamInformation *)info = streamInfo.audioInfo; 123431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross break; 124431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross case XA_DOMAINTYPE_VIDEO: 1253d40df335e4c0df972720271a84277077f168f65Dan Egnor *(XAVideoStreamInformation *)info = streamInfo.videoInfo; 12691317107a39a4f2a9347105b96aafcb98fe21feePaul Lawrence break; 12791317107a39a4f2a9347105b96aafcb98fe21feePaul Lawrence case XA_DOMAINTYPE_IMAGE: 12891317107a39a4f2a9347105b96aafcb98fe21feePaul Lawrence *(XAImageStreamInformation *)info = streamInfo.imageInfo; 12991317107a39a4f2a9347105b96aafcb98fe21feePaul Lawrence break; 13091317107a39a4f2a9347105b96aafcb98fe21feePaul Lawrence case XA_DOMAINTYPE_TIMEDTEXT: 13191317107a39a4f2a9347105b96aafcb98fe21feePaul Lawrence *(XATimedTextStreamInformation *)info = streamInfo.textInfo; 13291317107a39a4f2a9347105b96aafcb98fe21feePaul Lawrence break; 13391317107a39a4f2a9347105b96aafcb98fe21feePaul Lawrence case XA_DOMAINTYPE_MIDI: 13491317107a39a4f2a9347105b96aafcb98fe21feePaul Lawrence *(XAMIDIStreamInformation *)info = streamInfo.midiInfo; 135c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor break; 136289e58051dd575cee601c38d6816b9ecd745b505Dan Egnor case XA_DOMAINTYPE_VENDOR: 137289e58051dd575cee601c38d6816b9ecd745b505Dan Egnor *(XAVendorStreamInformation *)info = streamInfo.vendorInfo; 138431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross break; 139431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross default: 140431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross SL_LOGE("StreamInformation::QueryStreamInformation index %u has " 141431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross "unknown domain %u", streamIndex, streamInfo.domain); 142431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross result = XA_RESULT_INTERNAL_ERROR; 143c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor break; 144289e58051dd575cee601c38d6816b9ecd745b505Dan Egnor } 145e37030505ee3d461508611e1a291aff7b9e82a43Patrick Tjin 146e37030505ee3d461508611e1a291aff7b9e82a43Patrick Tjin } else { 147c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor SL_LOGE("Querying stream type for stream %d, only %d streams available", 148289e58051dd575cee601c38d6816b9ecd745b505Dan Egnor streamIndex, nbStreams); 149c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor result = XA_RESULT_PARAMETER_INVALID; 150289e58051dd575cee601c38d6816b9ecd745b505Dan Egnor } 15151611eb72897645eba2140d5de0795c1830b90daGeremy Condra 152fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall interface_unlock_shared(thiz); 1533d40df335e4c0df972720271a84277077f168f65Dan Egnor#endif 154c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor 155492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor } 156492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor 157492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor XA_LEAVE_INTERFACE 158492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor} 159492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor 160dea847c2ace8894a595cf9bd87764ce2ca9698abPatrick Tjin 161dea847c2ace8894a595cf9bd87764ce2ca9698abPatrick Tjinstatic XAresult IStreamInformation_QueryStreamName( XAStreamInformationItf self, 162dea847c2ace8894a595cf9bd87764ce2ca9698abPatrick Tjin XAuint32 streamIndex, /* [in] */ 163dea847c2ace8894a595cf9bd87764ce2ca9698abPatrick Tjin XAuint16 * pNameSize, /* [in/out] */ 1643d40df335e4c0df972720271a84277077f168f65Dan Egnor XAchar * pName) /* [out] */ 1653d40df335e4c0df972720271a84277077f168f65Dan Egnor{ 166492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor XA_ENTER_INTERFACE 167492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor 168492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor if (NULL == pNameSize || streamIndex == 0) { 169492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor result = XA_RESULT_PARAMETER_INVALID; 170492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor } else { 171492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor#ifdef ANDROID 172dea847c2ace8894a595cf9bd87764ce2ca9698abPatrick Tjin IStreamInformation *thiz = (IStreamInformation *) self; 173dea847c2ace8894a595cf9bd87764ce2ca9698abPatrick Tjin interface_lock_shared(thiz); 174dea847c2ace8894a595cf9bd87764ce2ca9698abPatrick Tjin 175dea847c2ace8894a595cf9bd87764ce2ca9698abPatrick Tjin XAuint32 nbStreams = thiz->mStreamInfoTable.itemAt(0).containerInfo.numStreams; 176492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor // streams in the container are numbered 1..nbStreams 1778a9b22056b13477f59df934928c00c58b5871c95Joe Onorato if (streamIndex <= nbStreams) { 178492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor char streamName[16]; // large enough for the fixed format in next line 179492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor snprintf(streamName, sizeof(streamName), "stream%u", streamIndex); 180492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor size_t actualNameLength = strlen(streamName); 181492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor if (NULL == pName) { 182492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor // application is querying the name length in order to allocate a buffer 1833d40df335e4c0df972720271a84277077f168f65Dan Egnor result = XA_RESULT_SUCCESS; 1843d40df335e4c0df972720271a84277077f168f65Dan Egnor } else { 185492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor SLuint16 availableNameLength = *pNameSize; 186492c6ed5b64cfdd72dc270e6b848025a26eff724Dan Egnor if (actualNameLength > availableNameLength) { 187289e58051dd575cee601c38d6816b9ecd745b505Dan Egnor memcpy(pName, streamName, availableNameLength); 188431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross result = XA_RESULT_BUFFER_INSUFFICIENT; 189431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross } else if (actualNameLength == availableNameLength) { 190431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross memcpy(pName, streamName, availableNameLength); 191431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross result = XA_RESULT_SUCCESS; 192431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross } else { // actualNameLength < availableNameLength 193431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross memcpy(pName, streamName, actualNameLength + 1); 194431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross result = XA_RESULT_SUCCESS; 195431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross } 196c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor } 1973d40df335e4c0df972720271a84277077f168f65Dan Egnor *pNameSize = actualNameLength; 1983d40df335e4c0df972720271a84277077f168f65Dan Egnor } else { 1993d40df335e4c0df972720271a84277077f168f65Dan Egnor result = XA_RESULT_PARAMETER_INVALID; 2003d40df335e4c0df972720271a84277077f168f65Dan Egnor } 2013d40df335e4c0df972720271a84277077f168f65Dan Egnor 202c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor interface_unlock_shared(thiz); 203c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor#else 204c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor SL_LOGE("unsupported XAStreamInformationItf function"); 205333b8cba996c8ebb8ca55ebfc5cc536bdd64af94Brad Fitzpatrick result = XA_RESULT_FEATURE_UNSUPPORTED; 206333b8cba996c8ebb8ca55ebfc5cc536bdd64af94Brad Fitzpatrick#endif 20766fce5068a8a3aeb28aaf713843891b286a75280Brad Fitzpatrick } 208c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor 20942471dd5552a346dd82a58a663159875ccc4fb79Dan Egnor XA_LEAVE_INTERFACE 210c95142d4a0ab7bebb899167da17c70c3196abbe4Dan Egnor} 211431614cb6b2170fc715757dc6f964fdbb140ee7dColin Cross 2123d40df335e4c0df972720271a84277077f168f65Dan Egnor 21351611eb72897645eba2140d5de0795c1830b90daGeremy Condrastatic XAresult IStreamInformation_RegisterStreamChangeCallback( XAStreamInformationItf self, 21451611eb72897645eba2140d5de0795c1830b90daGeremy Condra xaStreamEventChangeCallback callback, /* [in] */ 21551611eb72897645eba2140d5de0795c1830b90daGeremy Condra void * pContext) /* [in] */ 21651611eb72897645eba2140d5de0795c1830b90daGeremy Condra{ 21751611eb72897645eba2140d5de0795c1830b90daGeremy Condra XA_ENTER_INTERFACE 21851611eb72897645eba2140d5de0795c1830b90daGeremy Condra 21951611eb72897645eba2140d5de0795c1830b90daGeremy Condra IStreamInformation *thiz = (IStreamInformation *) self; 22051611eb72897645eba2140d5de0795c1830b90daGeremy Condra 221c95bb562e8c67c258623fe70e8001a08e59b8c7dTodd Poynor interface_lock_exclusive(thiz); 222c95bb562e8c67c258623fe70e8001a08e59b8c7dTodd Poynor 223c95bb562e8c67c258623fe70e8001a08e59b8c7dTodd Poynor thiz->mCallback = callback; 224c95bb562e8c67c258623fe70e8001a08e59b8c7dTodd Poynor thiz->mContext = pContext; 225c95bb562e8c67c258623fe70e8001a08e59b8c7dTodd Poynor result = SL_RESULT_SUCCESS; 22651611eb72897645eba2140d5de0795c1830b90daGeremy Condra 22751611eb72897645eba2140d5de0795c1830b90daGeremy Condra interface_unlock_exclusive(thiz); 22851611eb72897645eba2140d5de0795c1830b90daGeremy Condra 22951611eb72897645eba2140d5de0795c1830b90daGeremy Condra XA_LEAVE_INTERFACE 23051611eb72897645eba2140d5de0795c1830b90daGeremy Condra} 23151611eb72897645eba2140d5de0795c1830b90daGeremy Condra 23251611eb72897645eba2140d5de0795c1830b90daGeremy Condra 23351611eb72897645eba2140d5de0795c1830b90daGeremy Condrastatic XAresult IStreamInformation_QueryActiveStreams( XAStreamInformationItf self, 23451611eb72897645eba2140d5de0795c1830b90daGeremy Condra XAuint32 *numStreams, /* [in/out] */ 23551611eb72897645eba2140d5de0795c1830b90daGeremy Condra XAboolean *activeStreams) /* [out] */ 23651611eb72897645eba2140d5de0795c1830b90daGeremy Condra{ 23751611eb72897645eba2140d5de0795c1830b90daGeremy Condra XA_ENTER_INTERFACE 23851611eb72897645eba2140d5de0795c1830b90daGeremy Condra 23951611eb72897645eba2140d5de0795c1830b90daGeremy Condra if (NULL == numStreams) { 24051611eb72897645eba2140d5de0795c1830b90daGeremy Condra result = XA_RESULT_PARAMETER_INVALID; 24151611eb72897645eba2140d5de0795c1830b90daGeremy Condra XA_LEAVE_INTERFACE; 24251611eb72897645eba2140d5de0795c1830b90daGeremy Condra } 24351611eb72897645eba2140d5de0795c1830b90daGeremy Condra 24451611eb72897645eba2140d5de0795c1830b90daGeremy Condra#ifdef ANDROID 24551611eb72897645eba2140d5de0795c1830b90daGeremy Condra IStreamInformation *thiz = (IStreamInformation *) self; 246fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall interface_lock_shared(thiz); 247fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall 248fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall result = XA_RESULT_SUCCESS; 249fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall *numStreams = thiz->mStreamInfoTable.itemAt(0).containerInfo.numStreams; 250fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall activeStreams = thiz->mActiveStreams; 251fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall 252fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall interface_unlock_shared(thiz); 253fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall#else 254fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall result = SL_RESULT_FEATURE_UNSUPPORTED; 255fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall#endif 256fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall 257fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall XA_LEAVE_INTERFACE 258fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall} 259fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall 260fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall 261fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrallstatic XAresult IStreamInformation_SetActiveStream( XAStreamInformationItf self, 262fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall XAuint32 streamNum, /* [in] */ 263fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall XAboolean active, /* [in] */ 264fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall XAboolean commitNow) /* [in] */ 265fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall{ 266fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall XA_ENTER_INTERFACE 267fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall 268fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall SL_LOGE("unsupported XAStreamInformationItf function"); 269fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall result = XA_RESULT_FEATURE_UNSUPPORTED; 270fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall 271fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall XA_LEAVE_INTERFACE 272fefefbb17542a48f76aaabac42b376967bbcd3edKen Sumrall} 2733d40df335e4c0df972720271a84277077f168f65Dan Egnor 274 275static const struct XAStreamInformationItf_ IStreamInformation_Itf = { 276 IStreamInformation_QueryMediaContainerInformation, 277 IStreamInformation_QueryStreamType, 278 IStreamInformation_QueryStreamInformation, 279 IStreamInformation_QueryStreamName, 280 IStreamInformation_RegisterStreamChangeCallback, 281 IStreamInformation_QueryActiveStreams, 282 IStreamInformation_SetActiveStream 283}; 284 285 286void IStreamInformation_init(void *self) 287{ 288 SL_LOGV("IStreamInformation_init\n"); 289 IStreamInformation *thiz = (IStreamInformation *) self; 290 thiz->mItf = &IStreamInformation_Itf; 291 292 thiz->mCallback = NULL; 293 thiz->mContext = NULL; 294 295 for (int i=0 ; i < NB_SUPPORTED_STREAMS ; i++) { 296 thiz->mActiveStreams[i] = XA_BOOLEAN_FALSE; 297 } 298 299#ifdef ANDROID 300 // placement new constructor for C++ field within C struct 301 (void) new (&thiz->mStreamInfoTable) android::Vector<StreamInfo>(); 302 // initialize container info 303 StreamInfo contInf; 304 contInf.domain = XA_DOMAINTYPE_CONTAINER; 305 contInf.containerInfo.containerType = XA_CONTAINERTYPE_UNSPECIFIED; 306 contInf.containerInfo.mediaDuration = XA_TIME_UNKNOWN; 307 // FIXME shouldn't this be 1 ? 308 contInf.containerInfo.numStreams = 0; 309 // always storing container info at index 0, as per spec: here, the table was still empty 310 thiz->mStreamInfoTable.add(contInf); 311#endif 312} 313 314 315void IStreamInformation_deinit(void *self) { 316#ifdef ANDROID 317 IStreamInformation *thiz = (IStreamInformation *) self; 318 // explicit destructor 319 thiz->mStreamInfoTable.~Vector<StreamInfo>(); 320#endif 321} 322