diff --git a/media/sctp/sctptransport.cc b/media/sctp/sctptransport.cc index 6e047e2a87..b3459858d7 100644 --- a/media/sctp/sctptransport.cc +++ b/media/sctp/sctptransport.cc @@ -36,6 +36,7 @@ enum PreservedErrno { #include "rtc_base/helpers.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" +#include "rtc_base/stringutils.h" #include "rtc_base/thread_checker.h" #include "rtc_base/trace_event.h" #include "usrsctplib/usrsctp.h" @@ -312,8 +313,8 @@ class SctpTransport::UsrSctpWrapper { SctpTransport* transport = static_cast(addr); RTC_LOG(LS_VERBOSE) << "global OnSctpOutboundPacket():" << "addr: " << addr << "; length: " << length - << "; tos: " << std::hex << static_cast(tos) - << "; set_df: " << std::hex << static_cast(set_df); + << "; tos: " << rtc::ToHex(tos) + << "; set_df: " << rtc::ToHex(set_df); VerboseLogPacket(data, length, SCTP_DUMP_OUTBOUND); // Note: We have to copy the data; the caller will delete it. @@ -1056,7 +1057,7 @@ void SctpTransport::OnStreamResetEvent( const int num_sids = (evt->strreset_length - sizeof(*evt)) / sizeof(evt->strreset_stream_list[0]); RTC_LOG(LS_VERBOSE) << "SCTP_STREAM_RESET_EVENT(" << debug_name_ - << "): Flags = 0x" << std::hex << evt->strreset_flags + << "): Flags = 0x" << rtc::ToHex(evt->strreset_flags) << " (" << ListFlags(evt->strreset_flags) << ")"; RTC_LOG(LS_VERBOSE) << "Assoc = " << evt->strreset_assoc_id << ", Streams = [" << ListArray(evt->strreset_stream_list, num_sids) diff --git a/modules/audio_device/win/audio_device_core_win.cc b/modules/audio_device/win/audio_device_core_win.cc index 9476f311b1..731d4614e8 100644 --- a/modules/audio_device/win/audio_device_core_win.cc +++ b/modules/audio_device/win/audio_device_core_win.cc @@ -40,6 +40,7 @@ #include "rtc_base/logging.h" #include "rtc_base/platform_thread.h" +#include "rtc_base/stringutils.h" #include "rtc_base/thread_annotations.h" #include "system_wrappers/include/sleep.h" @@ -1872,8 +1873,8 @@ int32_t AudioDeviceWindowsCore::InitPlayout() { if (SUCCEEDED(hr)) { RTC_LOG(LS_VERBOSE) << "Audio Engine's current rendering mix format:"; // format type - RTC_LOG(LS_VERBOSE) << "wFormatTag : 0x" << std::hex - << pWfxOut->wFormatTag << std::dec << " (" + RTC_LOG(LS_VERBOSE) << "wFormatTag : 0x" + << rtc::ToHex(pWfxOut->wFormatTag) << " (" << pWfxOut->wFormatTag << ")"; // number of channels (i.e. mono, stereo...) RTC_LOG(LS_VERBOSE) << "nChannels : " << pWfxOut->nChannels; @@ -1947,8 +1948,8 @@ int32_t AudioDeviceWindowsCore::InitPlayout() { _playChannels = Wfx.nChannels; RTC_LOG(LS_VERBOSE) << "VoE selected this rendering format:"; - RTC_LOG(LS_VERBOSE) << "wFormatTag : 0x" << std::hex - << Wfx.wFormatTag << std::dec << " (" << Wfx.wFormatTag + RTC_LOG(LS_VERBOSE) << "wFormatTag : 0x" + << rtc::ToHex(Wfx.wFormatTag) << " (" << Wfx.wFormatTag << ")"; RTC_LOG(LS_VERBOSE) << "nChannels : " << Wfx.nChannels; RTC_LOG(LS_VERBOSE) << "nSamplesPerSec : " << Wfx.nSamplesPerSec; @@ -2189,8 +2190,8 @@ int32_t AudioDeviceWindowsCore::InitRecording() { if (SUCCEEDED(hr)) { RTC_LOG(LS_VERBOSE) << "Audio Engine's current capturing mix format:"; // format type - RTC_LOG(LS_VERBOSE) << "wFormatTag : 0x" << std::hex - << pWfxIn->wFormatTag << std::dec << " (" + RTC_LOG(LS_VERBOSE) << "wFormatTag : 0x" + << rtc::ToHex(pWfxIn->wFormatTag) << " (" << pWfxIn->wFormatTag << ")"; // number of channels (i.e. mono, stereo...) RTC_LOG(LS_VERBOSE) << "nChannels : " << pWfxIn->nChannels; @@ -2262,8 +2263,8 @@ int32_t AudioDeviceWindowsCore::InitRecording() { _recChannels = Wfx.Format.nChannels; RTC_LOG(LS_VERBOSE) << "VoE selected this capturing format:"; - RTC_LOG(LS_VERBOSE) << "wFormatTag : 0x" << std::hex - << Wfx.Format.wFormatTag << std::dec << " (" + RTC_LOG(LS_VERBOSE) << "wFormatTag : 0x" + << rtc::ToHex(Wfx.Format.wFormatTag) << " (" << Wfx.Format.wFormatTag << ")"; RTC_LOG(LS_VERBOSE) << "nChannels : " << Wfx.Format.nChannels; RTC_LOG(LS_VERBOSE) << "nSamplesPerSec : " << Wfx.Format.nSamplesPerSec; @@ -3327,8 +3328,8 @@ DWORD AudioDeviceWindowsCore::DoCaptureThread() { // IAudioClient::Stop, IAudioClient::Reset, and releasing the audio // client. RTC_LOG(LS_ERROR) << "IAudioCaptureClient::GetBuffer returned" - << " AUDCLNT_E_BUFFER_ERROR, hr = 0x" << std::hex - << hr << std::dec; + << " AUDCLNT_E_BUFFER_ERROR, hr = 0x" + << rtc::ToHex(hr); goto Exit; } @@ -3841,7 +3842,7 @@ int32_t AudioDeviceWindowsCore::_GetDeviceName(IMMDevice* pDevice, hr = pDevice->OpenPropertyStore(STGM_READ, &pProps); if (FAILED(hr)) { RTC_LOG(LS_ERROR) << "IMMDevice::OpenPropertyStore failed, hr = 0x" - << std::hex << hr << std::dec; + << rtc::ToHex(hr); } } @@ -3853,21 +3854,21 @@ int32_t AudioDeviceWindowsCore::_GetDeviceName(IMMDevice* pDevice, hr = pProps->GetValue(PKEY_Device_FriendlyName, &varName); if (FAILED(hr)) { RTC_LOG(LS_ERROR) << "IPropertyStore::GetValue failed, hr = 0x" - << std::hex << hr << std::dec; + << rtc::ToHex(hr); } } if ((SUCCEEDED(hr)) && (VT_EMPTY == varName.vt)) { hr = E_FAIL; RTC_LOG(LS_ERROR) << "IPropertyStore::GetValue returned no value," - << " hr = 0x" << std::hex << hr << std::dec; + << " hr = 0x" << rtc::ToHex(hr); } if ((SUCCEEDED(hr)) && (VT_LPWSTR != varName.vt)) { // The returned value is not a wide null terminated string. hr = E_UNEXPECTED; RTC_LOG(LS_ERROR) << "IPropertyStore::GetValue returned unexpected" - << " type, hr = 0x" << std::hex << hr << std::dec; + << " type, hr = 0x" << rtc::ToHex(hr); } if (SUCCEEDED(hr) && (varName.pwszVal != NULL)) { @@ -4056,16 +4057,16 @@ int32_t AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll( hr = pEndpoint->GetState(&dwState); CONTINUE_ON_ERROR(hr); if (dwState & DEVICE_STATE_ACTIVE) - RTC_LOG(LS_VERBOSE) << "state (0x" << std::hex << dwState << std::dec + RTC_LOG(LS_VERBOSE) << "state (0x" << rtc::ToHex(dwState) << ") : *ACTIVE*"; if (dwState & DEVICE_STATE_DISABLED) - RTC_LOG(LS_VERBOSE) << "state (0x" << std::hex << dwState << std::dec + RTC_LOG(LS_VERBOSE) << "state (0x" << rtc::ToHex(dwState) << ") : DISABLED"; if (dwState & DEVICE_STATE_NOTPRESENT) - RTC_LOG(LS_VERBOSE) << "state (0x" << std::hex << dwState << std::dec + RTC_LOG(LS_VERBOSE) << "state (0x" << rtc::ToHex(dwState) << ") : NOTPRESENT"; if (dwState & DEVICE_STATE_UNPLUGGED) - RTC_LOG(LS_VERBOSE) << "state (0x" << std::hex << dwState << std::dec + RTC_LOG(LS_VERBOSE) << "state (0x" << rtc::ToHex(dwState) << ") : UNPLUGGED"; // Check the hardware volume capabilities. @@ -4077,16 +4078,16 @@ int32_t AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll( CONTINUE_ON_ERROR(hr); if (dwHwSupportMask & ENDPOINT_HARDWARE_SUPPORT_VOLUME) // The audio endpoint device supports a hardware volume control - RTC_LOG(LS_VERBOSE) << "hwmask (0x" << std::hex << dwHwSupportMask - << std::dec << ") : HARDWARE_SUPPORT_VOLUME"; + RTC_LOG(LS_VERBOSE) << "hwmask (0x" << rtc::ToHex(dwHwSupportMask) + << ") : HARDWARE_SUPPORT_VOLUME"; if (dwHwSupportMask & ENDPOINT_HARDWARE_SUPPORT_MUTE) // The audio endpoint device supports a hardware mute control - RTC_LOG(LS_VERBOSE) << "hwmask (0x" << std::hex << dwHwSupportMask - << std::dec << ") : HARDWARE_SUPPORT_MUTE"; + RTC_LOG(LS_VERBOSE) << "hwmask (0x" << rtc::ToHex(dwHwSupportMask) + << ") : HARDWARE_SUPPORT_MUTE"; if (dwHwSupportMask & ENDPOINT_HARDWARE_SUPPORT_METER) // The audio endpoint device supports a hardware peak meter - RTC_LOG(LS_VERBOSE) << "hwmask (0x" << std::hex << dwHwSupportMask - << std::dec << ") : HARDWARE_SUPPORT_METER"; + RTC_LOG(LS_VERBOSE) << "hwmask (0x" << rtc::ToHex(dwHwSupportMask) + << ") : HARDWARE_SUPPORT_METER"; // Check the channel count (#channels in the audio stream that enters or // leaves the audio endpoint device) diff --git a/modules/pacing/paced_sender.cc b/modules/pacing/paced_sender.cc index a5546fe633..f8383187a9 100644 --- a/modules/pacing/paced_sender.cc +++ b/modules/pacing/paced_sender.cc @@ -353,7 +353,7 @@ void PacedSender::Process() { } void PacedSender::ProcessThreadAttached(ProcessThread* process_thread) { - RTC_LOG(LS_INFO) << "ProcessThreadAttached 0x" << std::hex << process_thread; + RTC_LOG(LS_INFO) << "ProcessThreadAttached 0x" << process_thread; rtc::CritScope cs(&process_thread_lock_); process_thread_ = process_thread; } diff --git a/modules/video_capture/windows/device_info_ds.cc b/modules/video_capture/windows/device_info_ds.cc index 5e158fe478..7cba0d40d4 100644 --- a/modules/video_capture/windows/device_info_ds.cc +++ b/modules/video_capture/windows/device_info_ds.cc @@ -10,11 +10,10 @@ #include "modules/video_capture/windows/device_info_ds.h" -#include // std::hex - #include "modules/video_capture/video_capture_config.h" #include "modules/video_capture/windows/help_functions_ds.h" #include "rtc_base/logging.h" +#include "rtc_base/stringutils.h" #include #include @@ -75,7 +74,7 @@ DeviceInfoDS::DeviceInfoDS() // RTC_LOG(LS_INFO) << __FUNCTION__ << ": CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)" - << " => RPC_E_CHANGED_MODE, error 0x" << std::hex << hr; + << " => RPC_E_CHANGED_MODE, error 0x" << rtc::ToHex(hr); } } } @@ -93,7 +92,7 @@ int32_t DeviceInfoDS::Init() { IID_ICreateDevEnum, (void**)&_dsDevEnum); if (hr != NOERROR) { RTC_LOG(LS_INFO) << "Failed to create CLSID_SystemDeviceEnum, error 0x" - << std::hex << hr; + << rtc::ToHex(hr); return -1; } return 0; @@ -132,7 +131,7 @@ int32_t DeviceInfoDS::GetDeviceInfo(uint32_t deviceNumber, &_dsMonikerDevEnum, 0); if (hr != NOERROR) { RTC_LOG(LS_INFO) << "Failed to enumerate CLSID_SystemDeviceEnum, error 0x" - << std::hex << hr << ". No webcam exist?"; + << rtc::ToHex(hr) << ". No webcam exist?"; return 0; } @@ -223,7 +222,7 @@ IBaseFilter* DeviceInfoDS::GetDeviceFilter(const char* deviceUniqueIdUTF8, &_dsMonikerDevEnum, 0); if (hr != NOERROR) { RTC_LOG(LS_INFO) << "Failed to enumerate CLSID_SystemDeviceEnum, error 0x" - << std::hex << hr << ". No webcam exist?"; + << rtc::ToHex(hr) << ". No webcam exist?"; return 0; } _dsMonikerDevEnum->Reset(); diff --git a/modules/video_capture/windows/sink_filter_ds.cc b/modules/video_capture/windows/sink_filter_ds.cc index 76d2fa9119..c2db44b3f2 100644 --- a/modules/video_capture/windows/sink_filter_ds.cc +++ b/modules/video_capture/windows/sink_filter_ds.cc @@ -10,12 +10,11 @@ #include "modules/video_capture/windows/sink_filter_ds.h" -#include // std::hex - #include "modules/video_capture/windows/help_functions_ds.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/platform_thread.h" +#include "rtc_base/stringutils.h" #include // VIDEOINFOHEADER2 #include @@ -148,7 +147,7 @@ CaptureInputPin::GetMediaType(IN int iPosition, OUT CMediaType* pmt) { RTC_LOG(LS_INFO) << "GetMediaType position " << iPosition << ", width " << _requestedCapability.width << ", height " << _requestedCapability.height << ", biCompression 0x" - << std::hex << pvi->bmiHeader.biCompression; + << rtc::ToHex(pvi->bmiHeader.biCompression); return NOERROR; } @@ -188,8 +187,8 @@ CaptureInputPin::CheckMediaType(IN const CMediaType* pMediaType) { RTC_LOG(LS_INFO) << "CheckMediaType width:" << pvi->bmiHeader.biWidth << " height:" << pvi->bmiHeader.biHeight - << " Compression:0x" << std::hex - << pvi->bmiHeader.biCompression; + << " Compression:0x" + << rtc::ToHex(pvi->bmiHeader.biCompression); if (*SubType == MEDIASUBTYPE_MJPG && pvi->bmiHeader.biCompression == MAKEFOURCC('M', 'J', 'P', 'G')) { @@ -233,8 +232,8 @@ CaptureInputPin::CheckMediaType(IN const CMediaType* pMediaType) { RTC_LOG(LS_INFO) << "CheckMediaType width:" << pvi->bmiHeader.biWidth << " height:" << pvi->bmiHeader.biHeight - << " Compression:0x" << std::hex - << pvi->bmiHeader.biCompression; + << " Compression:0x" + << rtc::ToHex(pvi->bmiHeader.biCompression); _resultingCapability.width = pvi->bmiHeader.biWidth; diff --git a/p2p/base/p2ptransportchannel.cc b/p2p/base/p2ptransportchannel.cc index c769097f98..486e293c26 100644 --- a/p2p/base/p2ptransportchannel.cc +++ b/p2p/base/p2ptransportchannel.cc @@ -2119,9 +2119,8 @@ void P2PTransportChannel::OnConnectionDestroyed(Connection* connection) { unpinged_connections_.erase(*iter); connections_.erase(iter); - RTC_LOG(LS_INFO) << ToString() << ": Removed connection " - << std::hex << connection << std::dec << " (" - << connections_.size() << " remaining)"; + RTC_LOG(LS_INFO) << ToString() << ": Removed connection " << connection + << " (" << connections_.size() << " remaining)"; // If this is currently the selected connection, then we need to pick a new // one. The call to SortConnectionsAndUpdateState will pick a new one. It diff --git a/rtc_base/unittest_main.cc b/rtc_base/unittest_main.cc index aa8a11bb5a..e32ca77185 100644 --- a/rtc_base/unittest_main.cc +++ b/rtc_base/unittest_main.cc @@ -45,11 +45,10 @@ void TestInvalidParameterHandler(const wchar_t* expression, const wchar_t* file, unsigned int line, uintptr_t pReserved) { + // In order to log `expression`, `function`, and `file` here, we would have + // to convert them to const char*. std::wcsrtombs can do that, but it's + // locale dependent. RTC_LOG(LS_ERROR) << "InvalidParameter Handler called. Exiting."; - RTC_LOG(LS_ERROR) << expression << std::endl - << function << std::endl - << file << std::endl - << line; exit(1); } void TestPureCallHandler() {