赞
踩
环境:Ubuntu 16.04
编译器:g++-5.4
设备:需要两个USB摄像头
WebRTC peerconnection在Ubuntu中运行会报错,出现段错误,现针对报错做以下修改。
vi physical_socket_server.cc +1171 注释检测行代码
- //RTC_DCHECK(!waiting_);
-
- //RTC_DCHECK(!*value_);
vi linux/main_wnd.cc
- void GtkMainWnd::OnRedraw()
- {
-
- gdk_threads_enter();
-
- VideoRenderer* remote_renderer = remote_renderer_.get();
- if (remote_renderer && remote_renderer->image() != NULL && draw_area_ != NULL) {
- width_ = remote_renderer->width();
- height_ = remote_renderer->height();
- int width = 640; int height = 480;
- if (!draw_buffer_.get()) {
- draw_buffer_size_ = (width * height) * 4;
- draw_buffer_.reset(new uint8_t[draw_buffer_size_]);
- gtk_widget_set_size_request(draw_area_, width, height);
- }
-
- const uint32_t* image = reinterpret_cast<const uint32_t*>(remote_renderer->image());
- uint32_t* scaled = reinterpret_cast<uint32_t*>(draw_buffer_.get());
- memset(scaled, 0xff, draw_buffer_size_);
- for (int r = 0; r < height_; r += 1) {
- for (int c = 0; c < width_; c += 1) {
- int x = c / 1;
- scaled[x] = image[c];
- }
- image += width_;
- scaled += width_;
- }
- gtk_widget_queue_draw(draw_area_);
- }
-
- gdk_threads_leave();
- }

- void GtkMainWnd::Draw(GtkWidget* widget, cairo_t* cr) {
- #if GTK_MAJOR_VERSION != 2
- cairo_format_t format = CAIRO_FORMAT_ARGB32;
- cairo_surface_t* surface = cairo_image_surface_create_for_data(
- draw_buffer_.get(), format, width_ * 1, height_ * 1,
- cairo_format_stride_for_width(format, width_ * 1));
- cairo_set_source_surface(cr, surface, 0, 0);
- cairo_rectangle(cr, 0, 0, width_ * 1, height_ * 1);
- cairo_fill(cr);
- cairo_surface_destroy(surface);
- #else
- RTC_DCHECK_NOTREACHED();
- #endif
- }
调试结果
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。