RemoteCaptureSampleManager.h [plain text]
#pragma once
#if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
#include "Connection.h"
#include "MessageReceiver.h"
#include "RemoteRealtimeMediaSource.h"
#include "SharedMemory.h"
#include <WebCore/CAAudioStreamDescription.h>
#include <WebCore/CARingBuffer.h>
#include <WebCore/WebAudioBufferList.h>
#include <wtf/HashMap.h>
#include <wtf/WorkQueue.h>
namespace WebKit {
class RemoteCaptureSampleManager : public IPC::Connection::ThreadMessageReceiverRefCounted {
WTF_MAKE_FAST_ALLOCATED;
public:
RemoteCaptureSampleManager();
~RemoteCaptureSampleManager();
void addSource(Ref<RemoteRealtimeMediaSource>&&);
void removeSource(WebCore::RealtimeMediaSourceIdentifier);
void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
private:
void dispatchToThread(Function<void()>&&) final;
void audioStorageChanged(WebCore::RealtimeMediaSourceIdentifier, const SharedMemory::IPCHandle&, const WebCore::CAAudioStreamDescription&, uint64_t numberOfFrames);
void audioSamplesAvailable(WebCore::RealtimeMediaSourceIdentifier, MediaTime, uint64_t numberOfFrames);
void setConnection(IPC::Connection*);
class RemoteAudio {
WTF_MAKE_FAST_ALLOCATED;
public:
explicit RemoteAudio(Ref<RemoteRealtimeMediaSource>&&);
void setStorage(const SharedMemory::Handle&, const WebCore::CAAudioStreamDescription&, uint64_t numberOfFrames);
void audioSamplesAvailable(MediaTime, uint64_t numberOfFrames);
private:
Ref<RemoteRealtimeMediaSource> m_source;
WebCore::CAAudioStreamDescription m_description;
std::unique_ptr<WebCore::CARingBuffer> m_ringBuffer;
std::unique_ptr<WebCore::WebAudioBufferList> m_buffer;
};
Ref<WorkQueue> m_queue;
RefPtr<IPC::Connection> m_connection;
HashMap<WebCore::RealtimeMediaSourceIdentifier, std::unique_ptr<RemoteAudio>> m_sources;
};
}
#endif