|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef MOZILLA_MEDIASOURCERESOURCE_H_ |
|
8 #define MOZILLA_MEDIASOURCERESOURCE_H_ |
|
9 |
|
10 #include "MediaResource.h" |
|
11 |
|
12 namespace mozilla { |
|
13 |
|
14 class MediaSourceResource MOZ_FINAL : public MediaResource |
|
15 { |
|
16 public: |
|
17 MediaSourceResource() {} |
|
18 |
|
19 virtual nsresult Close() MOZ_OVERRIDE { return NS_OK; } |
|
20 virtual void Suspend(bool aCloseImmediately) MOZ_OVERRIDE {} |
|
21 virtual void Resume() MOZ_OVERRIDE {} |
|
22 virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal() MOZ_OVERRIDE { return nullptr; } |
|
23 virtual bool CanClone() MOZ_OVERRIDE { return false; } |
|
24 virtual already_AddRefed<MediaResource> CloneData(MediaDecoder* aDecoder) MOZ_OVERRIDE { return nullptr; } |
|
25 virtual void SetReadMode(MediaCacheStream::ReadMode aMode) MOZ_OVERRIDE {} |
|
26 virtual void SetPlaybackRate(uint32_t aBytesPerSecond) MOZ_OVERRIDE {} |
|
27 virtual nsresult Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes) MOZ_OVERRIDE { return NS_ERROR_FAILURE; } |
|
28 virtual nsresult ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount, uint32_t* aBytes) MOZ_OVERRIDE { return NS_ERROR_FAILURE; } |
|
29 virtual nsresult Seek(int32_t aWhence, int64_t aOffset) MOZ_OVERRIDE { return NS_ERROR_FAILURE; } |
|
30 virtual void StartSeekingForMetadata() MOZ_OVERRIDE {} |
|
31 virtual void EndSeekingForMetadata() MOZ_OVERRIDE {} |
|
32 virtual int64_t Tell() MOZ_OVERRIDE { return -1; } |
|
33 virtual void Pin() MOZ_OVERRIDE {} |
|
34 virtual void Unpin() MOZ_OVERRIDE {} |
|
35 virtual double GetDownloadRate(bool* aIsReliable) MOZ_OVERRIDE { return 0; } |
|
36 virtual int64_t GetLength() MOZ_OVERRIDE { return -1; } |
|
37 virtual int64_t GetNextCachedData(int64_t aOffset) MOZ_OVERRIDE { return aOffset; } |
|
38 virtual int64_t GetCachedDataEnd(int64_t aOffset) MOZ_OVERRIDE { return GetLength(); } |
|
39 virtual bool IsDataCachedToEndOfResource(int64_t aOffset) MOZ_OVERRIDE { return false; } |
|
40 virtual bool IsSuspendedByCache() MOZ_OVERRIDE { return false; } |
|
41 virtual bool IsSuspended() MOZ_OVERRIDE { return false; } |
|
42 virtual nsresult ReadFromCache(char* aBuffer, int64_t aOffset, uint32_t aCount) MOZ_OVERRIDE { return NS_ERROR_FAILURE; } |
|
43 virtual nsresult Open(nsIStreamListener** aStreamListener) MOZ_OVERRIDE { return NS_ERROR_FAILURE; } |
|
44 |
|
45 virtual nsresult GetCachedRanges(nsTArray<MediaByteRange>& aRanges) MOZ_OVERRIDE |
|
46 { |
|
47 aRanges.AppendElement(MediaByteRange(0, GetLength())); |
|
48 return NS_OK; |
|
49 } |
|
50 |
|
51 virtual bool IsTransportSeekable() MOZ_OVERRIDE { return true; } |
|
52 virtual const nsCString& GetContentType() const MOZ_OVERRIDE { return mType; } |
|
53 |
|
54 private: |
|
55 virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE |
|
56 { |
|
57 size_t size = MediaResource::SizeOfExcludingThis(aMallocSizeOf); |
|
58 size += mType.SizeOfExcludingThisIfUnshared(aMallocSizeOf); |
|
59 |
|
60 return size; |
|
61 } |
|
62 |
|
63 virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE |
|
64 { |
|
65 return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); |
|
66 } |
|
67 |
|
68 const nsAutoCString mType; |
|
69 }; |
|
70 |
|
71 } // namespace mozilla |
|
72 |
|
73 #endif /* MOZILLA_MEDIASOURCERESOURCE_H_ */ |