~mmach/netext73/webkit2gtk

« back to all changes in this revision

Viewing changes to Source/WebKit/WebProcess/GPU/GPUProcessConnection.cpp

  • Committer: mmach
  • Date: 2023-06-16 17:21:37 UTC
  • Revision ID: netbit73@gmail.com-20230616172137-2rqx6yr96ga9g3kp
1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2019 Apple 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
 
6
 * are met:
 
7
 * 1. Redistributions of source code must retain the above copyright
 
8
 *    notice, this list of conditions and the following disclaimer.
 
9
 * 2. Redistributions in binary form must reproduce the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer in the
 
11
 *    documentation and/or other materials provided with the distribution.
 
12
 *
 
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 
23
 * THE POSSIBILITY OF SUCH DAMAGE.
 
24
 */
 
25
 
 
26
#include "config.h"
 
27
#include "GPUProcessConnection.h"
 
28
 
 
29
#if ENABLE(GPU_PROCESS)
 
30
 
 
31
#include "DataReference.h"
 
32
#include "GPUConnectionToWebProcessMessages.h"
 
33
#include "LibWebRTCCodecs.h"
 
34
#include "LibWebRTCCodecsMessages.h"
 
35
#include "MediaPlayerPrivateRemoteMessages.h"
 
36
#include "RemoteMediaPlayerManager.h"
 
37
#include "RemoteMediaPlayerManagerMessages.h"
 
38
#include "SampleBufferDisplayLayerMessages.h"
 
39
#include "UserMediaCaptureManager.h"
 
40
#include "UserMediaCaptureManagerMessages.h"
 
41
#include "WebCoreArgumentCoders.h"
 
42
#include "WebPage.h"
 
43
#include "WebPageMessages.h"
 
44
#include "WebProcess.h"
 
45
#include <WebCore/SharedBuffer.h>
 
46
 
 
47
namespace WebKit {
 
48
using namespace WebCore;
 
49
 
 
50
GPUProcessConnection::GPUProcessConnection(IPC::Connection::Identifier connectionIdentifier)
 
51
    : m_connection(IPC::Connection::createClientConnection(connectionIdentifier, *this))
 
52
{
 
53
    m_connection->open();
 
54
}
 
55
 
 
56
GPUProcessConnection::~GPUProcessConnection()
 
57
{
 
58
    m_connection->invalidate();
 
59
}
 
60
 
 
61
void GPUProcessConnection::didClose(IPC::Connection&)
 
62
{
 
63
}
 
64
 
 
65
void GPUProcessConnection::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference)
 
66
{
 
67
}
 
68
 
 
69
#if PLATFORM(COCOA) && ENABLE(VIDEO_TRACK) && ENABLE(MEDIA_STREAM)
 
70
SampleBufferDisplayLayerManager& GPUProcessConnection::sampleBufferDisplayLayerManager()
 
71
{
 
72
    if (!m_sampleBufferDisplayLayerManager)
 
73
        m_sampleBufferDisplayLayerManager = makeUnique<SampleBufferDisplayLayerManager>();
 
74
    return *m_sampleBufferDisplayLayerManager;
 
75
}
 
76
#endif
 
77
 
 
78
void GPUProcessConnection::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder)
 
79
{
 
80
    if (decoder.messageReceiverName() == Messages::MediaPlayerPrivateRemote::messageReceiverName()) {
 
81
        WebProcess::singleton().supplement<RemoteMediaPlayerManager>()->didReceivePlayerMessage(connection, decoder);
 
82
        return;
 
83
    }
 
84
 
 
85
#if ENABLE(MEDIA_STREAM)
 
86
    if (decoder.messageReceiverName() == Messages::UserMediaCaptureManager::messageReceiverName()) {
 
87
        if (auto* captureManager = WebProcess::singleton().supplement<UserMediaCaptureManager>())
 
88
            captureManager->didReceiveMessageFromGPUProcess(connection, decoder);
 
89
        return;
 
90
    }
 
91
#if PLATFORM(COCOA) && ENABLE(VIDEO_TRACK)
 
92
    if (decoder.messageReceiverName() == Messages::SampleBufferDisplayLayer::messageReceiverName()) {
 
93
        sampleBufferDisplayLayerManager().didReceiveLayerMessage(connection, decoder);
 
94
        return;
 
95
    }
 
96
#endif // PLATFORM(COCOA) && ENABLE(VIDEO_TRACK)
 
97
#endif // ENABLE(MEDIA_STREAM)
 
98
#if USE(LIBWEBRTC) && PLATFORM(COCOA)
 
99
    if (decoder.messageReceiverName() == Messages::LibWebRTCCodecs::messageReceiverName()) {
 
100
        WebProcess::singleton().libWebRTCCodecs().didReceiveMessage(connection, decoder);
 
101
        return;
 
102
    }
 
103
#endif
 
104
}
 
105
 
 
106
} // namespace WebKit
 
107
 
 
108
#endif // ENABLE(GPU_PROCESS)