/src/mozilla-central/dom/media/mp4/ResourceStream.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
2 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | | |
5 | | #ifndef RESOURCESTREAM_H_ |
6 | | #define RESOURCESTREAM_H_ |
7 | | |
8 | | #include "MediaResource.h" |
9 | | #include "ByteStream.h" |
10 | | #include "mozilla/RefPtr.h" |
11 | | |
12 | | namespace mozilla |
13 | | { |
14 | | |
15 | | DDLoggedTypeDeclNameAndBase(ResourceStream, ByteStream); |
16 | | |
17 | | class ResourceStream |
18 | | : public ByteStream |
19 | | , public DecoderDoctorLifeLogger<ResourceStream> |
20 | | { |
21 | | public: |
22 | | explicit ResourceStream(mozilla::MediaResource* aResource); |
23 | | |
24 | | virtual bool ReadAt(int64_t offset, void* aBuffer, size_t aCount, |
25 | | size_t* aBytesRead) override; |
26 | | virtual bool CachedReadAt(int64_t aOffset, void* aBuffer, size_t aCount, |
27 | | size_t* aBytesRead) override; |
28 | | virtual bool Length(int64_t* size) override; |
29 | | |
30 | | void Pin() |
31 | 0 | { |
32 | 0 | mResource.GetResource()->Pin(); |
33 | 0 | ++mPinCount; |
34 | 0 | } |
35 | | |
36 | | void Unpin() |
37 | 0 | { |
38 | 0 | mResource.GetResource()->Unpin(); |
39 | 0 | MOZ_ASSERT(mPinCount); |
40 | 0 | --mPinCount; |
41 | 0 | } |
42 | | |
43 | | protected: |
44 | | virtual ~ResourceStream(); |
45 | | |
46 | | private: |
47 | | mozilla::MediaResourceIndex mResource; |
48 | | uint32_t mPinCount; |
49 | | }; |
50 | | |
51 | | } |
52 | | |
53 | | #endif // RESOURCESTREAM_H_ |