Return undefined when browser call record() of MediaStream.
authorkeonho07.kim <keonho07.kim@samsung.com>
Wed, 27 Mar 2013 14:12:35 +0000 (23:12 +0900)
committerGerrit Code Review <gerrit2@kim11>
Thu, 28 Mar 2013 05:38:18 +0000 (14:38 +0900)
[Title] Return undefined when browser call record() of MediaStream.
[Problem] Media stream recording feature is supported on browser.
[Cause] It doesn't check caller of record().
[Solution] Return jsUndefined() when browser call record() of MediaStream.
caution : Merge this patch after WRT apply patch to set the TizenExtensible flag for media stream record
          and http://slp-info.sec.samsung.net/gerrit/#/c/169837/

Change-Id: I5617febc0a463dad275ed4f2458de8fbad6c1353

Source/WebCore/Modules/mediastream/MediaStream.idl
Source/WebCore/UseJSC.cmake
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSMediaStreamCustom.cpp [new file with mode: 0755]

index a680745..00114c9 100644 (file)
@@ -37,7 +37,7 @@ module core {
 
         // FIXME: implement the record method when MediaStreamRecorder is available.
 #if defined(ENABLE_TIZEN_MEDIA_STREAM_RECORDER) && ENABLE_TIZEN_MEDIA_STREAM_RECORDER
-        MediaStreamRecorder record();
+        [Custom] MediaStreamRecorder record();
 #endif
 
         const unsigned short LIVE = 1;
index 7bab607..6e07923 100644 (file)
@@ -287,6 +287,12 @@ IF (ENABLE_TIZEN_MEDIA_STREAM)
     )
 ENDIF ()
 
+IF (ENABLE_TIZEN_MEDIA_STREAM_RECORDER)
+    LIST(APPEND WebCore_SOURCES
+        bindings/js/JSMediaStreamCustom.cpp
+    )
+ENDIF ()
+
 IF (ENABLE_VIDEO_TRACK)
     LIST(APPEND WebCore_SOURCES
         bindings/js/JSTextTrackCueCustom.cpp
index b35c2df..c4e8d12 100644 (file)
 #include "JSLocationCustom.cpp"
 #include "JSMainThreadExecState.cpp"
 #include "JSMediaListCustom.cpp"
+#include "JSMediaStreamCustom.cpp"
 #include "JSMemoryInfoCustom.cpp"
 #include "JSMessageChannelCustom.cpp"
 #include "JSMessageEventCustom.cpp"
diff --git a/Source/WebCore/bindings/js/JSMediaStreamCustom.cpp b/Source/WebCore/bindings/js/JSMediaStreamCustom.cpp
new file mode 100755 (executable)
index 0000000..1cb4844
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2013 Samsung Electronics. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(TIZEN_MEDIA_STREAM_RECORDER)
+
+#include "JSMediaStream.h"
+#include "JSMediaStreamRecorder.h"
+#include "MediaStream.h"
+#if ENABLE(TIZEN_EXTENSIBLE_API)
+#include "TizenExtensibleAPI.h"
+#endif
+#include <wtf/GetPtr.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+JSValue JSMediaStream::record(ExecState* exec)
+{
+    JSValue thisValue = exec->hostThisValue();
+    if (!thisValue.inherits(&JSMediaStream::s_info))
+        return throwError(exec, createTypeError(exec, "Illegal type"));
+    JSMediaStream* castedThis = jsCast<JSMediaStream*>(asObject(thisValue));
+    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSMediaStream::s_info);
+    MediaStream* impl = static_cast<MediaStream*>(castedThis->impl());
+
+#if ENABLE(TIZEN_EXTENSIBLE_API)
+    JSValue result;
+    if (TizenExtensibleAPI::extensibleAPI().mediaStreamRecord())
+        result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->record()));
+    else
+        result = jsUndefined();
+#else
+    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->record()));
+#endif
+
+    return result;
+}
+
+}
+
+#endif // ENABLE(MEDIA_STREAM)