1 /* 2 * Copyright (C) 2017 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 19 #include "ATSParser.h" 20 #include <utils/KeyedVector.h> 21 #include <set> 22 23 namespace android { 24 namespace media { 25 class ICas; 26 class IDescrambler; 27 } 28 29 struct ATSParser::CasManager : public RefBase { 30 CasManager(); 31 virtual ~CasManager(); 32 33 status_t setMediaCas(const sp<ICas> &cas); 34 35 bool addProgram( 36 unsigned programNumber, const CADescriptor &descriptor); 37 38 bool addStream( 39 unsigned programNumber, unsigned elementaryPID, 40 const CADescriptor &descriptor); 41 42 bool getCasInfo( 43 unsigned programNumber, unsigned elementaryPID, 44 int32_t *systemId, sp<IDescrambler> *descrambler, 45 std::vector<uint8_t> *sessionId) const; 46 47 bool isCAPid(unsigned pid); 48 49 bool parsePID(ABitReader *br, unsigned pid); 50 51 private: 52 typedef KeyedVector<unsigned, std::vector<uint8_t> > PidToSessionMap; 53 struct ProgramCasManager; 54 55 bool setSystemId(int32_t CA_system_ID); 56 57 int32_t mSystemId; 58 sp<ICas> mICas; 59 KeyedVector<unsigned, sp<ProgramCasManager> > mProgramCasMap; 60 PidToSessionMap mCAPidToSessionIdMap; 61 std::set<uint32_t> mCAPidSet; 62 }; 63 64 } // namespace android 65