16c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen/*
26c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * Copyright (C) 2007, 2008, 2009, 2010 Apple, Inc.  All rights reserved.
36c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen *
46c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * Redistribution and use in source and binary forms, with or without
56c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * modification, are permitted provided that the following conditions
66c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * are met:
76c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * 1. Redistributions of source code must retain the above copyright
86c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen *    notice, this list of conditions and the following disclaimer.
96c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * 2. Redistributions in binary form must reproduce the above copyright
106c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen *    notice, this list of conditions and the following disclaimer in the
116c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen *    documentation and/or other materials provided with the distribution.
126c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen *
136c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
146c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
156c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
166c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
176c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
186c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
196c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
206c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
216c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
226c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
236c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
246c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen */
256c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
266c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen#ifndef QTMovieVisualContext_h
276c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen#define QTMovieVisualContext_h
286c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
296c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen#ifdef QTMOVIEWIN_EXPORTS
306c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen#define QTMOVIEWIN_API __declspec(dllexport)
316c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen#else
326c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen#define QTMOVIEWIN_API __declspec(dllimport)
336c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen#endif
346c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
356c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen#include "QTMovie.h"
366c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen#include "QTMovieTask.h"
376c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen#include "QTPixelBuffer.h"
386c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen#include <WTF/OwnPtr.h>
396c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen#include <WTF/RefCounted.h>
406c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
41e78cbe89e6f337f2f1fe40315be88f742b547151Steve Blocktypedef const struct __CFDictionary* CFDictionaryRef;
426c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsentypedef struct OpaqueQTVisualContext*   QTVisualContextRef;
436c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
446c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen// QTCVTimeStamp is a struct containing only a CVTimeStamp.  This is to
456c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen// work around the inability of CVTimeStamp to be forward declared, in
466c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen// addition to it being declared in different header files when building
476c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen// the QTMovieWin and WebCore projects.
486c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsenstruct QTCVTimeStamp;
496c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
506c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsenclass QTMovieVisualContextClient {
516c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsenpublic:
526c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    virtual void imageAvailableForTime(const QTCVTimeStamp*) = 0;
536c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen};
546c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
556c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsenclass QTMOVIEWIN_API QTMovieVisualContext : public RefCounted<QTMovieVisualContext> {
566c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsenpublic:
57e14391e94c850b8bd03680c23b38978db68687a8John Reck    static PassRefPtr<QTMovieVisualContext> create(QTMovieVisualContextClient*, QTPixelBuffer::Type);
586c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    ~QTMovieVisualContext();
596c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
606c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    bool isImageAvailableForTime(const QTCVTimeStamp*) const;
616c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    QTPixelBuffer imageForTime(const QTCVTimeStamp*);
626c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    void task();
636c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
646c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    QTVisualContextRef visualContextRef();
656c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
666c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    void setMovie(PassRefPtr<QTMovie>);
676c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    QTMovie* movie() const;
686c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
696c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    static double currentHostTime();
706c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
716c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsenprotected:
72e14391e94c850b8bd03680c23b38978db68687a8John Reck    QTMovieVisualContext(QTMovieVisualContextClient*, QTPixelBuffer::Type);
736c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    void setupVisualContext();
746c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
756c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    friend class QTMovieVisualContextPriv;
766c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen    OwnPtr<QTMovieVisualContextPriv> m_private;
776c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen};
786c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen
796c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen#endif
80