X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=input_mapping.cpp;h=45b60095e5af99cadecb01cb88389478974d5cc7;hb=8e86ae071c057a26e933b8452ac541050ba2cb9f;hp=deef92343c75c542b5aa9ecc698e8a4d94dec591;hpb=cf7b9ee186d4ef8e5da0531b75854c97b821be44;p=nageru diff --git a/input_mapping.cpp b/input_mapping.cpp index deef923..45b6009 100644 --- a/input_mapping.cpp +++ b/input_mapping.cpp @@ -14,6 +14,27 @@ using namespace std; using namespace google::protobuf; +string spec_to_string(DeviceSpec device_spec) +{ + char buf[256]; + + switch (device_spec.type) { + case InputSourceType::SILENCE: + return ""; + case InputSourceType::CAPTURE_CARD: + snprintf(buf, sizeof(buf), "Capture card %u", device_spec.index); + return buf; + case InputSourceType::ALSA_INPUT: + snprintf(buf, sizeof(buf), "ALSA input %u", device_spec.index); + return buf; + case InputSourceType::FFMPEG_VIDEO_INPUT: + snprintf(buf, sizeof(buf), "FFmpeg input %u", device_spec.index); + return buf; + default: + assert(false); + } +} + bool save_input_mapping_to_file(const map &devices, const InputMapping &input_mapping, const string &filename) { InputMappingProto mapping_proto; @@ -85,10 +106,15 @@ bool load_input_mapping_from_file(const map &devices, co case DeviceSpecProto::SILENCE: device_mapping.push_back(DeviceSpec{InputSourceType::SILENCE, 0}); break; + case DeviceSpecProto::FFMPEG_VIDEO_INPUT: case DeviceSpecProto::CAPTURE_CARD: { // First see if there's a card that matches on both index and name. - DeviceSpec spec{InputSourceType::CAPTURE_CARD, unsigned(device_proto.index())}; + DeviceSpec spec; + spec.type = (device_proto.type() == DeviceSpecProto::CAPTURE_CARD) ? + InputSourceType::CAPTURE_CARD : InputSourceType::FFMPEG_VIDEO_INPUT; + spec.index = unsigned(device_proto.index()); assert(devices.count(spec)); + const DeviceInfo &dev = devices.find(spec)->second; if (remaining_devices.count(spec) && dev.display_name == device_proto.display_name()) {