void DesktopCapturer::Run() { RTC_LOG(INFO) << "DesktopCapturer:Run start"; while (IsRunning()) { m_capturer->CaptureFrame(); } RTC_LOG(INFO) << "DesktopCapturer:Run exit"; }
void DesktopCapturer::OnCaptureResult(webrtc::DesktopCapturer::Result result, std::unique_ptr<webrtc::DesktopFrame> frame) { RTC_LOG(INFO) << "DesktopCapturer:OnCaptureResult"; if (result == webrtc::DesktopCapturer::Result::SUCCESS) { int width = frame->rect().width(); int height = frame->rect().height(); rtc::scoped_refptr<webrtc::I420Buffer> I420buffer = webrtc::I420Buffer::Create(width, height); const int conversionResult = libyuv::ConvertToI420(frame->data(), frame->stride()*webrtc::DesktopFrame::kBytesPerPixel, I420buffer->MutableDataY(), I420buffer->StrideY(), I420buffer->MutableDataU(), I420buffer->StrideU(), I420buffer->MutableDataV(), I420buffer->StrideV(), 0, 0, width, height, width, height, libyuv::kRotate0, ::libyuv::FOURCC_ARGB); if (conversionResult >= 0) { webrtc::VideoFrame videoFrame(I420buffer, webrtc::VideoRotation::kVideoRotation_0, rtc::TimeMicros()); if ( (m_height == 0) && (m_width == 0) ) { broadcaster_.OnFrame(videoFrame); } else { int height = m_height; int width = m_width; if (height == 0) { height = (videoFrame.height() * width) / videoFrame.width(); } else if (width == 0) { width = (videoFrame.width() * height) / videoFrame.height(); } int stride_y = width; int stride_uv = (width + 1) / 2; rtc::scoped_refptr<webrtc::I420Buffer> scaled_buffer = webrtc::I420Buffer::Create(width, height, stride_y, stride_uv, stride_uv); scaled_buffer->ScaleFrom(*videoFrame.video_frame_buffer()->ToI420()); webrtc::VideoFrame frame = webrtc::VideoFrame(scaled_buffer, webrtc::kVideoRotation_0, rtc::TimeMicros()); broadcaster_.OnFrame(videoFrame); } } else { RTC_LOG(LS_ERROR) << "DesktopCapturer:OnCaptureResult conversion error:" << conversionResult; } } else { RTC_LOG(LS_ERROR) << "DesktopCapturer:OnCaptureResult capture error:" << (int)result; } }
/*! * @brief logfile出力のテスト * * - ログレベルを ERROR にした場合のファイル出力が正しく行われるか? */ void test_logfile_ERROR(void) { // std::cout << "test_logfile_ERROR() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcERROR.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("ERROR"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("ERROR:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_ERROR"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_ERROR() OUT" << std::endl; }
/*! * @brief コンストラクタログレベルのテスト * * - コンストラクタ(name)の場合、Managerの設定ログレベル(INFO)で動作するか? */ void test_constract_name(void) { // std::cout << "test_constract_name() IN" << std::endl; RTC::Manager* m_mgr; m_mgr = RTC::Manager::init(0, NULL); CPPUNIT_ASSERT(m_mgr != NULL); RTC::Logger rtclog("TestName"); std::string log_level = m_mgr->getLogLevel(); CPPUNIT_ASSERT_EQUAL(std::string("INFO"), log_level); coil::Properties m_config = m_mgr->getConfig(); std::vector<std::string> logouts = coil::split(m_config["logger.file_name"], ","); // 汎用ログ出力マクロ、各種ログ出力マクロでファイル出力 RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); m_mgr->terminate(); // rtc*.log ファイルが作成され、4列目のログレベルが INFO以下か? // INFO WARNING ERROR FATAL SILENT だけが記録されているか? // Aug 03 14:03:09 INFO: manager: OpenRTM-aist-1.0.0 // [0] 1 2 3 4 5 std::string rstr; std::vector<std::string> vstr; bool bret; std::ifstream ifs(logouts[0].c_str()); while(getline(ifs, rstr)) { if(rstr.size() == 0) break; vstr = coil::split(rstr, " "); // ログレベル判定 bret = false; if( (vstr[3] == "INFO:") || (vstr[3] == "WARNING:") || (vstr[3] == "ERROR:") || (vstr[3] == "FATAL:") || (vstr[3] == "SILENT:") ) bret = true; CPPUNIT_ASSERT(bret); // name判定 bret = false; if( (vstr[4] == "manager:") || (vstr[4] == "TestName:") || (vstr[4] == "NamingOnCorba:") || (vstr[4] == "NamingManager:") || (vstr[4] == "ManagerServant:") ) bret = true; CPPUNIT_ASSERT(bret); } // std::cout << "test_constract_name() OUT" << std::endl; }