mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix for bug 711628 (Implement PeerConnection.localStreams/remoteStreams). r=bz.
--HG-- extra : rebase_source : d7be35954ba69563ed26b2173c75fe9e74707847
This commit is contained in:
parent
0a4b18d6ed
commit
772951ca5e
@ -247,6 +247,14 @@ DOMInterfaces = {
|
||||
'workers': True,
|
||||
}],
|
||||
|
||||
'MediaStreamList': {
|
||||
'headerFile': 'MediaStreamList.h',
|
||||
'wrapperCache': False,
|
||||
'nativeOwnership': 'owned',
|
||||
'resultNotAddRefed': [ '__indexedGetter' ],
|
||||
'binaryNames': { '__indexedGetter': 'IndexedGetter' }
|
||||
},
|
||||
|
||||
'MozChannel': [
|
||||
{
|
||||
'nativeType': 'nsIChannel',
|
||||
@ -608,6 +616,7 @@ addExternalIface('File')
|
||||
addExternalIface('HitRegionOptions', nativeType='nsISupports')
|
||||
addExternalIface('HTMLElement')
|
||||
addExternalIface('ImageData', nativeType='mozilla::dom::ImageData')
|
||||
addExternalIface('MediaStream')
|
||||
addExternalIface('Node', nativeType='nsINode')
|
||||
addExternalIface('PaintRequest')
|
||||
addExternalIface('SVGLength')
|
||||
|
@ -72,7 +72,8 @@ EXPORTS_$(binding_include_path) = \
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/js/xpconnect/src \
|
||||
-I$(topsrcdir)/js/xpconnect/wrappers \
|
||||
-I$(topsrcdir)/content/canvas/src \
|
||||
-I$(topsrcdir)/content/html/content/src
|
||||
-I$(topsrcdir)/content/html/content/src \
|
||||
-I$(topsrcdir)/media/webrtc/signaling/src/peerconnection
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
@ -404,6 +404,13 @@ PeerConnection.prototype = {
|
||||
});
|
||||
},
|
||||
|
||||
get localStreams() {
|
||||
return this._pc.localStreams;
|
||||
},
|
||||
get remoteStreams() {
|
||||
return this._pc.remoteStreams;
|
||||
},
|
||||
|
||||
createDataChannel: function(label, dict) {
|
||||
if (dict &&
|
||||
dict.maxRetransmitTime != undefined &&
|
||||
|
@ -83,6 +83,9 @@ interface IPeerConnection : nsISupports
|
||||
void removeStream(in nsIDOMMediaStream stream);
|
||||
void closeStreams();
|
||||
|
||||
[implicit_jscontext] readonly attribute jsval localStreams; // MediaStream[]
|
||||
[implicit_jscontext] readonly attribute jsval remoteStreams; // MediaStream[]
|
||||
|
||||
/* As the ICE candidates roll in this one should be called each time
|
||||
* in order to keep the candidate list up-to-date for the next SDP-related
|
||||
* call PeerConnectionImpl does not parse ICE candidates, just sticks them
|
||||
|
13
dom/webidl/MediaStreamList.webidl
Normal file
13
dom/webidl/MediaStreamList.webidl
Normal file
@ -0,0 +1,13 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*/
|
||||
|
||||
interface MediaStream;
|
||||
|
||||
[NoInterfaceObject]
|
||||
interface MediaStreamList {
|
||||
getter MediaStream? (unsigned long index);
|
||||
readonly attribute unsigned long length;
|
||||
};
|
@ -30,6 +30,7 @@ webidl_files = \
|
||||
HTMLCollection.webidl \
|
||||
HTMLOptionsCollection.webidl \
|
||||
HTMLPropertiesCollection.webidl \
|
||||
MediaStreamList.webidl \
|
||||
NodeList.webidl \
|
||||
PaintRequestList.webidl \
|
||||
Performance.webidl \
|
||||
|
@ -128,6 +128,8 @@
|
||||
'./src/softphonewrapper/CC_SIPCCLineInfo.h',
|
||||
'./src/softphonewrapper/CC_SIPCCService.h',
|
||||
# PeerConnection
|
||||
'./src/peerconnection/MediaStreamList.cpp',
|
||||
'./src/peerconnection/MediaStreamList.h',
|
||||
'./src/peerconnection/PeerConnectionCtx.cpp',
|
||||
'./src/peerconnection/PeerConnectionCtx.h',
|
||||
'./src/peerconnection/PeerConnectionImpl.cpp',
|
||||
|
@ -0,0 +1,83 @@
|
||||
/* 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 "base/basictypes.h"
|
||||
#include "MediaStreamList.h"
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "mozilla/dom/MediaStreamListBinding.h"
|
||||
#endif
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "PeerConnectionImpl.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
MediaStreamList::MediaStreamList(sipcc::PeerConnectionImpl* peerConnection,
|
||||
StreamType type)
|
||||
: mPeerConnection(peerConnection),
|
||||
mType(type)
|
||||
{
|
||||
MOZ_COUNT_CTOR(mozilla::dom::MediaStreamList);
|
||||
}
|
||||
|
||||
MediaStreamList::~MediaStreamList()
|
||||
{
|
||||
MOZ_COUNT_DTOR(mozilla::dom::MediaStreamList);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
MediaStreamList::WrapObject(JSContext* cx, ErrorResult& error)
|
||||
{
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
nsCOMPtr<nsIScriptGlobalObject> global =
|
||||
do_QueryInterface(mPeerConnection->GetWindow());
|
||||
JSObject* scope = global->GetGlobalJSObject();
|
||||
if (!scope) {
|
||||
error.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JSAutoCompartment ac(cx, scope);
|
||||
JSObject* obj = MediaStreamListBinding::Wrap(cx, scope, this);
|
||||
if (!obj) {
|
||||
error.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
return obj;
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static nsIDOMMediaStream*
|
||||
GetStreamFromInfo(T* info, bool& found)
|
||||
{
|
||||
if (!info) {
|
||||
found = false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
found = true;
|
||||
return info->GetMediaStream();
|
||||
}
|
||||
|
||||
nsIDOMMediaStream*
|
||||
MediaStreamList::IndexedGetter(uint32_t index, bool& found)
|
||||
{
|
||||
if (mType == Local) {
|
||||
return GetStreamFromInfo(mPeerConnection->GetLocalStream(index), found);
|
||||
}
|
||||
|
||||
return GetStreamFromInfo(mPeerConnection->GetRemoteStream(index), found);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MediaStreamList::Length()
|
||||
{
|
||||
return mType == Local ? mPeerConnection->LocalStreamsLength() :
|
||||
mPeerConnection->RemoteStreamsLength();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
46
media/webrtc/signaling/src/peerconnection/MediaStreamList.h
Normal file
46
media/webrtc/signaling/src/peerconnection/MediaStreamList.h
Normal file
@ -0,0 +1,46 @@
|
||||
/* 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 MediaStreamList_h__
|
||||
#define MediaStreamList_h__
|
||||
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "jspubtd.h"
|
||||
#include "mozilla/dom/NonRefcountedDOMObject.h"
|
||||
|
||||
class nsIDOMMediaStream;
|
||||
namespace sipcc {
|
||||
class PeerConnectionImpl;
|
||||
} // namespace sipcc
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class MediaStreamList : public NonRefcountedDOMObject
|
||||
{
|
||||
public:
|
||||
enum StreamType {
|
||||
Local,
|
||||
Remote
|
||||
};
|
||||
|
||||
MediaStreamList(sipcc::PeerConnectionImpl* peerConnection, StreamType type);
|
||||
~MediaStreamList();
|
||||
|
||||
JSObject* WrapObject(JSContext* cx, ErrorResult& error);
|
||||
|
||||
nsIDOMMediaStream* IndexedGetter(uint32_t index, bool& found);
|
||||
uint32_t Length();
|
||||
|
||||
private:
|
||||
nsRefPtr<sipcc::PeerConnectionImpl> mPeerConnection;
|
||||
StreamType mType;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // MediaStreamList_h__
|
@ -31,6 +31,11 @@
|
||||
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsDOMDataChannel.h"
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
#include "MediaStreamList.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "jsapi.h"
|
||||
#endif
|
||||
|
||||
#ifndef USE_FAKE_MEDIA_STREAMS
|
||||
#include "MediaSegment.h"
|
||||
@ -1130,7 +1135,7 @@ PeerConnectionImpl::IceStreamReady(NrIceMediaStream *aStream)
|
||||
CSFLogDebugS(logTag, __FUNCTION__ << ": " << aStream->name().c_str());
|
||||
}
|
||||
|
||||
nsRefPtr<LocalSourceStreamInfo>
|
||||
LocalSourceStreamInfo*
|
||||
PeerConnectionImpl::GetLocalStream(int aIndex)
|
||||
{
|
||||
if(aIndex < 0 || aIndex >= (int) mLocalSourceStreams.Length()) {
|
||||
@ -1141,7 +1146,7 @@ PeerConnectionImpl::GetLocalStream(int aIndex)
|
||||
return mLocalSourceStreams[aIndex];
|
||||
}
|
||||
|
||||
nsRefPtr<RemoteSourceStreamInfo>
|
||||
RemoteSourceStreamInfo*
|
||||
PeerConnectionImpl::GetRemoteStream(int aIndex)
|
||||
{
|
||||
if(aIndex < 0 || aIndex >= (int) mRemoteSourceStreams.Length()) {
|
||||
@ -1165,6 +1170,47 @@ PeerConnectionImpl::AddRemoteStream(nsRefPtr<RemoteSourceStreamInfo> aInfo,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
static nsresult
|
||||
GetStreams(JSContext* cx, PeerConnectionImpl* peerConnection,
|
||||
MediaStreamList::StreamType type, JS::Value* streams)
|
||||
{
|
||||
nsAutoPtr<MediaStreamList> list(new MediaStreamList(peerConnection, type));
|
||||
|
||||
ErrorResult rv;
|
||||
JSObject* obj = list->WrapObject(cx, rv);
|
||||
if (rv.Failed()) {
|
||||
streams->setNull();
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
// Transfer ownership to the binding.
|
||||
streams->setObject(*obj);
|
||||
list.forget();
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
PeerConnectionImpl::GetLocalStreams(JSContext* cx, JS::Value* streams)
|
||||
{
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
return GetStreams(cx, this, MediaStreamList::Local, streams);
|
||||
#else
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PeerConnectionImpl::GetRemoteStreams(JSContext* cx, JS::Value* streams)
|
||||
{
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
return GetStreams(cx, this, MediaStreamList::Remote, streams);
|
||||
#else
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
LocalSourceStreamInfo::StorePipeline(int aTrack,
|
||||
mozilla::RefPtr<mozilla::MediaPipeline> aPipeline)
|
||||
|
@ -329,10 +329,18 @@ public:
|
||||
}
|
||||
|
||||
// Get a specific local stream
|
||||
nsRefPtr<LocalSourceStreamInfo> GetLocalStream(int aIndex);
|
||||
uint32_t LocalStreamsLength()
|
||||
{
|
||||
return mLocalSourceStreams.Length();
|
||||
}
|
||||
LocalSourceStreamInfo* GetLocalStream(int index);
|
||||
|
||||
// Get a specific remote stream
|
||||
nsRefPtr<RemoteSourceStreamInfo> GetRemoteStream(int aIndex);
|
||||
uint32_t RemoteStreamsLength()
|
||||
{
|
||||
return mRemoteSourceStreams.Length();
|
||||
}
|
||||
RemoteSourceStreamInfo* GetRemoteStream(int index);
|
||||
|
||||
// Add a remote stream. Returns the index in index
|
||||
nsresult AddRemoteStream(nsRefPtr<RemoteSourceStreamInfo> aInfo, int *aIndex);
|
||||
@ -370,6 +378,8 @@ public:
|
||||
// Create a fake media stream
|
||||
nsresult CreateFakeMediaStream(uint32_t hint, nsIDOMMediaStream** retval);
|
||||
|
||||
nsPIDOMWindow* GetWindow() const { return mWindow; }
|
||||
|
||||
private:
|
||||
PeerConnectionImpl(const PeerConnectionImpl&rhs);
|
||||
PeerConnectionImpl& operator=(PeerConnectionImpl);
|
||||
|
Loading…
Reference in New Issue
Block a user