Re: [webm-discuss] Error while building WebRTC for linux x64

399 views
Skip to first unread message

James Zern

unread,
Apr 4, 2018, 2:30:52 AM4/4/18
to discuss...@googlegroups.com
Hi,

On Tue, Apr 3, 2018 at 12:49 AM <yihun...@gmail.com> wrote:
Hi All

I am trying to build webrtc version 59 , using the following:

ninja -C out/default CCServiceUnit

How to solve the error?

I don't see anything libvpx specific here, adding discuss-webrtc and moving webm-discuss to bcc.
 

Thank you. yh

I get the the following error: 

root@ubuntu-VirtualBox:/home/ubuntu/webrtc-checkout/src# ninja -C out/default CCServiceUnit
ninja: Entering directory `out/default'
[6/6] LINK ./CCServiceUnit
FAILED: CCServiceUnit 
python "../../build/toolchain/gcc_link_wrapper.py" --output="./CCServiceUnit" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--no-as-needed -lpthread -Wl,--as-needed -fuse-ld=gold -B../../third_party/binutils/Linux_x64/Release/bin -Wl,--threads -Wl,--thread-count=4 -Wl,--icf=all -m64 -pthread -Werror -Wl,--gdb-index -Wl,-rpath-link=. -Wl,--disable-new-dtags -L/usr/local/lib -o "./CCServiceUnit" -Wl,--start-group @"./CCServiceUnit.rsp"  -Wl,--end-group  /usr/local/lib/libjemalloc.a -ldl -lrt -lsocketiopoco -lx264 -lavcodec_fl2 -lavformat_fl2 -lavfilter_fl2 -lswscale_fl2 -lavutil_fl2 -lvo-aacenc -lPocoFoundationd -lPocoJSONd -lPocoNetd -lPocoNetSSLd -lXext -lX11 -lXcomposite -lXrender -lexpat -lm -lconfig++ 
../../webrtc/base/checks.h:176: error: undefined reference to 'std::string* rtc::MakeCheckOpString<unsigned long, unsigned long>(unsigned long const&, unsigned long const&, char const*)'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:496: error: undefined reference to 'webrtc::CreateIceCandidate(std::string const&, int, std::string const&, webrtc::SdpParseError*)'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:535: error: undefined reference to 'webrtc::CreateSessionDescription(std::string const&, std::string const&, webrtc::SdpParseError*)'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:360: error: undefined reference to 'Json::Value::asString() const'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:369: error: undefined reference to 'rtc::GetStringFromJsonObject(Json::Value const&, std::string const&, std::string*)'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:370: error: undefined reference to 'rtc::GetIntFromJsonObject(Json::Value const&, std::string const&, int*)'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:371: error: undefined reference to 'rtc::GetStringFromJsonObject(Json::Value const&, std::string const&, std::string*)'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:387: error: undefined reference to 'rtc::GetStringFromJsonObject(Json::Value const&, std::string const&, std::string*)'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:638: error: undefined reference to 'webrtc::CreateSessionDescription(std::string const&, std::string const&, webrtc::SdpParseError*)'
../../webrtc/base/array_view.h:149: error: undefined reference to 'rtc::FatalMessage::FatalMessage(char const*, int, std::string*)'
../../webrtc/base/array_view.h:150: error: undefined reference to 'rtc::FatalMessage::FatalMessage(char const*, int, std::string*)'
../../webrtc/base/array_view.h:151: error: undefined reference to 'rtc::FatalMessage::FatalMessage(char const*, int, std::string*)'
../../webrtc/base/array_view.h:149: error: undefined reference to 'rtc::FatalMessage::FatalMessage(char const*, int, std::string*)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.



PS

BUILD.gn file

defines = [] 
cflags_cc =[]
        defines += [
            "WEBRTC_POSIX",
            "_GLIBCXX_USE_CXX11_ABI=0",
        ]
if (is_linux) {
    executable("CCServiceUnit") {
        defines += [
            "WEBRTC_POSIX",
            "_GLIBCXX_USE_CXX11_ABI=0",
        ]
        cflags_cc += [ "-std=c++0x" ]
        sources = [
            "conductor.cc",
            "conductor.h",
            "main.cc",
            "channel/SocketIOChannel.h",
            "channel/SUSocketIOChannel.h",
            "channel/SUSocketIOChannel.cc",
            "channel/TestProgramChannel.h",
            "channel/TestProgramChannel.cc",
            "utils/flags/flagdefs.h",
        ]
        deps = [
            "//third_party/jsoncpp:jsoncpp",
            ":fl2_peerconnection",
        ]
        include_dirs = [".","//third_party/libyuv/include"]
        libs = ["/usr/local/lib/libjemalloc.a"]
    }
    static_library("fl2_utils") {
        cflags_cc += [ "-std=c++11" ]
        sources = [
            "utils/bitvector.h",
            "utils/buffer.h",
            "utils/callback.h",
            "utils/lock.cc",
            "utils/lock.h",
            "utils/parser.cc",
            "utils/parser.h",
            "utils/ptr.h",
            "utils/thread.h",
            "utils/timedloop.cc",
            "utils/timedloop.h",
            "utils/timestamp.h",
            "utils/tqueue.h",
            "utils/util.h",
            "utils/util.cc",
            "utils/xsleep.h",
        ]
        include_dirs = ["."]
        libs = ["config++"]

    }
    static_library("fl2_transcoder"){
        cflags_cc += [ "-std=c++11" ]
        sources = [
            "transcoder/gpl/DataStructure.h",
            "transcoder/gpl/x264Encoder.cc",
            "transcoder/gpl/x264Encoder.h",
            "transcoder/AVDecoder.cc",
            "transcoder/AVDecoder.h",
            "transcoder/buflogic.h",
            "transcoder/framerate.h",
            "transcoder/image2.cc",
            "transcoder/image2.h",
            "transcoder/LibAvTextAdder.cc",
            "transcoder/LibAvTextAdder.h",
            "transcoder/playback_buffer.cc",
            "transcoder/playback_buffer.h",
            "transcoder/tavarua_data_structure.h",
            "transcoder/tavarua_mode.h",
        ]
        include_dirs = ["."]
        lib_dirs = ["/usr/local/lib"]
        libs = [
            "x264",
            "avcodec_fl2",
            "avformat_fl2",
            "avfilter_fl2",
            "swscale_fl2",
            "avutil_fl2",
            "vo-aacenc",
         ]
    }
    static_library("fl2_peerconnection"){
        cflags_cc += [
            "-std=c++11",
            "-Wno-sign-compare",
            "-Wno-overloaded-virtual",
            "-Wno-deprecated-declarations",
            "-Wno-uninitialized",
            "-Wno-return-type"
        ]
        sources = [
            "file/file_io2.cc",
            "file/file_io2.h",
            "file/file_scanner.cc",
            "file/file_scanner.h",
            "file/LiveBufferWriter.cc",
            "file/LiveBufferWriter.h",
            "file/MediaFileWriter.cc",
            "file/MediaFileWriter.h",
            "file/MediaWriter.cc",
            "file/MediaWriter.h",
            "file/MediaWriterInterface.h",
            "file/MMAPfileWriter.cc",
            "file/MMAPfileWriter.h",
            "webrtc/AudioMixer.cc",
            "webrtc/AudioMixer.h",
            "webrtc/AudioSetting.h",
            "webrtc/AudioVirtualDeviceModule.cc",
            "webrtc/AudioVirtualDeviceModule.h",
            "webrtc/AVCodecContextDeleter.h",
            "webrtc/defaults.cc",
            "webrtc/defaults.h",
            "webrtc/ForwardVideoDecoder.cc",
            "webrtc/ForwardVideoDecoder.h",
            "webrtc/ForwardVideoDecoderFactory.cc",
            "webrtc/ForwardVideoDecoderFactory.h",
            "webrtc/ForwardVideoEncoder.cc",
            "webrtc/ForwardVideoEncoder.h",
            "webrtc/ForwardVideoEncoderFactory.cc",
            "webrtc/ForwardVideoEncoderFactory.h",
            "webrtc/VirtualVideoRenderer.cc",
            "webrtc/VirtualVideoRenderer.h",
            "webrtc/PeerConnectionController.cc",
            "webrtc/PeerConnectionController.h",
            "webrtc/PeerConnectionSession.cc",
            "webrtc/PeerConnectionSession.h",
            "webrtc/PeerConnectionSessionInterface.cc",
            "webrtc/PeerConnectionSessionInterface.h",
            "webrtc/QueueVideoCapturer.cc",
            "webrtc/QueueVideoCapturer.h",
            "webrtc/RTCMediaConstraints.cc",
            "webrtc/RTCMediaConstraints.h",
            "webrtc/TypedMessageData2.h",
            "webrtc/WebRtcAACEncoder.cc",
            "webrtc/WebRtcAACEncoder.h",
            "webrtc/WebRtcLibAvDecoder.cc",
            "webrtc/WebRtcLibAvDecoder.h",
            "webrtc/WebRtcOpusDecoder.cc",
            "webrtc/WebRtcOpusDecoder.h",
            "webrtc/WebRtcOpusEncoder.cc",
            "webrtc/WebRtcOpusEncoder.h",
            "webrtc/WebRtcVP8Encoder.cc",
            "webrtc/WebRtcVP8Encoder.h",
            "webrtc/WrapEncodedFrame.h",
            "webrtc/WebRtcX264Encoder.cc",
            "webrtc/WebRtcX264Encoder.h",
        ]
        deps = [
            "//third_party/jsoncpp:jsoncpp",
            "//webrtc/modules/video_coding:webrtc_vp8",
            "//webrtc/modules/video_coding:webrtc_vp9",
            "//third_party/libvpx:libvpx",
            "//webrtc/api:libjingle_peerconnection_api",
            "//webrtc/pc:libjingle_peerconnection",
            "//webrtc/base:rtc_base_approved",
            "//webrtc/base:rtc_base",
            "//webrtc/system_wrappers:field_trial_default",
            "//webrtc/modules/congestion_controller:congestion_controller",
            "//webrtc/system_wrappers:metrics_default",
            "//third_party/libyuv",
            "//webrtc/api:video_frame_api",
            "//webrtc/media:rtc_media",
            "//webrtc/modules/video_capture:video_capture_module",
            ":fl2_utils",
            ":fl2_transcoder",
        ]
        public_deps = [
            "//third_party/libvpx:libvpx",
        ]
        include_dirs = [".","//third_party/libyuv/include"]
        lib_dirs = ["/usr/local/lib"]
        libs = [
            "socketiopoco",
            "x264",
            "avcodec_fl2",
            "avformat_fl2",
            "avfilter_fl2",
            "swscale_fl2",
            "avutil_fl2",
            "vo-aacenc",
        ]
        if(is_debug){
                libs += [
                    "PocoFoundationd",
                    "PocoJSONd",
                    "PocoNetd",
                    "PocoNetSSLd",
                ]
            }else{
                libs += [
                    "PocoFoundation",
                    "PocoJSON",
                    "PocoNet",
                    "PocoNetSSL",
                ]
            }
        }
        static_library("QC3ClientProtocol") {
            cflags_cc += [ "-std=c++11" ]
            sources = [
                "channel/ClientSocketIOChannel.cc",
                "channel/ClientSocketIOChannel.h",
                "channel/QC3ClientProtocol.cc",
                "channel/QC3ClientProtocol.h",
                "channel/SocketIOChannel.h",
                "channel/SUSocketIOChannel.cc",
                "channel/SUSocketIOChannel.h",
            ]
            include_dirs = ["."]            
            deps = ["//webrtc/api:libjingle_peerconnection_api",]
            if(is_debug){
                libs = [
                    "PocoFoundationd",
                    "PocoJSONd",
                    "PocoNetd",
                    "PocoNetSSLd",
                ]
            }else{
                libs = [
                    "PocoFoundation",
                    "PocoJSON",
                    "PocoNet",
                    "PocoNetSSL",
                ]
            }

         }
         
        static_library("fl2_xv") {
            cflags_cc += [ "-std=c++11" ]
            sources = [
                "xv/video_out.h",
                "xv/xv.cc",
                "xv/xv.h",
                "xv/xv2.cc",
                "xv/xv2.h",
                "xv/XvViewer.cc",
                "xv/XvViewer.h",
                "xv/xwin.cc",
                "xv/xwin.h",
            ]
            libs = [
                "X11",
                "Xv",
                "Xcomposite",
                "Xext",
                "Xrender",
            ]
            include_dirs = ["."]
 
    }
}




--
You received this message because you are subscribed to the Google Groups "WebM Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webm-discuss...@webmproject.org.
To post to this group, send email to webm-d...@webmproject.org.
Visit this group at https://groups.google.com/a/webmproject.org/group/webm-discuss/.
For more options, visit https://groups.google.com/a/webmproject.org/d/optout.

Patrik Höglund

unread,
Apr 4, 2018, 5:02:02 AM4/4/18
to discuss-webrtc
Hmm. Does fl2_peerconnection link on its own?

The implementation of webrtc::CreateIceCandidate is in jsepicecandidate.cc, which is in the pc:peerconnection target. You should get that one indirectly through your dependency on pc:libjingle_peerconnection. I guess you can try adding pc:peerconnection to the deps list and hack the visibility to make it work, if necessary, but I don't think it should make a difference.

/ P

Hi,

To unsubscribe from this group and stop receiving emails from it, send an email to webm-discuss+unsubscribe@webmproject.org.

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrtc+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/CABWgkXL1T%3DWGp-2umk0FSgPtJbKdO4sM%2BBLhhNJXcKKbcRJ4QA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

yihungbakj hung

unread,
Apr 8, 2018, 11:05:16 PM4/8/18
to discuss-webrtc

Hi Patrik Höglund

Yes, it does.  I have replaced pc:libjingle_peerconnection with pc:peerconnection (rebuild).
The result seems correct, but the error message still appears....

root@ubuntu-VirtualBox:/home/ubuntu/webrtc-checkout/src# ninja -C out/default CCServiceUnit
ninja: Entering directory `out/default'
[6/6] LINK ./CCServiceUnit
FAILED: CCServiceUnit 
python "../../build/toolchain/gcc_link_wrapper.py" --output="./CCServiceUnit" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--no-as-needed -lpthread -Wl,--as-needed -fuse-ld=gold -B../../third_party/binutils/Linux_x64/Release/bin -Wl,--threads -Wl,--thread-count=4 -Wl,--icf=all -m64 -pthread -Werror -Wl,--gdb-index -Wl,-rpath-link=. -Wl,--disable-new-dtags -L/usr/local/lib -o "./CCServiceUnit" -Wl,--start-group @"./CCServiceUnit.rsp"  -Wl,--end-group  /usr/local/lib/libjemalloc.a -ldl -lrt -lsocketiopoco -lx264 -lavcodec_fl2 -lavformat_fl2 -lavfilter_fl2 -lswscale_fl2 -lavutil_fl2 -lvo-aacenc -lPocoFoundationd -lPocoJSONd -lPocoNetd -lPocoNetSSLd -lXext -lX11 -lXcomposite -lXrender -lexpat -lm -lconfig++ 
../../CCServiceUnit/channel/SUSocketIOChannel.cc:45: error: undefined reference to 'Poco::Net::HTTPResponse::getCookies(std::__debug::vector<Poco::Net::HTTPCookie, std::allocator<Poco::Net::HTTPCookie> >&) const'
../../CCServiceUnit/channel/SUSocketIOChannel.cc:73: error: undefined reference to 'SIOClient::connect(Poco::Net::HTTPClientSession*, std::__debug::vector<Poco::Net::HTTPCookie, std::allocator<Poco::Net::HTTPCookie> >&, std::string const&, bool)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Can you help me how solve this problem? 
Thank you.

