Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/mediasource/MediaSourceDecoder.h
Line
Count
Source (jump to first uncovered line)
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_MEDIASOURCEDECODER_H_
8
#define MOZILLA_MEDIASOURCEDECODER_H_
9
10
#include "MediaDecoder.h"
11
#include "mozilla/RefPtr.h"
12
13
namespace mozilla {
14
15
class MediaDecoderStateMachine;
16
class MediaSourceDemuxer;
17
18
namespace dom {
19
20
class MediaSource;
21
22
} // namespace dom
23
24
DDLoggedTypeDeclNameAndBase(MediaSourceDecoder, MediaDecoder);
25
26
class MediaSourceDecoder
27
  : public MediaDecoder
28
  , public DecoderDoctorLifeLogger<MediaSourceDecoder>
29
{
30
public:
31
  explicit MediaSourceDecoder(MediaDecoderInit& aInit);
32
33
  nsresult Load(nsIPrincipal* aPrincipal);
34
  media::TimeIntervals GetSeekable() override;
35
  media::TimeIntervals GetBuffered() override;
36
37
  void Shutdown() override;
38
39
  void AttachMediaSource(dom::MediaSource* aMediaSource);
40
  void DetachMediaSource();
41
42
  void Ended(bool aEnded);
43
44
  // Return the duration of the video in seconds.
45
  double GetDuration() override;
46
47
  void SetInitialDuration(int64_t aDuration);
48
  void SetMediaSourceDuration(double aDuration);
49
50
  MediaSourceDemuxer* GetDemuxer()
51
0
  {
52
0
    return mDemuxer;
53
0
  }
54
55
  already_AddRefed<nsIPrincipal> GetCurrentPrincipal() override;
56
57
0
  bool IsTransportSeekable() override { return true; }
58
59
  // Returns a string describing the state of the MediaSource internal
60
  // buffered data. Used for debugging purposes.
61
  void GetMozDebugReaderData(nsACString& aString) override;
62
63
  void AddSizeOfResources(ResourceSizes* aSizes) override;
64
65
  MediaDecoderOwner::NextFrameStatus NextFrameBufferedStatus() override;
66
67
0
  bool IsMSE() const override { return true; }
68
69
  void NotifyInitDataArrived();
70
71
  // Called as data appended to the source buffer or EOS is called on the media
72
  // source. Main thread only.
73
  void NotifyDataArrived();
74
75
private:
76
  MediaDecoderStateMachine* CreateStateMachine();
77
  void DoSetMediaSourceDuration(double aDuration);
78
  media::TimeInterval ClampIntervalToEnd(const media::TimeInterval& aInterval);
79
  bool CanPlayThroughImpl() override;
80
81
  RefPtr<nsIPrincipal> mPrincipal;
82
83
  // The owning MediaSource holds a strong reference to this decoder, and
84
  // calls Attach/DetachMediaSource on this decoder to set and clear
85
  // mMediaSource.
86
  dom::MediaSource* mMediaSource;
87
  RefPtr<MediaSourceDemuxer> mDemuxer;
88
89
  bool mEnded;
90
};
91
92
} // namespace mozilla
93
94
#endif /* MOZILLA_MEDIASOURCEDECODER_H_ */