2013-03-20 18:07:46 +04:00
|
|
|
/* 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 DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H
|
|
|
|
#define DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H
|
|
|
|
|
|
|
|
#include "VideoFrameContainer.h"
|
|
|
|
#include "MediaStreamGraph.h"
|
|
|
|
#include "mozilla/Mutex.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2014-09-09 17:27:24 +04:00
|
|
|
class FakeMediaStreamGraph : public MediaStreamGraph
|
|
|
|
{
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FakeMediaStreamGraph)
|
|
|
|
public:
|
|
|
|
FakeMediaStreamGraph()
|
2014-09-18 03:50:01 +04:00
|
|
|
: MediaStreamGraph(16000)
|
2014-09-09 17:27:24 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void
|
2015-03-21 19:28:04 +03:00
|
|
|
DispatchToMainThreadAfterStreamStateUpdate(already_AddRefed<nsIRunnable> aRunnable) override;
|
2014-09-09 17:27:24 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
~FakeMediaStreamGraph()
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2013-03-20 18:07:46 +04:00
|
|
|
/**
|
2014-07-03 03:55:00 +04:00
|
|
|
* This is a stream for camera preview.
|
2013-03-20 18:07:46 +04:00
|
|
|
*
|
|
|
|
* XXX It is a temporary fix of SourceMediaStream.
|
2014-12-13 05:18:03 +03:00
|
|
|
* A camera preview requests no delay and no buffering stream,
|
|
|
|
* but the SourceMediaStream does not support it.
|
2013-03-20 18:07:46 +04:00
|
|
|
*/
|
2016-04-19 18:12:24 +03:00
|
|
|
class CameraPreviewMediaStream : public ProcessedMediaStream
|
2013-06-10 23:01:19 +04:00
|
|
|
{
|
2013-03-20 18:07:46 +04:00
|
|
|
typedef mozilla::layers::Image Image;
|
|
|
|
|
|
|
|
public:
|
2016-06-29 13:27:13 +03:00
|
|
|
CameraPreviewMediaStream();
|
2013-06-10 23:01:19 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void AddAudioOutput(void* aKey) override;
|
|
|
|
virtual void SetAudioOutputVolume(void* aKey, float aVolume) override;
|
|
|
|
virtual void RemoveAudioOutput(void* aKey) override;
|
|
|
|
virtual void AddVideoOutput(VideoFrameContainer* aContainer) override;
|
|
|
|
virtual void RemoveVideoOutput(VideoFrameContainer* aContainer) override;
|
2015-09-10 16:45:36 +03:00
|
|
|
virtual void Suspend() override {}
|
|
|
|
virtual void Resume() override {}
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void AddListener(MediaStreamListener* aListener) override;
|
|
|
|
virtual void RemoveListener(MediaStreamListener* aListener) override;
|
|
|
|
virtual void Destroy() override;
|
2014-11-21 17:34:00 +03:00
|
|
|
void OnPreviewStateChange(bool aActive);
|
2013-03-20 18:07:46 +04:00
|
|
|
|
2014-07-03 03:55:00 +04:00
|
|
|
void Invalidate();
|
|
|
|
|
2016-04-19 18:12:24 +03:00
|
|
|
void ProcessInput(GraphTime aFrom, GraphTime aTo, uint32_t aFlags) override;
|
|
|
|
|
2013-03-20 18:07:46 +04:00
|
|
|
// Call these on any thread.
|
2015-09-23 21:49:05 +03:00
|
|
|
void SetCurrentFrame(const gfx::IntSize& aIntrinsicSize, Image* aImage);
|
2013-07-12 17:33:50 +04:00
|
|
|
void ClearCurrentFrame();
|
2014-07-03 03:55:00 +04:00
|
|
|
void RateLimit(bool aLimit);
|
2013-05-02 15:59:58 +04:00
|
|
|
|
2013-03-20 18:07:46 +04:00
|
|
|
protected:
|
|
|
|
// mMutex protects all the class' fields.
|
|
|
|
// This class is not registered to MediaStreamGraph.
|
|
|
|
// It needs to protect all the fields.
|
|
|
|
Mutex mMutex;
|
2014-07-03 03:55:00 +04:00
|
|
|
int32_t mInvalidatePending;
|
|
|
|
uint32_t mDiscardedFrames;
|
|
|
|
bool mRateLimit;
|
2014-11-21 17:34:00 +03:00
|
|
|
bool mTrackCreated;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<FakeMediaStreamGraph> mFakeMediaStreamGraph;
|
2013-03-20 18:07:46 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace mozilla
|
2013-03-20 18:07:46 +04:00
|
|
|
|
|
|
|
#endif // DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H
|