gecko-dev/dom/media/GetUserMediaRequest.cpp
Andreas Pehrson 3ceaba23ab Bug 1299515 - Flatten MediaEngineSource class hierarchy. r=jib
The scope of flattening this hierarchy quickly grows large, so this patch does
a couple more things:
- Creates a pure interface MediaEngineSourceInterface and a base class
  MediaEngineSource with common defaults and refcount support (no state!)
- Breaks out some of the helper classes to dedicated files, e.g.,
  AllocationHandle, MediaEnginePrefs.
- Clarifies the threading model (written on one thread *and* under lock,
  read under either)
- Fixes style, indentation, include-sorting in the affected files
- Adds comments, especially for clarifying what responsibilities methods have,
  and thread usage of class members
- Changes Monitors to Mutexes since we only use them as Mutexes anyhow
- Makes MediaEngineRemoteVideoSource no longer a shared source since we now
  support scaling in this source and CamerasChild can act as a broker of frames.
  This greatly simplifies it. The only shared source is now
  MediaEngineWebRTCMicrophoneSource, so the sharing specific common methods have
  been moved to that source.

MozReview-Commit-ID: KeVZQo6gLm2

--HG--
rename : dom/media/webrtc/MediaEngine.h => dom/media/webrtc/MediaEnginePrefs.h
extra : rebase_source : c785a5feb896312912170475d6b8d997e712e48f
2018-01-24 16:49:13 +01:00

105 lines
2.5 KiB
C++

/* 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/. */
#include "GetUserMediaRequest.h"
#include "base/basictypes.h"
#include "mozilla/dom/MediaStreamBinding.h"
#include "mozilla/dom/GetUserMediaRequestBinding.h"
#include "nsIScriptGlobalObject.h"
#include "nsPIDOMWindow.h"
namespace mozilla {
namespace dom {
GetUserMediaRequest::GetUserMediaRequest(
nsPIDOMWindowInner* aInnerWindow,
const nsAString& aCallID,
const MediaStreamConstraints& aConstraints,
bool aIsSecure,
bool aIsHandlingUserInput)
: mInnerWindowID(aInnerWindow->WindowID())
, mOuterWindowID(aInnerWindow->GetOuterWindow()->WindowID())
, mCallID(aCallID)
, mConstraints(new MediaStreamConstraints(aConstraints))
, mIsSecure(aIsSecure)
, mIsHandlingUserInput(aIsHandlingUserInput)
{
}
GetUserMediaRequest::GetUserMediaRequest(
nsPIDOMWindowInner* aInnerWindow,
const nsAString& aRawId,
const nsAString& aMediaSource)
: mRawID(aRawId)
, mMediaSource(aMediaSource)
{
if (aInnerWindow && aInnerWindow->GetOuterWindow()) {
mOuterWindowID = aInnerWindow->GetOuterWindow()->WindowID();
}
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(GetUserMediaRequest)
NS_IMPL_CYCLE_COLLECTING_ADDREF(GetUserMediaRequest)
NS_IMPL_CYCLE_COLLECTING_RELEASE(GetUserMediaRequest)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(GetUserMediaRequest)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
JSObject*
GetUserMediaRequest::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return GetUserMediaRequestBinding::Wrap(aCx, this, aGivenProto);
}
nsISupports* GetUserMediaRequest::GetParentObject()
{
return nullptr;
}
void GetUserMediaRequest::GetCallID(nsString& retval)
{
retval = mCallID;
}
void GetUserMediaRequest::GetRawID(nsString& retval)
{
retval = mRawID;
}
void GetUserMediaRequest::GetMediaSource(nsString& retval)
{
retval = mMediaSource;
}
uint64_t GetUserMediaRequest::WindowID()
{
return mOuterWindowID;
}
uint64_t GetUserMediaRequest::InnerWindowID()
{
return mInnerWindowID;
}
bool GetUserMediaRequest::IsSecure()
{
return mIsSecure;
}
bool GetUserMediaRequest::IsHandlingUserInput() const
{
return mIsHandlingUserInput;
}
void
GetUserMediaRequest::GetConstraints(MediaStreamConstraints &result)
{
result = *mConstraints;
}
} // namespace dom
} // namespace mozilla