/usr/include/thunderbird/MediaEngineDefault.h is in thunderbird-dev 1:38.6.0+build1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MEDIAENGINEDEFAULT_H_
#define MEDIAENGINEDEFAULT_H_
#include "nsITimer.h"
#include "nsCOMPtr.h"
#include "DOMMediaStream.h"
#include "nsComponentManagerUtils.h"
#include "mozilla/Monitor.h"
#include "VideoUtils.h"
#include "MediaEngine.h"
#include "VideoSegment.h"
#include "AudioSegment.h"
#include "StreamBuffer.h"
#include "MediaStreamGraph.h"
namespace mozilla {
namespace layers {
class ImageContainer;
class PlanarYCbCrImage;
}
class MediaEngineDefault;
/**
* The default implementation of the MediaEngine interface.
*/
class MediaEngineDefaultVideoSource : public nsITimerCallback,
public MediaEngineVideoSource
{
public:
MediaEngineDefaultVideoSource();
virtual void GetName(nsAString&) override;
virtual void GetUUID(nsAString&) override;
virtual nsresult Allocate(const dom::MediaTrackConstraints &aConstraints,
const MediaEnginePrefs &aPrefs) override;
virtual nsresult Deallocate() override;
virtual nsresult Start(SourceMediaStream*, TrackID) override;
virtual nsresult Stop(SourceMediaStream*, TrackID) override;
virtual void SetDirectListeners(bool aHasDirectListeners) override {};
virtual nsresult Config(bool aEchoOn, uint32_t aEcho,
bool aAgcOn, uint32_t aAGC,
bool aNoiseOn, uint32_t aNoise,
int32_t aPlayoutDelay) override { return NS_OK; };
virtual void NotifyPull(MediaStreamGraph* aGraph,
SourceMediaStream *aSource,
TrackID aId,
StreamTime aDesiredTime) override;
virtual uint32_t GetBestFitnessDistance(
const nsTArray<const dom::MediaTrackConstraintSet*>& aConstraintSets) override
{
return true;
}
virtual bool IsFake() override {
return true;
}
virtual const dom::MediaSourceEnum GetMediaSource() override {
return dom::MediaSourceEnum::Camera;
}
virtual nsresult TakePhoto(PhotoCallback* aCallback) override
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSITIMERCALLBACK
protected:
~MediaEngineDefaultVideoSource();
friend class MediaEngineDefault;
TrackID mTrackID;
nsCOMPtr<nsITimer> mTimer;
// mMonitor protects mImage access/changes, and transitions of mState
// from kStarted to kStopped (which are combined with EndTrack() and
// image changes). Note that mSources is not accessed from other threads
// for video and is not protected.
Monitor mMonitor;
nsRefPtr<layers::Image> mImage;
nsRefPtr<layers::ImageContainer> mImageContainer;
MediaEnginePrefs mOpts;
int mCb;
int mCr;
};
class SineWaveGenerator;
class MediaEngineDefaultAudioSource : public nsITimerCallback,
public MediaEngineAudioSource
{
public:
MediaEngineDefaultAudioSource();
virtual void GetName(nsAString&) override;
virtual void GetUUID(nsAString&) override;
virtual nsresult Allocate(const dom::MediaTrackConstraints &aConstraints,
const MediaEnginePrefs &aPrefs) override;
virtual nsresult Deallocate() override;
virtual nsresult Start(SourceMediaStream*, TrackID) override;
virtual nsresult Stop(SourceMediaStream*, TrackID) override;
virtual void SetDirectListeners(bool aHasDirectListeners) override {};
virtual nsresult Config(bool aEchoOn, uint32_t aEcho,
bool aAgcOn, uint32_t aAGC,
bool aNoiseOn, uint32_t aNoise,
int32_t aPlayoutDelay) override { return NS_OK; };
virtual void NotifyPull(MediaStreamGraph* aGraph,
SourceMediaStream *aSource,
TrackID aId,
StreamTime aDesiredTime) override {}
virtual bool IsFake() override {
return true;
}
virtual const dom::MediaSourceEnum GetMediaSource() override {
return dom::MediaSourceEnum::Microphone;
}
virtual nsresult TakePhoto(PhotoCallback* aCallback) override
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSITIMERCALLBACK
protected:
~MediaEngineDefaultAudioSource();
TrackID mTrackID;
nsCOMPtr<nsITimer> mTimer;
SourceMediaStream* mSource;
nsAutoPtr<SineWaveGenerator> mSineGenerator;
};
class MediaEngineDefault : public MediaEngine
{
public:
explicit MediaEngineDefault(bool aHasFakeTracks = false)
: mHasFakeTracks(aHasFakeTracks)
, mMutex("mozilla::MediaEngineDefault")
{}
virtual void EnumerateVideoDevices(dom::MediaSourceEnum,
nsTArray<nsRefPtr<MediaEngineVideoSource> >*);
virtual void EnumerateAudioDevices(dom::MediaSourceEnum,
nsTArray<nsRefPtr<MediaEngineAudioSource> >*);
protected:
bool mHasFakeTracks;
private:
~MediaEngineDefault() {}
Mutex mMutex;
// protected with mMutex:
nsTArray<nsRefPtr<MediaEngineVideoSource> > mVSources;
nsTArray<nsRefPtr<MediaEngineAudioSource> > mASources;
};
}
#endif /* NSMEDIAENGINEDEFAULT_H_ */
|