Home | History | Annotate | Download | only in sfplugin
      1 /*
      2  * Copyright 2018 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 #ifndef ANDROID_CODEC2_MAPPER_H_
     18 #define ANDROID_CODEC2_MAPPER_H_
     19 
     20 #include <C2Config.h>
     21 
     22 #include <memory>
     23 
     24 namespace android {
     25 
     26     /**
     27      * Utility class to map Codec 2.0 values to android values.
     28      */
     29     struct C2Mapper {
     30         struct ProfileLevelMapper {
     31             virtual bool mapProfile(C2Config::profile_t, int32_t*) = 0;
     32             virtual bool mapProfile(int32_t, C2Config::profile_t*) = 0;
     33             virtual bool mapLevel(C2Config::level_t, int32_t*) = 0;
     34             virtual bool mapLevel(int32_t, C2Config::level_t*) = 0;
     35             virtual ~ProfileLevelMapper() = default;
     36         };
     37 
     38         static std::shared_ptr<ProfileLevelMapper>
     39         GetProfileLevelMapper(std::string mediaType);
     40 
     41         // convert between bitrates
     42         static bool map(C2Config::bitrate_mode_t, int32_t*);
     43         static bool map(int32_t, C2Config::bitrate_mode_t*);
     44 
     45         // convert between pcm encodings
     46         static bool map(C2Config::pcm_encoding_t, int32_t*);
     47         static bool map(int32_t, C2Config::pcm_encoding_t*);
     48 
     49         // convert between picture types
     50         static bool map(C2Config::picture_type_t, int32_t*);
     51         static bool map(int32_t, C2Config::picture_type_t*);
     52     };
     53 }
     54 
     55 #endif  // ANDROID_CODEC2_MAPPER_H_
     56 
     57