1 /*
2 * Copyright (C) 2000 Harri Porten (porten@kde.org)
3 * Copyright (c) 2000 Daniel Molkentin (molkentin@kde.org)
4 * Copyright (c) 2000 Stefan Schimanski (schimmi@kde.org)
5 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include "config.h"
24 #include "modules/mediastream/NavigatorMediaStream.h"
25
26 #include "bindings/v8/Dictionary.h"
27 #include "bindings/v8/ExceptionState.h"
28 #include "core/dom/Document.h"
29 #include "core/dom/ExceptionCode.h"
30 #include "core/frame/Frame.h"
31 #include "core/frame/Navigator.h"
32 #include "core/page/Page.h"
33 #include "modules/mediastream/NavigatorUserMediaErrorCallback.h"
34 #include "modules/mediastream/NavigatorUserMediaSuccessCallback.h"
35 #include "modules/mediastream/UserMediaController.h"
36 #include "modules/mediastream/UserMediaRequest.h"
37
38 namespace WebCore {
39
NavigatorMediaStream()40 NavigatorMediaStream::NavigatorMediaStream()
41 {
42 }
43
~NavigatorMediaStream()44 NavigatorMediaStream::~NavigatorMediaStream()
45 {
46 }
47
webkitGetUserMedia(Navigator * navigator,const Dictionary & options,PassOwnPtr<NavigatorUserMediaSuccessCallback> successCallback,PassOwnPtr<NavigatorUserMediaErrorCallback> errorCallback,ExceptionState & exceptionState)48 void NavigatorMediaStream::webkitGetUserMedia(Navigator* navigator, const Dictionary& options, PassOwnPtr<NavigatorUserMediaSuccessCallback> successCallback, PassOwnPtr<NavigatorUserMediaErrorCallback> errorCallback, ExceptionState& exceptionState)
49 {
50 if (!successCallback)
51 return;
52
53 UserMediaController* userMedia = UserMediaController::from(navigator->frame() ? navigator->frame()->page() : 0);
54 if (!userMedia) {
55 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedError);
56 return;
57 }
58
59 RefPtr<UserMediaRequest> request = UserMediaRequest::create(navigator->frame()->document(), userMedia, options, successCallback, errorCallback, exceptionState);
60 if (!request) {
61 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedError);
62 return;
63 }
64
65 request->start();
66 }
67
68 } // namespace WebCore
69