LibWebRTCCodecsProxy.h [plain text]
#pragma once
#if USE(LIBWEBRTC) && PLATFORM(COCOA) && ENABLE(GPU_PROCESS)
#include "Connection.h"
#include "DataReference.h"
#include "RTCDecoderIdentifier.h"
#include "RTCEncoderIdentifier.h"
#include <WebCore/ImageTransferSessionVT.h>
namespace IPC {
class Connection;
class Decoder;
}
namespace WebCore {
class RemoteVideoSample;
}
namespace webrtc {
using LocalDecoder = void*;
using LocalEncoder = void*;
}
namespace WebKit {
class GPUConnectionToWebProcess;
class LibWebRTCCodecsProxy : public IPC::Connection::ThreadMessageReceiverRefCounted {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<LibWebRTCCodecsProxy> create(GPUConnectionToWebProcess& process) { return adoptRef(*new LibWebRTCCodecsProxy(process)); }
~LibWebRTCCodecsProxy();
void close();
private:
explicit LibWebRTCCodecsProxy(GPUConnectionToWebProcess&);
void dispatchToThread(Function<void()>&&) final;
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
void createH264Decoder(RTCDecoderIdentifier);
void createH265Decoder(RTCDecoderIdentifier);
void createVP9Decoder(RTCDecoderIdentifier);
void releaseDecoder(RTCDecoderIdentifier);
void decodeFrame(RTCDecoderIdentifier, uint32_t timeStamp, const IPC::DataReference&);
void setFrameSize(RTCDecoderIdentifier, uint16_t width, uint16_t height);
void createEncoder(RTCEncoderIdentifier, const String&, const Vector<std::pair<String, String>>&, bool useLowLatency);
void releaseEncoder(RTCEncoderIdentifier);
void initializeEncoder(RTCEncoderIdentifier, uint16_t width, uint16_t height, unsigned startBitrate, unsigned maxBitrate, unsigned minBitrate, uint32_t maxFramerate);
void encodeFrame(RTCEncoderIdentifier, WebCore::RemoteVideoSample&&, uint32_t timeStamp, bool shouldEncodeAsKeyFrame);
void setEncodeRates(RTCEncoderIdentifier, uint32_t bitRate, uint32_t frameRate);
CFDictionaryRef ioSurfacePixelBufferCreationOptions(IOSurfaceRef);
GPUConnectionToWebProcess& m_gpuConnectionToWebProcess;
HashMap<RTCDecoderIdentifier, webrtc::LocalDecoder> m_decoders;
HashMap<RTCEncoderIdentifier, webrtc::LocalEncoder> m_encoders;
Ref<WorkQueue> m_queue;
std::unique_ptr<WebCore::ImageTransferSessionVT> m_imageTransferSession;
};
}
#endif