yh



Patrik Höglund於 2018年4月4日星期三 UTC+8下午5時02分02秒寫道:
Hi,

To unsubscribe from this group and stop receiving emails from it, send an email to webm-discuss...@webmproject.org.

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.

Patrik Höglund

unread,
Apr 10, 2018, 3:55:45 AM4/10/18
to discuss-webrtc
Hi!

On Mon, Apr 9, 2018 at 5:05 AM, yihungbakj hung <yihun...@gmail.com> wrote:

Hi Patrik Höglund

Yes, it does.  I have replaced pc:libjingle_peerconnection with pc:peerconnection (rebuild).
The result seems correct, but the error message still appears....

root@ubuntu-VirtualBox:/home/ubuntu/webrtc-checkout/src# ninja -C out/default CCServiceUnit
ninja: Entering directory `out/default'
[6/6] LINK ./CCServiceUnit
FAILED: CCServiceUnit 
python "../../build/toolchain/gcc_link_wrapper.py" --output="./CCServiceUnit" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--no-as-needed -lpthread -Wl,--as-needed -fuse-ld=gold -B../../third_party/binutils/Linux_x64/Release/bin -Wl,--threads -Wl,--thread-count=4 -Wl,--icf=all -m64 -pthread -Werror -Wl,--gdb-index -Wl,-rpath-link=. -Wl,--disable-new-dtags -L/usr/local/lib -o "./CCServiceUnit" -Wl,--start-group @"./CCServiceUnit.rsp"  -Wl,--end-group  /usr/local/lib/libjemalloc.a -ldl -lrt -lsocketiopoco -lx264 -lavcodec_fl2 -lavformat_fl2 -lavfilter_fl2 -lswscale_fl2 -lavutil_fl2 -lvo-aacenc -lPocoFoundationd -lPocoJSONd -lPocoNetd -lPocoNetSSLd -lXext -lX11 -lXcomposite -lXrender -lexpat -lm -lconfig++ 
../../CCServiceUnit/channel/SUSocketIOChannel.cc:45: error: undefined reference to 'Poco::Net::HTTPResponse::getCookies(std::__debug::vector<Poco::Net::HTTPCookie, std::allocator<Poco::Net::HTTPCookie> >&) const'
../../CCServiceUnit/channel/SUSocketIOChannel.cc:73: error: undefined reference to 'SIOClient::connect(Poco::Net::HTTPClientSession*, std::__debug::vector<Poco::Net::HTTPCookie, std::allocator<Poco::Net::HTTPCookie> >&, std::string const&, bool)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Can you help me how solve this problem? 
Thank you.

yh



Ok, looks like adding pc:peerconnection fixed the problem. The two remaining errors are in the Poco:: and SIOClient:: namespaces, which is outside of the WebRTC code, so you have to fix those by yourself.

As for how the problem got fixed, it sounds like you're confused. Consider the following example:

executable("meh") {
  sources = ["meh.cc"]
  deps = [
      "../pc:libjingle_peerconnection",
      "../api:libjingle_peerconnection_api",
      "../system_wrappers:field_trial_default",
      "../system_wrappers:metrics_default",
      "../system_wrappers:runtime_enabled_features_default",
  ]
  if (!build_with_chromium && is_clang) {
    # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
    configs -= [ "//build/config/clang:find_bad_constructs" ]
  }
}

meh.cc:
#include "api/jsepicecandidate.h"

int main(int argc, char** argv) {
  webrtc::CreateIceCandidate("!!", 17, "18", nullptr);
  return 0;
}

If I remove "../pc:libjingle_peerconnection" from deps, I get the expected link error:

python "../../build/toolchain/gcc_link_wrapper.py" --output="./meh" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--no-as-needed -lpthread -Wl,--as-needed -fuse-ld=lld -Wl,--icf=all -m64 -Werror -Wl,--gdb-index -Wl,--fatal-warnings -nostdlib++ --sysroot=../../build/linux/debian_sid_amd64-sysroot -L../../build/linux/debian_sid_amd64-sysroot/usr/local/lib/x86_64-linux-gnu -Wl,-rpath-link=../../build/linux/debian_sid_amd64-sysroot/usr/local/lib/x86_64-linux-gnu -L../../build/linux/debian_sid_amd64-sysroot/lib/x86_64-linux-gnu -Wl,-rpath-link=../../build/linux/debian_sid_amd64-sysroot/lib/x86_64-linux-gnu -L../../build/linux/debian_sid_amd64-sysroot/usr/lib/x86_64-linux-gnu -Wl,-rpath-link=../../build/linux/debian_sid_amd64-sysroot/usr/lib/x86_64-linux-gnu -Wl,-rpath-link=. -Wl,--disable-new-dtags -o "./meh" -Wl,--start-group @"./meh.rsp"  -Wl,--end-group   -ldl -lpthread -lrt -lXext -lX11 -lXcomposite -lXrender 
~/dev/webrtc/src/out/Default/../../third_party/llvm-build/Release+Asserts/bin/ld.lld: error: undefined symbol: webrtc::CreateIceCandidate(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, webrtc::SdpParseError*)
>>> referenced by meh.cc:4 (../../ortc/meh.cc:4)
>>>               obj/ortc/meh/meh.o:(main)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

If I add "../pc:libjingle_peerconnection" back, it links. If I replace it with "../pc:peerconnection", it also links. This is what I would have expected, since

rtc_source_set("libjingle_peerconnection") {
  visibility = [ "*" ]
  deps = [
    ":create_pc_factory",
    ":peerconnection",
    "../api:libjingle_peerconnection_api",
  ]
}

transitively includes pc:peerconnection for you. This correctly puts pc:peerconnection to the right of CCServiceUnit in the linker order, and the linker will resolve CreateIceCandidate when it gets to pc:peerconnection.

Note that gn enforces that you directly depend on targets you #include from, but you don't have to directly depend on targets that has a .cc with a symbol you need. Transitive deps are fine (perhaps even encouraged) there. Either way, it's almost always the case that .h and .cc files live together in the WebRTC repo, but there some exceptions where api/ targets declare a bunch of things in .h files and it's up to you to choose your implementation. api:libjingle_peerconnection_api and pc:peerconnection have this relationship, for instance.

/ P
 
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrtc+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/81e9e754-9d7c-4eb0-bebf-3f5ae9d8690a%40googlegroups.com.

yihungbakj hung

unread,
Apr 12, 2018, 7:01:07 PM4/12/18
to discuss-webrtc
Thank you.

Following your suggestions. I solved it, gn args add deps = [ "//webrtc/api:libjingle_peerconnection_api", "//webrtc/pc:libjingle_peerconnection", ]. 

I have some questions I would like to ask.

1. How to replace "SignalFrameCaptured" with "OnFrame"  in my code?

2. How to replace "cricket::CapturedFrame" with "webrtc::VideoFrame"  in my code?

Here is my code.

bool QueueVideoCapturer::CaptureCustomFrame(const shared_ptr<CaptureFrame>& cf) {

if (!running_) {
return false;
}

int width = GetCaptureFormat()->width;
int height = GetCaptureFormat()->height;
int fourcc = GetCaptureFormat()->fourcc;

if(cf) {
if(start_rtc_timestamp==-1) {
start_rtc_timestamp = cf->rtc_timestamp;
}

// Currently, |fourcc| is always I420 or ARGB.
// TODO(fbarchard): Extend SizeOf to take fourcc.
uint32_t size = 0u;
if (fourcc == cricket::FOURCC_ARGB) {
size = width * 4 * height;
} else if (fourcc == cricket::FOURCC_I420) {
size = FrameSizeOf(width, height);
} else {
return false; // Unsupported FOURCC.
}
if (size == 0u) {
return false; // Width and/or Height were zero.
}
#if 0
cricket::CapturedFrame frame; <-- 1
frame.width = cf->width;
frame.height = cf->height;
frame.fourcc = fourcc;
frame.data_size = cf->frame_size;
frame.time_stamp = cf->rtc_timestamp * 1000;//webrtc::TickTime::MicrosecondTimestamp()*1000;
frame.data = cf->frame.get_data();
SignalFrameCaptured(this, &frame); <-- 2
#else
rtc::scoped_refptr<webrtc::I420Buffer> buffer(webrtc::I420Buffer::Create(cf->width, cf->height));
buffer->InitializeData();
int crop_x;
int crop_y;
int crop_width;
int crop_height;
const uint8_t* y_plane = (const uint8_t*)(cf->frame.get_data());
const uint8_t* uv_plane = y_plane + width * height;
int uv_width = (width + 1) / 2;
crop_x &= ~1;
crop_y &= ~1;
libyuv::NV12ToI420Rotate(
      y_plane + width * crop_y + crop_x, width,
      uv_plane + uv_width * crop_y + crop_x, width, buffer->MutableDataY(),
      buffer->StrideY(),
      // Swap U and V, since we have NV21, not NV12.
      buffer->MutableDataV(), buffer->StrideV(), buffer->MutableDataU(),
      buffer->StrideU(), crop_width, crop_height,
      static_cast<libyuv::RotationMode>(0));

const webrtc::VideoFrame frame(buffer, webrtc::kVideoRotation_0, cf->rtc_timestamp * 1000);
this->OnFrame(frame, cf->width, cf->height);

#endif
}
return true;
}

Patrik Höglund於 2018年4月10日星期二 UTC+8下午3時55分45秒寫道:
Hi!

Reply all
Reply to author
Forward
0 new messages