libwebrtc测试验证

1.创建cmakelists.txt

# CMake 最低版本号要求
cmake_minimum_required (VERSION 3.12)

# 设置指定的C++编译器版本是必须的,如果不设置,或者为OFF,则指定版本不可用时,会使用上一版本。
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 指定为C++11 版本
set(CMAKE_CXX_STANDARD 11)

add_definitions(-DRTC_DESKTOP_DEVICE)

# 项目信息
project(TestLibwebrtc)

link_directories(./)

# 查找当前目录下的所有源文件
# 并将名称保存到 DIR_SRCS 变量
aux_source_directory(. DIR_SRCS)

# 查找当前目录下的所有头文件
include_directories(./)
include_directories(./include/)

# 指定生成目标 
#add_executable(Test ${DIR_SRCS})
add_executable(Test main.cc)
target_link_libraries(Test libwebrtc.dylib)

2.main.cc

#include <iostream>
#include <string>
#include <string.h>
#include <list>
#include <map>
#include <memory>
#include <mutex>
#include <chrono>
#include <thread>

#include "libwebrtc.h"

#include "rtc_audio_device.h"
#include "rtc_desktop_device.h"
#include "rtc_dtmf_sender.h"
#include "rtc_media_stream.h"
#include "rtc_media_track.h"
#include "rtc_mediaconstraints.h"
#include "rtc_peerconnection.h"
#include "rtc_peerconnection_factory.h"
#include "rtc_video_device.h"
#include "rtc_desktop_capturer.h"
#include "rtc_desktop_media_list.h"
using namespace std;
using namespace libwebrtc;
int main() {
  cout<<"------test webrtc start------"<<endl;
  LibWebRTC::Initialize();

  scoped_refptr<RTCPeerConnectionFactory> factory_;
  scoped_refptr<RTCAudioDevice> audio_device_;
  scoped_refptr<RTCVideoDevice> video_device_;
  scoped_refptr<RTCDesktopDevice> desktop_device_;
  factory_ = LibWebRTC::CreateRTCPeerConnectionFactory();
  audio_device_ = factory_->GetAudioDevice();
  video_device_ = factory_->GetVideoDevice();
  desktop_device_ = factory_->GetDesktopDevice();


  //DesktopType desktop_type = DesktopType::kScreen;
  DesktopType desktop_type = DesktopType::kWindow;
  scoped_refptr<RTCDesktopMediaList> source_list;
  source_list = desktop_device_->GetDesktopMediaList(desktop_type);
  source_list->UpdateSourceList();
  int count = source_list->GetSourceCount();
  for (int j = 0; j < count; j++) {
    cout<<"------source list:------"<<source_list->GetSource(j)->name().c_string()<<endl;
  }


  LibWebRTC::Terminate();
  std::this_thread::sleep_for(std::chrono::seconds(1));
  cout<<"test webrtc end"<<endl;
  return 0;
}

3.vscode配置launch.json

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug",
            "program": "/Users/works/electron/libwebrtc_build/webrtc/test/build/Test",
            "args": [],
            "cwd": "${workspaceFolder}",
            "sourceMap": {
                        "./":"/Users/works/electron/libwebrtc_build/webrtc/src/libwebrtc/",
                        "../":"/Users/works/electron/libwebrtc_build/webrtc/src/"
                      }
        }
    ]
}

  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值