From 88274c9bff980b43081341e64e9f54a0e5977c6c Mon Sep 17 00:00:00 2001 From: Michel Promonet Date: Fri, 1 Nov 2024 17:07:58 +0100 Subject: [PATCH] rollback building with g++ --- .github/workflows/cpp-cross-linux-arm.yml | 2 +- .vscode/settings.json | 75 ++++++++++++++++++++++- inc/V4l2AlsaMap.h | 6 +- inc/VideoDecoder.h | 11 +++- inc/VideoScaler.h | 2 +- 5 files changed, 87 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cpp-cross-linux-arm.yml b/.github/workflows/cpp-cross-linux-arm.yml index 96d8c00e..b9009494 100644 --- a/.github/workflows/cpp-cross-linux-arm.yml +++ b/.github/workflows/cpp-cross-linux-arm.yml @@ -76,7 +76,7 @@ jobs: - name: build run: | export PATH=$(pwd)/webrtc/src/third_party/llvm-build/Release+Asserts/bin:$PATH - cmake -DWEBRTCROOT=$(pwd)/webrtc -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} -DCMAKE_LIBRARY_ARCHITECTURE=${{ matrix.prefix }} -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY -DWEBRTCDESKTOPCAPTURE=OFF . + cmake -DWEBRTCROOT=$(pwd)/webrtc -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} -DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} -DCMAKE_LIBRARY_ARCHITECTURE=${{ matrix.prefix }} -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_C_COMPILER=${{ matrix.prefix }}-gcc -DCMAKE_CXX_COMPILER=${{ matrix.prefix }}-g++ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY -DWEBRTCDESKTOPCAPTURE=OFF . make - name: cpack diff --git a/.vscode/settings.json b/.vscode/settings.json index 4fdcdfb1..3c947f76 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,79 @@ "string_view": "cpp", "ranges": "cpp", "span": "cpp", - "vector": "cpp" + "vector": "cpp", + "cstdint": "cpp", + "bitset": "cpp", + "format": "cpp", + "initializer_list": "cpp", + "regex": "cpp", + "valarray": "cpp", + "chrono": "cpp", + "any": "cpp", + "atomic": "cpp", + "strstream": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "cfenv": "cpp", + "charconv": "cpp", + "cinttypes": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "codecvt": "cpp", + "compare": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "forward_list": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "ratio": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "future": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "new": "cpp", + "numbers": "cpp", + "ostream": "cpp", + "scoped_allocator": "cpp", + "semaphore": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "stop_token": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "typeindex": "cpp", + "typeinfo": "cpp", + "variant": "cpp" } } \ No newline at end of file diff --git a/inc/V4l2AlsaMap.h b/inc/V4l2AlsaMap.h index 4b9f4d81..0d8207c1 100644 --- a/inc/V4l2AlsaMap.h +++ b/inc/V4l2AlsaMap.h @@ -11,6 +11,7 @@ #ifdef HAVE_V4L2 #include +#include #include #include #include @@ -38,13 +39,12 @@ std::string getDeviceId(const std::string& devicePath) { std::map videoDev2Idx() { std::map dev2idx; uint32_t count = 0; - char device[20]; int fd = -1; struct v4l2_capability cap; for (int devId = 0; devId < 64; devId++) { - snprintf(device, sizeof(device), "/dev/video%d", devId); - if ((fd = open(device, O_RDONLY)) != -1) { + std::string device = std::format("/dev/video{}", devId); + if ((fd = open(device.c_str(), O_RDONLY)) != -1) { if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0 || !(cap.device_caps & V4L2_CAP_VIDEO_CAPTURE)) { close(fd); diff --git a/inc/VideoDecoder.h b/inc/VideoDecoder.h index 90760cea..abcce114 100644 --- a/inc/VideoDecoder.h +++ b/inc/VideoDecoder.h @@ -153,12 +153,17 @@ class VideoDecoder : public rtc::VideoSourceInterface, publi int64_t ts = std::chrono::high_resolution_clock::now().time_since_epoch().count()/1000/1000; RTC_LOG(LS_VERBOSE) << "VideoDecoder::Decoded size:" << decodedImage.size() - << " decode ts:" << decodedImage.ntp_time_ms() + << " decode rtptime:" << decodedImage.rtp_timestamp() + << " decode ts:" << decodedImage.timestamp_us()/1000 << " source ts:" << ts; + if (decodedImage.timestamp_us() == 0) { + decodedImage.set_timestamp_us(decodedImage.rtp_timestamp()*1000); + } + // waiting if ( (m_wait) && (m_prevts != 0) ) { - int64_t periodSource = decodedImage.ntp_time_ms() - m_previmagets; + int64_t periodSource = decodedImage.timestamp_us()/1000 - m_previmagets; int64_t periodDecode = ts-m_prevts; RTC_LOG(LS_VERBOSE) << "VideoDecoder::Decoded interframe decode:" << periodDecode << " source:" << periodSource; @@ -172,7 +177,7 @@ class VideoDecoder : public rtc::VideoSourceInterface, publi m_scaler.OnFrame(decodedImage); - m_previmagets = decodedImage.ntp_time_ms(); + m_previmagets = decodedImage.timestamp_us()/1000; m_prevts = std::chrono::high_resolution_clock::now().time_since_epoch().count()/1000/1000; return 1; diff --git a/inc/VideoScaler.h b/inc/VideoScaler.h index aec8e510..4dd84952 100644 --- a/inc/VideoScaler.h +++ b/inc/VideoScaler.h @@ -156,7 +156,7 @@ class VideoScaler : public rtc::VideoSinkInterface, public .set_video_frame_buffer(scaled_buffer) .set_rotation(m_rotation) .set_timestamp_rtp(frame.rtp_timestamp()) - .set_timestamp_ms(frame.render_time_ms()) + .set_timestamp_us(frame.timestamp_us()) .set_id(frame.timestamp_us()) .build();