1 /*
2  * Copyright 2020, 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 MEDIA_TEST_HELPER_H_
18 
19 #define MEDIA_TEST_HELPER_H_
20 
21 #include <media/stagefright/foundation/AString.h>
22 #include <utils/StrongPointer.h>
23 
24 namespace android {
25 
26 struct ALooper;
27 struct CodecBase;
28 struct MediaCodec;
29 struct MediaCodecInfo;
30 struct MediaCodecListWriter;
31 
32 class MediaTestHelper {
33 public:
34     // MediaCodec
35     static sp<MediaCodec> CreateCodec(
36             const AString &name,
37             const sp<ALooper> &looper,
38             std::function<sp<CodecBase>(const AString &, const char *)> getCodecBase,
39             std::function<status_t(const AString &, sp<MediaCodecInfo> *)> getCodecInfo);
40     static void Reclaim(const sp<MediaCodec> &codec, bool force);
41 
42     // MediaCodecListWriter
43     static std::shared_ptr<MediaCodecListWriter> CreateCodecListWriter();
44     static void WriteCodecInfos(
45             const std::shared_ptr<MediaCodecListWriter> &writer,
46             std::vector<sp<MediaCodecInfo>> *codecInfos);
47 };
48 
49 }  // namespace android
50 
51 #endif  // MEDIA_TEST_HELPER_H_
52