Skip to content

armgit / Piik

Public Imported from GitHub
0

Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。

1.4 KB
Raw Blame
#pragma once

#include <windows.h>

#include <cstdint>
#include <functional>
#include <string>

namespace piik::capture {

constexpr UINT32 kAudioSampleRate = 48'000;
constexpr UINT16 kAudioChannels = 2;
constexpr UINT16 kAudioBytesPerSample = 2;
constexpr UINT32 kAudioFramesPerChunk = 960;
constexpr DWORD kAudioBytesPerChunk =
    kAudioFramesPerChunk * kAudioChannels * kAudioBytesPerSample;
constexpr UINT64 kAudioChunkDuration100ns = 200'000;

using PCMWriter =
    std::function<HRESULT(UINT64 timestamp100ns, const BYTE* data, DWORD size)>;
using ReadyWriter = std::function<HRESULT()>;
using StopProbe = std::function<bool()>;

bool ProcessAudioAvailable(bool exclude = false);
bool SystemAudioAvailable();
HRESULT CaptureMicrophone(const std::wstring& device_id, HANDLE stop_event, const StopProbe& stop_probe,
                         const ReadyWriter& ready_writer, const PCMWriter& writer);
HRESULT CaptureProcessAudio(DWORD pid, UINT64 expected_creation_time, bool exclude,
                            HANDLE stop_event, const StopProbe& stop_probe,
                            const ReadyWriter& ready_writer,
                            const PCMWriter& writer);
HRESULT CaptureSystemAudio(HANDLE stop_event, const StopProbe& stop_probe,
                           const ReadyWriter& ready_writer,
                           const PCMWriter& writer);

}  // namespace piik::capture