1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
/*
* Copyright (C) 2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "MDNSRegisterError.h"
#include "MediaCapabilitiesInfo.h"
#include "RTCDataChannelRemoteHandlerConnection.h"
#include "RTCRtpCapabilities.h"
#include "ScriptExecutionContextIdentifier.h"
#include <wtf/CompletionHandler.h>
#include <wtf/Expected.h>
#include <wtf/TZoneMalloc.h>
#include <wtf/UniqueRef.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class ContentType;
struct VideoConfiguration;
struct MediaCapabilitiesDecodingInfo;
struct MediaCapabilitiesEncodingInfo;
struct MediaDecodingConfiguration;
struct MediaEncodingConfiguration;
class WEBCORE_EXPORT WebRTCProvider {
WTF_MAKE_TZONE_ALLOCATED_EXPORT(WebRTCProvider, WEBCORE_EXPORT);
public:
static UniqueRef<WebRTCProvider> create();
WebRTCProvider() = default;
virtual ~WebRTCProvider() = default;
static bool webRTCAvailable();
static void setH264HardwareEncoderAllowed(bool);
virtual RefPtr<RTCDataChannelRemoteHandlerConnection> createRTCDataChannelRemoteHandlerConnection();
using DecodingConfigurationCallback = Function<void(MediaCapabilitiesDecodingInfo&&)>;
using EncodingConfigurationCallback = Function<void(MediaCapabilitiesEncodingInfo&&)>;
void createDecodingConfiguration(MediaDecodingConfiguration&&, DecodingConfigurationCallback&&);
void createEncodingConfiguration(MediaEncodingConfiguration&&, EncodingConfigurationCallback&&);
void setAV1Support(bool);
void setH265Support(bool);
void setVP9Support(bool supportsVP9Profile0, bool supportsVP9Profile2);
bool isSupportingAV1() const;
bool isSupportingH265() const;
bool isSupportingVP9Profile0() const;
bool isSupportingVP9Profile2() const;
bool isSupportingMDNS() const;
#if ENABLE(WEB_RTC)
virtual std::optional<RTCRtpCapabilities> receiverCapabilities(const String&);
virtual std::optional<RTCRtpCapabilities> senderCapabilities(const String&);
#endif
virtual void setLoggingLevel(WTFLogLevel);
virtual void clearFactory();
void setPortAllocatorRange(StringView);
std::optional<std::pair<int, int>> portAllocatorRange() const;
virtual bool isLibWebRTCProvider() const { return false; }
protected:
#if ENABLE(WEB_RTC)
std::optional<RTCRtpCapabilities>& audioDecodingCapabilities();
std::optional<RTCRtpCapabilities>& videoDecodingCapabilities();
std::optional<RTCRtpCapabilities>& audioEncodingCapabilities();
std::optional<RTCRtpCapabilities>& videoEncodingCapabilities();
std::optional<RTCRtpCodecCapability> codecCapability(const ContentType&, const std::optional<RTCRtpCapabilities>&);
std::optional<RTCRtpCapabilities> m_audioDecodingCapabilities;
std::optional<RTCRtpCapabilities> m_videoDecodingCapabilities;
std::optional<RTCRtpCapabilities> m_audioEncodingCapabilities;
std::optional<RTCRtpCapabilities> m_videoEncodingCapabilities;
#endif
virtual std::optional<MediaCapabilitiesInfo> computeVPParameters(const VideoConfiguration&);
virtual bool isVPSoftwareDecoderSmooth(const VideoConfiguration&);
virtual bool isVPXEncoderSmooth(const VideoConfiguration&);
virtual bool isH264EncoderSmooth(const VideoConfiguration&);
bool m_supportsAV1 { false };
bool m_supportsH265 { false };
bool m_supportsVP9Profile0 { false };
bool m_supportsVP9Profile2 { false };
bool m_supportsMDNS { false };
std::optional<std::pair<int, int>> m_portAllocatorRange;
private:
virtual void initializeAudioDecodingCapabilities();
virtual void initializeVideoDecodingCapabilities();
virtual void initializeAudioEncodingCapabilities();
virtual void initializeVideoEncodingCapabilities();
virtual std::optional<MediaCapabilitiesDecodingInfo> videoDecodingCapabilitiesOverride(const VideoConfiguration&);
virtual std::optional<MediaCapabilitiesEncodingInfo> videoEncodingCapabilitiesOverride(const VideoConfiguration&);
};
} // namespace WebCore
|