Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: media/formats/mp2t/ts_section_cat.cc

Issue 1517473002: Support HLS MPEG2 TS with SAMPLE-AES encryption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@encryption_scheme
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/formats/mp2t/ts_section_cat.h ('k') | media/formats/mp2t/ts_section_cets_ecm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "media/formats/mp2t/ts_section_cat.h"
6
7 #include <vector>
8
9 #include "base/logging.h"
10 #include "media/base/bit_reader.h"
11 #include "media/formats/mp2t/descriptors.h"
12 #include "media/formats/mp2t/mp2t_common.h"
13
14 namespace media {
15 namespace mp2t {
16
17 TsSectionCat::TsSectionCat(const RegisterCencPidsCb& register_cenc_ids_cb)
18 : register_cenc_ids_cb_(register_cenc_ids_cb), version_number_(-1) {}
19
20 TsSectionCat::~TsSectionCat() {}
21
22 bool TsSectionCat::ParsePsiSection(BitReader* bit_reader) {
23 DCHECK(bit_reader);
24 // Read the fixed section length.
25 int table_id;
26 int section_syntax_indicator;
27 int dummy_zero;
28 int reserved;
29 int section_length;
30 int version_number;
31 int current_next_indicator;
32 int section_number;
33 int last_section_number;
34 RCHECK(bit_reader->ReadBits(8, &table_id));
35 RCHECK(bit_reader->ReadBits(1, &section_syntax_indicator));
36 RCHECK(bit_reader->ReadBits(1, &dummy_zero));
37 RCHECK(bit_reader->ReadBits(2, &reserved));
38 RCHECK(bit_reader->ReadBits(12, &section_length));
39 RCHECK(section_length >= 5);
40 RCHECK(section_length <= 1021);
41 RCHECK(bit_reader->ReadBits(18, &reserved));
42 RCHECK(bit_reader->ReadBits(5, &version_number));
43 RCHECK(bit_reader->ReadBits(1, &current_next_indicator));
44 RCHECK(bit_reader->ReadBits(8, &section_number));
45 RCHECK(bit_reader->ReadBits(8, &last_section_number));
46 section_length -= 5;
47
48 // Perform a few more verifications, including:
49 // - Table ID should be 1 for a CAT.
50 // - section_syntax_indicator should be one.
51 RCHECK(table_id == 0x1);
52 RCHECK(section_syntax_indicator);
53 RCHECK(!dummy_zero);
54
55 Descriptors descriptors;
56 int ca_pid, pssh_pid;
57 RCHECK(descriptors.Read(bit_reader, section_length - 4));
58 RCHECK(descriptors.HasCADescriptorCenc(&ca_pid, &pssh_pid));
59 int crc32;
60 RCHECK(bit_reader->ReadBits(32, &crc32));
61
62 // Just ignore the CAT if not applicable yet.
63 if (!current_next_indicator) {
64 DVLOG(1) << "Not supported: received a CAT not applicable yet";
65 return true;
66 }
67
68 // Ignore the CAT if it hasn't changed.
69 if (version_number == version_number_)
70 return true;
71
72 // Can now register the PIDs.
73 register_cenc_ids_cb_.Run(ca_pid, pssh_pid);
74
75 version_number_ = version_number;
76
77 return true;
78 }
79
80 void TsSectionCat::ResetPsiSection() {
81 version_number_ = -1;
82 }
83
84 } // namespace mp2t
85 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/mp2t/ts_section_cat.h ('k') | media/formats/mp2t/ts_section_cets_ecm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698