| Differences between
and this patch
- a/LayoutTests/ChangeLog +20 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2012-12-04  Adam Bergkvist  <adam.bergkvist@ericsson.com>
2
3
        MediaStream API: Update the MediaStream constructor
4
        https://bugs.webkit.org/show_bug.cgi?id=98416
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Updated the MediaStream constructor to support the more general argument
9
        list from the latest Media Capture and Streams specification:
10
        http://dev.w3.org/2011/webrtc/editor/getusermedia.html
11
12
        * fast/js/constructor-length.html:
13
        * fast/mediastream/MediaStreamConstructor-expected.txt:
14
        * fast/mediastream/MediaStreamConstructor.html:
15
        * platform/blackberry/fast/js/constructor-length-expected.txt:
16
        * platform/chromium/fast/js/constructor-length-expected.txt:
17
        * platform/gtk/fast/js/constructor-length-expected.txt:
18
        * platform/mac/fast/js/constructor-length-expected.txt:
19
        * platform/qt/fast/js/constructor-length-expected.txt:
20
1
2012-11-30  Sheriff Bot  <webkit.review.bot@gmail.com>
21
2012-11-30  Sheriff Bot  <webkit.review.bot@gmail.com>
2
22
3
        Unreviewed, rolling out r136142.
23
        Unreviewed, rolling out r136142.
