1 /* 2 * Copyright (C) 2010 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 /* MetadataTraversal implementation */ 18 19 #include "sles_allinclusive.h" 20 21 22 static SLresult IMetadataTraversal_SetMode(SLMetadataTraversalItf self, SLuint32 mode) 23 { 24 SL_ENTER_INTERFACE 25 26 switch (mode) { 27 case SL_METADATATRAVERSALMODE_ALL: 28 case SL_METADATATRAVERSALMODE_NODE: 29 { 30 IMetadataTraversal *thiz = (IMetadataTraversal *) self; 31 interface_lock_poke(thiz); 32 thiz->mMode = mode; 33 interface_unlock_poke(thiz); 34 result = SL_RESULT_SUCCESS; 35 } 36 break; 37 default: 38 result = SL_RESULT_PARAMETER_INVALID; 39 break; 40 } 41 42 SL_LEAVE_INTERFACE 43 } 44 45 46 static SLresult IMetadataTraversal_GetChildCount(SLMetadataTraversalItf self, SLuint32 *pCount) 47 { 48 SL_ENTER_INTERFACE 49 50 if (NULL == pCount) { 51 result = SL_RESULT_PARAMETER_INVALID; 52 } else { 53 IMetadataTraversal *thiz = (IMetadataTraversal *) self; 54 interface_lock_peek(thiz); 55 SLuint32 count = thiz->mCount; 56 interface_unlock_peek(thiz); 57 *pCount = count; 58 result = SL_RESULT_SUCCESS; 59 } 60 61 SL_LEAVE_INTERFACE 62 } 63 64 65 static SLresult IMetadataTraversal_GetChildMIMETypeSize( 66 SLMetadataTraversalItf self, SLuint32 index, SLuint32 *pSize) 67 { 68 SL_ENTER_INTERFACE 69 70 if (NULL == pSize) { 71 result = SL_RESULT_PARAMETER_INVALID; 72 } else { 73 IMetadataTraversal *thiz = (IMetadataTraversal *) self; 74 interface_lock_peek(thiz); 75 SLuint32 size = thiz->mSize; 76 interface_unlock_peek(thiz); 77 *pSize = size; 78 result = SL_RESULT_SUCCESS; 79 } 80 81 SL_LEAVE_INTERFACE 82 } 83 84 85 static SLresult IMetadataTraversal_GetChildInfo(SLMetadataTraversalItf self, SLuint32 index, 86 SLint32 *pNodeID, SLuint32 *pType, SLuint32 size, SLchar *pMimeType) 87 { 88 SL_ENTER_INTERFACE 89 90 //IMetadataTraversal *thiz = (IMetadataTraversal *) self; 91 result = SL_RESULT_FEATURE_UNSUPPORTED; 92 93 SL_LEAVE_INTERFACE 94 } 95 96 97 static SLresult IMetadataTraversal_SetActiveNode(SLMetadataTraversalItf self, SLuint32 index) 98 { 99 SL_ENTER_INTERFACE 100 101 if (SL_NODE_PARENT == index) { 102 ; 103 } 104 IMetadataTraversal *thiz = (IMetadataTraversal *) self; 105 thiz->mIndex = index; 106 result = SL_RESULT_PARAMETER_INVALID; 107 108 SL_LEAVE_INTERFACE 109 } 110 111 112 static const struct SLMetadataTraversalItf_ IMetadataTraversal_Itf = { 113 IMetadataTraversal_SetMode, 114 IMetadataTraversal_GetChildCount, 115 IMetadataTraversal_GetChildMIMETypeSize, 116 IMetadataTraversal_GetChildInfo, 117 IMetadataTraversal_SetActiveNode 118 }; 119 120 void IMetadataTraversal_init(void *self) 121 { 122 IMetadataTraversal *thiz = (IMetadataTraversal *) self; 123 thiz->mItf = &IMetadataTraversal_Itf; 124 thiz->mIndex = 0; 125 thiz->mMode = SL_METADATATRAVERSALMODE_NODE; 126 thiz->mCount = 0; 127 thiz->mSize = 0; 128 } 129