OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/mp4/cenc.h" | 5 #include "media/mp4/cenc.h" |
6 | 6 |
7 #include <string.h> | |
xhwang
2012/06/27 19:37:43
Use C++ headers? #include <cstring>
strobe_
2012/07/13 00:47:07
Done.
| |
8 | |
7 #include "media/mp4/box_reader.h" | 9 #include "media/mp4/box_reader.h" |
8 #include "media/mp4/rcheck.h" | 10 #include "media/mp4/rcheck.h" |
9 | 11 |
10 namespace media { | 12 namespace media { |
11 namespace mp4 { | 13 namespace mp4 { |
12 | 14 |
13 FrameCENCInfo::FrameCENCInfo() {} | 15 FrameCENCInfo::FrameCENCInfo() {} |
14 FrameCENCInfo::~FrameCENCInfo() {} | 16 FrameCENCInfo::~FrameCENCInfo() {} |
15 | 17 |
16 bool FrameCENCInfo::Parse(int iv_size, BufferReader* reader) { | 18 bool FrameCENCInfo::Parse(int iv_size, BufferReader* reader) { |
17 const int kEntrySize = 6; | 19 const int kEntrySize = 6; |
18 | |
19 // Mandated by CENC spec | 20 // Mandated by CENC spec |
20 RCHECK(iv_size == 8 || iv_size == 16); | 21 RCHECK(iv_size == 8 || iv_size == 16); |
21 iv.resize(iv_size); | 22 |
23 memset(iv, 0, sizeof(iv)); | |
24 for (int i = 0; i < iv_size; i++) | |
25 RCHECK(reader->Read1(&iv[i])); | |
26 | |
27 if (!reader->HasBytes(1)) return true; | |
22 | 28 |
23 uint16 subsample_count; | 29 uint16 subsample_count; |
24 RCHECK(reader->ReadVec(&iv, iv_size) && | 30 RCHECK(reader->Read2(&subsample_count) && |
25 reader->Read2(&subsample_count) && | |
26 reader->HasBytes(subsample_count * kEntrySize)); | 31 reader->HasBytes(subsample_count * kEntrySize)); |
32 | |
27 subsamples.resize(subsample_count); | 33 subsamples.resize(subsample_count); |
28 | |
29 for (int i = 0; i < subsample_count; i++) { | 34 for (int i = 0; i < subsample_count; i++) { |
30 RCHECK(reader->Read2(&subsamples[i].clear_size) && | 35 uint16 clear_bytes; |
31 reader->Read4(&subsamples[i].encrypted_size)); | 36 uint32 cypher_bytes; |
37 RCHECK(reader->Read2(&clear_bytes) && | |
38 reader->Read4(&cypher_bytes)); | |
39 subsamples[i].clear_bytes = clear_bytes; | |
40 subsamples[i].cypher_bytes = cypher_bytes; | |
ddorwin
2012/07/03 21:03:47
This doesn't cause a possible overflow warning? (u
strobe_
2012/07/13 00:47:07
Surprisingly, no. I'm more than happy to use uint3
ddorwin
2012/07/17 01:14:21
I think if you're dealing with data and it can rea
strobe_
2012/07/19 02:43:34
Done.
| |
32 } | 41 } |
33 return true; | 42 return true; |
34 } | 43 } |
35 | 44 |
36 size_t FrameCENCInfo::GetTotalSize() const { | 45 size_t FrameCENCInfo::GetTotalSizeOfSubsamples() const { |
37 size_t size = 0; | 46 size_t size = 0; |
38 for (size_t i = 0; i < subsamples.size(); i++) { | 47 for (size_t i = 0; i < subsamples.size(); i++) { |
39 size += subsamples[i].clear_size + subsamples[i].encrypted_size; | 48 size += subsamples[i].clear_bytes + subsamples[i].cypher_bytes; |
40 } | 49 } |
41 return size; | 50 return size; |
42 } | 51 } |
43 | 52 |
44 } // namespace mp4 | 53 } // namespace mp4 |
45 } // namespace media | 54 } // namespace media |
OLD | NEW |