Home | History | Annotate | Download | only in itf
      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 /* AudioEncoderCapabilities implementation */
     18 
     19 #include "sles_allinclusive.h"
     20 
     21 
     22 static SLresult IAudioEncoderCapabilities_GetAudioEncoders(SLAudioEncoderCapabilitiesItf self,
     23     SLuint32 *pNumEncoders, SLuint32 *pEncoderIds)
     24 {
     25     SL_ENTER_INTERFACE
     26 
     27     if (NULL == pNumEncoders) {
     28         result = SL_RESULT_PARAMETER_INVALID;
     29     } else {
     30         result = SL_RESULT_SUCCESS;
     31         if (NULL != pEncoderIds) {
     32             SLuint32 numEncoders = *pNumEncoders;
     33             if (numEncoders > MAX_ENCODERS) {
     34                 numEncoders = MAX_ENCODERS;
     35             } else if (numEncoders < MAX_ENCODERS) {
     36                 // FIXME starting in 1.1 this will be SL_RESULT_BUFFER_INSUFFICIENT
     37                 result = SL_RESULT_PARAMETER_INVALID;
     38             }
     39             memcpy(pEncoderIds, Encoder_IDs, numEncoders * sizeof(SLuint32));
     40         }
     41         *pNumEncoders = MAX_ENCODERS;
     42     }
     43 
     44     SL_LEAVE_INTERFACE
     45 }
     46 
     47 
     48 static SLresult IAudioEncoderCapabilities_GetAudioEncoderCapabilities(
     49     SLAudioEncoderCapabilitiesItf self, SLuint32 encoderId, SLuint32 *pIndex,
     50     SLAudioCodecDescriptor *pDescriptor)
     51 {
     52     SL_ENTER_INTERFACE
     53 
     54     result = GetCodecCapabilities(encoderId, pIndex, pDescriptor,
     55         EncoderDescriptors);
     56 
     57     SL_LEAVE_INTERFACE
     58 }
     59 
     60 
     61 static const struct SLAudioEncoderCapabilitiesItf_ IAudioEncoderCapabilities_Itf = {
     62     IAudioEncoderCapabilities_GetAudioEncoders,
     63     IAudioEncoderCapabilities_GetAudioEncoderCapabilities
     64 };
     65 
     66 void IAudioEncoderCapabilities_init(void *self)
     67 {
     68     IAudioEncoderCapabilities *thiz = (IAudioEncoderCapabilities *) self;
     69     thiz->mItf = &IAudioEncoderCapabilities_Itf;
     70 }
     71