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/core/v8/Dictionary.h" 27#include "bindings/core/v8/ExceptionState.h" 28#include "core/dom/Document.h" 29#include "core/dom/ExceptionCode.h" 30#include "core/frame/LocalFrame.h" 31#include "core/frame/Navigator.h" 32#include "core/page/Page.h" 33#include "modules/mediastream/MediaDeviceInfoCallback.h" 34#include "modules/mediastream/MediaDevicesRequest.h" 35#include "modules/mediastream/NavigatorUserMediaErrorCallback.h" 36#include "modules/mediastream/NavigatorUserMediaSuccessCallback.h" 37#include "modules/mediastream/UserMediaController.h" 38#include "modules/mediastream/UserMediaRequest.h" 39 40namespace blink { 41 42NavigatorMediaStream::NavigatorMediaStream() 43{ 44} 45 46NavigatorMediaStream::~NavigatorMediaStream() 47{ 48} 49 50void NavigatorMediaStream::webkitGetUserMedia(Navigator& navigator, const Dictionary& options, NavigatorUserMediaSuccessCallback* successCallback, NavigatorUserMediaErrorCallback* errorCallback, ExceptionState& exceptionState) 51{ 52 if (!successCallback) 53 return; 54 55 UserMediaController* userMedia = UserMediaController::from(navigator.frame()); 56 if (!userMedia) { 57 exceptionState.throwDOMException(NotSupportedError, "No user media controller available; is this a detached window?"); 58 return; 59 } 60 61 UserMediaRequest* request = UserMediaRequest::create(navigator.frame()->document(), userMedia, options, successCallback, errorCallback, exceptionState); 62 if (!request) { 63 ASSERT(exceptionState.hadException()); 64 return; 65 } 66 67 request->start(); 68} 69 70void NavigatorMediaStream::getMediaDevices(Navigator& navigator, MediaDeviceInfoCallback* callback, ExceptionState& exceptionState) 71{ 72 UserMediaController* userMedia = UserMediaController::from(navigator.frame()); 73 if (!userMedia) { 74 exceptionState.throwDOMException(NotSupportedError, "No media device controller available; is this a detached window?"); 75 return; 76 } 77 78 MediaDevicesRequest* request = MediaDevicesRequest::create(navigator.frame()->document(), userMedia, callback, exceptionState); 79 if (!request) { 80 if (!exceptionState.hadException()) 81 exceptionState.throwDOMException(NotSupportedError, "Failed to request media devices."); 82 return; 83 } 84 85 request->start(); 86} 87 88} // namespace blink 89