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

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

Issue 1915443003: Replace scoped_ptr with std::unique_ptr in //media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptr-media-base
Patch Set: scopedptr-media: rebase Created 4 years, 8 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 | « media/cdm/cdm_allocator.h ('k') | media/cdm/json_web_key.cc » ('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>
8
7 #include "base/macros.h" 9 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "media/formats/mp4/box_definitions.h" 10 #include "media/formats/mp4/box_definitions.h"
10 #include "media/formats/mp4/box_reader.h" 11 #include "media/formats/mp4/box_reader.h"
11 12
12 namespace media { 13 namespace media {
13 14
14 // The initialization data for encrypted media files using the ISO Common 15 // The initialization data for encrypted media files using the ISO Common
15 // Encryption ('cenc') protection scheme may contain one or more protection 16 // Encryption ('cenc') protection scheme may contain one or more protection
16 // system specific header ('pssh') boxes. 17 // system specific header ('pssh') boxes.
17 // ref: https://w3c.github.io/encrypted-media/cenc-format.html 18 // ref: https://w3c.github.io/encrypted-media/cenc-format.html
18 19
(...skipping 12 matching lines...) Expand all
31 std::vector<mp4::FullProtectionSystemSpecificHeader>* pssh_boxes) { 32 std::vector<mp4::FullProtectionSystemSpecificHeader>* pssh_boxes) {
32 DCHECK(!input.empty()); 33 DCHECK(!input.empty());
33 34
34 // Verify that |input| contains only 'pssh' boxes. 35 // Verify that |input| contains only 'pssh' boxes.
35 // ReadAllChildrenAndCheckFourCC() is templated, so it checks that each 36 // ReadAllChildrenAndCheckFourCC() is templated, so it checks that each
36 // box in |input| matches the box type of the parameter (in this case 37 // box in |input| matches the box type of the parameter (in this case
37 // mp4::ProtectionSystemSpecificHeader is a 'pssh' box). 38 // mp4::ProtectionSystemSpecificHeader is a 'pssh' box).
38 // mp4::ProtectionSystemSpecificHeader doesn't validate the 'pssh' contents, 39 // mp4::ProtectionSystemSpecificHeader doesn't validate the 'pssh' contents,
39 // so this simply verifies that |input| only contains 'pssh' boxes and 40 // so this simply verifies that |input| only contains 'pssh' boxes and
40 // nothing else. 41 // nothing else.
41 scoped_ptr<mp4::BoxReader> input_reader( 42 std::unique_ptr<mp4::BoxReader> input_reader(
42 mp4::BoxReader::ReadConcatentatedBoxes(input.data(), input.size())); 43 mp4::BoxReader::ReadConcatentatedBoxes(input.data(), input.size()));
43 std::vector<mp4::ProtectionSystemSpecificHeader> raw_pssh_boxes; 44 std::vector<mp4::ProtectionSystemSpecificHeader> raw_pssh_boxes;
44 if (!input_reader->ReadAllChildrenAndCheckFourCC(&raw_pssh_boxes)) 45 if (!input_reader->ReadAllChildrenAndCheckFourCC(&raw_pssh_boxes))
45 return false; 46 return false;
46 47
47 // Now that we have |input| parsed into |raw_pssh_boxes|, reparse each one 48 // Now that we have |input| parsed into |raw_pssh_boxes|, reparse each one
48 // into a mp4::FullProtectionSystemSpecificHeader, which extracts all the 49 // into a mp4::FullProtectionSystemSpecificHeader, which extracts all the
49 // relevant fields from the box. Since there may be unparseable 'pssh' boxes 50 // relevant fields from the box. Since there may be unparseable 'pssh' boxes
50 // (due to unsupported version, for example), this is done one by one, 51 // (due to unsupported version, for example), this is done one by one,
51 // ignoring any boxes that can't be parsed. 52 // ignoring any boxes that can't be parsed.
52 for (const auto& raw_pssh_box : raw_pssh_boxes) { 53 for (const auto& raw_pssh_box : raw_pssh_boxes) {
53 scoped_ptr<mp4::BoxReader> raw_pssh_reader( 54 std::unique_ptr<mp4::BoxReader> raw_pssh_reader(
54 mp4::BoxReader::ReadConcatentatedBoxes(raw_pssh_box.raw_box.data(), 55 mp4::BoxReader::ReadConcatentatedBoxes(raw_pssh_box.raw_box.data(),
55 raw_pssh_box.raw_box.size())); 56 raw_pssh_box.raw_box.size()));
56 // ReadAllChildren() appends any successfully parsed box onto it's 57 // ReadAllChildren() appends any successfully parsed box onto it's
57 // parameter, so |pssh_boxes| will contain the collection of successfully 58 // parameter, so |pssh_boxes| will contain the collection of successfully
58 // parsed 'pssh' boxes. If an error occurs, try the next box. 59 // parsed 'pssh' boxes. If an error occurs, try the next box.
59 if (!raw_pssh_reader->ReadAllChildrenAndCheckFourCC(pssh_boxes)) 60 if (!raw_pssh_reader->ReadAllChildrenAndCheckFourCC(pssh_boxes))
60 continue; 61 continue;
61 } 62 }
62 63
63 // Must have successfully parsed at least one 'pssh' box. 64 // Must have successfully parsed at least one 'pssh' box.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 pssh_data->assign(child.data.begin(), child.data.end()); 118 pssh_data->assign(child.data.begin(), child.data.end());
118 return true; 119 return true;
119 } 120 }
120 } 121 }
121 122
122 // No matching 'pssh' box found. 123 // No matching 'pssh' box found.
123 return false; 124 return false;
124 } 125 }
125 126
126 } // namespace media 127 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/cdm_allocator.h ('k') | media/cdm/json_web_key.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698