• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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 #ifndef JSON_ASSET_LOADER_H_
17 #define JSON_ASSET_LOADER_H_
18 
19 #include <media/stagefright/foundation/ABase.h>
20 #include <utils/KeyedVector.h>
21 #include <utils/String8.h>
22 #include <utils/StrongPointer.h>
23 #include "protos/license_protos.pb.h"
24 
25 #include "jsmn.h"
26 
27 namespace android {
28 struct ABuffer;
29 
30 namespace clearkeycas {
31 
32 class JsonAssetLoader {
33  public:
34     JsonAssetLoader();
35     virtual ~JsonAssetLoader();
36 
37     status_t extractAssetFromString(
38             const String8& jsonAssetString, Asset *asset);
39 
40  private:
41     Vector<jsmntok_t> mJsmnTokens;
42     Vector<String8> mJsonObjects;
43     Vector<String8> mTokens;
44 
45     static sp<ABuffer> decodeBase64String(
46             const String8& encodedText);
47     bool findKey(const String8& jsonObject, Asset *asset);
48     void findValue(
49             const String8 &key, String8* value);
50     bool parseJsonObject(
51             const String8& jsonObject, Vector<String8>* tokens);
52     bool parseJsonAssetString(
53             const String8& jsonString, Vector<String8>* jsonObjects);
54 
55     DISALLOW_EVIL_CONSTRUCTORS(JsonAssetLoader);
56 };
57 
58 }  // namespace clearkeycas
59 }  // namespace android
60 
61 #endif  // JSON_ASSET_LOADER_H_
62