Skip to content

Commit

Permalink
Make VideoCaptureFormat::ToString static.
Browse files Browse the repository at this point in the history
BUG=501134

Review URL: https://codereview.chromium.org/1213193004

Cr-Commit-Position: refs/heads/master@{#337111}
  • Loading branch information
ajose authored and Commit bot committed Jul 1, 2015
1 parent ca6dce9 commit 5d00e98
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 33 deletions.
2 changes: 1 addition & 1 deletion content/browser/media/media_internals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ void MediaInternals::UpdateVideoCaptureDeviceCapabilities(
for (const auto& video_capture_device_info : video_capture_device_infos) {
base::ListValue* format_list = new base::ListValue();
for (const auto& format : video_capture_device_info.supported_formats)
format_list->AppendString(format.ToString());
format_list->AppendString(media::VideoCaptureFormat::ToString(format));

base::DictionaryValue* device_dict = new base::DictionaryValue();
device_dict->SetString("id", video_capture_device_info.name.id());
Expand Down
5 changes: 3 additions & 2 deletions content/browser/media/media_internals_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ TEST_F(MediaInternalsVideoCaptureDeviceTest,
kFrameSize.ToString().c_str(), kFrameRate,
media::VideoCaptureFormat::PixelFormatToString(kPixelFormat).c_str(),
media::VideoCaptureFormat::PixelStorageToString(kPixelStorage).c_str());
EXPECT_EQ(expected_string, capture_format.ToString());
EXPECT_EQ(expected_string,
media::VideoCaptureFormat::ToString(capture_format));
}

TEST_F(MediaInternalsVideoCaptureDeviceTest,
Expand Down Expand Up @@ -207,7 +208,7 @@ TEST_F(MediaInternalsVideoCaptureDeviceTest,
#endif
ExpectString("name", "dummy");
base::ListValue expected_list;
expected_list.AppendString(format_hd.ToString());
expected_list.AppendString(media::VideoCaptureFormat::ToString(format_hd));
ExpectListOfStrings("formats", expected_list);
#if defined(OS_LINUX)
ExpectString("captureApi", "V4L2 SPLANE");
Expand Down
22 changes: 11 additions & 11 deletions content/browser/renderer_host/media/video_capture_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,17 @@ void VideoCaptureHost::OnStartCapture(int device_id,
const media::VideoCaptureParams& params) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DVLOG(1) << "VideoCaptureHost::OnStartCapture:"
<< " session_id=" << session_id
<< ", device_id=" << device_id
<< ", format=" << params.requested_format.ToString()
<< "@" << params.requested_format.frame_rate
<< " (" << (params.resolution_change_policy ==
media::RESOLUTION_POLICY_FIXED_RESOLUTION ?
"fixed resolution" :
(params.resolution_change_policy ==
media::RESOLUTION_POLICY_FIXED_ASPECT_RATIO ?
"fixed aspect ratio" : "variable resolution"))
<< ")";
<< " session_id=" << session_id << ", device_id=" << device_id
<< ", format="
<< media::VideoCaptureFormat::ToString(params.requested_format)
<< "@" << params.requested_format.frame_rate << " ("
<< (params.resolution_change_policy ==
media::RESOLUTION_POLICY_FIXED_RESOLUTION
? "fixed resolution"
: (params.resolution_change_policy ==
media::RESOLUTION_POLICY_FIXED_ASPECT_RATIO
? "fixed aspect ratio"
: "variable resolution")) << ")";
VideoCaptureControllerID controller_id(device_id);
if (entries_.find(controller_id) != entries_.end()) {
Send(new VideoCaptureMsg_StateChanged(device_id,
Expand Down
3 changes: 2 additions & 1 deletion content/browser/renderer_host/media/video_capture_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ void VideoCaptureManager::StartCaptureForClient(
const DoneCB& done_cb) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DVLOG(1) << "VideoCaptureManager::StartCaptureForClient #" << session_id
<< ", request: " << params.requested_format.ToString();
<< ", request: "
<< media::VideoCaptureFormat::ToString(params.requested_format);

DeviceEntry* entry = GetOrCreateDeviceEntry(session_id);
if (!entry) {
Expand Down
4 changes: 2 additions & 2 deletions content/common/media/media_param_traits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ bool ParamTraits<VideoCaptureFormat>::Read(const Message* m,

void ParamTraits<VideoCaptureFormat>::Log(const VideoCaptureFormat& p,
std::string* l) {
l->append(
base::StringPrintf("<VideoCaptureFormat> %s", p.ToString().c_str()));
l->append(base::StringPrintf("<VideoCaptureFormat> %s",
media::VideoCaptureFormat::ToString(p).c_str()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void SetScreenCastParamsFromConstraints(
}

DVLOG(1) << "SetScreenCastParamsFromConstraints: "
<< params->requested_format.ToString()
<< media::VideoCaptureFormat::ToString(params->requested_format)
<< " with resolution change policy "
<< params->resolution_change_policy;
}
Expand Down
3 changes: 2 additions & 1 deletion content/renderer/media/media_stream_video_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ void MediaStreamVideoSource::OnSupportedFormats(
}

state_ = STARTING;
DVLOG(3) << "Starting the capturer with " << current_format_.ToString();
DVLOG(3) << "Starting the capturer with "
<< media::VideoCaptureFormat::ToString(current_format_);

StartSourceImpl(
current_format_,
Expand Down
10 changes: 6 additions & 4 deletions media/base/video_capture_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ size_t VideoCaptureFormat::ImageAllocationSize() const {
return result_frame_size;
}

std::string VideoCaptureFormat::ToString() const {
//static
std::string VideoCaptureFormat::ToString(const VideoCaptureFormat& format) {
return base::StringPrintf("(%s)@%.3ffps, pixel format: %s storage: %s.",
frame_size.ToString().c_str(), frame_rate,
PixelFormatToString(pixel_format).c_str(),
PixelStorageToString(pixel_storage).c_str());
format.frame_size.ToString().c_str(),
format.frame_rate,
PixelFormatToString(format.pixel_format).c_str(),
PixelStorageToString(format.pixel_storage).c_str());
}

//static
Expand Down
3 changes: 1 addition & 2 deletions media/base/video_capture_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ struct MEDIA_EXPORT VideoCaptureFormat {
VideoPixelFormat pixel_format,
VideoPixelStorage pixel_storage);

// TODO(mcasas): Remove this method http://crbug.com/501134.
std::string ToString() const;
static std::string ToString(const VideoCaptureFormat& format);
static std::string PixelFormatToString(VideoPixelFormat format);
static std::string PixelStorageToString(VideoPixelStorage storage);

Expand Down
3 changes: 2 additions & 1 deletion media/capture/screen_capture_device_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ void ScreenCaptureDeviceCore::AllocateAndStart(
!(params.requested_format.pixel_format == PIXEL_FORMAT_ARGB &&
params.requested_format.pixel_storage == PIXEL_STORAGE_TEXTURE)) {
const std::string error_msg = base::StringPrintf(
"unsupported format: %s", params.requested_format.ToString().c_str());
"unsupported format: %s",
VideoCaptureFormat::ToString(params.requested_format).c_str());
DVLOG(1) << error_msg;
client->OnError(error_msg);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ void VideoCaptureDeviceFactoryAndroid::GetDeviceSupportedFormats(
format.obj()),
pixel_format);
capture_formats->push_back(capture_format);
DVLOG(1) << device.name() << " " << capture_format.ToString();
DVLOG(1) << device.name() << " "
<< VideoCaptureFormat::ToString(capture_format);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static void GetSupportedFormatsForV4L2BufferType(
for (const auto& frame_rate : frame_rates) {
supported_format.frame_rate = frame_rate;
supported_formats->push_back(supported_format);
DVLOG(1) << supported_format.ToString();
DVLOG(1) << VideoCaptureFormat::ToString(supported_format);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ + (void)getDevice:(const media::VideoCaptureDevice::Name&)name
frameRate.maxFrameRate,
pixelFormat);
formats->push_back(format);
DVLOG(2) << name.name() << " " << format.ToString();
DVLOG(2) << name.name() << " "
<< media::VideoCaptureFormat::ToString(format);
}
}

Expand Down
5 changes: 3 additions & 2 deletions media/video/capture/mac/video_capture_device_decklink_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ static float GetDisplayModeFrameRate(
return;
}
#if !defined(NDEBUG)
DVLOG(1) << "Requested format: " << params.requested_format.ToString();
DVLOG(1) << "Requested format: "
<< media::VideoCaptureFormat::ToString(params.requested_format);
CFStringRef format_name = NULL;
if (chosen_display_mode->GetName(&format_name) == S_OK)
DVLOG(1) << "Chosen format: " << base::SysCFStringRefToUTF8(format_name);
Expand Down Expand Up @@ -422,7 +423,7 @@ static float GetDisplayModeFrameRate(
GetDisplayModeFrameRate(display_mode),
PIXEL_FORMAT_UNKNOWN);
supported_formats->push_back(format);
DVLOG(2) << device.name() << " " << format.ToString();
DVLOG(2) << device.name() << " " << VideoCaptureFormat::ToString(format);
display_mode.Release();
}
return;
Expand Down
5 changes: 3 additions & 2 deletions media/video/capture/win/video_capture_device_factory_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ static void GetDeviceSupportedFormatsDirectShow(const Name& device,
kSecondsToReferenceTime / static_cast<float>(h->AvgTimePerFrame) :
0.0f;
formats->push_back(format);
DVLOG(1) << device.name() << " " << format.ToString();
DVLOG(1) << device.name() << " " << VideoCaptureFormat::ToString(format);
}
}
}
Expand Down Expand Up @@ -347,7 +347,8 @@ static void GetDeviceSupportedFormatsMediaFoundation(
formats->push_back(capture_format);
++stream_index;

DVLOG(1) << device.name() << " " << capture_format.ToString();
DVLOG(1) << device.name() << " "
<< VideoCaptureFormat::ToString(capture_format);
}
}

Expand Down

0 comments on commit 5d00e98

Please sign in to comment.