Changeset 197702 in webkit


Ignore:
Timestamp:
Mar 7, 2016 1:25:03 PM (8 years ago)
Author:
adam.bergkvist@ericsson.com
Message:

WebRTC: Implement MediaEndpointPeerConnection::createOffer()
https://bugs.webkit.org/show_bug.cgi?id=154867

Reviewed by Eric Carlson and Jer Noble.

Source/WebCore:

  • MediaEndpointPeerConnection: Initial implementation of createOffer()

added. createOffer() is split up into a synchronous part, and a
scheduled task. The task will be deferred until information, requiring
some amount of work, such as the DTLS fingerprint is available. Other
async API functions will also follow this pattern.

  • SDPProcessor (added): The SDPProcessors parses SDP to a

MediaEndpointSessionConfiguration object and generates SDP in the
reverse direction. Any SDP string handling is confined to the
SDPProcessor and all configuration of the media session is done via the
MediaEndpointSessionConfiguration object.

The SDP parser and generator logic is implemented in JavaScript and
works with JSON (SDP->JSON, JSON->SDP). The SDPProcessor runs JS in an
isolated scope and converts JSON to a MediaEndpointSessionConfiguration
object and the reverse. Using JSON signaling (nonstandard) can be
helpful during debugging.

  • MockMediaEndpoint (added): Mock MediaEndpoint implementation with

support for generating offers. DTLS information, such as fingerprint,
is hard coded to facilitate testing with expected values.

Test: fast/mediastream/RTCPeerConnection-inspect-offer.html

The test is currently skipped on the mac port until support to read the
SDPProcessor JavaScript resource is added.

  • CMakeLists.txt:
  • Modules/mediastream/MediaEndpointPeerConnection.cpp:

(WebCore::WrappedSessionDescriptionPromise::create):
(WebCore::WrappedSessionDescriptionPromise::promise):
(WebCore::WrappedSessionDescriptionPromise::WrappedSessionDescriptionPromise):
(WebCore::randomString):
(WebCore::MediaEndpointPeerConnection::MediaEndpointPeerConnection):
(WebCore::MediaEndpointPeerConnection::runTask):
(WebCore::MediaEndpointPeerConnection::startRunningTasks):
(WebCore::MediaEndpointPeerConnection::createOffer):
(WebCore::MediaEndpointPeerConnection::createOfferTask):
(WebCore::MediaEndpointPeerConnection::gotDtlsFingerprint):

  • Modules/mediastream/MediaEndpointPeerConnection.h:
  • Modules/mediastream/SDPProcessor.cpp: Added.

(WebCore::SDPProcessor::SDPProcessor):
(WebCore::createCandidateObject):
(WebCore::createCandidate):
(WebCore::configurationFromJSON):
(WebCore::iceCandidateFromJSON):
(WebCore::configurationToJSON):
(WebCore::iceCandidateToJSON):
(WebCore::SDPProcessor::generate):
(WebCore::SDPProcessor::parse):
(WebCore::SDPProcessor::generateCandidateLine):
(WebCore::SDPProcessor::parseCandidateLine):
(WebCore::SDPProcessor::callScript):

  • Modules/mediastream/SDPProcessor.h: Added.
  • Modules/mediastream/sdp.js: Added.

(match):
(addDefaults):
(fillTemplate):
(SDP.parse):
(SDP.generate):
(SDP.generateCandidateLine):
(hasAllProperties):
(SDP.verifyObject):
(generate):
(parse):
(generateCandidateLine):
(parseCandidateLine):

  • PlatformGTK.cmake:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/mediastream/MediaEndpoint.cpp:

(WebCore::createMediaEndpoint):

  • platform/mediastream/MediaEndpoint.h:
  • platform/mediastream/PeerMediaDescription.h:
  • platform/mediastream/SDPProcessorScriptResource.cpp: Added.

(WebCore::SDPProcessorScriptResource::scriptString):

  • platform/mediastream/SDPProcessorScriptResource.h: Added.
  • platform/mediastream/gtk/SDPProcessorScriptResourceGtk.cpp: Added.

(WebCore::SDPProcessorScriptResource::scriptString):

  • platform/mock/MockMediaEndpoint.cpp: Added.

(WebCore::MockMediaEndpoint::create):
(WebCore::MockMediaEndpoint::MockMediaEndpoint):
(WebCore::MockMediaEndpoint::~MockMediaEndpoint):
(WebCore::MockMediaEndpoint::setConfiguration):
(WebCore::MockMediaEndpoint::generateDtlsInfo):
(WebCore::MockMediaEndpoint::getDefaultAudioPayloads):
(WebCore::MockMediaEndpoint::getDefaultVideoPayloads):
(WebCore::MockMediaEndpoint::updateReceiveConfiguration):
(WebCore::MockMediaEndpoint::updateSendConfiguration):
(WebCore::MockMediaEndpoint::addRemoteCandidate):
(WebCore::MockMediaEndpoint::replaceSendSource):
(WebCore::MockMediaEndpoint::stop):

  • platform/mock/MockMediaEndpoint.h: Added.
  • testing/Internals.cpp:

(WebCore::Internals::Internals):
(WebCore::Internals::enableMockMediaEndpoint):

  • testing/Internals.h:

LayoutTests:

The output SDP from createOffer() is processed by verifying all variable
identifiers, such as session and user id, and replacing them with
predefined values to make the SDP comparable with an expected result.

