• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <iostream>
17 #include <cstddef>
18 #include <cstdint>
19 #include "audio_policy_server.h"
20 #include "message_parcel.h"
21 #include "accesstoken_kit.h"
22 #include "nativetoken_kit.h"
23 #include "token_setproc.h"
24 #include "access_token.h"
25 #include "audio_info.h"
26 #include "audio_concurrency_parser.h"
27 using namespace std;
28 
29 namespace OHOS {
30 namespace AudioStandard {
31 const int32_t LIMITSIZE = 4;
32 
AudioConcurrencyParserLoadConfigFuzzTest(const uint8_t * rawData,size_t size)33 void AudioConcurrencyParserLoadConfigFuzzTest(const uint8_t* rawData, size_t size)
34 {
35     if (rawData == nullptr || size < LIMITSIZE) {
36         return;
37     }
38     std::map<std::pair<AudioPipeType, AudioPipeType>, ConcurrencyAction> concurrencyMap;
39     concurrencyMap[std::make_pair(PIPE_TYPE_UNKNOWN, PIPE_TYPE_UNKNOWN)] = PLAY_BOTH;
40     concurrencyMap[std::make_pair(PIPE_TYPE_SPATIALIZATION, PIPE_TYPE_SPATIALIZATION)] = CONCEDE_INCOMING;
41     concurrencyMap[std::make_pair(PIPE_TYPE_NORMAL_OUT, PIPE_TYPE_NORMAL_OUT)] = CONCEDE_EXISTING;
42     AudioConcurrencyParser audioConcurrencyParser;
43     audioConcurrencyParser.LoadConfig(concurrencyMap);
44 }
45 } // namespace AudioStandard
46 } // namesapce OHOS
47 
48 /* Fuzzer entry point */
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)49 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
50 {
51     /* Run your code on data */
52     OHOS::AudioStandard::AudioConcurrencyParserLoadConfigFuzzTest(data, size);
53     return 0;
54 }
55