Home | History | Annotate | Download | only in libstagefright
      1 /*
      2  * Copyright 2012, 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 //#define LOG_NDEBUG 0
     18 #define LOG_TAG "MediaCodecListWriter"
     19 #include <utils/Log.h>
     20 
     21 #include <media/stagefright/foundation/AMessage.h>
     22 #include <media/stagefright/MediaCodecListWriter.h>
     23 #include <media/MediaCodecInfo.h>
     24 
     25 namespace android {
     26 
     27 void MediaCodecListWriter::addGlobalSetting(
     28         const char* key, const char* value) {
     29     mGlobalSettings.emplace_back(key, value);
     30 }
     31 
     32 std::unique_ptr<MediaCodecInfoWriter>
     33         MediaCodecListWriter::addMediaCodecInfo() {
     34     sp<MediaCodecInfo> info = new MediaCodecInfo();
     35     mCodecInfos.push_back(info);
     36     return std::unique_ptr<MediaCodecInfoWriter>(
     37             new MediaCodecInfoWriter(info.get()));
     38 }
     39 
     40 std::unique_ptr<MediaCodecInfoWriter>
     41         MediaCodecListWriter::findMediaCodecInfo(const char *name) {
     42     for (const sp<MediaCodecInfo> &info : mCodecInfos) {
     43         if (!strcmp(info->getCodecName(), name)) {
     44             return std::unique_ptr<MediaCodecInfoWriter>(new MediaCodecInfoWriter(info.get()));
     45         }
     46     }
     47     return nullptr;
     48 }
     49 
     50 void MediaCodecListWriter::writeGlobalSettings(
     51         const sp<AMessage> &globalSettings) const {
     52     for (const std::pair<std::string, std::string> &kv : mGlobalSettings) {
     53         globalSettings->setString(kv.first.c_str(), kv.second.c_str());
     54     }
     55 }
     56 
     57 void MediaCodecListWriter::writeCodecInfos(
     58         std::vector<sp<MediaCodecInfo>> *codecInfos) const {
     59     for (const sp<MediaCodecInfo> &info : mCodecInfos) {
     60         codecInfos->push_back(info);
     61     }
     62 }
     63 
     64 }  // namespace android
     65