The test is currently skipped on the mac port until support to read the
SDPProcessor JavaScript resource is added.

  • fast/mediastream/RTCPeerConnection-inspect-offer-expected.txt: Added.
  • fast/mediastream/RTCPeerConnection-inspect-offer.html: Added.
  • platform/mac/TestExpectations:
Location:
trunk
Files:
6 added
13 edited
5 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r197700 r197702  
     12016-03-07  Adam Bergkvist  <adam.bergkvist@ericsson.com>
     2
     3        WebRTC: Implement MediaEndpointPeerConnection::createOffer()
     4        https://bugs.webkit.org/show_bug.cgi?id=154867
     5
     6        Reviewed by Eric Carlson and Jer Noble.
     7
     8        The output SDP from createOffer() is processed by verifying all variable
     9        identifiers, such as session and user id, and replacing them with
     10        predefined values to make the SDP comparable with an expected result.
     11
     12        The test is currently skipped on the mac port until support to read the
     13        SDPProcessor JavaScript resource is added.
     14
     15        * fast/mediastream/RTCPeerConnection-inspect-offer-expected.txt: Added.
     16        * fast/mediastream/RTCPeerConnection-inspect-offer.html: Added.
     17        * platform/mac/TestExpectations:
     18
    1192016-03-07  Ryan Haddad  <ryanhaddad@apple.com>
    220
  • trunk/LayoutTests/platform/mac/TestExpectations

    r197696 r197702  
    179179fast/mediastream/RTCPeerConnection-stable.html
    180180fast/mediastream/RTCPeerConnection.html
     181fast/mediastream/RTCPeerConnection-inspect-offer.html
    181182
    182183# Asserts in debug.
  • trunk/Source/WebCore/CMakeLists.txt

    r197628 r197702  
    941941    Modules/mediastream/RTCStatsResponse.cpp
    942942    Modules/mediastream/RTCTrackEvent.cpp
     943    Modules/mediastream/SDPProcessor.cpp
    943944    Modules/mediastream/SourceInfo.cpp
    944945    Modules/mediastream/UserMediaController.cpp
     
    22982299    platform/mock/GeolocationClientMock.cpp
    22992300    platform/mock/MediaConstraintsMock.cpp
     2301    platform/mock/MockMediaEndpoint.cpp
    23002302    platform/mock/MockRealtimeAudioSource.cpp
    23012303    platform/mock/MockRealtimeMediaSource.cpp
     
    35843586endif ()
    35853587
     3588if (WebCore_SDP_PROCESSOR_SCRIPTS)
     3589    # Necessary variables:
     3590    # WebCore_SDP_PROCESSOR_SCRIPTS containing the JavaScript sources list
     3591    # WebCore_SDP_PROCESSOR_SCRIPTS_DEPENDENCIES containing the source file that will load the scripts to add the proper
     3592    #   dependency and having them built at the right moment
     3593
     3594    add_custom_command(
     3595        OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/SDPProcessorScriptsData.cpp ${DERIVED_SOURCES_WEBCORE_DIR}/SDPProcessorScripts.h
     3596        MAIN_DEPENDENCY ${WEBCORE_DIR}/Scripts/make-js-file-arrays.py
     3597        DEPENDS ${WebCore_SDP_PROCESSOR_SCRIPTS}
     3598        COMMAND "PYTHONPATH=${JavaScriptCore_SCRIPTS_DIR}" ${PYTHON_EXECUTABLE} ${WEBCORE_DIR}/Scripts/make-js-file-arrays.py ${DERIVED_SOURCES_WEBCORE_DIR}/SDPProcessorScripts.h ${DERIVED_SOURCES_WEBCORE_DIR}/SDPProcessorScriptsData.cpp ${WebCore_SDP_PROCESSOR_SCRIPTS}
     3599        VERBATIM)
     3600    list(APPEND WebCore_SOURCES ${DERIVED_SOURCES_WEBCORE_DIR}/SDPProcessorScriptsData.cpp)
     3601    ADD_SOURCE_WEBCORE_DERIVED_DEPENDENCIES(${WebCore_SDP_PROCESSOR_SCRIPTS_DEPENDENCIES} SDPProcessorScriptsData.cpp SDPProcessorScripts.h)
     3602endif ()
     3603
    35863604# Generate plug-in resources
    35873605add_custom_command(
  • trunk/Source/WebCore/ChangeLog

    r197697 r197702  
     12016-03-07  Adam Bergkvist  <adam.bergkvist@ericsson.com>
     2
     3        WebRTC: Implement MediaEndpointPeerConnection::createOffer()
     4        https://bugs.webkit.org/show_bug.cgi?id=154867
     5
     6        Reviewed by Eric Carlson and Jer Noble.
     7
     8        - MediaEndpointPeerConnection: Initial implementation of createOffer()
     9        added. createOffer() is split up into a synchronous part, and a
     10        scheduled task. The task will be deferred until information, requiring
     11        some amount of work, such as the DTLS fingerprint is available. Other
     12        async API functions will also follow this pattern.
     13
     14        - SDPProcessor (added): The SDPProcessors parses SDP to a
     15        MediaEndpointSessionConfiguration object and generates SDP in the
     16        reverse direction. Any SDP string handling is confined to the
     17        SDPProcessor and all configuration of the media session is done via the
     18        MediaEndpointSessionConfiguration object.
     19
     20        The SDP parser and generator logic is implemented in JavaScript and
     21        works with JSON (SDP->JSON, JSON->SDP). The SDPProcessor runs JS in an
     22        isolated scope and converts JSON to a MediaEndpointSessionConfiguration
     23        object and the reverse. Using JSON signaling (nonstandard) can be
     24        helpful during debugging.
     25
     26        - MockMediaEndpoint (added): Mock MediaEndpoint implementation with
     27        support for generating offers. DTLS information, such as fingerprint,
     28        is hard coded to facilitate testing with expected values.
     29
     30        Test: fast/mediastream/RTCPeerConnection-inspect-offer.html
     31
     32        The test is currently skipped on the mac port until support to read the
     33        SDPProcessor JavaScript resource is added.
     34
     35        * CMakeLists.txt:
     36        * Modules/mediastream/MediaEndpointPeerConnection.cpp:
     37        (WebCore::WrappedSessionDescriptionPromise::create):
     38        (WebCore::WrappedSessionDescriptionPromise::promise):
     39        (WebCore::WrappedSessionDescriptionPromise::WrappedSessionDescriptionPromise):
     40        (WebCore::randomString):
     41        (WebCore::MediaEndpointPeerConnection::MediaEndpointPeerConnection):
     42        (WebCore::MediaEndpointPeerConnection::runTask):
     43        (WebCore::MediaEndpointPeerConnection::startRunningTasks):
     44        (WebCore::MediaEndpointPeerConnection::createOffer):
     45        (WebCore::MediaEndpointPeerConnection::createOfferTask):
     46        (WebCore::MediaEndpointPeerConnection::gotDtlsFingerprint):
     47        * Modules/mediastream/MediaEndpointPeerConnection.h:
     48        * Modules/mediastream/SDPProcessor.cpp: Added.
     49        (WebCore::SDPProcessor::SDPProcessor):
     50        (WebCore::createCandidateObject):
     51        (WebCore::createCandidate):
     52        (WebCore::configurationFromJSON):
     53        (WebCore::iceCandidateFromJSON):
     54        (WebCore::configurationToJSON):
     55        (WebCore::iceCandidateToJSON):
     56        (WebCore::SDPProcessor::generate):
     57        (WebCore::SDPProcessor::parse):
     58        (WebCore::SDPProcessor::generateCandidateLine):
     59        (WebCore::SDPProcessor::parseCandidateLine):
     60        (WebCore::SDPProcessor::callScript):
     61        * Modules/mediastream/SDPProcessor.h: Added.
     62        * Modules/mediastream/sdp.js: Added.
     63        (match):
     64        (addDefaults):
     65        (fillTemplate):
     66        (SDP.parse):
     67        (SDP.generate):
     68        (SDP.generateCandidateLine):
     69        (hasAllProperties):
     70        (SDP.verifyObject):
     71        (generate):
     72        (parse):
     73        (generateCandidateLine):
     74        (parseCandidateLine):
     75        * PlatformGTK.cmake:
     76        * WebCore.xcodeproj/project.pbxproj:
     77        * platform/mediastream/MediaEndpoint.cpp:
     78        (WebCore::createMediaEndpoint):
     79        * platform/mediastream/MediaEndpoint.h:
     80        * platform/mediastream/PeerMediaDescription.h:
     81        * platform/mediastream/SDPProcessorScriptResource.cpp: Added.
     82        (WebCore::SDPProcessorScriptResource::scriptString):
     83        * platform/mediastream/SDPProcessorScriptResource.h: Added.
     84        * platform/mediastream/gtk/SDPProcessorScriptResourceGtk.cpp: Added.
     85        (WebCore::SDPProcessorScriptResource::scriptString):
     86        * platform/mock/MockMediaEndpoint.cpp: Added.
     87        (WebCore::MockMediaEndpoint::create):
     88        (WebCore::MockMediaEndpoint::MockMediaEndpoint):
     89        (WebCore::MockMediaEndpoint::~MockMediaEndpoint):
     90        (WebCore::MockMediaEndpoint::setConfiguration):
     91        (WebCore::MockMediaEndpoint::generateDtlsInfo):
     92        (WebCore::MockMediaEndpoint::getDefaultAudioPayloads):
     93        (WebCore::MockMediaEndpoint::getDefaultVideoPayloads):
     94        (WebCore::MockMediaEndpoint::updateReceiveConfiguration):
     95        (WebCore::MockMediaEndpoint::updateSendConfiguration):
     96        (WebCore::MockMediaEndpoint::addRemoteCandidate):
     97        (WebCore::MockMediaEndpoint::replaceSendSource):
     98        (WebCore::MockMediaEndpoint::stop):
     99        * platform/mock/MockMediaEndpoint.h: Added.
     100        * testing/Internals.cpp:
     101        (WebCore::Internals::Internals):
     102        (WebCore::Internals::enableMockMediaEndpoint):
     103        * testing/Internals.h:
     104
    11052016-03-07  Daniel Bates  <dabates@apple.com>
    2106
  • trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp

    r197053 r197702  
    3636#include "DOMError.h"
    3737#include "JSDOMError.h"
     38#include "JSRTCSessionDescription.h"
     39#include "MediaEndpointSessionConfiguration.h"
     40#include "MediaStreamTrack.h"
     41#include "RTCOfferAnswerOptions.h"
     42#include "RTCRtpSender.h"
     43#include "SDPProcessor.h"
    3844#include <wtf/MainThread.h>
     45#include <wtf/text/Base64.h>
    3946
    4047namespace WebCore {
     
    4956CreatePeerConnectionBackend PeerConnectionBackend::create = createMediaEndpointPeerConnection;
    5057
     58class WrappedSessionDescriptionPromise : public RefCounted<WrappedSessionDescriptionPromise> {
     59public:
     60    static Ref<WrappedSessionDescriptionPromise> create(SessionDescriptionPromise&& promise)
     61    {
     62        return *adoptRef(new WrappedSessionDescriptionPromise(WTFMove(promise)));
     63    }
     64
     65    SessionDescriptionPromise& promise() { return m_promise; }
     66
     67private:
     68    WrappedSessionDescriptionPromise(SessionDescriptionPromise&& promise)
     69        : m_promise(WTFMove(promise))
     70    { }
     71
     72    SessionDescriptionPromise m_promise;
     73};
     74
     75static String randomString(size_t length)
     76{
     77    const size_t size = ceil(length * 3 / 4);
     78    unsigned char randomValues[size];
     79    cryptographicallyRandomValues(randomValues, size);
     80    return base64Encode(randomValues, size);
     81}
     82
    5183MediaEndpointPeerConnection::MediaEndpointPeerConnection(PeerConnectionBackendClient* client)
    52 {
    53     UNUSED_PARAM(client);
     84    : m_client(client)
     85    , m_sdpProcessor(std::unique_ptr<SDPProcessor>(new SDPProcessor(m_client->scriptExecutionContext())))
     86    , m_cname(randomString(16))
     87    , m_iceUfrag(randomString(4))
     88    , m_icePassword(randomString(22))
     89{
     90    m_mediaEndpoint = MediaEndpoint::create(*this);
     91    ASSERT(m_mediaEndpoint);
     92
     93    m_defaultAudioPayloads = m_mediaEndpoint->getDefaultAudioPayloads();
     94    m_defaultVideoPayloads = m_mediaEndpoint->getDefaultVideoPayloads();
     95
     96    // Tasks (see runTask()) will be deferred until we get the DTLS fingerprint.
     97    m_mediaEndpoint->generateDtlsInfo();
     98}
     99
     100void MediaEndpointPeerConnection::runTask(std::function<void()> task)
     101{
     102    if (m_dtlsFingerprint.isNull()) {
     103        // Only one task needs to be deferred since it will hold off any others until completed.
     104        ASSERT(!m_initialDeferredTask);
     105        m_initialDeferredTask = task;
     106    } else
     107        callOnMainThread(task);
     108}
     109
     110void MediaEndpointPeerConnection::startRunningTasks()
     111{
     112    if (!m_initialDeferredTask)
     113        return;
     114
     115    m_initialDeferredTask();
     116    m_initialDeferredTask = nullptr;
    54117}
    55118
    56119void MediaEndpointPeerConnection::createOffer(RTCOfferOptions& options, SessionDescriptionPromise&& promise)
    57120{
    58     UNUSED_PARAM(options);
    59 
    60     notImplemented();
    61 
    62     promise.reject(DOMError::create("NotSupportedError"));
     121    const RefPtr<RTCOfferOptions> protectedOptions = &options;
     122    RefPtr<WrappedSessionDescriptionPromise> wrappedPromise = WrappedSessionDescriptionPromise::create(WTFMove(promise));
     123
     124    runTask([this, protectedOptions, wrappedPromise]() {
     125        createOfferTask(*protectedOptions, wrappedPromise->promise());
     126    });
     127}
     128
     129void MediaEndpointPeerConnection::createOfferTask(RTCOfferOptions&, SessionDescriptionPromise& promise)
     130{
     131    ASSERT(!m_dtlsFingerprint.isEmpty());
     132
     133    RefPtr<MediaEndpointSessionConfiguration> configurationSnapshot = MediaEndpointSessionConfiguration::create();
     134
     135    configurationSnapshot->setSessionVersion(m_sdpSessionVersion++);
     136
     137    RtpSenderVector senders = m_client->getSenders();
     138
     139    // Add media descriptions for senders.
     140    for (auto& sender : senders) {
     141        RefPtr<PeerMediaDescription> mediaDescription = PeerMediaDescription::create();
     142        MediaStreamTrack* track = sender->track();
     143
     144        mediaDescription->setMediaStreamId(sender->mediaStreamIds()[0]);
     145        mediaDescription->setMediaStreamTrackId(track->id());
     146        mediaDescription->setType(track->kind());
     147        mediaDescription->setPayloads(track->kind() == "audio" ? m_defaultAudioPayloads : m_defaultVideoPayloads);
     148        mediaDescription->setDtlsFingerprintHashFunction(m_dtlsFingerprintFunction);
     149        mediaDescription->setDtlsFingerprint(m_dtlsFingerprint);
     150        mediaDescription->setCname(m_cname);
     151        mediaDescription->addSsrc(cryptographicallyRandomNumber());
     152        mediaDescription->setIceUfrag(m_iceUfrag);
     153        mediaDescription->setIcePassword(m_icePassword);
     154
     155        configurationSnapshot->addMediaDescription(WTFMove(mediaDescription));
     156    }
     157
     158    String sdpString;
     159    SDPProcessor::Result result = m_sdpProcessor->generate(*configurationSnapshot, sdpString);
     160    if (result != SDPProcessor::Result::Success) {
     161        LOG_ERROR("SDPProcessor internal error");
     162        return;
     163    }
     164
     165    promise.resolve(RTCSessionDescription::create("offer", sdpString));
    63166}
    64167
     
    180283    ASSERT(isMainThread());
    181284
    182     UNUSED_PARAM(fingerprint);
    183     UNUSED_PARAM(fingerprintFunction);
    184 
    185     notImplemented();
     285    m_dtlsFingerprint = fingerprint;
     286    m_dtlsFingerprintFunction = fingerprintFunction;
     287
     288    startRunningTasks();
    186289}
    187290
  • trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h

    r197563 r197702  
    4343
    4444class MediaStreamTrack;
     45class SDPProcessor;
     46
     47typedef Vector<RefPtr<RTCRtpSender>> RtpSenderVector;
    4548
    4649class MediaEndpointPeerConnection : public PeerConnectionBackend, public MediaEndpointClient {
     
    7578
    7679private:
     80    void runTask(std::function<void()>);
     81    void startRunningTasks();
     82
     83    void createOfferTask(RTCOfferOptions&, PeerConnection::SessionDescriptionPromise&);
     84
    7785    // MediaEndpointClient
    7886    void gotDtlsFingerprint(const String& fingerprint, const String& fingerprintFunction) override;
     
    8088    void doneGatheringCandidates(unsigned mdescIndex) override;
    8189    void gotRemoteSource(unsigned mdescIndex, RefPtr<RealtimeMediaSource>&&) override;
     90
     91    PeerConnectionBackendClient* m_client;
     92    std::unique_ptr<MediaEndpoint> m_mediaEndpoint;
     93
     94    std::function<void()> m_initialDeferredTask;
     95
     96    std::unique_ptr<SDPProcessor> m_sdpProcessor;
     97
     98    Vector<RefPtr<MediaPayload>> m_defaultAudioPayloads;
     99    Vector<RefPtr<MediaPayload>> m_defaultVideoPayloads;
     100
     101    String m_cname;
     102    String m_iceUfrag;
     103    String m_icePassword;
     104    String m_dtlsFingerprint;
     105    String m_dtlsFingerprintFunction;
     106    unsigned m_sdpSessionVersion { 0 };
    82107};
    83108
  • trunk/Source/WebCore/Modules/mediastream/SDPProcessor.h

    r197701 r197702  
    2929 */
    3030
    31 #include "config.h"
     31#ifndef SDPProcessor_h
     32#define SDPProcessor_h
    3233
    3334#if ENABLE(MEDIA_STREAM)
    34 #include "MediaEndpoint.h"
     35
     36#include "ContextDestructionObserver.h"
     37#include "IceCandidate.h"
     38#include "MediaEndpointSessionConfiguration.h"
     39#include <wtf/RefPtr.h>
     40#include <wtf/text/WTFString.h>
    3541
    3642namespace WebCore {
    3743
    38 static std::unique_ptr<MediaEndpoint> createMediaEndpoint(MediaEndpointClient*)
    39 {
    40     return nullptr;
    41 }
     44class DOMWrapperWorld;
     45class ScriptExecutionContext;
    4246
    43 CreateMediaEndpoint MediaEndpoint::create = createMediaEndpoint;
     47class SDPProcessor : public ContextDestructionObserver {
     48public:
     49    enum class Result {
     50        Success = 1,
     51        InternalError = 2,
     52        ParseError = 3
     53    };
     54
     55    SDPProcessor(ScriptExecutionContext*);
     56
     57    Result generate(const MediaEndpointSessionConfiguration&, String& outSdpString) const;
     58    Result parse(const String& sdp, RefPtr<MediaEndpointSessionConfiguration>&) const;
     59
     60    Result generateCandidateLine(const IceCandidate&, String& outCandidateLine) const;
     61    Result parseCandidateLine(const String& candidateLine, RefPtr<IceCandidate>&) const;
     62
     63private:
     64    bool callScript(const String& functionName, const String& argument, String& outResult) const;
     65
     66    mutable RefPtr<DOMWrapperWorld> m_isolatedWorld;
     67};
    4468
    4569} // namespace WebCore
    4670
    4771#endif // ENABLE(MEDIA_STREAM)
     72
     73#endif // SDPProcessor_h
  • trunk/Source/WebCore/PlatformGTK.cmake

    r197623 r197702  
    4545    "${WEBCORE_DIR}/platform/graphics/wayland"
    4646    "${WEBCORE_DIR}/platform/graphics/x11"
     47    "${WEBCORE_DIR}/platform/mediastream/gtk"
    4748    "${WEBCORE_DIR}/platform/mock/mediasource"
    4849    "${WEBCORE_DIR}/platform/network/gtk"
     
    155156    platform/image-decoders/cairo/ImageDecoderCairo.cpp
    156157
     158    platform/mediastream/gtk/SDPProcessorScriptResourceGtk.cpp
     159
    157160    platform/network/gtk/CredentialBackingStore.cpp
    158161
     
    248251
    249252set(WebCore_USER_AGENT_SCRIPTS_DEPENDENCIES ${WEBCORE_DIR}/platform/gtk/RenderThemeGtk.cpp)
     253
     254set(WebCore_SDP_PROCESSOR_SCRIPTS ${WEBCORE_DIR}/Modules/mediastream/sdp.js)
     255set(WebCore_SDP_PROCESSOR_SCRIPTS_DEPENDENCIES ${WEBCORE_DIR}/platform/mediastream/gtk/SDPProcessorScriptResource.cpp)
    250256
    251257list(APPEND WebCore_LIBRARIES
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r197628 r197702  
    23972397                5E2C437B1BCF9A570001E2BC /* RTCPeerConnectionBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E2C43761BCF9A0B0001E2BC /* RTCPeerConnectionBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
    23982398                5E2C437C1BCF9A840001E2BC /* RTCPeerConnectionInternalsBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E2C43791BCF9A0B0001E2BC /* RTCPeerConnectionInternalsBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2399                5EA3D6DF1C859D7F00300BBB /* MockMediaEndpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 5EA3D6DE1C859D5300300BBB /* MockMediaEndpoint.h */; };
     2400                5EA3D6E01C859D8400300BBB /* MockMediaEndpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EA3D6DD1C859D5300300BBB /* MockMediaEndpoint.cpp */; };
     2401                5EA3D6E31C859DC100300BBB /* SDPProcessor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EA3D6E11C859DAA00300BBB /* SDPProcessor.cpp */; };
     2402                5EA3D6E41C859DC100300BBB /* SDPProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 5EA3D6E21C859DAA00300BBB /* SDPProcessor.h */; };
     2403                5EA3D6E71C85A9DB00300BBB /* SDPProcessorScriptResource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EA3D6E51C85A9C300300BBB /* SDPProcessorScriptResource.cpp */; };
     2404                5EA3D6E81C85A9DB00300BBB /* SDPProcessorScriptResource.h in Headers */ = {isa = PBXBuildFile; fileRef = 5EA3D6E61C85A9C300300BBB /* SDPProcessorScriptResource.h */; };
    23992405                5EA725D21ACABD4700EAD17B /* MediaDevices.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5EA725CD1ACABCD900EAD17B /* MediaDevices.cpp */; };
    24002406                5EA725D31ACABD4700EAD17B /* MediaDevices.h in Headers */ = {isa = PBXBuildFile; fileRef = 5EA725CE1ACABCD900EAD17B /* MediaDevices.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    99739979                5E2C43781BCF9A0B0001E2BC /* RTCPeerConnectionInternalsBuiltins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCPeerConnectionInternalsBuiltins.cpp; sourceTree = "<group>"; };
    99749980                5E2C43791BCF9A0B0001E2BC /* RTCPeerConnectionInternalsBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCPeerConnectionInternalsBuiltins.h; sourceTree = "<group>"; };
     9981                5EA3D6DD1C859D5300300BBB /* MockMediaEndpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockMediaEndpoint.cpp; sourceTree = "<group>"; };
     9982                5EA3D6DE1C859D5300300BBB /* MockMediaEndpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockMediaEndpoint.h; sourceTree = "<group>"; };
     9983                5EA3D6E11C859DAA00300BBB /* SDPProcessor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SDPProcessor.cpp; sourceTree = "<group>"; };
     9984                5EA3D6E21C859DAA00300BBB /* SDPProcessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDPProcessor.h; sourceTree = "<group>"; };
     9985                5EA3D6E51C85A9C300300BBB /* SDPProcessorScriptResource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SDPProcessorScriptResource.cpp; sourceTree = "<group>"; };
     9986                5EA3D6E61C85A9C300300BBB /* SDPProcessorScriptResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDPProcessorScriptResource.h; sourceTree = "<group>"; };
    99759987                5EA725CA1ACABCB500EAD17B /* NavigatorMediaDevices.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigatorMediaDevices.cpp; sourceTree = "<group>"; };
    99769988                5EA725CB1ACABCB500EAD17B /* NavigatorMediaDevices.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigatorMediaDevices.h; sourceTree = "<group>"; };
     
    1544215454                                5E2C43651BCEE3720001E2BC /* RTCTrackEvent.h */,
    1544315455                                5E2C43661BCEE3720001E2BC /* RTCTrackEvent.idl */,
     15456                                5EA3D6E11C859DAA00300BBB /* SDPProcessor.cpp */,
     15457                                5EA3D6E21C859DAA00300BBB /* SDPProcessor.h */,
    1544415458                                076306D417E149CF005A7C4E /* SourceInfo.cpp */,
    1544515459                                076306D517E149CF005A7C4E /* SourceInfo.h */,
     
    1550315517                                07221BAF17CF0AD400848E51 /* RTCStatsResponseBase.h */,
    1550415518                                07221BB017CF0AD400848E51 /* RTCVoidRequest.h */,
     15519                                5EA3D6E51C85A9C300300BBB /* SDPProcessorScriptResource.cpp */,
     15520                                5EA3D6E61C85A9C300300BBB /* SDPProcessorScriptResource.h */,
    1550515521                                070E81D01BF27656001FDA48 /* VideoTrackPrivateMediaStream.h */,
    1550615522                        );
     
    1743917455                                077B64101B94F12E003E9AD5 /* MediaPlaybackTargetPickerMock.cpp */,
    1744017456                                077B64111B94F12E003E9AD5 /* MediaPlaybackTargetPickerMock.h */,
     17457                                5EA3D6DD1C859D5300300BBB /* MockMediaEndpoint.cpp */,
     17458                                5EA3D6DE1C859D5300300BBB /* MockMediaEndpoint.h */,
    1744117459                                07D6A4F11BED5F8800174146 /* MockRealtimeAudioSource.cpp */,
    1744217460                                07D6A4F21BED5F8800174146 /* MockRealtimeAudioSource.h */,
     
    2566225680                                85DF2EED0AA387CB00AD64C5 /* DOMHTMLElement.h in Headers */,
    2566325681                                85E711A70AC5D5350053270F /* DOMHTMLElementInternal.h in Headers */,
     25682                                5EA3D6DF1C859D7F00300BBB /* MockMediaEndpoint.h in Headers */,
    2566425683                                8540756A0AD6CBF900620C57 /* DOMHTMLEmbedElement.h in Headers */,
    2566525684                                855247D00AD850B80012093B /* DOMHTMLEmbedElementInternal.h in Headers */,
     
    2586325882                                31C0FF4E0E4CEFDD007D6FE5 /* DOMWebKitTransitionEventInternal.h in Headers */,
    2586425883                                85C7F5E70AAFBAFB004014DD /* DOMWheelEvent.h in Headers */,
     25884                                5EA3D6E41C859DC100300BBB /* SDPProcessor.h in Headers */,
    2586525885                                85989DD10ACC8BBD00A0BC51 /* DOMWheelEventInternal.h in Headers */,
    2586625886                                1403B99709EB13AF00797C7F /* DOMWindow.h in Headers */,
     
    2733627356                                F3820893147D35F90010BC06 /* PageConsoleAgent.h in Headers */,
    2733727357                                DAED203116F244480070EC0F /* PageConsoleClient.h in Headers */,
     27358                                5EA3D6E81C85A9DB00300BBB /* SDPProcessorScriptResource.h in Headers */,
    2733827359                                A5A2AF0C1829734300DE1729 /* PageDebuggable.h in Headers */,
    2733927360                                F34742DD134362F000531BC2 /* PageDebuggerAgent.h in Headers */,
     
    3030030321                                BC2ED7A50C6C0F3600920BFF /* JSHTMLFrameElementCustom.cpp in Sources */,
    3030130322                                BC926F800C0552470082776B /* JSHTMLFrameSetElement.cpp in Sources */,
     30323                                5EA3D6E31C859DC100300BBB /* SDPProcessor.cpp in Sources */,
    3030230324                                BCD41ABB0C060DE800C0E446 /* JSHTMLFrameSetElementCustom.cpp in Sources */,
    3030330325                                A80E7B140A19D606007FB8C5 /* JSHTMLHeadElement.cpp in Sources */,
     
    3134231364                                5824ABA21AE81116009074B7 /* RubyElement.cpp in Sources */,
    3134331365                                5824ABA61AE81384009074B7 /* RubyTextElement.cpp in Sources */,
     31366                                5EA3D6E71C85A9DB00300BBB /* SDPProcessorScriptResource.cpp in Sources */,
    3134431367                                A79BADA1161E7F3F00C2E652 /* RuleFeature.cpp in Sources */,
    3134531368                                A79BADA3161E7F3F00C2E652 /* RuleSet.cpp in Sources */,
     
    3138531408                                1AF62EE614DA22A70041556C /* ScrollingCoordinatorMac.mm in Sources */,
    3138631409                                93C38BFE164473C700091EB2 /* ScrollingStateFixedNode.cpp in Sources */,
     31410                                5EA3D6E01C859D8400300BBB /* MockMediaEndpoint.cpp in Sources */,
    3138731411                                0FEA3E7C191B2FC5000F1B55 /* ScrollingStateFrameScrollingNode.cpp in Sources */,
    3138831412                                0FA88EBD16A8D1BD00F99984 /* ScrollingStateFrameScrollingNodeMac.mm in Sources */,
  • trunk/Source/WebCore/platform/mediastream/MediaEndpoint.cpp

    r197053 r197702  
    3636namespace WebCore {
    3737
    38 static std::unique_ptr<MediaEndpoint> createMediaEndpoint(MediaEndpointClient*)
     38static std::unique_ptr<MediaEndpoint> createMediaEndpoint(MediaEndpointClient&)
    3939{
    4040    return nullptr;
  • trunk/Source/WebCore/platform/mediastream/MediaEndpoint.h

    r197053 r197702  
    5555};
    5656
    57 typedef std::unique_ptr<MediaEndpoint> (*CreateMediaEndpoint)(MediaEndpointClient*);
     57typedef std::unique_ptr<MediaEndpoint> (*CreateMediaEndpoint)(MediaEndpointClient&);
    5858
    5959class MediaEndpoint {
  • trunk/Source/WebCore/platform/mediastream/PeerMediaDescription.h

    r197053 r197702  
    151151
    152152    String m_type;
    153     unsigned short m_port { 0 };
    154     String m_address;
    155     String m_mode;
     153    unsigned short m_port { 9 };
     154    String m_address { "0.0.0.0" };
     155    String m_mode { "sendrecv" };
    156156
    157157    Vector<RefPtr<MediaPayload>> m_payloads;
    158158
    159     bool m_rtcpMux { false };
     159    bool m_rtcpMux { true };
    160160    String m_rtcpAddress;
    161161    unsigned short m_rtcpPort { 0 };
     
    164164    String m_mediaStreamTrackId;
    165165
    166     String m_dtlsSetup;
     166    String m_dtlsSetup { "actpass" };
    167167    String m_dtlsFingerprintHashFunction;
    168168    String m_dtlsFingerprint;
  • trunk/Source/WebCore/platform/mediastream/SDPProcessorScriptResource.cpp

    r197701 r197702  
    3232
    3333#if ENABLE(MEDIA_STREAM)
    34 #include "MediaEndpoint.h"
     34#include "SDPProcessorScriptResource.h"
    3535
    3636namespace WebCore {
    3737
    38 static std::unique_ptr<MediaEndpoint> createMediaEndpoint(MediaEndpointClient*)
     38namespace SDPProcessorScriptResource {
     39
     40const String& scriptString()
    3941{
    40     return nullptr;
     42    return emptyString();
    4143}
    4244
    43 CreateMediaEndpoint MediaEndpoint::create = createMediaEndpoint;
     45} // namespace SDPProcessorScriptResource
    4446
    4547} // namespace WebCore
  • trunk/Source/WebCore/platform/mediastream/SDPProcessorScriptResource.h

    r197701 r197702  
    2929 */
    3030
    31 #include "config.h"
     31#ifndef SDPProcessorScriptResource_h
     32#define SDPProcessorScriptResource_h
    3233
    3334#if ENABLE(MEDIA_STREAM)
    34 #include "MediaEndpoint.h"
     35
     36#include <wtf/text/WTFString.h>
    3537
    3638namespace WebCore {
    3739
    38 static std::unique_ptr<MediaEndpoint> createMediaEndpoint(MediaEndpointClient*)
    39 {
    40     return nullptr;
    41 }
     40namespace SDPProcessorScriptResource {
    4241
    43 CreateMediaEndpoint MediaEndpoint::create = createMediaEndpoint;
     42const String& scriptString();
     43
     44} // namespace SDPProcessorScriptResource
    4445
    4546} // namespace WebCore
    4647
    4748#endif // ENABLE(MEDIA_STREAM)
     49
     50#endif // SDPProcessorScriptResource_h
  • trunk/Source/WebCore/platform/mediastream/gtk/SDPProcessorScriptResourceGtk.cpp

    r197701 r197702  
    3232
    3333#if ENABLE(MEDIA_STREAM)
    34 #include "MediaEndpoint.h"
     34#include "SDPProcessorScriptResource.h"
     35
     36#include "SDPProcessorScripts.h"
     37#include <wtf/NeverDestroyed.h>
    3538
    3639namespace WebCore {
    3740
    38 static std::unique_ptr<MediaEndpoint> createMediaEndpoint(MediaEndpointClient*)
     41namespace SDPProcessorScriptResource {
     42
     43const String& scriptString()
    3944{
    40     return nullptr;
     45    static NeverDestroyed<const String> script = String(sdpJavaScript);
     46    return script;
    4147}
    4248
    43 CreateMediaEndpoint MediaEndpoint::create = createMediaEndpoint;
     49} // namespace SDPProcessorScriptResource
    4450
    4551} // namespace WebCore
  • trunk/Source/WebCore/platform/mock/MockMediaEndpoint.h

    r197701 r197702  
    2929 */
    3030
    31 #include "config.h"
     31#ifndef MockMediaEndpoint_h
     32#define MockMediaEndpoint_h
    3233
    3334#if ENABLE(MEDIA_STREAM)
     35
    3436#include "MediaEndpoint.h"
    3537
    3638namespace WebCore {
    3739
    38 static std::unique_ptr<MediaEndpoint> createMediaEndpoint(MediaEndpointClient*)
    39 {
    40     return nullptr;
    41 }
     40class MockMediaEndpoint : public MediaEndpoint {
     41public:
     42    WEBCORE_EXPORT static std::unique_ptr<MediaEndpoint> create(MediaEndpointClient&);
    4243
    43 CreateMediaEndpoint MediaEndpoint::create = createMediaEndpoint;
     44    MockMediaEndpoint(MediaEndpointClient&);
     45    ~MockMediaEndpoint();
     46
     47    void setConfiguration(RefPtr<MediaEndpointConfiguration>&&) override;
     48
     49    void generateDtlsInfo() override;
     50    Vector<RefPtr<MediaPayload>> getDefaultAudioPayloads() override;
     51    Vector<RefPtr<MediaPayload>> getDefaultVideoPayloads() override;
     52
     53    UpdateResult updateReceiveConfiguration(MediaEndpointSessionConfiguration*, bool isInitiator) override;
     54    UpdateResult updateSendConfiguration(MediaEndpointSessionConfiguration*, bool isInitiator) override;
     55
     56    void addRemoteCandidate(IceCandidate&, unsigned mdescIndex, const String& ufrag, const String& password) override;
     57
     58    void replaceSendSource(RealtimeMediaSource&, unsigned mdescIndex) override;
     59
     60    void stop() override;
     61
     62private:
     63    MediaEndpointClient& m_client;
     64};
    4465
    4566} // namespace WebCore
    4667
    4768#endif // ENABLE(MEDIA_STREAM)
     69
     70#endif // MockMediaEndpoint_h
  • trunk/Source/WebCore/testing/Internals.cpp

    r197626 r197702  
    177177
    178178#if ENABLE(MEDIA_STREAM)
     179#include "MockMediaEndpoint.h"
    179180#include "MockRealtimeMediaSourceCenter.h"
    180181#include "RTCPeerConnection.h"
     
    417418#if ENABLE(MEDIA_STREAM)
    418419    setMockMediaCaptureDevicesEnabled(true);
     420    enableMockMediaEndpoint();
    419421    enableMockRTCPeerConnectionHandler();
    420422#endif
     
    10171019
    10181020#if ENABLE(MEDIA_STREAM)
     1021void Internals::enableMockMediaEndpoint()
     1022{
     1023    MediaEndpoint::create = MockMediaEndpoint::create;
     1024}
     1025
    10191026void Internals::enableMockRTCPeerConnectionHandler()
    10201027{
  • trunk/Source/WebCore/testing/Internals.h

    r197626 r197702  
    371371
    372372#if ENABLE(MEDIA_STREAM)
     373    void enableMockMediaEndpoint();
    373374    void enableMockRTCPeerConnectionHandler();
    374375    void setMockMediaCaptureDevicesEnabled(bool);
Note: See TracChangeset for help on using the changeset viewer.