~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/platform/mediastream/chromium/MediaStreamCenterChromium.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions are
 
6
 * met:
 
7
 *
 
8
 *     * Redistributions of source code must retain the above copyright
 
9
 * notice, this list of conditions and the following disclaimer.
 
10
 *     * Redistributions in binary form must reproduce the above
 
11
 * copyright notice, this list of conditions and the following disclaimer
 
12
 * in the documentation and/or other materials provided with the
 
13
 * distribution.
 
14
 *     * Neither the name of Google Inc. nor the names of its
 
15
 * contributors may be used to endorse or promote products derived from
 
16
 * this software without specific prior written permission.
 
17
 *
 
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
19
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
20
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
21
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
22
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
23
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
24
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
28
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
29
 */
 
30
 
 
31
#include "config.h"
 
32
 
 
33
#if ENABLE(MEDIA_STREAM)
 
34
 
 
35
#include "MediaStreamCenterChromium.h"
 
36
 
 
37
#include "MediaStreamDescriptor.h"
 
38
#include "MediaStreamSourcesQueryClient.h"
 
39
#include <public/Platform.h>
 
40
#include <public/WebMediaStreamCenter.h>
 
41
#include <public/WebMediaStreamComponent.h>
 
42
#include <public/WebMediaStreamDescriptor.h>
 
43
#include <public/WebMediaStreamSourcesRequest.h>
 
44
#include <wtf/MainThread.h>
 
45
#include <wtf/PassOwnPtr.h>
 
46
 
 
47
namespace WebCore {
 
48
 
 
49
MediaStreamCenter& MediaStreamCenter::instance()
 
50
{
 
51
    ASSERT(isMainThread());
 
52
    DEFINE_STATIC_LOCAL(MediaStreamCenterChromium, center, ());
 
53
    return center;
 
54
}
 
55
 
 
56
MediaStreamCenterChromium::MediaStreamCenterChromium()
 
57
    : m_private(adoptPtr(WebKit::Platform::current()->createMediaStreamCenter(this)))
 
58
{
 
59
}
 
60
 
 
61
MediaStreamCenterChromium::~MediaStreamCenterChromium()
 
62
{
 
63
}
 
64
 
 
65
void MediaStreamCenterChromium::queryMediaStreamSources(PassRefPtr<MediaStreamSourcesQueryClient> client)
 
66
{
 
67
    if (m_private)
 
68
        m_private->queryMediaStreamSources(client);
 
69
    else {
 
70
        MediaStreamSourceVector audioSources, videoSources;
 
71
        client->didCompleteQuery(audioSources, videoSources);
 
72
    }
 
73
}
 
74
 
 
75
void MediaStreamCenterChromium::didSetMediaStreamTrackEnabled(MediaStreamDescriptor* stream,  MediaStreamComponent* component)
 
76
{
 
77
    if (m_private) {
 
78
        if (component->enabled())
 
79
            m_private->didEnableMediaStreamTrack(stream, component);
 
80
        else
 
81
            m_private->didDisableMediaStreamTrack(stream, component);
 
82
    }
 
83
}
 
84
 
 
85
bool MediaStreamCenterChromium::didAddMediaStreamTrack(MediaStreamDescriptor* stream, MediaStreamComponent* component)
 
86
{
 
87
    return m_private ? m_private->didAddMediaStreamTrack(stream, component) : false;
 
88
}
 
89
 
 
90
bool MediaStreamCenterChromium::didRemoveMediaStreamTrack(MediaStreamDescriptor* stream, MediaStreamComponent* component)
 
91
{
 
92
    return m_private ? m_private->didRemoveMediaStreamTrack(stream, component) : false;
 
93
}
 
94
 
 
95
void MediaStreamCenterChromium::didStopLocalMediaStream(MediaStreamDescriptor* stream)
 
96
{
 
97
    if (m_private)
 
98
        m_private->didStopLocalMediaStream(stream);
 
99
}
 
100
 
 
101
void MediaStreamCenterChromium::didCreateMediaStream(MediaStreamDescriptor* stream)
 
102
{
 
103
    if (m_private) {
 
104
        WebKit::WebMediaStreamDescriptor webStream(stream);
 
105
        m_private->didCreateMediaStream(webStream);
 
106
    }
 
107
}
 
108
 
 
109
void MediaStreamCenterChromium::stopLocalMediaStream(const WebKit::WebMediaStreamDescriptor& stream)
 
110
{
 
111
    endLocalMediaStream(stream);
 
112
}
 
113
 
 
114
void MediaStreamCenterChromium::addMediaStreamTrack(const WebKit::WebMediaStreamDescriptor& stream, const WebKit::WebMediaStreamComponent& component)
 
115
{
 
116
    MediaStreamCenter::addMediaStreamTrack(stream, component);
 
117
}
 
118
 
 
119
void MediaStreamCenterChromium::removeMediaStreamTrack(const WebKit::WebMediaStreamDescriptor& stream, const WebKit::WebMediaStreamComponent& component)
 
120
{
 
121
    MediaStreamCenter::removeMediaStreamTrack(stream, component);
 
122
}
 
123
 
 
124
} // namespace WebCore
 
125
 
 
126
#endif // ENABLE(MEDIA_STREAM)