summaryrefslogtreecommitdiffstats
path: root/pica-client/videodshow.cpp
Commit message (Collapse)AuthorAgeFilesLines
* pica-client: fix capture at requested fpsAnton2026-10-031-6/+19
|
* pica-client: configurable resolutions, codecs, bitrates for a callAnton2026-09-261-5/+235
|
* pica-client: compressed camera formats on WindowsAnton2026-08-241-0/+261
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Lets a camera's own H.264 or MJPEG go straight onto the network on Windows as it already could on Linux, so nothing has to be decoded and re-encoded. Finding out what a camera offers takes rather more than the single v4l2 ioctl it takes on Linux: the camera has to be instantiated, its output pins found, and each pin's stream capabilities walked through IAMStreamConfig, reading the FourCC out of the BITMAPINFOHEADER in every media type. Asking for the result is spelled differently too - dshow has no input_format option and takes the choice from AVFormatContext::video_codec_id instead, which is what "-vcodec mjpeg" ahead of "-i" sets, and which has to be set on a context allocated by us rather than by avformat_open_input(). Opening now loosens its constraints a step at a time rather than giving up on the format at the first refusal. Listing a format, producing it at a given size, and producing it at a given frame rate are three separate claims, and cameras honour them independently: an integrated webcam here offers MJPEG but not at 640x480 15fps, and was falling all the way back to re-encoding. The frame rate is given up first, then the size, and the format last, since the format is the one that decides whether anything has to be re-encoded at all. What the camera settles on is what gets announced to the peer, so this changes what is sent rather than what is claimed about it. That relaxation exposed an assumption that was already wrong: the encoder was hard-wired to kFrameRate with a plain incrementing pts, while the pre-existing "let the camera choose" fallback had always been able to open without a frame rate at all. A camera delivering 30fps therefore produced a stream whose timestamps claimed half that. It now takes the rate from the opened stream, and the keyframe interval with it, so two seconds between keyframes stays two seconds - kGopSize is gone, a fixed frame count no longer meaning a fixed duration. Every FourCC a camera reports is logged, mapped or not. An integrated camera offering nothing but uncompressed types while advertising MJPEG under v4l2 would have meant the Windows Camera Frame Server had already decoded it, with nothing to be done from here - worth being able to tell apart from a FourCC we simply failed to map, which is what this turned out not to be. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CBqDgvq3Ty6C6BjLFH16bw
* pica-client: camera enumeration and capture on WindowsAnton2026-08-241-0/+172
Capture already went through FFmpeg's "dshow" demuxer, which does the job - unlike the audio case there is nothing here the platform offers that we cannot reach any other way, so there is no reason to drive DirectShow ourselves. Two things were missing to make it work. Enumeration, because the demuxer has none: it can only print device names to the log with -list_devices, which is no use to a settings dialog. The list is built in videodshow.cpp instead, walking the same CLSID_VideoInputDeviceCategory the demuxer walks, so the names handed back are the ones it matches on. Where a friendly name is not unique - two identical cameras - later duplicates fall back to the device path, which the demuxer also accepts. And the "video=" prefix, since DirectShow namespaces its devices by type and the same name behind "audio=" would be a microphone. The name is stored unprefixed and decorated at open time, so what the settings dialog shows and writes stays readable. Also adds a last-resort open with no constraints at all. DirectShow refuses a video_size or framerate it cannot produce exactly rather than settling for the nearest, so a camera with an unusual set of modes would otherwise give no picture; whatever comes back is scaled by the transcode loop anyway. The failure message on Windows now names the likely cause. A camera that enumerated but will not open is usually not a broken camera: Windows lists devices it then refuses to instantiate, which is what the "Let desktop apps access your camera" privacy setting being off looks like from here, and what another application holding the camera looks like too. None of them are distinguishable from a real fault at that level, and the bare "I/O error" sent me looking at the wrong layer entirely. compressedFormats is left empty on Windows, so "prefer compressed formats" has no effect there - finding out what a DirectShow camera can deliver means walking its output pin's media types through IAMStreamConfig, which is a good deal more than the one v4l2 ioctl that fills this in on Linux. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CBqDgvq3Ty6C6BjLFH16bw