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

Side by Side Diff: media/formats/webm/webm_stream_parser.cc

Issue 346613003: Fix WebMStreamParser to handle Cues between Clusters correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
« no previous file with comments | « media/filters/chunk_demuxer_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/formats/webm/webm_stream_parser.h" 5 #include "media/formats/webm/webm_stream_parser.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 end_of_segment_cb_ = end_of_segment_cb; 54 end_of_segment_cb_ = end_of_segment_cb;
55 log_cb_ = log_cb; 55 log_cb_ = log_cb;
56 } 56 }
57 57
58 void WebMStreamParser::Flush() { 58 void WebMStreamParser::Flush() {
59 DCHECK_NE(state_, kWaitingForInit); 59 DCHECK_NE(state_, kWaitingForInit);
60 60
61 byte_queue_.Reset(); 61 byte_queue_.Reset();
62 parsing_cluster_ = false; 62 parsing_cluster_ = false;
63 63
64 if (state_ != kParsingClusters) 64 if (state_ != kParsingClusters)
wolenetz 2014/06/18 19:51:25 Hmm. On second (third) look, it seems we should Re
Sergey Ulanov 2014/06/18 21:47:55 Done.
65 return; 65 return;
66 66
67 cluster_parser_->Reset(); 67 cluster_parser_->Reset();
68 } 68 }
69 69
70 bool WebMStreamParser::Parse(const uint8* buf, int size) { 70 bool WebMStreamParser::Parse(const uint8* buf, int size) {
71 DCHECK_NE(state_, kWaitingForInit); 71 DCHECK_NE(state_, kWaitingForInit);
72 72
73 if (state_ == kError) 73 if (state_ == kError)
74 return false; 74 return false;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 case kWebMIdCues: 144 case kWebMIdCues:
145 case kWebMIdChapters: 145 case kWebMIdChapters:
146 // TODO(matthewjheaney): Implement support for chapters. 146 // TODO(matthewjheaney): Implement support for chapters.
147 if (cur_size < (result + element_size)) { 147 if (cur_size < (result + element_size)) {
148 // We don't have the whole element yet. Signal we need more data. 148 // We don't have the whole element yet. Signal we need more data.
149 return 0; 149 return 0;
150 } 150 }
151 // Skip the element. 151 // Skip the element.
152 return result + element_size; 152 return result + element_size;
153 break; 153 break;
154 case kWebMIdCluster:
155 if (!cluster_parser_) {
156 MEDIA_LOG(log_cb_) << "Found Cluster element before Info.";
157 return -1;
158 }
159 ChangeState(kParsingClusters);
160 return 0;
154 case kWebMIdSegment: 161 case kWebMIdSegment:
155 // Segment of unknown size indicates live stream. 162 // Segment of unknown size indicates live stream.
156 if (element_size == kWebMUnknownSize) 163 if (element_size == kWebMUnknownSize)
157 unknown_segment_size_ = true; 164 unknown_segment_size_ = true;
158 // Just consume the segment header. 165 // Just consume the segment header.
159 return result; 166 return result;
160 break; 167 break;
161 case kWebMIdInfo: 168 case kWebMIdInfo:
162 // We've found the element we are looking for. 169 // We've found the element we are looking for.
163 break; 170 break;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 tracks_parser.audio_track_num(), 231 tracks_parser.audio_track_num(),
225 tracks_parser.GetAudioDefaultDuration(timecode_scale_in_us), 232 tracks_parser.GetAudioDefaultDuration(timecode_scale_in_us),
226 tracks_parser.video_track_num(), 233 tracks_parser.video_track_num(),
227 tracks_parser.GetVideoDefaultDuration(timecode_scale_in_us), 234 tracks_parser.GetVideoDefaultDuration(timecode_scale_in_us),
228 tracks_parser.text_tracks(), 235 tracks_parser.text_tracks(),
229 tracks_parser.ignored_tracks(), 236 tracks_parser.ignored_tracks(),
230 tracks_parser.audio_encryption_key_id(), 237 tracks_parser.audio_encryption_key_id(),
231 tracks_parser.video_encryption_key_id(), 238 tracks_parser.video_encryption_key_id(),
232 log_cb_)); 239 log_cb_));
233 240
234 ChangeState(kParsingClusters); 241 ChangeState(kParsingClusters);
acolwell GONE FROM CHROMIUM 2014/06/18 19:54:22 You should probably remove this so that the same c
Sergey Ulanov 2014/06/18 21:47:55 Done.
235 242
236 if (!init_cb_.is_null()) 243 if (!init_cb_.is_null())
237 base::ResetAndReturn(&init_cb_).Run(true, params); 244 base::ResetAndReturn(&init_cb_).Run(true, params);
238 245
239 return bytes_parsed; 246 return bytes_parsed;
240 } 247 }
241 248
242 int WebMStreamParser::ParseCluster(const uint8* data, int size) { 249 int WebMStreamParser::ParseCluster(const uint8* data, int size) {
243 if (!cluster_parser_) 250 if (!cluster_parser_)
244 return -1; 251 return -1;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 end_of_segment_cb_.Run(); 304 end_of_segment_cb_.Run();
298 } 305 }
299 306
300 result += bytes_parsed; 307 result += bytes_parsed;
301 data += bytes_parsed; 308 data += bytes_parsed;
302 size -= bytes_parsed; 309 size -= bytes_parsed;
303 310
304 // WebMClusterParser returns 0 and |cluster_ended| is true if previously 311 // WebMClusterParser returns 0 and |cluster_ended| is true if previously
305 // parsing an unknown-size cluster and |data| does not continue that 312 // parsing an unknown-size cluster and |data| does not continue that
306 // cluster. Try parsing again in that case. 313 // cluster. Try parsing again in that case.
307 } while (size > 0 && (bytes_parsed > 0 || cluster_ended)); 314 } while (size > 0 && (bytes_parsed > 0 || cluster_ended));
acolwell GONE FROM CHROMIUM 2014/06/18 19:54:22 Do we still need this loop? Can't you just transit
Sergey Ulanov 2014/06/18 21:47:55 see crbug.com/382807. We need to handle the case w
308 315
309 return result; 316 return result;
310 } 317 }
311 318
312 void WebMStreamParser::FireNeedKey(const std::string& key_id) { 319 void WebMStreamParser::FireNeedKey(const std::string& key_id) {
313 std::vector<uint8> key_id_vector(key_id.begin(), key_id.end()); 320 std::vector<uint8> key_id_vector(key_id.begin(), key_id.end());
314 need_key_cb_.Run(kWebMEncryptInitDataType, key_id_vector); 321 need_key_cb_.Run(kWebMEncryptInitDataType, key_id_vector);
315 } 322 }
316 323
317 } // namespace media 324 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698