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

Side by Side Diff: media/webm/webm_tracks_parser.cc

Issue 10826098: Use std::string for decryption key ID in webm parser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
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/webm/webm_tracks_parser.h" 5 #include "media/webm/webm_tracks_parser.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "media/base/buffers.h" 9 #include "media/base/buffers.h"
10 #include "media/webm/webm_constants.h" 10 #include "media/webm/webm_constants.h"
11 #include "media/webm/webm_content_encodings.h" 11 #include "media/webm/webm_content_encodings.h"
12 12
13 namespace media { 13 namespace media {
14 14
15 // Values for TrackType element. 15 // Values for TrackType element.
16 static const int kWebMTrackTypeVideo = 1; 16 static const int kWebMTrackTypeVideo = 1;
17 static const int kWebMTrackTypeAudio = 2; 17 static const int kWebMTrackTypeAudio = 2;
18 18
19 WebMTracksParser::WebMTracksParser(int64 timecode_scale) 19 WebMTracksParser::WebMTracksParser(int64 timecode_scale)
20 : timecode_scale_(timecode_scale), 20 : timecode_scale_(timecode_scale),
21 track_type_(-1), 21 track_type_(-1),
22 track_num_(-1), 22 track_num_(-1),
23 audio_track_num_(-1), 23 audio_track_num_(-1),
24 video_track_num_(-1) { 24 video_track_num_(-1) {
25 } 25 }
26 26
27 WebMTracksParser::~WebMTracksParser() {} 27 WebMTracksParser::~WebMTracksParser() {}
28 28
29 const uint8* WebMTracksParser::video_encryption_key_id() const { 29 const std::string& WebMTracksParser::video_encryption_key_id() const {
30 if (!video_content_encodings_client_.get()) 30 if (!video_content_encodings_client_.get())
31 return NULL; 31 return EmptyString();
32 32
33 DCHECK(!video_content_encodings_client_->content_encodings().empty()); 33 DCHECK(!video_content_encodings_client_->content_encodings().empty());
34 return video_content_encodings_client_->content_encodings()[0]-> 34 return video_content_encodings_client_->content_encodings()[0]->
35 encryption_key_id(); 35 encryption_key_id();
36 } 36 }
37 37
38 int WebMTracksParser::video_encryption_key_id_size() const {
39 if (!video_content_encodings_client_.get())
40 return 0;
41
42 DCHECK(!video_content_encodings_client_->content_encodings().empty());
43 return video_content_encodings_client_->content_encodings()[0]->
44 encryption_key_id_size();
45 }
46
47 int WebMTracksParser::Parse(const uint8* buf, int size) { 38 int WebMTracksParser::Parse(const uint8* buf, int size) {
48 track_type_ =-1; 39 track_type_ =-1;
49 track_num_ = -1; 40 track_num_ = -1;
50 audio_track_num_ = -1; 41 audio_track_num_ = -1;
51 video_track_num_ = -1; 42 video_track_num_ = -1;
52 43
53 WebMListParser parser(kWebMIdTracks, this); 44 WebMListParser parser(kWebMIdTracks, this);
54 int result = parser.Parse(buf, size); 45 int result = parser.Parse(buf, size);
55 46
56 if (result <= 0) 47 if (result <= 0)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 bool WebMTracksParser::OnString(int id, const std::string& str) { 142 bool WebMTracksParser::OnString(int id, const std::string& str) {
152 if (id == kWebMIdCodecID && str != "A_VORBIS" && str != "V_VP8") { 143 if (id == kWebMIdCodecID && str != "A_VORBIS" && str != "V_VP8") {
153 DVLOG(1) << "Unexpected CodecID " << str; 144 DVLOG(1) << "Unexpected CodecID " << str;
154 return false; 145 return false;
155 } 146 }
156 147
157 return true; 148 return true;
158 } 149 }
159 150
160 } // namespace media 151 } // namespace media
OLDNEW
« media/webm/webm_cluster_parser_unittest.cc ('K') | « media/webm/webm_tracks_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698