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

Unified Diff: media/formats/webm/webm_stream_parser.cc

Issue 231283005: Add live mode detection in WebM MediaSource parser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/formats/webm/webm_stream_parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/formats/webm/webm_stream_parser.cc
diff --git a/media/formats/webm/webm_stream_parser.cc b/media/formats/webm/webm_stream_parser.cc
index b4ae1ff7227fc999231f7ebbcd6983b8e305a3cf..a90a623a2bdf9aa729206e66cc53574d6453b95e 100644
--- a/media/formats/webm/webm_stream_parser.cc
+++ b/media/formats/webm/webm_stream_parser.cc
@@ -20,6 +20,7 @@ namespace media {
WebMStreamParser::WebMStreamParser()
: state_(kWaitingForInit),
+ unknown_segment_size_(false),
parsing_cluster_(false) {
}
@@ -150,6 +151,9 @@ int WebMStreamParser::ParseInfoAndTracks(const uint8* data, int size) {
return result + element_size;
break;
case kWebMIdSegment:
+ // Segment of unknown size indicates live stream.
+ if (element_size == kWebMUnknownSize)
+ unknown_segment_size_ = true;
// Just consume the segment header.
return result;
break;
@@ -190,6 +194,15 @@ int WebMStreamParser::ParseInfoAndTracks(const uint8* data, int size) {
params.timeline_offset = info_parser.date_utc();
+ if (unknown_segment_size_ && (info_parser.duration() <= 0) &&
+ !info_parser.date_utc().is_null()) {
+ params.liveness = Demuxer::LIVENESS_LIVE;
+ } else if (info_parser.duration() >= 0) {
+ params.liveness = Demuxer::LIVENESS_RECORDED;
+ } else {
+ params.liveness = Demuxer::LIVENESS_UNKNOWN;
+ }
+
const AudioDecoderConfig& audio_config = tracks_parser.audio_decoder_config();
if (audio_config.is_encrypted())
FireNeedKey(tracks_parser.audio_encryption_key_id());
@@ -205,7 +218,6 @@ int WebMStreamParser::ParseInfoAndTracks(const uint8* data, int size) {
return -1;
}
-
cluster_parser_.reset(new WebMClusterParser(
info_parser.timecode_scale(),
tracks_parser.audio_track_num(),
« no previous file with comments | « media/formats/webm/webm_stream_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698