content/media/BufferDecoder.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:c8004395c19b
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 BUFFER_DECODER_H_
8 #define BUFFER_DECODER_H_
9
10 #include "AbstractMediaDecoder.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/ReentrantMonitor.h"
13
14 namespace mozilla {
15
16 /**
17 * This class provides a decoder object which decodes a media file that lives in
18 * a memory buffer.
19 */
20 class BufferDecoder : public AbstractMediaDecoder
21 {
22 public:
23 // This class holds a weak pointer to MediaResource. It's the responsibility
24 // of the caller to manage the memory of the MediaResource object.
25 explicit BufferDecoder(MediaResource* aResource);
26 virtual ~BufferDecoder();
27
28 NS_DECL_THREADSAFE_ISUPPORTS
29
30 // This has to be called before decoding begins
31 void BeginDecoding(nsIThread* aDecodeThread);
32
33 virtual ReentrantMonitor& GetReentrantMonitor() MOZ_OVERRIDE;
34
35 virtual bool IsShutdown() const MOZ_FINAL MOZ_OVERRIDE;
36
37 virtual bool OnStateMachineThread() const MOZ_OVERRIDE;
38
39 virtual bool OnDecodeThread() const MOZ_OVERRIDE;
40
41 virtual MediaResource* GetResource() const MOZ_OVERRIDE;
42
43 virtual void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) MOZ_FINAL MOZ_OVERRIDE;
44
45 virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded) MOZ_FINAL MOZ_OVERRIDE;
46
47 virtual int64_t GetEndMediaTime() const MOZ_FINAL MOZ_OVERRIDE;
48
49 virtual int64_t GetMediaDuration() MOZ_OVERRIDE;
50
51 virtual void SetMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
52
53 virtual void UpdateEstimatedMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
54
55 virtual void SetMediaSeekable(bool aMediaSeekable) MOZ_OVERRIDE;
56
57 virtual void SetTransportSeekable(bool aTransportSeekable) MOZ_OVERRIDE;
58
59 virtual VideoFrameContainer* GetVideoFrameContainer() MOZ_FINAL MOZ_OVERRIDE;
60 virtual layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE;
61
62 virtual bool IsTransportSeekable() MOZ_FINAL MOZ_OVERRIDE;
63
64 virtual bool IsMediaSeekable() MOZ_FINAL MOZ_OVERRIDE;
65
66 virtual void MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE;
67 virtual void QueueMetadata(int64_t aTime, int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE;
68
69 virtual void SetMediaEndTime(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE;
70
71 virtual void UpdatePlaybackPosition(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE;
72
73 virtual void OnReadMetadataCompleted() MOZ_FINAL MOZ_OVERRIDE;
74
75 virtual MediaDecoderOwner* GetOwner() MOZ_OVERRIDE;
76
77 virtual void NotifyWaitingForResourcesStatusChanged() MOZ_FINAL MOZ_OVERRIDE;
78
79 protected:
80 // This monitor object is not really used to synchronize access to anything.
81 // It's just there in order for us to be able to override
82 // GetReentrantMonitor correctly.
83 ReentrantMonitor mReentrantMonitor;
84 nsCOMPtr<nsIThread> mDecodeThread;
85 nsRefPtr<MediaResource> mResource;
86 };
87
88 } // namespace mozilla
89
90 #endif /* BUFFER_DECODER_H_ */

mercurial