Bug 1005366 - Minor tidy up of string use in content/media/mediasource. r=cajbir
authorMatthew Gregan <kinetik@flim.org>
Thu, 08 May 2014 14:22:27 +1200
changeset 182080 82ad7813f515
parent 182079 321376574687
child 182081 3c695f32262b
push id43202
push usermgregan@mozilla.com
push dateThu, 08 May 2014 02:23:17 +0000
treeherdermozilla-inbound@3c695f32262b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscajbir
bugs1005366
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1005366 - Minor tidy up of string use in content/media/mediasource. r=cajbir
content/media/mediasource/MediaSourceResource.h
content/media/mediasource/SourceBuffer.cpp
content/media/mediasource/SourceBuffer.h
content/media/mediasource/SourceBufferResource.h
--- a/content/media/mediasource/MediaSourceResource.h
+++ b/content/media/mediasource/MediaSourceResource.h
@@ -60,14 +60,14 @@ private:
     return size;
   }
 
   virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE
   {
     return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
   }
 
-  const nsAutoCString mType;
+  const nsCString mType;
 };
 
 } // namespace mozilla
 
 #endif /* MOZILLA_MEDIASOURCERESOURCE_H_ */
--- a/content/media/mediasource/SourceBuffer.cpp
+++ b/content/media/mediasource/SourceBuffer.cpp
@@ -127,16 +127,18 @@ SubBufferDecoder::ConvertToByteOffset(do
 class ContainerParser {
 public:
   virtual ~ContainerParser() {}
 
   virtual bool IsInitSegmentPresent(const uint8_t* aData, uint32_t aLength)
   {
     return false;
   }
+
+  static ContainerParser* CreateForMIMEType(const nsACString& aType);
 };
 
 class WebMContainerParser : public ContainerParser {
 public:
   bool IsInitSegmentPresent(const uint8_t* aData, uint32_t aLength)
   {
     // XXX: This is overly primitive, needs to collect data as it's appended
     // to the SB and handle, rather than assuming everything is present in a
@@ -151,16 +153,27 @@ public:
     if (aLength >= 4 &&
         aData[0] == 0x1a && aData[1] == 0x45 && aData[2] == 0xdf && aData[3] == 0xa3) {
       return true;
     }
     return false;
   }
 };
 
+/*static*/ ContainerParser*
+ContainerParser::CreateForMIMEType(const nsACString& aType)
+{
+  if (aType.LowerCaseEqualsLiteral("video/webm") || aType.LowerCaseEqualsLiteral("audio/webm")) {
+    return new WebMContainerParser();
+  }
+
+  // XXX: Plug in parsers for MPEG4, etc. here.
+  return new ContainerParser();
+}
+
 namespace dom {
 
 void
 SourceBuffer::SetMode(SourceBufferAppendMode aMode, ErrorResult& aRv)
 {
   if (!IsAttached() || mUpdating) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
@@ -315,22 +328,17 @@ SourceBuffer::SourceBuffer(MediaSource* 
   , mAppendWindowStart(0)
   , mAppendWindowEnd(PositiveInfinity<double>())
   , mTimestampOffset(0)
   , mAppendMode(SourceBufferAppendMode::Segments)
   , mUpdating(false)
   , mDecoderInit(false)
 {
   MOZ_ASSERT(aMediaSource);
-  if (mType.EqualsIgnoreCase("video/webm") || mType.EqualsIgnoreCase("audio/webm")) {
-    mParser = new WebMContainerParser();
-  } else {
-    // XXX: Plug in parsers for MPEG4, etc. here.
-    mParser = new ContainerParser();
-  }
+  mParser = ContainerParser::CreateForMIMEType(aType);
   MSE_DEBUG("%p SourceBuffer: Creating initial decoder.", this);
   InitNewDecoder();
 }
 
 already_AddRefed<SourceBuffer>
 SourceBuffer::Create(MediaSource* aMediaSource, const nsACString& aType)
 {
   nsRefPtr<SourceBuffer> sourceBuffer = new SourceBuffer(aMediaSource, aType);
--- a/content/media/mediasource/SourceBuffer.h
+++ b/content/media/mediasource/SourceBuffer.h
@@ -131,17 +131,17 @@ private:
   void AppendData(const uint8_t* aData, uint32_t aLength, ErrorResult& aRv);
 
   // Provide the minimum start time and maximum end time that is available
   // in the data buffered by this SourceBuffer.
   void GetBufferedStartEndTime(double* aStart, double* aEnd);
 
   nsRefPtr<MediaSource> mMediaSource;
 
-  const nsAutoCString mType;
+  const nsCString mType;
 
   nsAutoPtr<ContainerParser> mParser;
 
   nsRefPtr<SubBufferDecoder> mDecoder;
 
   double mAppendWindowStart;
   double mAppendWindowEnd;
 
--- a/content/media/mediasource/SourceBufferResource.h
+++ b/content/media/mediasource/SourceBufferResource.h
@@ -278,17 +278,17 @@ public:
   // number of bytes. Returns true if some data was evicted.
   bool EvictData(uint32_t aThreshold);
 
   // Remove data from resource before the given offset.
   void EvictBefore(uint64_t aOffset);
 
 private:
   nsCOMPtr<nsIPrincipal> mPrincipal;
-  const nsAutoCString mType;
+  const nsCString mType;
 
   // Provides synchronization between SourceBuffers and InputAdapters.
   // Protects all of the member variables below.  Read() will await a
   // Notify() (from Seek, AppendData, Ended, or Close) when insufficient
   // data is available in mData.
   mutable ReentrantMonitor mMonitor;
 
   // The buffer holding resource data is a queue of ResourceItem's.