/** @file MOMPlayer.h
 *
 * Copyright (C) Espial Limited 2014 - Company confidential - All rights reserved.
 *
 */

#ifndef MOMPlayer_h
#define MOMPlayer_h

#if ENABLE(RMAI)

#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/text/AtomicString.h>

#include "MOMRenderer.h"
#include "ExceptionCode.h"

extern "C" {
#include "layers.h"
#include "cdf/mom_player.h"
}

namespace WebCore {

class MOMConnectionInfo;
class MOMContentItem;

class MOMPlayer : public MOMRenderer {
public:

    static PassRefPtr<MOMPlayer> create(ScriptExecutionContext* context, mom_player player);
    static PassRefPtr<MOMPlayer> create(ScriptExecutionContext* context);
    virtual ~MOMPlayer();

    // MOMRenderer overrides
    int offset() const;
    int duration() const;
    int connect( const String & source, int mode, int offset, ExceptionCode& ec );
    int connect( MOMContentItem* source, int mode, int offset, ExceptionCode& ec );
    void disconnect();
    void play( int speed, ExceptionCode& ec );
    void rendererStop();
    void seek( int offset, ExceptionCode& ec );
    void seek( int offset, int reference, ExceptionCode& ec );

    bool locked() const;
    bool blanked() const;
    bool enableVideoMode() const;
    void setEnableVideoMode(bool enableVideoMode);

    bool muteOnConnect() const;
    void setMuteOnConnect(bool muteOnConnect);

    PassRefPtr<MOMContentItem> currentConnection() const;

    void sendAccessEvent();
    PassRefPtr<MOMConnectionInfo> checkConnect( MOMContentItem* asset = 0);

    ALWAYS_INLINE mom_player player() const { return m_player; }

protected:
    MOMPlayer(ScriptExecutionContext* context, mom_player player);

private:
    static mom_error eventDispatcher(mom_event_t which, void* target, mom_event_params* params, unsigned int queue);

    mom_player m_player;
};

} // namespace WebCore

#endif // ENABLE(RMAI)

#endif // MOMPlayer_h