- a/LayoutTests/fast/js/constructor-length.html -1 / +1 lines
Lines 29-35 shouldBe('Int32Array.length', '1'); a/LayoutTests/fast/js/constructor-length.html_sec1
29
shouldBe('Int8Array.length', '1');
29
shouldBe('Int8Array.length', '1');
30
shouldBe('Intent.length', '3');
30
shouldBe('Intent.length', '3');
31
shouldBe('MediaController.length', '0');
31
shouldBe('MediaController.length', '0');
32
shouldBe('MediaStream.length', '2');
32
shouldBe('MediaStream.length', '0');
33
shouldBe('MessageChannel.length', '0');
33
shouldBe('MessageChannel.length', '0');
34
shouldBe('MessageEvent.length', '2');
34
shouldBe('MessageEvent.length', '2');
35
shouldBe('OverflowEvent.length', '2');
35
shouldBe('OverflowEvent.length', '2');
- a/LayoutTests/fast/mediastream/MediaStreamConstructor-expected.txt -4 / +47 lines
Lines 7-18 PASS Got local stream. a/LayoutTests/fast/mediastream/MediaStreamConstructor-expected.txt_sec1
7
PASS localStream.audioTracks.length is 1
7
PASS localStream.audioTracks.length is 1
8
PASS localStream.videoTracks.length is 1
8
PASS localStream.videoTracks.length is 1
9
PASS typeof webkitMediaStream === 'function' is true
9
PASS typeof webkitMediaStream === 'function' is true
10
PASS stream = new webkitMediaStream(localStream.audioTracks, localStream.videoTracks); did not throw exception.
10
PASS new webkitMediaStream(document) threw exception TypeError: Type error.
11
PASS new webkitMediaStream([document]) threw exception TypeError: Invalid Array element type.
12
PASS new webkitMediaStream([stream.audioTracks[0], document]) threw exception TypeError: Invalid Array element type.
13
PASS new webkitMediaStream([null]) threw exception TypeError: Invalid Array element type.
14
PASS new webkitMediaStream([undefined]) threw exception TypeError: Invalid Array element type.
15
PASS new webkitMediaStream(null) threw exception TypeError: Type error.
16
PASS new webkitMediaStream(undefined) threw exception TypeError: Type error.
17
PASS Stream constructed
11
PASS [object MediaStream] is non-null.
18
PASS [object MediaStream] is non-null.
12
PASS [object MediaStream] is defined.
19
PASS [object MediaStream] is defined.
13
PASS stream.constructor.name is 'MediaStream'
20
PASS newStream.constructor.name is 'MediaStream'
14
PASS stream.audioTracks.length is 1
21
PASS newStream.audioTracks.length is nAudio
15
PASS stream.videoTracks.length is 1
22
PASS newStream.videoTracks.length is nVideo
23
PASS Stream constructed
24
PASS [object MediaStream] is non-null.
25
PASS [object MediaStream] is defined.
26
PASS newStream.constructor.name is 'MediaStream'
27
PASS newStream.audioTracks.length is nAudio
28
PASS newStream.videoTracks.length is nVideo
29
PASS Stream constructed
30
PASS [object MediaStream] is non-null.
31
PASS [object MediaStream] is defined.
32
PASS newStream.constructor.name is 'MediaStream'
33
PASS newStream.audioTracks.length is nAudio
34
PASS newStream.videoTracks.length is nVideo
35
PASS Stream constructed
36
PASS [object MediaStream] is non-null.
37
PASS [object MediaStream] is defined.
38
PASS newStream.constructor.name is 'MediaStream'
39
PASS newStream.audioTracks.length is nAudio
40
PASS newStream.videoTracks.length is nVideo
41
PASS Stream constructed
42
PASS [object MediaStream] is non-null.
43
PASS [object MediaStream] is defined.
44
PASS newStream.constructor.name is 'MediaStream'
45
PASS newStream.audioTracks.length is nAudio
46
PASS newStream.videoTracks.length is nVideo
47
PASS Stream constructed
48
PASS [object MediaStream] is non-null.
49
PASS [object MediaStream] is defined.
50
PASS newStream.constructor.name is 'MediaStream'
51
PASS newStream.audioTracks.length is nAudio
52
PASS newStream.videoTracks.length is nVideo
53
PASS Stream constructed
54
PASS [object MediaStream] is non-null.
55
PASS [object MediaStream] is defined.
56
PASS newStream.constructor.name is 'MediaStream'
57
PASS newStream.audioTracks.length is nAudio
58
PASS newStream.videoTracks.length is nVideo
16
PASS successfullyParsed is true
59
PASS successfullyParsed is true
17
60
18
TEST COMPLETE
61
TEST COMPLETE
- a/LayoutTests/fast/mediastream/MediaStreamConstructor.html -7 / +43 lines
Lines 10-15 a/LayoutTests/fast/mediastream/MediaStreamConstructor.html_sec1
10
<script>
10
<script>
11
description("Tests webkitMediaStream.");
11
description("Tests webkitMediaStream.");
12
12
13
var undefined;
14
var stream;
15
var newStream;
16
var nAudio;
17
var nVideo;
18
13
function error() {
19
function error() {
14
    testFailed('Stream generation failed.');
20
    testFailed('Stream generation failed.');
15
    finishJSTest();
21
    finishJSTest();
Lines 30-46 function gotStream(s) { a/LayoutTests/fast/mediastream/MediaStreamConstructor.html_sec2
30
    shouldBe('localStream.audioTracks.length', '1');
36
    shouldBe('localStream.audioTracks.length', '1');
31
    shouldBe('localStream.videoTracks.length', '1');
37
    shouldBe('localStream.videoTracks.length', '1');
32
38
33
    stream = null;
34
    shouldBeTrue("typeof webkitMediaStream === 'function'");
39
    shouldBeTrue("typeof webkitMediaStream === 'function'");
35
    shouldNotThrow("stream = new webkitMediaStream(localStream.audioTracks, localStream.videoTracks);");
40
36
    shouldBeNonNull(stream);
41
    testConstructor(localStream);
37
    shouldBeDefined(stream);
42
38
    shouldBe("stream.constructor.name", "'MediaStream'");
39
    shouldBe('stream.audioTracks.length', '1');
40
    shouldBe('stream.videoTracks.length', '1');
41
    finishJSTest();
43
    finishJSTest();
42
}
44
}
43
45
46
function testConstructor(s) {
47
    stream = s;
48
    shouldThrow('new webkitMediaStream(document)');
49
    shouldThrow('new webkitMediaStream([document])');
50
    shouldThrow('new webkitMediaStream([stream.audioTracks[0], document])');
51
    shouldThrow('new webkitMediaStream([null])');
52
    shouldThrow('new webkitMediaStream([undefined])');
53
    shouldThrow('new webkitMediaStream(null)');
54
    shouldThrow('new webkitMediaStream(undefined)');
55
56
    verifyStream(new webkitMediaStream(), 0, 0);
57
    verifyStream(new webkitMediaStream([]), 0, 0);
58
59
    verifyStream(new webkitMediaStream(s), s.audioTracks.length, s.videoTracks.length);
60
61
    verifyStream(new webkitMediaStream([s.audioTracks[0]]), 1, 0);
62
    verifyStream(new webkitMediaStream([s.videoTracks[0]]), 0, 1);
63
    verifyStream(new webkitMediaStream([s.audioTracks[0], s.videoTracks[0]]), 1, 1);
64
    verifyStream(new webkitMediaStream([s.videoTracks[0], s.audioTracks[0], s.videoTracks[0]]), 1, 1);
65
}
66
67
function verifyStream(s, numAudioTracks, numVideoTracks) {
68
    newStream = s;
69
    nAudio = numAudioTracks;
70
    nVideo = numVideoTracks;
71
72
    testPassed('Stream constructed');
73
    shouldBeNonNull(newStream);
74
    shouldBeDefined(newStream);
75
    shouldBe("newStream.constructor.name", "'MediaStream'");
76
    shouldBe('newStream.audioTracks.length', 'nAudio');
77
    shouldBe('newStream.videoTracks.length', 'nVideo');
78
}
79
44
getUserMedia({video:true, audio:true}, gotStream);
80
getUserMedia({video:true, audio:true}, gotStream);
45
81
46
window.jsTestIsAsync = true;
82
window.jsTestIsAsync = true;
- a/LayoutTests/platform/blackberry/fast/js/constructor-length-expected.txt -1 / +1 lines
Lines 25-31 PASS Int32Array.length is 1 a/LayoutTests/platform/blackberry/fast/js/constructor-length-expected.txt_sec1
25
PASS Int8Array.length is 1
25
PASS Int8Array.length is 1
26
FAIL Intent.length should be 3. Threw exception ReferenceError: Can't find variable: Intent
26
FAIL Intent.length should be 3. Threw exception ReferenceError: Can't find variable: Intent
27
PASS MediaController.length is 0
27
PASS MediaController.length is 0
28
FAIL MediaStream.length should be 2. Threw exception ReferenceError: Can't find variable: MediaStream
28
FAIL MediaStream.length should be 0. Threw exception ReferenceError: Can't find variable: MediaStream
29
PASS MessageChannel.length is 0
29
PASS MessageChannel.length is 0
30
PASS MessageEvent.length is 2
30
PASS MessageEvent.length is 2
31
PASS OverflowEvent.length is 2
31
PASS OverflowEvent.length is 2
- a/LayoutTests/platform/chromium/fast/js/constructor-length-expected.txt -1 / +1 lines
Lines 25-31 FAIL Int32Array.length should be 1. Was 0. a/LayoutTests/platform/chromium/fast/js/constructor-length-expected.txt_sec1
25
FAIL Int8Array.length should be 1. Was 0.
25
FAIL Int8Array.length should be 1. Was 0.
26
FAIL Intent.length should be 3. Threw exception ReferenceError: Intent is not defined
26
FAIL Intent.length should be 3. Threw exception ReferenceError: Intent is not defined
27
PASS MediaController.length is 0
27
PASS MediaController.length is 0
28
FAIL MediaStream.length should be 2. Threw exception ReferenceError: MediaStream is not defined
28
FAIL MediaStream.length should be 0. Threw exception ReferenceError: MediaStream is not defined
29
PASS MessageChannel.length is 0
29
PASS MessageChannel.length is 0
30
FAIL MessageEvent.length should be 2. Was 0.
30
FAIL MessageEvent.length should be 2. Was 0.
31
FAIL OverflowEvent.length should be 2. Was 0.
31
FAIL OverflowEvent.length should be 2. Was 0.
- a/LayoutTests/platform/gtk/fast/js/constructor-length-expected.txt -1 / +1 lines
Lines 25-31 PASS Int32Array.length is 1 a/LayoutTests/platform/gtk/fast/js/constructor-length-expected.txt_sec1
25
PASS Int8Array.length is 1
25
PASS Int8Array.length is 1
26
FAIL Intent.length should be 3. Threw exception ReferenceError: Can't find variable: Intent
26
FAIL Intent.length should be 3. Threw exception ReferenceError: Can't find variable: Intent
27
PASS MediaController.length is 0
27
PASS MediaController.length is 0
28
FAIL MediaStream.length should be 2. Threw exception ReferenceError: Can't find variable: MediaStream
28
FAIL MediaStream.length should be 0. Threw exception ReferenceError: Can't find variable: MediaStream
29
PASS MessageChannel.length is 0
29
PASS MessageChannel.length is 0
30
PASS MessageEvent.length is 2
30
PASS MessageEvent.length is 2
31
PASS OverflowEvent.length is 2
31
PASS OverflowEvent.length is 2
- a/LayoutTests/platform/mac/fast/js/constructor-length-expected.txt -1 / +1 lines
Lines 25-31 PASS Int32Array.length is 1 a/LayoutTests/platform/mac/fast/js/constructor-length-expected.txt_sec1
25
PASS Int8Array.length is 1
25
PASS Int8Array.length is 1
26
FAIL Intent.length should be 3. Threw exception ReferenceError: Can't find variable: Intent
26
FAIL Intent.length should be 3. Threw exception ReferenceError: Can't find variable: Intent
27
PASS MediaController.length is 0
27
PASS MediaController.length is 0
28
FAIL MediaStream.length should be 2. Threw exception ReferenceError: Can't find variable: MediaStream
28
FAIL MediaStream.length should be 0. Threw exception ReferenceError: Can't find variable: MediaStream
29
PASS MessageChannel.length is 0
29
PASS MessageChannel.length is 0
30
PASS MessageEvent.length is 2
30
PASS MessageEvent.length is 2
31
PASS OverflowEvent.length is 2
31
PASS OverflowEvent.length is 2
- a/LayoutTests/platform/qt/fast/js/constructor-length-expected.txt -1 / +1 lines
Lines 25-31 PASS Int32Array.length is 1 a/LayoutTests/platform/qt/fast/js/constructor-length-expected.txt_sec1
25
PASS Int8Array.length is 1
25
PASS Int8Array.length is 1
26
FAIL Intent.length should be 3. Threw exception ReferenceError: Can't find variable: Intent
26
FAIL Intent.length should be 3. Threw exception ReferenceError: Can't find variable: Intent
27
PASS MediaController.length is 0
27
PASS MediaController.length is 0
28
FAIL MediaStream.length should be 2. Threw exception ReferenceError: Can't find variable: MediaStream
28
FAIL MediaStream.length should be 0. Threw exception ReferenceError: Can't find variable: MediaStream
29
PASS MessageChannel.length is 0
29
PASS MessageChannel.length is 0
30
PASS MessageEvent.length is 2
30
PASS MessageEvent.length is 2
31
PASS OverflowEvent.length is 2
31
PASS OverflowEvent.length is 2
- a/Source/WebCore/ChangeLog +27 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2012-12-04  Adam Bergkvist  <adam.bergkvist@ericsson.com>
2
3
        MediaStream API: Update the MediaStream constructor
4
        https://bugs.webkit.org/show_bug.cgi?id=98416
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Updated the MediaStream constructor to support the more general argument
9
        list from the latest Media Capture and Streams specification:
10
        http://dev.w3.org/2011/webrtc/editor/getusermedia.html
11
12
        Added more test cases to existing tests.
13
14
        * GNUmakefile.list.am:
15
        * Modules/mediastream/MediaStream.cpp:
16
        (WebCore::containsSource):
17
        (WebCore):
18
        (WebCore::processTrack):
19
        (WebCore::createFromSourceVectors):
20
        (WebCore::MediaStream::create):
21
        * Modules/mediastream/MediaStream.h:
22
        * Modules/mediastream/MediaStream.idl:
23
        * WebCore.gypi:
24
        * bindings/js/JSMediaStreamCustom.cpp: Added.
25
        (WebCore):
26
        (WebCore::JSMediaStreamConstructor::constructJSMediaStream):
27
1
2012-11-30  Sheriff Bot  <webkit.review.bot@gmail.com>
28
2012-11-30  Sheriff Bot  <webkit.review.bot@gmail.com>
2
29
3
        Unreviewed, rolling out r136142.
30
        Unreviewed, rolling out r136142.
- a/Source/WebCore/GNUmakefile.list.am +1 lines
Lines 2355-2360 webcore_sources += \ a/Source/WebCore/GNUmakefile.list.am_sec1
2355
	Source/WebCore/bindings/js/JSMainThreadExecState.cpp \
2355
	Source/WebCore/bindings/js/JSMainThreadExecState.cpp \
2356
	Source/WebCore/bindings/js/JSMainThreadExecState.h \
2356
	Source/WebCore/bindings/js/JSMainThreadExecState.h \
2357
	Source/WebCore/bindings/js/JSMediaListCustom.cpp \
2357
	Source/WebCore/bindings/js/JSMediaListCustom.cpp \
2358
	Source/WebCore/bindings/js/JSMediaStreamCustom.cpp \
2358
	Source/WebCore/bindings/js/JSMemoryInfoCustom.cpp \
2359
	Source/WebCore/bindings/js/JSMemoryInfoCustom.cpp \
2359
	Source/WebCore/bindings/js/JSMessageChannelCustom.cpp \
2360
	Source/WebCore/bindings/js/JSMessageChannelCustom.cpp \
2360
	Source/WebCore/bindings/js/JSMessageEventCustom.cpp \
2361
	Source/WebCore/bindings/js/JSMessageEventCustom.cpp \
- a/Source/WebCore/Modules/mediastream/MediaStream.cpp -31 / +49 lines
Lines 1-6 a/Source/WebCore/Modules/mediastream/MediaStream.cpp_sec1
1
/*
1
/*
2
 * Copyright (C) 2011 Google Inc. All rights reserved.
2
 * Copyright (C) 2011 Google Inc. All rights reserved.
3
 * Copyright (C) 2011 Ericsson AB. All rights reserved.
3
 * Copyright (C) 2011, 2012 Ericsson AB. All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
Lines 36-82 a/Source/WebCore/Modules/mediastream/MediaStream.cpp_sec2
36
36
37
namespace WebCore {
37
namespace WebCore {
38
38
39
static void processTrackList(PassRefPtr<MediaStreamTrackList> prpTracks, const String& kind, MediaStreamSourceVector& sources, ExceptionCode& ec)
39
static bool containsSource(MediaStreamSourceVector& sourceVector, MediaStreamSource* source)
40
{
40
{
41
    RefPtr<MediaStreamTrackList> tracks = prpTracks;
41
    for (size_t i = 0; i < sourceVector.size(); ++i)
42
    if (!tracks)
42
        if (source->id() == sourceVector[i]->id())
43
            return true;
44
    return false;
45
}
46
47
static void processTrack(MediaStreamTrack* track, MediaStreamSourceVector& sourceVector)
48
{
49
    if (track->readyState() == MediaStreamTrack::ENDED)
43
        return;
50
        return;
44
51
45
    for (unsigned i = 0; i < tracks->length(); ++i) {
52
    MediaStreamSource* source = track->component()->source();
46
        MediaStreamTrack* track = tracks->item(i);
53
    if (!containsSource(sourceVector, source))
47
        if (track->kind() != kind) {
54
        sourceVector.append(source);
48
            ec = SYNTAX_ERR;
55
}
49
            return;
56
50
        }
57
static PassRefPtr<MediaStream> createFromSourceVectors(ScriptExecutionContext* context, const MediaStreamSourceVector& audioSources, const MediaStreamSourceVector& videoSources)
51
        MediaStreamSource* source = track->component()->source();
58
{
52
        bool isDuplicate = false;
59
    RefPtr<MediaStreamDescriptor> descriptor = MediaStreamDescriptor::create(createCanonicalUUIDString(), audioSources, videoSources);
53
        for (MediaStreamSourceVector::iterator j = sources.begin(); j < sources.end(); ++j) {
60
    MediaStreamCenter::instance().didCreateMediaStream(descriptor.get());
54
            if ((*j)->id() == source->id()) {
61
55
                isDuplicate = true;
62
    return MediaStream::create(context, descriptor.release());
56
                break;
63
}
57
            }
64
58
        }
65
PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context)
59
        if (!isDuplicate)
66
{
60
            sources.append(source);
67
    MediaStreamSourceVector audioSources;
61
    }
68
    MediaStreamSourceVector videoSources;
69
70
    return createFromSourceVectors(context, audioSources, videoSources);
62
}
71
}
63
72
64
PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context, PassRefPtr<MediaStreamTrackList> audioTracks, PassRefPtr<MediaStreamTrackList> videoTracks, ExceptionCode& ec)
73
PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context, PassRefPtr<MediaStream> stream)
65
{
74
{
75
    ASSERT(stream);
76
66
    MediaStreamSourceVector audioSources;
77
    MediaStreamSourceVector audioSources;
67
    processTrackList(audioTracks, "audio", audioSources, ec);
78
    MediaStreamSourceVector videoSources;
68
    if (ec)
79
69
        return 0;
80
    for (size_t i = 0; i < stream->audioTracks()->length(); ++i)
81
        processTrack(stream->audioTracks()->item(i), audioSources);
82
83
    for (size_t i = 0; i < stream->videoTracks()->length(); ++i)
84
        processTrack(stream->videoTracks()->item(i), videoSources);
70
85
86
    return createFromSourceVectors(context, audioSources, videoSources);
87
}
88
89
PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context, const MediaStreamTrackVector& tracks)
90
{
91
    MediaStreamSourceVector audioSources;
71
    MediaStreamSourceVector videoSources;
92
    MediaStreamSourceVector videoSources;
72
    processTrackList(videoTracks, "video", videoSources, ec);
73
    if (ec)
74
        return 0;
75
93
76
    RefPtr<MediaStreamDescriptor> descriptor = MediaStreamDescriptor::create(createCanonicalUUIDString(), audioSources, videoSources);
94
    for (size_t i = 0; i < tracks.size(); ++i)
77
    MediaStreamCenter::instance().didCreateMediaStream(descriptor.get());
95
        processTrack(tracks[i].get(), tracks[i]->kind() == "audio" ? audioSources : videoSources);
78
96
79
    return adoptRef(new MediaStream(context, descriptor.release()));
97
    return createFromSourceVectors(context, audioSources, videoSources);
80
}
98
}
81
99
82
PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context, PassRefPtr<MediaStreamDescriptor> streamDescriptor)
100
PassRefPtr<MediaStream> MediaStream::create(ScriptExecutionContext* context, PassRefPtr<MediaStreamDescriptor> streamDescriptor)
- a/Source/WebCore/Modules/mediastream/MediaStream.h -1 / +3 lines
Lines 44-51 public: a/Source/WebCore/Modules/mediastream/MediaStream.h_sec1
44
        ENDED = 2
44
        ENDED = 2
45
    };
45
    };
46
46
47
    static PassRefPtr<MediaStream> create(ScriptExecutionContext*);
48
    static PassRefPtr<MediaStream> create(ScriptExecutionContext*, PassRefPtr<MediaStream>);
49
    static PassRefPtr<MediaStream> create(ScriptExecutionContext*, const MediaStreamTrackVector&);
47
    static PassRefPtr<MediaStream> create(ScriptExecutionContext*, PassRefPtr<MediaStreamDescriptor>);
50
    static PassRefPtr<MediaStream> create(ScriptExecutionContext*, PassRefPtr<MediaStreamDescriptor>);
48
    static PassRefPtr<MediaStream> create(ScriptExecutionContext*, PassRefPtr<MediaStreamTrackList>, PassRefPtr<MediaStreamTrackList>, ExceptionCode&);
49
    virtual ~MediaStream();
51
    virtual ~MediaStream();
50
52
51
    DEFINE_ATTRIBUTE_EVENT_LISTENER(ended);
53
    DEFINE_ATTRIBUTE_EVENT_LISTENER(ended);
- a/Source/WebCore/Modules/mediastream/MediaStream.idl -2 / +5 lines
Lines 25-33 a/Source/WebCore/Modules/mediastream/MediaStream.idl_sec1
25
[
25
[
26
    Conditional=MEDIA_STREAM,
26
    Conditional=MEDIA_STREAM,
27
    EventTarget,
27
    EventTarget,
28
    Constructor(in MediaStreamTrackList audioTracks, in MediaStreamTrackList videoTracks),
28
    Constructor,
29
    Constructor(in MediaStream stream),
30
    Constructor(in MediaStreamTrack[] tracks),
31
    JSCustomConstructor,
32
    ConstructorParameters=0,
29
    CallWith=ScriptExecutionContext,
33
    CallWith=ScriptExecutionContext,
30
    ConstructorRaisesException
31
   ] interface MediaStream {
34
   ] interface MediaStream {
32
    readonly attribute DOMString label;
35
    readonly attribute DOMString label;
33
    readonly attribute MediaStreamTrackList audioTracks;
36
    readonly attribute MediaStreamTrackList audioTracks;
- a/Source/WebCore/WebCore.gypi +1 lines
Lines 2100-2105 a/Source/WebCore/WebCore.gypi_sec1
2100
            'bindings/js/JSMainThreadExecState.cpp',
2100
            'bindings/js/JSMainThreadExecState.cpp',
2101
            'bindings/js/JSMainThreadExecState.h',
2101
            'bindings/js/JSMainThreadExecState.h',
2102
            'bindings/js/JSMediaListCustom.cpp',
2102
            'bindings/js/JSMediaListCustom.cpp',
2103
            'bindings/js/JSMediaStreamCustom.cpp',
2103
            'bindings/js/JSMemoryInfoCustom.cpp',
2104
            'bindings/js/JSMemoryInfoCustom.cpp',
2104
            'bindings/js/JSMessageChannelCustom.cpp',
2105
            'bindings/js/JSMessageChannelCustom.cpp',
2105
            'bindings/js/JSMessageEventCustom.cpp',
2106
            'bindings/js/JSMessageEventCustom.cpp',
- a/Source/WebCore/bindings/js/JSMediaStreamCustom.cpp +83 lines
Line 0 a/Source/WebCore/bindings/js/JSMediaStreamCustom.cpp_sec1
1
/*
2
 * Copyright (C) 2012 Ericsson AB. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer
12
 *    in the documentation and/or other materials provided with the
13
 *    distribution.
14
 * 3. Neither the name of Ericsson nor the names of its contributors
15
 *    may be used to endorse or promote products derived from this
16
 *    software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 */
30
31
32
#include "config.h"
33
34
#if ENABLE(MEDIA_STREAM)
35
36
#include "JSMediaStream.h"
37
38
#include "JSMediaStreamTrack.h"
39
#include "MediaStream.h"
40
#include <runtime/Error.h>
41
42
using namespace JSC;
43
44
namespace WebCore {
45
46
EncodedJSValue JSC_HOST_CALL JSMediaStreamConstructor::constructJSMediaStream(ExecState* exec)
47
{
48
    JSMediaStreamConstructor* jsConstructor = static_cast<JSMediaStreamConstructor*>(exec->callee());
49
    ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();
50
    if (!context)
51
        return throwVMError(exec, createReferenceError(exec, "MediaStream constructor associated document is unavailable"));
52
53
    RefPtr<MediaStream> mediaStream;
54
55
    if (!exec->argumentCount()) {
56
        mediaStream = MediaStream::create(context);
57
58
    } else if (isJSArray(exec->argument(0))) {
59
        JSArray* tracksArray = asArray(exec->argument(0));
60
        MediaStreamTrackVector trackVector;
61
62
        for (size_t i = 0; i < tracksArray->length(); ++i) {
63
            JSValue element = tracksArray->getIndex(exec, i);
64
            if (element.inherits(&JSMediaStreamTrack::s_info))
65
                trackVector.append(toMediaStreamTrack(element));
66
            else
67
                return throwVMError(exec, createTypeError(exec, "Invalid Array element type"));
68
        }
69
        mediaStream = MediaStream::create(context, trackVector);
70
71
    } else if (exec->argument(0).inherits(&JSMediaStream::s_info)) {
72
        MediaStream* stream = toMediaStream(exec->argument(0));
73
        mediaStream = MediaStream::create(context, stream);
74
75
    } else
76
        return throwVMTypeError(exec);
77
78
    return JSValue::encode(CREATE_DOM_WRAPPER(exec, jsConstructor->globalObject(), MediaStream, mediaStream.get()));
79
}
80
81
} // namespace WebCore
82
83
#endif // ENABLE(MEDIA_STREAM)

Return to Bug 98416