content/media/mediasource/MediaSourceResource.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/mediasource/MediaSourceResource.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=8 sts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef MOZILLA_MEDIASOURCERESOURCE_H_
    1.11 +#define MOZILLA_MEDIASOURCERESOURCE_H_
    1.12 +
    1.13 +#include "MediaResource.h"
    1.14 +
    1.15 +namespace mozilla {
    1.16 +
    1.17 +class MediaSourceResource MOZ_FINAL : public MediaResource
    1.18 +{
    1.19 +public:
    1.20 +  MediaSourceResource() {}
    1.21 +
    1.22 +  virtual nsresult Close() MOZ_OVERRIDE { return NS_OK; }
    1.23 +  virtual void Suspend(bool aCloseImmediately) MOZ_OVERRIDE {}
    1.24 +  virtual void Resume() MOZ_OVERRIDE {}
    1.25 +  virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal() MOZ_OVERRIDE { return nullptr; }
    1.26 +  virtual bool CanClone() MOZ_OVERRIDE { return false; }
    1.27 +  virtual already_AddRefed<MediaResource> CloneData(MediaDecoder* aDecoder) MOZ_OVERRIDE { return nullptr; }
    1.28 +  virtual void SetReadMode(MediaCacheStream::ReadMode aMode) MOZ_OVERRIDE {}
    1.29 +  virtual void SetPlaybackRate(uint32_t aBytesPerSecond) MOZ_OVERRIDE  {}
    1.30 +  virtual nsresult Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes) MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
    1.31 +  virtual nsresult ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount, uint32_t* aBytes) MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
    1.32 +  virtual nsresult Seek(int32_t aWhence, int64_t aOffset) MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
    1.33 +  virtual void StartSeekingForMetadata() MOZ_OVERRIDE {}
    1.34 +  virtual void EndSeekingForMetadata() MOZ_OVERRIDE {}
    1.35 +  virtual int64_t Tell() MOZ_OVERRIDE { return -1; }
    1.36 +  virtual void Pin() MOZ_OVERRIDE {}
    1.37 +  virtual void Unpin() MOZ_OVERRIDE {}
    1.38 +  virtual double GetDownloadRate(bool* aIsReliable) MOZ_OVERRIDE { return 0; }
    1.39 +  virtual int64_t GetLength() MOZ_OVERRIDE { return -1; }
    1.40 +  virtual int64_t GetNextCachedData(int64_t aOffset) MOZ_OVERRIDE { return aOffset; }
    1.41 +  virtual int64_t GetCachedDataEnd(int64_t aOffset) MOZ_OVERRIDE { return GetLength(); }
    1.42 +  virtual bool IsDataCachedToEndOfResource(int64_t aOffset) MOZ_OVERRIDE { return false; }
    1.43 +  virtual bool IsSuspendedByCache() MOZ_OVERRIDE { return false; }
    1.44 +  virtual bool IsSuspended() MOZ_OVERRIDE { return false; }
    1.45 +  virtual nsresult ReadFromCache(char* aBuffer, int64_t aOffset, uint32_t aCount) MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
    1.46 +  virtual nsresult Open(nsIStreamListener** aStreamListener) MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
    1.47 +
    1.48 +  virtual nsresult GetCachedRanges(nsTArray<MediaByteRange>& aRanges) MOZ_OVERRIDE
    1.49 +  {
    1.50 +    aRanges.AppendElement(MediaByteRange(0, GetLength()));
    1.51 +    return NS_OK;
    1.52 +  }
    1.53 +
    1.54 +  virtual bool IsTransportSeekable() MOZ_OVERRIDE { return true; }
    1.55 +  virtual const nsCString& GetContentType() const MOZ_OVERRIDE { return mType; }
    1.56 +
    1.57 +private:
    1.58 +  virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE
    1.59 +  {
    1.60 +    size_t size = MediaResource::SizeOfExcludingThis(aMallocSizeOf);
    1.61 +    size += mType.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
    1.62 +
    1.63 +    return size;
    1.64 +  }
    1.65 +
    1.66 +  virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE
    1.67 +  {
    1.68 +    return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
    1.69 +  }
    1.70 +
    1.71 +  const nsAutoCString mType;
    1.72 +};
    1.73 +
    1.74 +} // namespace mozilla
    1.75 +
    1.76 +#endif /* MOZILLA_MEDIASOURCERESOURCE_H_ */

mercurial