Changed manifest header to include all of the header data.

The MediaHeader range will be from 0 until the first cluster. The
player will download a little extra data but the manifest will
have more in common with live adaptive. Added a version number
to the manifest.

Change-Id: I4a4fb3c3d0cbc3c364245eb2db9facb7a7148ada
diff --git a/manifest_model.cc b/manifest_model.cc
index d94e127..d54ad9a 100644
--- a/manifest_model.cc
+++ b/manifest_model.cc
@@ -26,14 +26,15 @@
 
 ManifestModel::ManifestModel()
     : duration_(0.0),
-      output_filename_("manifest.xml") {
+      output_filename_("manifest.xml"),
+      manifest_version_(1) {
 }
 
 ManifestModel::~ManifestModel() {
   vector<MediaGroup*>::iterator iter;
   for(iter = media_groups_.begin(); iter != media_groups_.end(); ++iter) {
     MediaGroup* mg = *iter;
-    delete mg; 
+    delete mg;
   }
 
   vector<MediaInterval*>::iterator mi_iter;
@@ -41,7 +42,7 @@
       mi_iter != media_intervals_.end();
       ++mi_iter) {
     MediaInterval* mi = *mi_iter;
-    delete mi; 
+    delete mi;
   }
 }
 
@@ -163,6 +164,7 @@
   of << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
   of << "<Presentation";
   of << " duration=\"" << duration_ << "\"";
+  of << " version=\"" << manifest_version_ << "\"";
   of << " >" << endl;
 
   indent_webm::Indent indt(0);
@@ -204,7 +206,7 @@
     MediaInterval* mi = *iter;
     o << *mi;
   }
-	return o ;
+  return o ;
 }
 
 }  // namespace adaptive_manifest
\ No newline at end of file
diff --git a/manifest_model.h b/manifest_model.h
index 7bb2ead..479f33b 100644
--- a/manifest_model.h
+++ b/manifest_model.h
@@ -76,6 +76,9 @@
   // Path to output the manifest.
   string output_filename_;
 
+  // Version number of the manifest.
+  int manifest_version_;
+
   // Disallow copy and assign
   ManifestModel(const ManifestModel&);
   ManifestModel& operator=(const ManifestModel&);
diff --git a/media.cc b/media.cc
index fb53e56..78f042b 100644
--- a/media.cc
+++ b/media.cc
@@ -390,6 +390,18 @@
   return bandwidth;
 }
 
+long long Media::GetClusterRangeStart() const {
+  assert(segment_.get()!=NULL);
+  const mkvparser::Cluster* cluster = segment_->GetFirst();
+
+  long long start = -1;
+  if (cluster) {
+    start = cluster->m_element_start;
+  }
+
+  return start;
+}
+
 void Media::GetSegmentInfoRange(long long& start, long long& end) const {
   assert(segment_.get()!=NULL);
   const mkvparser::SegmentInfo* const segment_info = segment_->GetInfo();
@@ -425,22 +437,8 @@
 }
 
 void Media::GetHeaderRange(long long& start, long long& end) const {
-  long long info_start;
-  long long info_end;
-  long long tracks_start;
-  long long tracks_end;
-  GetSegmentInfoRange(info_start, info_end);
-  GetTracksRange(tracks_start, tracks_end);
-
-  if (info_start < tracks_start)
-    start = info_start;
-  else
-    start = tracks_start;
-
-  if (info_end > tracks_end)
-    end = info_end;
-  else
-    end = tracks_end;
+  start = 0;
+  end = GetClusterRangeStart();
 }
 
 double Media::GetVideoFramerate() const {
diff --git a/media.h b/media.h
index e8b0873..a4e9bb5 100644
--- a/media.h
+++ b/media.h
@@ -110,6 +110,10 @@
   // per second.
   long long GetAverageBandwidth() const;
 
+  // Returns the byte offset in the file for the start of the first Cluster
+  // element starting with the EBML element ID. A value of -1 indicates there
+  // was an error.
+  long long GetClusterRangeStart() const;
 
   // Returns the byte offset in the file for the start of the SegmentInfo
   // element starting with the EBML element ID to the end offset of the
@@ -126,7 +130,7 @@
 
   // Returns the byte offset in the file for the start of the Segment Info and
   // Tracks element starting with the EBML element ID to the end offset of the
-  // element.
+  // element. A return value of -1 for either value indicates an error.
   void GetHeaderRange(long long& start, long long& end) const;
 
   // Returns the average framerate of the first video track. Returns 0.0 if