From 5e34506566d03b0b566fc46c145d0e9d473e9807 Mon Sep 17 00:00:00 2001
From: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
Date: Sat, 9 Nov 2019 16:34:15 -0500
Subject: [PATCH] video macOS: use device id

Change-Id: I341fcfda799bc9bda2f3683a4cf3e59d24bda269
---
 src/media/media_decoder.cpp                   | 10 ++++++++--
 src/media/video/osxvideo/video_device_impl.mm |  2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/media/media_decoder.cpp b/src/media/media_decoder.cpp
index 720ccbfd20..cae92429e0 100644
--- a/src/media/media_decoder.cpp
+++ b/src/media/media_decoder.cpp
@@ -119,13 +119,19 @@ MediaDemuxer::openInput(const DeviceParams& params)
         av_dict_set(&options_, "pixel_format", params.pixel_format.c_str(), 0);
     }
 
-    JAMI_DBG("Trying to open device %s with format %s, pixel format %s, size %dx%d, rate %lf", params.input.c_str(),
+#if defined(__APPLE__) && TARGET_OS_MAC
+    std::string input = params.name;
+#else
+    std::string input = params.input;
+#endif
+
+    JAMI_DBG("Trying to open device %s with format %s, pixel format %s, size %dx%d, rate %lf", input.c_str(),
                                                         params.format.c_str(), params.pixel_format.c_str(), params.width, params.height, params.framerate.real());
 
     av_opt_set_int(inputCtx_, "fpsprobesize", 1, AV_OPT_SEARCH_CHILDREN); // Don't waste time fetching framerate when finding stream info
     int ret = avformat_open_input(
         &inputCtx_,
-        params.input.c_str(),
+        input.c_str(),
         iformat,
         options_ ? &options_ : NULL);
 
diff --git a/src/media/video/osxvideo/video_device_impl.mm b/src/media/video/osxvideo/video_device_impl.mm
index 45a3cbff54..e16cee1c2c 100644
--- a/src/media/video/osxvideo/video_device_impl.mm
+++ b/src/media/video/osxvideo/video_device_impl.mm
@@ -112,7 +112,7 @@ VideoDeviceImpl::getDeviceParams() const
 {
     DeviceParams params;
     params.name = [[avDevice_ localizedName] UTF8String];
-    params.input = [[avDevice_ localizedName] UTF8String];
+    params.input = id;
     params.framerate = rate_;
     params.format = "avfoundation";
     params.pixel_format = "nv12";
-- 
GitLab