michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _PEER_CONNECTION_IMPL_H_ michael@0: #define _PEER_CONNECTION_IMPL_H_ michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #include "prlock.h" michael@0: #include "mozilla/RefPtr.h" michael@0: #include "nsWeakPtr.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsIWeakReferenceUtils.h" // for the definition of nsWeakPtr michael@0: #include "IPeerConnection.h" michael@0: #include "sigslot.h" michael@0: #include "nricectx.h" michael@0: #include "nricemediastream.h" michael@0: #include "nsComponentManagerUtils.h" michael@0: #include "nsPIDOMWindow.h" michael@0: #include "nsIThread.h" michael@0: michael@0: #include "mozilla/ErrorResult.h" michael@0: #include "mozilla/dom/PeerConnectionImplEnumsBinding.h" michael@0: #include "StreamBuffer.h" michael@0: #include "LoadManagerFactory.h" michael@0: michael@0: #ifdef MOZILLA_INTERNAL_API michael@0: #include "mozilla/TimeStamp.h" michael@0: #include "mozilla/net/DataChannel.h" michael@0: #include "VideoUtils.h" michael@0: #include "VideoSegment.h" michael@0: #include "nsNSSShutDown.h" michael@0: #include "mozilla/dom/RTCStatsReportBinding.h" michael@0: #endif michael@0: michael@0: namespace test { michael@0: #ifdef USE_FAKE_PCOBSERVER michael@0: class AFakePCObserver; michael@0: #endif michael@0: } michael@0: michael@0: #ifdef USE_FAKE_MEDIA_STREAMS michael@0: class Fake_DOMMediaStream; michael@0: #endif michael@0: michael@0: class nsGlobalWindow; michael@0: class nsIDOMMediaStream; michael@0: class nsDOMDataChannel; michael@0: michael@0: namespace mozilla { michael@0: class DataChannel; michael@0: class DtlsIdentity; michael@0: class NrIceCtx; michael@0: class NrIceMediaStream; michael@0: class NrIceStunServer; michael@0: class NrIceTurnServer; michael@0: class MediaPipeline; michael@0: michael@0: #ifdef USE_FAKE_MEDIA_STREAMS michael@0: typedef Fake_DOMMediaStream DOMMediaStream; michael@0: #else michael@0: class DOMMediaStream; michael@0: #endif michael@0: michael@0: namespace dom { michael@0: class RTCConfiguration; michael@0: class MediaConstraintsInternal; michael@0: class MediaStreamTrack; michael@0: class RTCStatsReportInternal; michael@0: michael@0: #ifdef USE_FAKE_PCOBSERVER michael@0: typedef test::AFakePCObserver PeerConnectionObserver; michael@0: typedef const char *PCObserverString; michael@0: #else michael@0: class PeerConnectionObserver; michael@0: typedef NS_ConvertUTF8toUTF16 PCObserverString; michael@0: #endif michael@0: } michael@0: class MediaConstraintsExternal; michael@0: } michael@0: michael@0: #if defined(__cplusplus) && __cplusplus >= 201103L michael@0: typedef struct Timecard Timecard; michael@0: #else michael@0: #include "timecard.h" michael@0: #endif michael@0: michael@0: // To preserve blame, convert nsresult to ErrorResult with wrappers. These macros michael@0: // help declare wrappers w/function being wrapped when there are no differences. michael@0: michael@0: #define NS_IMETHODIMP_TO_ERRORRESULT(func, rv, ...) \ michael@0: NS_IMETHODIMP func(__VA_ARGS__); \ michael@0: void func (__VA_ARGS__, rv) michael@0: michael@0: #define NS_IMETHODIMP_TO_ERRORRESULT_RETREF(resulttype, func, rv, ...) \ michael@0: NS_IMETHODIMP func(__VA_ARGS__, resulttype **result); \ michael@0: already_AddRefed func (__VA_ARGS__, rv) michael@0: michael@0: namespace sipcc { michael@0: michael@0: using mozilla::dom::PeerConnectionObserver; michael@0: using mozilla::dom::RTCConfiguration; michael@0: using mozilla::dom::MediaConstraintsInternal; michael@0: using mozilla::MediaConstraintsExternal; michael@0: using mozilla::DOMMediaStream; michael@0: using mozilla::NrIceCtx; michael@0: using mozilla::NrIceMediaStream; michael@0: using mozilla::DtlsIdentity; michael@0: using mozilla::ErrorResult; michael@0: using mozilla::NrIceStunServer; michael@0: using mozilla::NrIceTurnServer; michael@0: michael@0: class PeerConnectionWrapper; michael@0: class PeerConnectionMedia; michael@0: class RemoteSourceStreamInfo; michael@0: class OnCallEventArgs; michael@0: michael@0: class IceConfiguration michael@0: { michael@0: public: michael@0: bool addStunServer(const std::string& addr, uint16_t port) michael@0: { michael@0: NrIceStunServer* server(NrIceStunServer::Create(addr, port)); michael@0: if (!server) { michael@0: return false; michael@0: } michael@0: addStunServer(*server); michael@0: return true; michael@0: } michael@0: bool addTurnServer(const std::string& addr, uint16_t port, michael@0: const std::string& username, michael@0: const std::string& pwd, michael@0: const char* transport) michael@0: { michael@0: // TODO(ekr@rtfm.com): Need support for SASLprep for michael@0: // username and password. Bug # ??? michael@0: std::vector password(pwd.begin(), pwd.end()); michael@0: michael@0: NrIceTurnServer* server(NrIceTurnServer::Create(addr, port, username, password, michael@0: transport)); michael@0: if (!server) { michael@0: return false; michael@0: } michael@0: addTurnServer(*server); michael@0: return true; michael@0: } michael@0: void addStunServer(const NrIceStunServer& server) { mStunServers.push_back (server); } michael@0: void addTurnServer(const NrIceTurnServer& server) { mTurnServers.push_back (server); } michael@0: const std::vector& getStunServers() const { return mStunServers; } michael@0: const std::vector& getTurnServers() const { return mTurnServers; } michael@0: private: michael@0: std::vector mStunServers; michael@0: std::vector mTurnServers; michael@0: }; michael@0: michael@0: #ifdef MOZILLA_INTERNAL_API michael@0: // Not an inner class so we can forward declare. michael@0: class RTCStatsQuery { michael@0: public: michael@0: explicit RTCStatsQuery(bool internalStats); michael@0: ~RTCStatsQuery(); michael@0: michael@0: mozilla::dom::RTCStatsReportInternal report; michael@0: std::string error; michael@0: michael@0: private: michael@0: friend class PeerConnectionImpl; michael@0: std::string pcName; michael@0: bool internalStats; michael@0: nsTArray> pipelines; michael@0: mozilla::RefPtr iceCtx; michael@0: nsTArray> streams; michael@0: DOMHighResTimeStamp now; michael@0: }; michael@0: #endif // MOZILLA_INTERNAL_API michael@0: michael@0: // Enter an API call and check that the state is OK, michael@0: // the PC isn't closed, etc. michael@0: #define PC_AUTO_ENTER_API_CALL(assert_ice_ready) \ michael@0: do { \ michael@0: /* do/while prevents res from conflicting with locals */ \ michael@0: nsresult res = CheckApiState(assert_ice_ready); \ michael@0: if (NS_FAILED(res)) return res; \ michael@0: } while(0) michael@0: #define PC_AUTO_ENTER_API_CALL_VOID_RETURN(assert_ice_ready) \ michael@0: do { \ michael@0: /* do/while prevents res from conflicting with locals */ \ michael@0: nsresult res = CheckApiState(assert_ice_ready); \ michael@0: if (NS_FAILED(res)) return; \ michael@0: } while(0) michael@0: #define PC_AUTO_ENTER_API_CALL_NO_CHECK() CheckThread() michael@0: michael@0: class PeerConnectionImpl MOZ_FINAL : public nsISupports, michael@0: #ifdef MOZILLA_INTERNAL_API michael@0: public mozilla::DataChannelConnection::DataConnectionListener, michael@0: public nsNSSShutDownObject, michael@0: #endif michael@0: public sigslot::has_slots<> michael@0: { michael@0: class Internal; // Avoid exposing c includes to bindings michael@0: michael@0: public: michael@0: PeerConnectionImpl(const mozilla::dom::GlobalObject* aGlobal = nullptr); michael@0: virtual ~PeerConnectionImpl(); michael@0: michael@0: enum Error { michael@0: kNoError = 0, michael@0: kInvalidConstraintsType = 1, michael@0: kInvalidCandidateType = 2, michael@0: kInvalidMediastreamTrack = 3, michael@0: kInvalidState = 4, michael@0: kInvalidSessionDescription = 5, michael@0: kIncompatibleSessionDescription = 6, michael@0: kIncompatibleConstraints = 7, michael@0: kIncompatibleMediaStreamTrack = 8, michael@0: kInternalError = 9 michael@0: }; michael@0: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: michael@0: #ifdef MOZILLA_INTERNAL_API michael@0: virtual JSObject* WrapObject(JSContext* cx); michael@0: #endif michael@0: michael@0: static already_AddRefed michael@0: Constructor(const mozilla::dom::GlobalObject& aGlobal, ErrorResult& rv); michael@0: static PeerConnectionImpl* CreatePeerConnection(); michael@0: static nsresult ConvertRTCConfiguration(const RTCConfiguration& aSrc, michael@0: IceConfiguration *aDst); michael@0: static already_AddRefed MakeMediaStream(nsPIDOMWindow* aWindow, michael@0: uint32_t aHint); michael@0: michael@0: nsresult CreateRemoteSourceStreamInfo(nsRefPtr* aInfo); michael@0: michael@0: // Implementation of the only observer we need michael@0: void onCallEvent(const OnCallEventArgs &args); michael@0: michael@0: // DataConnection observers michael@0: void NotifyConnection(); michael@0: void NotifyClosedConnection(); michael@0: void NotifyDataChannel(already_AddRefed aChannel); michael@0: michael@0: // Get the media object michael@0: const nsRefPtr& media() const { michael@0: PC_AUTO_ENTER_API_CALL_NO_CHECK(); michael@0: return mMedia; michael@0: } michael@0: michael@0: mozilla::LoadManager* load_manager() { michael@0: return mLoadManager; michael@0: } michael@0: michael@0: // Handle system to allow weak references to be passed through C code michael@0: virtual const std::string& GetHandle(); michael@0: michael@0: // Name suitable for exposing to content michael@0: virtual const std::string& GetName(); michael@0: michael@0: // ICE events michael@0: void IceConnectionStateChange(NrIceCtx* ctx, michael@0: NrIceCtx::ConnectionState state); michael@0: void IceGatheringStateChange(NrIceCtx* ctx, michael@0: NrIceCtx::GatheringState state); michael@0: void IceStreamReady(NrIceMediaStream *aStream); michael@0: michael@0: static void ListenThread(void *aData); michael@0: static void ConnectThread(void *aData); michael@0: michael@0: // Get the main thread michael@0: nsCOMPtr GetMainThread() { michael@0: PC_AUTO_ENTER_API_CALL_NO_CHECK(); michael@0: return mThread; michael@0: } michael@0: michael@0: // Get the STS thread michael@0: nsCOMPtr GetSTSThread() { michael@0: PC_AUTO_ENTER_API_CALL_NO_CHECK(); michael@0: return mSTSThread; michael@0: } michael@0: michael@0: // Get the DTLS identity michael@0: mozilla::RefPtr const GetIdentity() const; michael@0: std::string GetFingerprint() const; michael@0: std::string GetFingerprintAlgorithm() const; michael@0: std::string GetFingerprintHexValue() const; michael@0: michael@0: // Create a fake media stream michael@0: nsresult CreateFakeMediaStream(uint32_t hint, nsIDOMMediaStream** retval); michael@0: michael@0: nsPIDOMWindow* GetWindow() const { michael@0: PC_AUTO_ENTER_API_CALL_NO_CHECK(); michael@0: return mWindow; michael@0: } michael@0: michael@0: // Initialize PeerConnection from an IceConfiguration object (unit-tests) michael@0: nsresult Initialize(PeerConnectionObserver& aObserver, michael@0: nsGlobalWindow* aWindow, michael@0: const IceConfiguration& aConfiguration, michael@0: nsIThread* aThread) { michael@0: return Initialize(aObserver, aWindow, &aConfiguration, nullptr, aThread); michael@0: } michael@0: michael@0: // Initialize PeerConnection from an RTCConfiguration object (JS entrypoint) michael@0: void Initialize(PeerConnectionObserver& aObserver, michael@0: nsGlobalWindow& aWindow, michael@0: const RTCConfiguration& aConfiguration, michael@0: nsISupports* aThread, michael@0: ErrorResult &rv) michael@0: { michael@0: nsresult r = Initialize(aObserver, &aWindow, nullptr, &aConfiguration, aThread); michael@0: if (NS_FAILED(r)) { michael@0: rv.Throw(r); michael@0: } michael@0: } michael@0: michael@0: NS_IMETHODIMP_TO_ERRORRESULT(CreateOffer, ErrorResult &rv, michael@0: const MediaConstraintsInternal& aConstraints) michael@0: { michael@0: rv = CreateOffer(aConstraints); michael@0: } michael@0: michael@0: NS_IMETHODIMP_TO_ERRORRESULT(CreateAnswer, ErrorResult &rv, michael@0: const MediaConstraintsInternal& aConstraints) michael@0: { michael@0: rv = CreateAnswer(aConstraints); michael@0: } michael@0: michael@0: NS_IMETHODIMP CreateOffer(const MediaConstraintsExternal& aConstraints); michael@0: NS_IMETHODIMP CreateAnswer(const MediaConstraintsExternal& aConstraints); michael@0: michael@0: NS_IMETHODIMP SetLocalDescription (int32_t aAction, const char* aSDP); michael@0: michael@0: void SetLocalDescription (int32_t aAction, const nsAString& aSDP, ErrorResult &rv) michael@0: { michael@0: rv = SetLocalDescription(aAction, NS_ConvertUTF16toUTF8(aSDP).get()); michael@0: } michael@0: michael@0: NS_IMETHODIMP SetRemoteDescription (int32_t aAction, const char* aSDP); michael@0: michael@0: void SetRemoteDescription (int32_t aAction, const nsAString& aSDP, ErrorResult &rv) michael@0: { michael@0: rv = SetRemoteDescription(aAction, NS_ConvertUTF16toUTF8(aSDP).get()); michael@0: } michael@0: michael@0: NS_IMETHODIMP_TO_ERRORRESULT(GetStats, ErrorResult &rv, michael@0: mozilla::dom::MediaStreamTrack *aSelector) michael@0: { michael@0: rv = GetStats(aSelector); michael@0: } michael@0: michael@0: NS_IMETHODIMP AddIceCandidate(const char* aCandidate, const char* aMid, michael@0: unsigned short aLevel); michael@0: michael@0: void AddIceCandidate(const nsAString& aCandidate, const nsAString& aMid, michael@0: unsigned short aLevel, ErrorResult &rv) michael@0: { michael@0: rv = AddIceCandidate(NS_ConvertUTF16toUTF8(aCandidate).get(), michael@0: NS_ConvertUTF16toUTF8(aMid).get(), aLevel); michael@0: } michael@0: michael@0: NS_IMETHODIMP CloseStreams(); michael@0: michael@0: void CloseStreams(ErrorResult &rv) michael@0: { michael@0: rv = CloseStreams(); michael@0: } michael@0: michael@0: NS_IMETHODIMP_TO_ERRORRESULT(AddStream, ErrorResult &rv, michael@0: DOMMediaStream& aMediaStream, michael@0: const MediaConstraintsInternal& aConstraints) michael@0: { michael@0: rv = AddStream(aMediaStream, aConstraints); michael@0: } michael@0: michael@0: NS_IMETHODIMP AddStream(DOMMediaStream & aMediaStream, michael@0: const MediaConstraintsExternal& aConstraints); michael@0: michael@0: NS_IMETHODIMP_TO_ERRORRESULT(RemoveStream, ErrorResult &rv, michael@0: DOMMediaStream& aMediaStream) michael@0: { michael@0: rv = RemoveStream(aMediaStream); michael@0: } michael@0: michael@0: NS_IMETHODIMP GetFingerprint(char** fingerprint); michael@0: void GetFingerprint(nsAString& fingerprint) michael@0: { michael@0: char *tmp; michael@0: GetFingerprint(&tmp); michael@0: fingerprint.AssignASCII(tmp); michael@0: delete[] tmp; michael@0: } michael@0: michael@0: NS_IMETHODIMP GetLocalDescription(char** aSDP); michael@0: michael@0: void GetLocalDescription(nsAString& aSDP) michael@0: { michael@0: char *tmp; michael@0: GetLocalDescription(&tmp); michael@0: aSDP.AssignASCII(tmp); michael@0: delete tmp; michael@0: } michael@0: michael@0: NS_IMETHODIMP GetRemoteDescription(char** aSDP); michael@0: michael@0: void GetRemoteDescription(nsAString& aSDP) michael@0: { michael@0: char *tmp; michael@0: GetRemoteDescription(&tmp); michael@0: aSDP.AssignASCII(tmp); michael@0: delete tmp; michael@0: } michael@0: michael@0: NS_IMETHODIMP ReadyState(mozilla::dom::PCImplReadyState* aState); michael@0: michael@0: mozilla::dom::PCImplReadyState ReadyState() michael@0: { michael@0: mozilla::dom::PCImplReadyState state; michael@0: ReadyState(&state); michael@0: return state; michael@0: } michael@0: michael@0: NS_IMETHODIMP SignalingState(mozilla::dom::PCImplSignalingState* aState); michael@0: michael@0: mozilla::dom::PCImplSignalingState SignalingState() michael@0: { michael@0: mozilla::dom::PCImplSignalingState state; michael@0: SignalingState(&state); michael@0: return state; michael@0: } michael@0: michael@0: NS_IMETHODIMP SipccState(mozilla::dom::PCImplSipccState* aState); michael@0: michael@0: mozilla::dom::PCImplSipccState SipccState() michael@0: { michael@0: mozilla::dom::PCImplSipccState state; michael@0: SipccState(&state); michael@0: return state; michael@0: } michael@0: michael@0: NS_IMETHODIMP IceConnectionState( michael@0: mozilla::dom::PCImplIceConnectionState* aState); michael@0: michael@0: mozilla::dom::PCImplIceConnectionState IceConnectionState() michael@0: { michael@0: mozilla::dom::PCImplIceConnectionState state; michael@0: IceConnectionState(&state); michael@0: return state; michael@0: } michael@0: michael@0: NS_IMETHODIMP IceGatheringState( michael@0: mozilla::dom::PCImplIceGatheringState* aState); michael@0: michael@0: mozilla::dom::PCImplIceGatheringState IceGatheringState() michael@0: { michael@0: mozilla::dom::PCImplIceGatheringState state; michael@0: IceGatheringState(&state); michael@0: return state; michael@0: } michael@0: michael@0: NS_IMETHODIMP Close(); michael@0: michael@0: void Close(ErrorResult &rv) michael@0: { michael@0: rv = Close(); michael@0: } michael@0: michael@0: nsresult InitializeDataChannel(int track_id, uint16_t aLocalport, michael@0: uint16_t aRemoteport, uint16_t aNumstreams); michael@0: michael@0: NS_IMETHODIMP_TO_ERRORRESULT(ConnectDataConnection, ErrorResult &rv, michael@0: uint16_t aLocalport, michael@0: uint16_t aRemoteport, michael@0: uint16_t aNumstreams) michael@0: { michael@0: rv = ConnectDataConnection(aLocalport, aRemoteport, aNumstreams); michael@0: } michael@0: michael@0: NS_IMETHODIMP_TO_ERRORRESULT_RETREF(nsDOMDataChannel, michael@0: CreateDataChannel, ErrorResult &rv, michael@0: const nsAString& aLabel, michael@0: const nsAString& aProtocol, michael@0: uint16_t aType, michael@0: bool outOfOrderAllowed, michael@0: uint16_t aMaxTime, michael@0: uint16_t aMaxNum, michael@0: bool aExternalNegotiated, michael@0: uint16_t aStream); michael@0: michael@0: NS_IMETHODIMP_TO_ERRORRESULT(GetLocalStreams, ErrorResult &rv, michael@0: nsTArray >& result) michael@0: { michael@0: rv = GetLocalStreams(result); michael@0: } michael@0: michael@0: NS_IMETHODIMP_TO_ERRORRESULT(GetRemoteStreams, ErrorResult &rv, michael@0: nsTArray >& result) michael@0: { michael@0: rv = GetRemoteStreams(result); michael@0: } michael@0: michael@0: // Called whenever something is unrecognized by the parser michael@0: // May be called more than once and does not necessarily mean michael@0: // that parsing was stopped, only that something was unrecognized. michael@0: void OnSdpParseError(const char* errorMessage); michael@0: michael@0: // Called when OnLocal/RemoteDescriptionSuccess/Error michael@0: // is called to start the list over. michael@0: void ClearSdpParseErrorMessages(); michael@0: michael@0: // Called to retreive the list of parsing errors. michael@0: const std::vector &GetSdpParseErrors(); michael@0: michael@0: // Sets the RTC Signaling State michael@0: void SetSignalingState_m(mozilla::dom::PCImplSignalingState aSignalingState); michael@0: michael@0: bool IsClosed() const; michael@0: michael@0: bool HasMedia() const; michael@0: michael@0: #ifdef MOZILLA_INTERNAL_API michael@0: // initialize telemetry for when calls start michael@0: void startCallTelem(); michael@0: michael@0: nsresult BuildStatsQuery_m( michael@0: mozilla::dom::MediaStreamTrack *aSelector, michael@0: RTCStatsQuery *query); michael@0: michael@0: static nsresult ExecuteStatsQuery_s(RTCStatsQuery *query); michael@0: #endif michael@0: michael@0: private: michael@0: PeerConnectionImpl(const PeerConnectionImpl&rhs); michael@0: PeerConnectionImpl& operator=(PeerConnectionImpl); michael@0: NS_IMETHODIMP Initialize(PeerConnectionObserver& aObserver, michael@0: nsGlobalWindow* aWindow, michael@0: const IceConfiguration* aConfiguration, michael@0: const RTCConfiguration* aRTCConfiguration, michael@0: nsISupports* aThread); michael@0: michael@0: NS_IMETHODIMP EnsureDataConnection(uint16_t aNumstreams); michael@0: michael@0: nsresult CloseInt(); michael@0: void ChangeReadyState(mozilla::dom::PCImplReadyState aReadyState); michael@0: nsresult CheckApiState(bool assert_ice_ready) const; michael@0: void CheckThread() const { michael@0: NS_ABORT_IF_FALSE(CheckThreadInt(), "Wrong thread"); michael@0: } michael@0: bool CheckThreadInt() const { michael@0: #ifdef MOZILLA_INTERNAL_API michael@0: // Thread assertions are disabled in the C++ unit tests because those michael@0: // make API calls off the main thread. michael@0: // TODO(ekr@rtfm.com): Fix the unit tests so they don't do that. michael@0: bool on; michael@0: NS_ENSURE_SUCCESS(mThread->IsOnCurrentThread(&on), false); michael@0: NS_ENSURE_TRUE(on, false); michael@0: #endif michael@0: return true; michael@0: } michael@0: michael@0: #ifdef MOZILLA_INTERNAL_API michael@0: void virtualDestroyNSSReference() MOZ_FINAL; michael@0: void destructorSafeDestroyNSSReference(); michael@0: nsresult GetTimeSinceEpoch(DOMHighResTimeStamp *result); michael@0: #endif michael@0: michael@0: // Shut down media - called on main thread only michael@0: void ShutdownMedia(); michael@0: michael@0: NS_IMETHOD FingerprintSplitHelper( michael@0: std::string& fingerprint, size_t& spaceIdx) const; michael@0: michael@0: michael@0: #ifdef MOZILLA_INTERNAL_API michael@0: static void GetStatsForPCObserver_s( michael@0: const std::string& pcHandle, michael@0: nsAutoPtr query); michael@0: michael@0: // Sends an RTCStatsReport to JS. Must run on main thread. michael@0: static void DeliverStatsReportToPCObserver_m( michael@0: const std::string& pcHandle, michael@0: nsresult result, michael@0: nsAutoPtr query); michael@0: #endif michael@0: michael@0: // When ICE completes, we record a bunch of statistics that outlive the michael@0: // PeerConnection. This is just telemetry right now, but this can also michael@0: // include things like dumping the RLogRingbuffer somewhere, saving away michael@0: // an RTCStatsReport somewhere so it can be inspected after the call is over, michael@0: // or other things. michael@0: void RecordLongtermICEStatistics(); michael@0: michael@0: // Timecard used to measure processing time. This should be the first class michael@0: // attribute so that we accurately measure the time required to instantiate michael@0: // any other attributes of this class. michael@0: Timecard *mTimeCard; michael@0: michael@0: // The call michael@0: mozilla::ScopedDeletePtr mInternal; michael@0: mozilla::dom::PCImplReadyState mReadyState; michael@0: mozilla::dom::PCImplSignalingState mSignalingState; michael@0: michael@0: // ICE State michael@0: mozilla::dom::PCImplIceConnectionState mIceConnectionState; michael@0: mozilla::dom::PCImplIceGatheringState mIceGatheringState; michael@0: michael@0: nsCOMPtr mThread; michael@0: // TODO: Remove if we ever properly wire PeerConnection for cycle-collection. michael@0: nsWeakPtr mPCObserver; michael@0: michael@0: nsCOMPtr mWindow; michael@0: michael@0: // The SDP sent in from JS - here for debugging. michael@0: std::string mLocalRequestedSDP; michael@0: std::string mRemoteRequestedSDP; michael@0: // The SDP we are using. michael@0: std::string mLocalSDP; michael@0: std::string mRemoteSDP; michael@0: michael@0: // DTLS fingerprint michael@0: std::string mFingerprint; michael@0: std::string mRemoteFingerprint; michael@0: michael@0: // The DTLS identity michael@0: mozilla::RefPtr mIdentity; michael@0: michael@0: // A handle to refer to this PC with michael@0: std::string mHandle; michael@0: michael@0: // A name for this PC that we are willing to expose to content. michael@0: std::string mName; michael@0: michael@0: // The target to run stuff on michael@0: nsCOMPtr mSTSThread; michael@0: michael@0: // CPU Load adaptation stuff michael@0: mozilla::LoadManager* mLoadManager; michael@0: michael@0: #ifdef MOZILLA_INTERNAL_API michael@0: // DataConnection that's used to get all the DataChannels michael@0: nsRefPtr mDataConnection; michael@0: #endif michael@0: michael@0: nsRefPtr mMedia; michael@0: michael@0: #ifdef MOZILLA_INTERNAL_API michael@0: // Start time of ICE, used for telemetry michael@0: mozilla::TimeStamp mIceStartTime; michael@0: // Start time of call used for Telemetry michael@0: mozilla::TimeStamp mStartTime; michael@0: #endif michael@0: michael@0: // Temporary: used to prevent multiple audio streams or multiple video streams michael@0: // in a single PC. This is tied up in the IETF discussion around proper michael@0: // representation of multiple streams in SDP, and strongly related to michael@0: // Bug 840728. michael@0: int mNumAudioStreams; michael@0: int mNumVideoStreams; michael@0: michael@0: bool mHaveDataStream; michael@0: michael@0: // Holder for error messages from parsing SDP michael@0: std::vector mSDPParseErrorMessages; michael@0: michael@0: bool mTrickle; michael@0: michael@0: public: michael@0: //these are temporary until the DataChannel Listen/Connect API is removed michael@0: unsigned short listenPort; michael@0: unsigned short connectPort; michael@0: char *connectStr; // XXX ownership/free michael@0: }; michael@0: michael@0: // This is what is returned when you acquire on a handle michael@0: class PeerConnectionWrapper michael@0: { michael@0: public: michael@0: PeerConnectionWrapper(const std::string& handle); michael@0: michael@0: PeerConnectionImpl *impl() { return impl_; } michael@0: michael@0: private: michael@0: nsRefPtr impl_; michael@0: }; michael@0: michael@0: } // end sipcc namespace michael@0: michael@0: #undef NS_IMETHODIMP_TO_ERRORRESULT michael@0: #undef NS_IMETHODIMP_TO_ERRORRESULT_RETREF michael@0: #endif // _PEER_CONNECTION_IMPL_H_