193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)/*
293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * Copyright (C) 2013 Google Inc. All rights reserved.
393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * modification, are permitted provided that the following conditions
693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * are met:
793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * 1.  Redistributions of source code must retain the above copyright
893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     notice, this list of conditions and the following disclaimer.
993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * 2.  Redistributions in binary form must reproduce the above copyright
1093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     notice, this list of conditions and the following disclaimer in the
1193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     documentation and/or other materials provided with the distribution.
1293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
1393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
1493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
1793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
2093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) */
2493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
2593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#ifndef WebMediaStreamTrack_h
2693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#define WebMediaStreamTrack_h
2793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
2893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "WebCommon.h"
2993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "WebNonCopyable.h"
3093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "WebPrivatePtr.h"
3193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
32c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
3393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
34e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)class MediaStreamComponent;
359bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)class WebAudioSourceProvider;
3693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)class WebMediaStream;
3793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)class WebMediaStreamSource;
3893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)class WebString;
3993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
4093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)class WebMediaStreamTrack {
4193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)public:
421e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    class ExtraData {
431e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    public:
4409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        ExtraData() : m_owner(0) { }
451e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)        virtual ~ExtraData() { }
4609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
4709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)        BLINK_PLATFORM_EXPORT WebMediaStreamTrack owner();
4809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
4909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#if INSIDE_BLINK
50e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)        BLINK_PLATFORM_EXPORT void setOwner(MediaStreamComponent*);
5109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#endif
5209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
5309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    private:
54e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)        MediaStreamComponent* m_owner;
551e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    };
561e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)
5793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    WebMediaStreamTrack() { }
5893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    WebMediaStreamTrack(const WebMediaStreamTrack& other) { assign(other); }
5993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    ~WebMediaStreamTrack() { reset(); }
6093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
6193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    WebMediaStreamTrack& operator=(const WebMediaStreamTrack& other)
6293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    {
6393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        assign(other);
6493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        return *this;
6593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    }
6609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void assign(const WebMediaStreamTrack&);
6793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
6809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void initialize(const WebMediaStreamSource&);
6909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void initialize(const WebString& id, const WebMediaStreamSource&);
7093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
7109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void reset();
7293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    bool isNull() const { return m_private.isNull(); }
7393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
7409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    BLINK_PLATFORM_EXPORT WebString id() const;
7593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
7609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    BLINK_PLATFORM_EXPORT WebMediaStreamSource source() const;
7709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    BLINK_PLATFORM_EXPORT bool isEnabled() const;
7893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
791e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    // Extra data associated with this WebMediaStream.
801e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    // If non-null, the extra data pointer will be deleted when the object is destroyed.
811e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    // Setting the extra data pointer will cause any existing non-null
821e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)    // extra data pointer to be deleted.
8309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    BLINK_PLATFORM_EXPORT ExtraData* extraData() const;
8409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void setExtraData(ExtraData*);
851e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)
869bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)    // The lifetime of the WebAudioSourceProvider should outlive the
879bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)    // WebMediaStreamTrack, and clients are responsible for calling
889bbd2f5e390b01907d97ecffde80aa1b06113aacTorne (Richard Coles)    // setSourceProvider(0) before the WebMediaStreamTrack is going away.
8909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)    BLINK_PLATFORM_EXPORT void setSourceProvider(WebAudioSourceProvider*);
9009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)
9109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#if INSIDE_BLINK
92e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    BLINK_PLATFORM_EXPORT WebMediaStreamTrack(PassRefPtr<MediaStreamComponent>);
93e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    BLINK_PLATFORM_EXPORT WebMediaStreamTrack(MediaStreamComponent*);
94e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    BLINK_PLATFORM_EXPORT WebMediaStreamTrack& operator=(MediaStreamComponent*);
95e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    BLINK_PLATFORM_EXPORT operator WTF::PassRefPtr<MediaStreamComponent>() const;
96e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    BLINK_PLATFORM_EXPORT operator MediaStreamComponent*() const;
9793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#endif
9893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
9993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)private:
100e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)    WebPrivatePtr<MediaStreamComponent> m_private;
10193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)};
10293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
10351b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} // namespace blink
10493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
10593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#endif // WebMediaStreamTrack_h
106