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

Side by Side Diff: media/cdm/cenc_utils.cc

Issue 2966493005: Turn MediaLog usage from plain wrong into questionable (Closed)
Patch Set: Created 3 years, 5 months 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 | « no previous file | media/formats/mp4/box_reader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cdm/cenc_utils.h" 5 #include "media/cdm/cenc_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "media/formats/mp4/box_definitions.h" 10 #include "media/formats/mp4/box_definitions.h"
(...skipping 14 matching lines...) Expand all
25 25
26 // Returns true if |input| contains only 1 or more valid 'pssh' boxes, false 26 // Returns true if |input| contains only 1 or more valid 'pssh' boxes, false
27 // otherwise. |pssh_boxes| is updated as the set of parsed 'pssh' boxes. 27 // otherwise. |pssh_boxes| is updated as the set of parsed 'pssh' boxes.
28 // Note: All boxes in |input| must be 'pssh' boxes. However, if they can't be 28 // Note: All boxes in |input| must be 'pssh' boxes. However, if they can't be
29 // properly parsed (e.g. unsupported version), then they will be skipped. 29 // properly parsed (e.g. unsupported version), then they will be skipped.
30 static bool ReadAllPsshBoxes( 30 static bool ReadAllPsshBoxes(
31 const std::vector<uint8_t>& input, 31 const std::vector<uint8_t>& input,
32 std::vector<mp4::FullProtectionSystemSpecificHeader>* pssh_boxes) { 32 std::vector<mp4::FullProtectionSystemSpecificHeader>* pssh_boxes) {
33 DCHECK(!input.empty()); 33 DCHECK(!input.empty());
34 34
35 // TODO(wolenetz): Questionable MediaLog usage, http://crbug.com/712310
36 MediaLog media_log;
37
35 // Verify that |input| contains only 'pssh' boxes. 38 // Verify that |input| contains only 'pssh' boxes.
36 // ReadAllChildrenAndCheckFourCC() is templated, so it checks that each 39 // ReadAllChildrenAndCheckFourCC() is templated, so it checks that each
37 // box in |input| matches the box type of the parameter (in this case 40 // box in |input| matches the box type of the parameter (in this case
38 // mp4::ProtectionSystemSpecificHeader is a 'pssh' box). 41 // mp4::ProtectionSystemSpecificHeader is a 'pssh' box).
39 // mp4::ProtectionSystemSpecificHeader doesn't validate the 'pssh' contents, 42 // mp4::ProtectionSystemSpecificHeader doesn't validate the 'pssh' contents,
40 // so this simply verifies that |input| only contains 'pssh' boxes and 43 // so this simply verifies that |input| only contains 'pssh' boxes and
41 // nothing else. 44 // nothing else.
42 std::unique_ptr<mp4::BoxReader> input_reader( 45 std::unique_ptr<mp4::BoxReader> input_reader(
43 mp4::BoxReader::ReadConcatentatedBoxes(input.data(), input.size())); 46 mp4::BoxReader::ReadConcatentatedBoxes(input.data(), input.size(),
47 &media_log));
44 std::vector<mp4::ProtectionSystemSpecificHeader> raw_pssh_boxes; 48 std::vector<mp4::ProtectionSystemSpecificHeader> raw_pssh_boxes;
45 if (!input_reader->ReadAllChildrenAndCheckFourCC(&raw_pssh_boxes)) 49 if (!input_reader->ReadAllChildrenAndCheckFourCC(&raw_pssh_boxes))
46 return false; 50 return false;
47 51
48 // Now that we have |input| parsed into |raw_pssh_boxes|, reparse each one 52 // Now that we have |input| parsed into |raw_pssh_boxes|, reparse each one
49 // into a mp4::FullProtectionSystemSpecificHeader, which extracts all the 53 // into a mp4::FullProtectionSystemSpecificHeader, which extracts all the
50 // relevant fields from the box. Since there may be unparseable 'pssh' boxes 54 // relevant fields from the box. Since there may be unparseable 'pssh' boxes
51 // (due to unsupported version, for example), this is done one by one, 55 // (due to unsupported version, for example), this is done one by one,
52 // ignoring any boxes that can't be parsed. 56 // ignoring any boxes that can't be parsed.
53 for (const auto& raw_pssh_box : raw_pssh_boxes) { 57 for (const auto& raw_pssh_box : raw_pssh_boxes) {
54 std::unique_ptr<mp4::BoxReader> raw_pssh_reader( 58 std::unique_ptr<mp4::BoxReader> raw_pssh_reader(
55 mp4::BoxReader::ReadConcatentatedBoxes(raw_pssh_box.raw_box.data(), 59 mp4::BoxReader::ReadConcatentatedBoxes(raw_pssh_box.raw_box.data(),
56 raw_pssh_box.raw_box.size())); 60 raw_pssh_box.raw_box.size(),
61 &media_log));
57 // ReadAllChildren() appends any successfully parsed box onto it's 62 // ReadAllChildren() appends any successfully parsed box onto it's
58 // parameter, so |pssh_boxes| will contain the collection of successfully 63 // parameter, so |pssh_boxes| will contain the collection of successfully
59 // parsed 'pssh' boxes. If an error occurs, try the next box. 64 // parsed 'pssh' boxes. If an error occurs, try the next box.
60 if (!raw_pssh_reader->ReadAllChildrenAndCheckFourCC(pssh_boxes)) 65 if (!raw_pssh_reader->ReadAllChildrenAndCheckFourCC(pssh_boxes))
61 continue; 66 continue;
62 } 67 }
63 68
64 // Must have successfully parsed at least one 'pssh' box. 69 // Must have successfully parsed at least one 'pssh' box.
65 return pssh_boxes->size() > 0; 70 return pssh_boxes->size() > 0;
66 } 71 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 pssh_data->assign(child.data.begin(), child.data.end()); 123 pssh_data->assign(child.data.begin(), child.data.end());
119 return true; 124 return true;
120 } 125 }
121 } 126 }
122 127
123 // No matching 'pssh' box found. 128 // No matching 'pssh' box found.
124 return false; 129 return false;
125 } 130 }
126 131
127 } // namespace media 132 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/formats/mp4/box_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698