1 // Copyright 2015 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef MEDIA_FORMATS_MP2T_DESCRIPTORS_H_ 6 #define MEDIA_FORMATS_MP2T_DESCRIPTORS_H_ 7 8 #include <stdint.h> 9 10 #include <map> 11 #include <string> 12 13 #include "media/base/decrypt_config.h" 14 15 namespace media { 16 17 class BitReader; 18 19 namespace mp2t { 20 21 // Representation of a list of descriptors, used in the MPEG-2 Systems standard 22 // to extend the definitions of programs or program elements. While the standard 23 // appears to permit multiple descriptors in such a list to have the same tag 24 // value, the implementation herein will not support this. 25 class Descriptors { 26 public: 27 Descriptors(); 28 Descriptors(const Descriptors& other); 29 ~Descriptors(); 30 31 // Attempts to read a (possibly empty) list of descriptors from the |reader|. 32 // If |size| > 0, the descriptors must occupy exactly |size| bytes, Otherwise, 33 // the descriptors should use all available bits from the reader. 34 bool Read(BitReader* reader, int size); 35 36 // Indicates whether a Registration descriptor is present. If so, the 37 // |format_identifier| and |additional_info| values are populated with the 38 // contents of the descriptor. 39 bool HasRegistrationDescriptor(int64_t* format_identifier, 40 std::string* additional_info) const; 41 42 // Indicates whether a CA descriptor is present. If so, the |system_id|, 43 // |pid|, and |private_data| values are populated with the contents of the 44 // descriptor. 45 bool HasCADescriptor(int* system_id, 46 int* pid, 47 std::string* private_data) const; 48 49 // Indicates whether a CA descriptor is present, and if so, whether it is 50 // of the type defined by ISO/IEC 23001-9:2014 (i.e. with a specific 51 // system_id value and layout of the private_data). If so, the |ca_pid|, 52 // |pssh_pid| and |mode| are populated with the contents of the descriptor. 53 bool HasCADescriptorCenc(int* ca_pid, 54 int* pssh_pid, 55 EncryptionScheme* scheme) const; 56 57 // Indicates whether a Private Data Indicator descriptor is present with a 58 // particular |value|. 59 bool HasPrivateDataIndicator(int64_t value) const; 60 61 private: 62 using Descriptor = std::pair<int, std::string>; 63 std::map<int, std::string> descriptors_; 64 65 // Allow copy and assign so that it can be used in a std C++ container. 66 }; 67 68 } // namespace mp2t 69 } // namespace media 70 71 #endif // MEDIA_FORMATS_MP2T_DESCRIPTOR_LIST_H_ 72