Commit dbf8a2a6 authored by eric@webkit.org's avatar eric@webkit.org

2009-08-12 Crystal Zhang <crystal.zhang@torchmobile.com>

        Reviewed by George Staikos.

        WINCE PORT: MediaPlayerProxy and MediaPlayerPrivate
        https://bugs.webkit.org/show_bug.cgi?id=28178

        * platform/graphics/wince/MediaPlayerPrivateWince.h: Added.
        * platform/graphics/wince/MediaPlayerProxy.cpp: Added.
        * platform/graphics/wince/MediaPlayerProxy.h: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@47115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0a2a5bb8
2009-08-12 Crystal Zhang <crystal.zhang@torchmobile.com>
Reviewed by George Staikos.
WINCE PORT: MediaPlayerProxy and MediaPlayerPrivate
https://bugs.webkit.org/show_bug.cgi?id=28178
* platform/graphics/wince/MediaPlayerPrivateWince.h: Added.
* platform/graphics/wince/MediaPlayerProxy.cpp: Added.
* platform/graphics/wince/MediaPlayerProxy.h: Added.
2009-08-12 Laszlo Gombos <laszlo.1.gombos@nokia.com>
Reviewed by Eric Seidel.
/*
* Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
*/
#ifndef MediaPlayerPrivateWince_h
#define MediaPlayerPrivateWince_h
#if ENABLE(VIDEO)
#include "MediaPlayerPrivate.h"
#include "Timer.h"
#include <wtf/OwnPtr.h>
namespace WebCore {
class GraphicsContext;
class IntSize;
class IntRect;
class String;
class MediaPlayerPrivate : public MediaPlayerPrivateInterface {
public:
static void registerMediaEngine(MediaEngineRegistrar);
~MediaPlayerPrivate();
IntSize naturalSize() const;
bool hasVideo() const;
void load(const String& url);
void cancelLoad();
void play();
void pause();
bool paused() const;
bool seeking() const;
float duration() const;
float currentTime() const;
void seek(float time);
void setEndTime(float);
void setRate(float);
void setVolume(float);
int dataRate() const;
MediaPlayer::NetworkState networkState() const { return m_networkState; }
MediaPlayer::ReadyState readyState() const { return m_readyState; }
float maxTimeBuffered() const;
float maxTimeSeekable() const;
unsigned bytesLoaded() const;
bool totalBytesKnown() const;
unsigned totalBytes() const;
void setVisible(bool);
void setSize(const IntSize&);
void loadStateChanged();
void didEnd();
void paint(GraphicsContext*, const IntRect&);
private:
MediaPlayerPrivate(MediaPlayer*);
void updateStates();
void doSeek();
void cancelSeek();
void seekTimerFired(Timer<MediaPlayerPrivate>*);
float maxTimeLoaded() const;
void sawUnsupportedTracks();
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
void setMediaPlayerProxy(WebMediaPlayerProxy*);
void setPoster(const String& url);
void deliverNotification(MediaPlayerProxyNotificationType);
#endif
// engine support
static MediaPlayerPrivateInterface* create(MediaPlayer*);
static void getSupportedTypes(HashSet<String>& types);
static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs);
static bool isAvailable();
MediaPlayer* m_player;
float m_seekTo;
float m_endTime;
Timer<MediaPlayerPrivate> m_seekTimer;
MediaPlayer::NetworkState m_networkState;
MediaPlayer::ReadyState m_readyState;
unsigned m_enabledTrackCount;
unsigned m_totalTrackCount;
bool m_hasUnsupportedTracks;
bool m_startedPlaying;
bool m_isStreaming;
#if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
WebMediaPlayerProxy* m_proxy;
#endif
};
}
#endif
#endif
/*
* Copyright (C) 2009 Torch Mobile, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#if ENABLE(VIDEO)
#include "config.h"
#include "MediaPlayerProxy.h"
#include "c_class.h"
#include "c_instance.h"
#include "c_runtime.h"
#include "DocumentLoader.h"
#include "HTMLPlugInElement.h"
#include "HTMLVideoElement.h"
#include "JSDOMBinding.h"
#include "JSPluginElementFunctions.h"
#include "MediaPlayer.h"
#include "Node.h"
#include "npruntime_impl.h"
#include "PlatformString.h"
#include "PluginView.h"
#include "RenderPartObject.h"
#include "RenderWidget.h"
#include "runtime.h"
#include <runtime/Identifier.h>
#include "Widget.h"
using namespace JSC;
namespace WebCore {
using namespace Bindings;
using namespace HTMLNames;
WebMediaPlayerProxy::WebMediaPlayerProxy(MediaPlayer* player)
: m_mediaPlayer(player)
, m_init(false)
, m_hasSentResponseToPlugin(false)
{
if (!m_init)
initEngine();
}
WebMediaPlayerProxy::~WebMediaPlayerProxy()
{
m_instance.release();
}
ScriptInstance WebMediaPlayerProxy::pluginInstance()
{
if (!m_instance) {
RenderObject* r = element()->renderer();
if (!r || !r->isWidget())
return 0;
Frame* frame = element()->document()->frame();
RenderWidget* renderWidget = static_cast<RenderWidget*>(element()->renderer());
if (renderWidget && renderWidget->widget())
m_instance = frame->script()->createScriptInstanceForWidget(renderWidget->widget());
}
return m_instance;
}
void WebMediaPlayerProxy::load(const String& url)
{
if (!m_init)
initEngine();
if (m_init)
invokeMethod("play");
}
void WebMediaPlayerProxy::initEngine()
{
HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_mediaPlayer->mediaPlayerClient());
String url = element->initialURL();
if (url.isEmpty())
return;
Frame* frame = element->document()->frame();
Vector<String> paramNames;
Vector<String> paramValues;
String serviceType;
// add all attributes set on the embed object
if (NamedNodeMap* attributes = element->attributes()) {
for (unsigned i = 0; i < attributes->length(); ++i) {
Attribute* it = attributes->attributeItem(i);
paramNames.append(it->name().localName().string());
paramValues.append(it->value().string());
}
}
serviceType = "application/x-mplayer2";
frame->loader()->requestObject(static_cast<RenderPartObject*>(element->renderer()), url, nullAtom, serviceType, paramNames, paramValues);
m_init = true;
}
HTMLMediaElement* WebMediaPlayerProxy::element()
{
return static_cast<HTMLMediaElement*>(m_mediaPlayer->mediaPlayerClient());
}
void WebMediaPlayerProxy::invokeMethod(const String& methodName)
{
Frame* frame = element()->document()->frame();
RootObject *root = frame->script()->bindingRootObject();
if (!root)
return;
ExecState *exec = root->globalObject()->globalExec();
Instance* instance = pluginInstance().get();
if (!instance)
return;
instance->begin();
Class *aClass = instance->getClass();
Identifier iden(exec, methodName);
MethodList methodList = aClass->methodsNamed(iden, instance);
ArgList args;
instance->invokeMethod(exec, methodList , args);
instance->end();
}
}
#endif
/*
* Copyright (C) 2009 Torch Mobile, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef MediaPlayerProxy_h
#define MediaPlayerProxy_h
#if ENABLE(VIDEO)
#include "ScriptInstance.h"
namespace WebCore {
class IntRect;
class IntSize;
class String;
class MediaPlayer;
class PluginView;
class HTMLMediaElement;
enum MediaPlayerProxyNotificationType {
MediaPlayerNotificationPlayPauseButtonPressed,
Idle,
Loading,
Loaded,
FormatError,
NetworkError,
DecodeError
};
class WebMediaPlayerProxy {
public:
WebMediaPlayerProxy(MediaPlayer* player);
~WebMediaPlayerProxy();
MediaPlayer* mediaPlayer() {return m_mediaPlayer;}
void initEngine();
void load(const String& url);
HTMLMediaElement* element();
void invokeMethod(const String& methodName);
ScriptInstance pluginInstance();
private:
MediaPlayer* m_mediaPlayer;
bool m_init;
WebCore::PluginView* m_pluginView;
bool m_hasSentResponseToPlugin;
ScriptInstance m_instance;
};
}
#endif // ENABLE(VIDEO)
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment